For example one of the MOV has 2 versions, one with REX, one without (from Intel's doc) :
88 /r MOV r/m8, r8
REX + 88 /r MOV r/m8***, r8***
***In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is used: AH, BH, CH, DH.
From what I understand, the 2 instructions are identical except the second one uses an additional byte and provides less options ... So basically it is useless.
What am I missing ?
REX prefixes are instruction-prefix bytes used in 64-bit mode. They do the following: • • Specify 64-bit operand size.
The REX prefix is also used for mov instructions with 64-bit immediate operands; the default operand size, even in 64-bit mode, is 32-bits. All of these have to do with extending existing instructions to support 64-bit operation.
The Latin title rex has the meaning of "king, ruler" (monarch). It is derived from Proto-Indo-European *h₃rḗǵs. Its cognates include Sanskrit rājan, Gothic reiks, and Old Irish rí, etc. Its Greek equivalent is archon (ἄρχων), "leader, ruler, chieftain".
Opcode with prefixes (1-4 bytes, required) ModR/M (1 byte, if required) SIB (1 byte, if required) Displacement (1, 2, 4 or 8 bytes, if required)
It's not useless, but not overwhelmingly useful either.
A REX prefix changes ah
, ch,
dh
and bh
into spl
, bpl
, sil
and dil
(respectively). So while you cannot use the first set, you can use the second set.
It's to do with the encoding of the registers in the instruction. The bits available in the r/m part select from a set of registers - those registers change, depending upon the REX prefix:
Available 8-bit registers without REX prefix:
AL, CL, DL, BL, AH, CH, DH, BH
Available 8-bit registers with REX prefix set:
AL, CL, DL, BL, SPL, BPL, SIL, DIL, R8B, R9B, R10B, R11B, R12B, R13B, R14B, R15B
This is why Intel docs draw attention to the fact that you cannot select certain registers with the REX prefix set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With