问题
I am trying to write a program which takes the binary input from a text file and sends it as a parameter to an assembly function. That assembly function must print this binary input to the screen. The input is sent from c code to assembly code by its address.
When I try to assemble my asm file, I get an "invalid combination of opcode and operands" error on the mov msg, [esp+8]
line. I want to copy my char
arg from the stack to my static variable. Why isn't that a valid instruction?
The full code is:
segment .data
len equ 31
segment .bss
msg resb 0
segment .text
global sequence_generator
sequence_generator:
push ebp
mov ebp, esp
mov msg, [esp+8]
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,len
int 80h
pop ebp
ret
回答1:
I wonder what have you tried to do in this line:
mov msg, [esp+8]
But you are not allowed to mov
e from memory to memory. Refer to this page, for instance.
If you want to move something from memory to memory, use a register as a temporary storage. For example:
mov eax, [var1]
mov [var2], eax
来源:https://stackoverflow.com/questions/39958149/invalid-combination-of-opcode-and-operands-error