“ movl”组装中的说明
我正在学习组装和阅读“计算机系统:程序员的观点”。实际上,问题3.3,它说movl%eax,%rdx
将产生错误。答案键说movl%eax,%dx目标操作数不正确的大小
。我不确定这是否是错别字,但是我的问题是:movl%eax,%rdx
法律指令吗?我认为它正在以%eax
中的32位移动零扩展名为%rdx
,这不会以> movzql
生成
一项指令生成带有寄存器的4字节值,因为目的地将填充上4个字节的零(来自书籍)。
我尝试编写一些C代码来生成它,但是我总是会得到movslq%eax,%rdx
(GCC 4.8.5 -og)。我完全困惑。
I am learning assembly and reading "Computer Systems: A programmer's perspective". In Practice Problem 3.3, it says movl %eax,%rdx
will generate an error. The answer keys says movl %eax,%dx Destination operand incorrect size
. I am not sure if this is a typo or not, but my question is: is movl %eax,%rdx
a legal instruction? I think it is moving the 32 bits in %eax
with zero extension to %rdx
, which will not be generated as movzql
since
an instruction generating a 4-byte value with a register as the destination will fill the upper 4 bytes with zeros` (from the book).
I tried to write some C code to generate it, but I always get movslq %eax, %rdx
(GCC 4.8.5 -Og). I am completely confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GNU汇编程序不接受
movl%eax,%rdx
。对于编码而言,这也没有意义,因为mov
必须具有单个操作数大小(如果需要的话,请使用前缀字节),而不是两个不同尺寸的操作数。您想要的效果是通过
movl%eax,%edx
来实现的,因为将写入32位寄存器的写入始终为零 - 零 - 在相应的64位寄存器中。请参阅为什么在32位寄存器上x86-64说明完整的上部64位注册?。movzlq%eax,%rdx
可能是合乎逻辑的,但是不支持它,因为它是多余的。The GNU assembler doesn't accept
movl %eax,%rdx
. It also doesn't make sense for the encoding, sincemov
must have a single operand size (using a prefix byte if needed), not two different sized operands.The effect you want is achieved by
movl %eax, %edx
since writes to a 32-bit register always zero-extend into the corresponding 64-bit register. See Why do x86-64 instructions on 32-bit registers zero the upper part of the full 64-bit register?.movzlq %eax, %rdx
might make logical sense, but it's not supported since it would be redundant.