问题描述
我有以下来自反汇编程序的mov指令(不带后缀).
I have the following mov instruction (without the suffix) from a disassembler.
mov %dx,(%eax)
指令后缀是什么?首先,我认为目标寄存器确定了后缀,但是根据我正在阅读的书,我猜它是由最小"寄存器确定的.因此,在这种情况下
What would be the instruction suffix? First I thought that the destination register determines the suffix, however according to the book I'm reading, I guess it's determined by the "smallest" register. So in this case would be
movw %dx, (%eax)
因为%dx(16位字寄存器)是最小的.我的推理正确吗? (有时CSAPP的书有些混乱,没有清楚地说明细节.)
since %dx (16-bit word register) is the smallest one.Is my reasoning correct? (Sometimes the CSAPP book is a little bit confusing, doesn't explain details clearly).
推荐答案
目标不是示例中的寄存器,而是源,是寄存器.因此操作数大小为16位,因此AT& T将使用movw
.
The destination isn't a register in your examples, it's the source that's a register. So the operand-size is 16-bit, thus AT&T would use movw
.
目标是内存中的2个字节,由32位寻址模式选择. mov
要求源和目标必须具有相同的宽度.如果至少一个操作数是一个寄存器,那么它将唯一地确定操作数的大小.
The destination is 2 bytes in memory, selected by a 32-bit addressing mode. mov
requires both source and dest to be the same width. If at least one operand is a register, that uniquely determines the operand size.
对于mov $123, (%eax)
之类的内容,您需要一个明确的后缀,因为这两个操作数都不是寄存器.
You need an explicit suffix for something like mov $123, (%eax)
because neither operand is a register.
您最小"的想法完全是虚假的. movl %eax, (%bx)
之所以是movl
,是因为寄存器操作数是32位,并且通过16位寻址模式选择了4字节的目的地.
Your idea of "smallest" is totally bogus. movl %eax, (%bx)
is movl
because the register operand is 32 bits, and the 4-byte destination is selected by a 16-bit addressing mode.
一个或多个处于寻址模式的寄存器对操作数大小的影响为零.地址大小和操作数大小是独立的,您可以覆盖其中一个,但不能覆盖另一个. (这就是为什么操作数大小(0x66
)和地址大小(0x67
)有单独的机器代码前缀字节的原因.
The register or registers in the addressing mode have zero effect on the operand-size. Address-size and operand-size are independent, and you can override one but not the other. (That's why there are separate machine-code prefix bytes for operand-size (0x66
) and address-size (0x67
).
这篇关于不带后缀的汇编mov指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!