assembly getting input - invalid instruction operands with StdIn

I'm making a program to practice getting input and arithmetic, and when storing the user's input in a buffer and then doing arithmetic with them, I get error A2070 - invalid instruction operands. Here is my code:

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

Here is the feedback from MASM's ml.exe:

test.asm(29) - A2070 - Invalid instruction operands.
test.asm(39) - A2070 - Invalid instruction operands.

What is wrong with the variables? I suspect it might be the variable declaration.

Any help would be appreciated.

Answers


You should push the address of buffer1 - do it exactly as you push the addresses of mgs and mgs2...

Instead of

push buffer1

do

lea eax, buffer1
push eax

Need Your Help

How to omit empty part-000x files from Python streaming MapReduce job

python hadoop mapreduce hadoop-streaming

I created a Python mapper that I run as a Hadoop streaming MapReduce job. It validates the input and writes a message to output if the input is invalid.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.