我正在编写一个程序来练习获取输入和算术,当将用户的输入存储在缓冲区中然后用它们进行算术运算时,我得到错误 A2070 - 指令操作数无效。这是我的代码:
include C:\masm32\include\masm32rt.inc
.data
msg db "Enter a number: ", 0
msg2 db "Enter another number: ",13,10,0
msg3 db "Your numbers: ", 13,10,0
msg4 db "Added = ", 0
spacer db " ",13,10,0
msg5 db "Subtracted = ", 0
msg6 db "Multiplied = ", 0
ansadd sdword 0
anstake sdword 0
ansmul sdword 0
.data?
buffer1 db 12 dup(?)
buffer2 db 12 dup(?)
.code
start:
lea eax, msg
push eax
call StdOut
push 100
push buffer1 ;line 29
call StdIn
xor eax, eax
lea eax, msg2
push eax
call StdOut
push 100
push buffer2 ;line 39
call StdIn
xor eax, eax
lea eax, buffer1
lea ebx, buffer2
add eax, ebx
push eax
pop ansadd
lea eax, buffer1
lea ebx, buffer2
sub eax, ebx
push eax
pop anstake
xor ebx, ebx
lea eax, buffer1
lea ecx, buffer2
mul eax
push eax
pop ansmul
xor eax, eax
xor ebx, ebx
xor ecx, ecx
lea eax, msg3
push eax
call StdOut
lea eax, msg4
push eax
call StdOut
lea eax, ansadd
push eax
call StdOut
lea eax, msg5
push eax
call StdOut
lea eax, anstake
push eax
call StdOut
lea eax, msg6
push eax
call StdOut
lea eax, ansmul
push eax
call StdOut
push 0
call ExitProcess
END start
以下是 MASM 的反馈ml.exe
:
test.asm(29) - A2070 - Invalid instruction operands.
test.asm(39) - A2070 - Invalid instruction operands.
变量有什么问题?我怀疑它可能是变量声明。
任何帮助,将不胜感激。