简单的装配程序可以吐出两个用户输入数字中较大的一个。我无法正确输出输出。例如,如果我输入45和55,最大值将是55,但是当我尝试反向55和45(答案应该仍然是55)时,我得到45.这看起来似乎只能输出第二个输入值存储在EAX。任何帮助是极大的赞赏。来自输入的装配最大值
.586
.MODEL FLAT
INCLUDE io.h
.STACK 4096
.DATA
value1 DWORD ?
value2 DWORD ?
prompt1 BYTE "Enter the first number", 0
prompt2 BYTE "Enter the second number", 0
string BYTE 40 DUP (?)
resultLbl BYTE "The maximum value you entered was:", 0
.CODE
_MainProc PROC
input prompt1, string, 40 ;get user input value1
atod string ;convert input (ASCII) to integer
mov ebx, eax
input prompt2, string, 40 ; repeat for value2
atod string
mov value2, eax
cmp eax, ebx ;compare user inputs
jg greater_than ;jump conditional if value 1 is greater then value 2
greater_than: ;condition if greater than ouput
dtoa value1, eax ;decimal to ASC for output of
integer value stored at ebx
output resultLbl, value1 ;output value 1
jmp exit
less_than: ;condition if less than ouput
dtoa value1, eax
output resultLbl, value2 ;else output value 2
jmp exit
exit: ;quit jump ;end if/else conditional
mov eax, 0 ;clear memory
mov ebx, 0
ret
_MainProc ENDP
END
调试。函数调用中很可能会覆盖ebx。存储在内存中,而不是一个寄存器 –
@SamiKuhmonen没有寄存器被'input'影响,根据以下链接:http://flylib.com/books/en/2.265.1.27/1/ 从链接引用: 输入宏只更改指定目标处的内存。它不会更改任何寄存器内容,包括标志寄存器。 –