assemblyx86-64instruction-setinstruction-encoding

ModR/M Historical Notation /0.../7


While learning about x64, I struggled to understand some notations in the intel manual.

Let's look at 0xC7 MOV:

opcode instruction Op/Enc Description
C7 /0 iw MOV r/m16, imm16 MI Move imm16 to r/m16.
C7 /0 id MOV r/m32, imm32 MI Move imm32 to r/m32.
REX.W + C7 /0 id MOV r/m64, imm32 MI Move imm32 sign extended to 64-bits to r/m64.

About the /0../7 it says:

Historically this document only specified the ModR/M.reg field restrictions with the notation /0 ... /7 and did not specify restrictions on the ModR/M.mod and ModR/M.r/m fields in the encoding boxes.

My questions are:

{ xxd --ps -r | ndisasm -b64 -; } <<<c7c701020304 
00000000  C7C701020304      mov edi,0x4030201

Solution

  • /digit still only restricts the ModRM.reg field. It means, put whatever digit is after the slash, in the reg field of the ModRM byte.

    That note is about new Intel AMX instructions, some of which have a different ModRM specification. For example TDPBSSD/TDPBSUD/TDPBUSD/TDPBUU require mod=11 (in other words, they cannot have a memory operand)

    TDPBSSD/TDPBSUD/TDPBUSD/TDPBUU encoding table

    And TILELOADD/TILELOADDT1 require mod!=11 and rm=100 (they must have a memory operand, and it must be encoded with SIB)

    enter image description here