2
votes

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.
1
I suppose this is one of these “the REX.W prefix is legal here, but it doesn't really do anything” deals.fuz

1 Answers

2
votes

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.