您好我正在尝试编写一个程序来减去用户输入的三个整数(x-y-z),然后将其输出到屏幕。我相信自己走在了正确的轨道上,但我却迷失在下一步的地方。我是集会的初学者。这是irvine32汇编。谢谢!
TITLE Programming Assignment 1 (main.asm)
INCLUDE Irvine32.inc
.data
myMessage1 BYTE "Please input integer x: ",0dh,0ah,0
myMessage2 BYTE "Please input integer y: ",0dh,0ah,0
myMessage3 BYTE "Please input integer z: ",0dh,0ah,0
inputNum1 DWORD ?
inputNum2 DWORD ?
inputNum3 DWORD ?
.code
main PROC
call Clrscr
mov edx,offset myMessage1
call WriteString
call ReadInt
mov inputNum1,eax
mov edx,offset myMessage2
call WriteString
call ReadInt
mov inputNum2,ebx
mov edx,offset myMessage3
call WriteString
call ReadInt
mov inputNum3,ecx
sub eax, ebx
sub ebx, ecx
exit
main ENDP
END main
答案 0 :(得分:4)
ReadInt
会返回eax
中的数字。因此,您应该将其写入变量中。要执行算术,您需要使用所述变量。如:
mov edx,offset myMessage1
call WriteString
call ReadInt
mov inputNum1,eax
mov edx,offset myMessage2
call WriteString
call ReadInt
mov inputNum2,eax
mov edx,offset myMessage3
call WriteString
call ReadInt
mov inputNum3,eax
mov eax, inputNum1
sub eax, inputNum2
sub eax, inputNum3
call WriteInt
PS:学会使用调试器并阅读文档。