Invalid combination of opcode and operands error

馋奶兔 提交于 2019-12-17 19:53:46

问题


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 move 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!