简体   繁体   中英

Difference between MOVZX r32, r/m16 and MOVZX r64, r/m16 in 64-bit x86

Both MOVZX r32, r/m16 and MOVZX r64, r/m16 have the opcode 0F B7, but the latter has a REX.W prefix. What makes these two instructions different? Shouldnt both of them zero the upper 32-bits of the destination operand anyways since according to

Intel 64 and IA-32 Architectures - Software Developer’s Manual, Volume 1, 3.4.1.1
    : General-Purpose Registers in 64-Bit Mode.

the following statement holds:

32-bit operands generate a 32-bit result,
    zero-extended to a 64-bit result in the destination general-purpose register.

There is no difference in what these two instructions do, just how they're encoded. This is no different than how XOR EAX, EAX and XOR RAX, RAX do the same thing, but the former is one byte shorter. (XOR RAX, RAX also has the disadvantage of not breaking dependencies on Silvermont, but this difference doesn't apply to MOVZX.)

Even before x86-64 there were various ways of encoding what was effectively the same instruction (eg. SUB EAX, EAX), the automatic zeroing of the upper part of registers just adds more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM