2

我的代码如下:(在 Windows 64 位环境下,在 Windows 7 上的 Visual Express 2012 中调试,Core i5 520M CPU)

mov edx, a_number_which_is_less than_16_bits
shl rdx,32       ; moves that number to upper 32 bits of RDX
<few lines that leave an useless number in EDX, but does not touch upper 32 bits of RDX>
xor edx,edx      ; should clear the lower 32 bits of RDX keeping upper 32 bits intact

但它也清除了 RDX 的高 32 位...将整个 RDX 保留为零 64 位处理器的英特尔手册未指定 XOR 指令也清除高 32 位(第 2 B 卷,第 4-531 页)。

其他程序员是否也看到了这一点?

4

2 回答 2

3

零扩展和符号扩展的结果是 AMD 的设计决策,英特尔紧随其后。所以这是预期的行为。技术优点在别处讨论。

于 2013-05-05T06:46:42.317 回答
2

Intel 的“Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture” - 3.4中描述了在处理 32 位操作数时清除 64 位目标寄存器的高 32 位这一事实。 1.1 64 位模式下的通用寄存器:

  • 32 位操作数生成 32 位结果,在目标通用寄存器中零扩展为 64 位结果。
于 2013-05-05T07:16:30.650 回答