如何在不使用循环的情况下用汇编语言添加数字?
How to Add Numbers in Assembly Language without using a loop?
我需要这个程序来打印出1 + 3 + 4 + 10 = 18,但是到目前为止我还没有成功。我可以让它单独打印出 18,但这不是我被要求做的。我不允许使用循环。谁能帮我解决这个问题?
INCLUDE Irvine32.inc
.data
y1 DWORD 1
y2 DWORD 3
y3 DWORD 4
y4 DWORD 10
plus byte " + ",0
equal byte " = ",0
.code
main PROC
exit
main ENDP
END main
好吧,我昨晚花了整整一晚才弄明白,但这行得通。
INCLUDE Irvine32.inc ; like import
.data
y1 dword 1
y2 dword 3
y3 dword 4
y4 dword 10
plus byte " + ",0
equal byte " = ",0;
.code
main PROC
mov eax,0
mov edx,offset plus
mov ebx,0
mov eax,y1
call writedec
add ebx,eax
call writestring
mov eax,y2
call writedec
add ebx,eax
call writestring
mov eax,y3
call writedec
add ebx,eax
call writestring
mov eax,y4
call writedec
add ebx,eax
mov edx,offset equal
call writestring
mov eax,ebx
call writedec
exit
main ENDP
end main
我需要这个程序来打印出1 + 3 + 4 + 10 = 18,但是到目前为止我还没有成功。我可以让它单独打印出 18,但这不是我被要求做的。我不允许使用循环。谁能帮我解决这个问题?
INCLUDE Irvine32.inc
.data
y1 DWORD 1
y2 DWORD 3
y3 DWORD 4
y4 DWORD 10
plus byte " + ",0
equal byte " = ",0
.code
main PROC
exit
main ENDP
END main
好吧,我昨晚花了整整一晚才弄明白,但这行得通。
INCLUDE Irvine32.inc ; like import
.data
y1 dword 1
y2 dword 3
y3 dword 4
y4 dword 10
plus byte " + ",0
equal byte " = ",0;
.code
main PROC
mov eax,0
mov edx,offset plus
mov ebx,0
mov eax,y1
call writedec
add ebx,eax
call writestring
mov eax,y2
call writedec
add ebx,eax
call writestring
mov eax,y3
call writedec
add ebx,eax
call writestring
mov eax,y4
call writedec
add ebx,eax
mov edx,offset equal
call writestring
mov eax,ebx
call writedec
exit
main ENDP
end main