MOVSX汇编指令如何工作? [英] How does MOVSX assembly instruction work?
问题描述
在以下示例中,汇编指令MOVSX
如何工作:
How does the assembly instruction MOVSX
work in this following example:
MOVSX ECX,BYTE PTR DS:[EDX]
在这种情况下,这是寄存器的状态:
In this case, here are the state of the registers:
ECX = 0000000F
EDX = 0012FD9F
根据我的想法,它需要[EDX] = 9F的最后一个字节,将其移至ECX,然后对其进行符号扩展以匹配16位= 0000009F.但是,实际结果是00000016.有人可以帮我解释我错了吗?
From what I thought, it takes last bytes of [EDX] = 9F, moves it to ECX and then sign extends it to match 16 bits = 0000009F. However, the actual result is 00000016. Can someone help explain where I'm wrong?
推荐答案
部分正确.但是:
BYTE PTR DS:[EDX]
获取位于EDX中保存的地址中的字节.该字节被复制到ECX
的最低有效字节中,其余字节用该字节的符号填充.
BYTE PTR DS:[EDX]
obtains the byte located at the address held in EDX. This byte is copied to ECX
into the least significant byte and the rest is filled with the sign of the byte.
对于意外的结果,这意味着在内存地址 1 0x12FD9F
中位于字节0x16
.
For your unexpected result, this means that at the memory address1 0x12FD9F
the byte 0x16
is located.
注意:
- 段覆盖前缀
DS:
在这里不是必需的.[EDX]
自动引用DS
.
- the Segment Override Prefix
DS:
isn't necessary here.[EDX]
automatically refers toDS
.
1 内存地址"在这里是指虚拟或物理内存
1 "memory address" refers to either virtual or physical memory here
这篇关于MOVSX汇编指令如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!