X86-64 Instruction Encoding: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
→‎32-bit addressing: fixed mod 11 registers to 32-bit and special SSE
→‎ModR/M: clarification
Line 165:
 
=== ModR/M ===
The ModR/M byte encodes a register or an opcode extension, and a register or a memory address. It is only required when ''/r'' or ''/0'' through ''/7'' is specified at the opcode syntax. It has the following fields:
The ModR/M byte has the following fields:
<pre>
* Mod (2 bits)
8 7 6 5 4 3 2 1 0
* Reg/Opcode (3 bits)
+--+--+--+--+--+--+--+--+
* R/M (3 bits)
| mod | reg | rm |
+--+--+--+--+--+--+--+--+
</pre>
* Modmod (2 bits)
* Reg/Opcodereg (3 bits)
* R/Mrm (3 bits)
 
The ''Modmod'' and ''R/Mrm'' fields are explained in the table. The ''Reg/Opcodereg'' field can have one of two values:
* A 3-bit opcode extension, which is used by some instructions but has no futher meaning other than distincting the instruction from other instructions. When ''/0'' through ''/7'' is specified at the opcode syntax, use that value as the value for the ''reg'' field.
* A 3-bit register reference, which can be used as the source or the destination of an instruction (depending on the instruction). When this is the case, ''/r'' is specified at the opcode syntax. Which register is meant depends on the [[#Operand-size and address-size override prefix|operand-size]] of the instruction and the instruction itself:
** b000 - AL, AX, EAX, MM0 or XMM0
** b001 - CL, CX, ECX, MM1 or XMM1