错误:"movq"的操作数大小不匹配 [英] Error: operand size mismatch for `movq'
问题描述
我正在尝试编译以下程序集...
I'm trying to compile the following assembly...
movq $0x3534373536383235, 0x000000000055638f8
movq $0x55638f8, %rdi
retq
第一行引发错误Error: operand size mismatch for 'movq'
这对我来说没有意义,因为它们都是8字节数字.
Which doesn't make sense to me, because they are both 8 byte numbers.
我做了一些研究,并推荐了movabsq
,就像这样...
I did a little research and movabsq
was recommended, like so...
movabsq $0x3534373536383235, 0x000000000055638f8
movq $0x55638f8, %rdi
retq
但这会引发错误:Error: operand size mismatch for 'movabs'
我想念什么?
这是我的Mac上的全部错误
Here's the entire error from my mac
level3.s:1:27: error: invalid operand for instruction
movq $0x3534373536383235, 0x000000000055638f8
^~~~~~~~~~~~~~~~~~~
推荐答案
如果您在引理MOV
下查看该手册(诚然有点吓人),您会发现没有mov r/m64, imm64
If you look in the manual under the lemma MOV
(which is, admittedly, a bit intimidating), you will find that there is no mov r/m64, imm64
.
有一种方法可以将完整的64位常量加载到寄存器中,也可以将符号扩展的32位常量加载到64位内存位置中,但是没有一条指令可以立即使用64位并将其写入内存
There's a way to load a full 64bit constant into a register, and there's a way to load a sign-extended 32bit constant into a 64bit memory location, but there is no single instruction that takes a 64bit immediate and writes it to memory.
因此,您必须分两个步骤进行操作,例如通过使用临时寄存器或直接将两个双字直接写入内存.
So you have to do it in two steps, such as by using a temporary register or by writing two dwords straight to memory separately.
这篇关于错误:"movq"的操作数大小不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!