“ movl”组装中的说明

发布于 2025-02-12 15:29:23 字数 418 浏览 1 评论 0原文

我正在学习组装和阅读“计算机系统:程序员的观点”。实际上,问题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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2025-02-19 15:29:23

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, since mov 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文