Logo
Articles Compilers Libraries Books MiniBooklets Assembly C++ Rust Go Linux CPU Others Videos
Advertisement

Article by Ayman Alheraki on May 12 2026 01:03 PM

Visual diagram of ModRM + REX decoding

Visual diagram of ModR/M + REX decoding

 

1. Full Instruction Layout (x86-64)

A typical instruction looks like this:

Not all fields are always present.


2. Focus: REX + ModR/M Interaction

Step-by-step decoding pipeline


3. ModR/M Byte Structure (Core)

Meaning:

FieldPurpose
MODaddressing mode
REGregister operand
R/Mregister or memory operand

4. Where REX Fits In

REX does NOT replace ModR/M.

It extends its fields:


5. Visual Mapping: REG Field Expansion

Without REX (3-bit only)

Diagram:


With REX (adds 1 bit)

Diagram:


6. Full Decoding Example (Visual Walkthrough)

Instruction:

Machine code:


STEP 1 — REX Byte

Split:

Diagram:


STEP 2 — ModR/M Byte

Split:

Diagram:


STEP 3 — Apply REX Extensions


FINAL RESULT


7. Complete Visual Pipeline


8. SIB Extension (Visual Add-on)

When memory indexing is used:

SIB byte:

REX.X extends INDEX:

Diagram:


9. Key Insight Diagram (Mental Model)


10. Final Summary

  • ModR/M encodes register fields in 3 bits

  • REX adds a missing 4th bit

  • Final register = 0–15 range

  • Enables R8–R15 without breaking old x86

Advertisements

Responsive Counter
General Counter
1311526
Daily Counter
1957