操作码和操作数错误的无效组合 [英] Invalid combination of opcode and operands error

查看:302
本文介绍了操作码和操作数错误的无效组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序,该程序从文本文件获取二进制输入并将其作为参数发送给汇编函数.该汇编功能必须将此二进制输入打印到屏幕上.输入通过其地址从c代码发送到汇编代码.

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.

当我尝试汇编我的asm文件时,在mov msg, [esp+8]行上收到操作码和操作数的无效组合"错误.我想将char arg从堆栈复制到我的静态变量中.为什么那不是有效的指令?

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?

完整代码是:

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

推荐答案

我想知道您在此行尝试做什么:

I wonder what have you tried to do in this line:

mov msg, [esp+8]

但是不允许您在内存之间进行mov e操作.例如,请参见页面.

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

这篇关于操作码和操作数错误的无效组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆