ModR/M

The ModR/M byte is an important part of instruction encoding for the x86 instruction set.

Description
Opcodes in x86 are generally one-byte, though two-byte instructions and prefixes exist. ModR/M is the byte following the opcode and adds additional information for how the instruction is executed. The format is:

where REG specifies a register and R/M may contain a register or specify an addressing mode, depending upon the value of MOD.

Some instructions cannot make use of the REG portion of the ModR/M byte. Many of these instructions are "multiplexed" using this field, where a single opcode can refer to multiple instructions, and the REG field determines the instruction. In opcode listings, these are specified by following the opcode with a slash and a digit 0-7.

64-bit changes
The ModR/M byte is central to the changes introduced with AMD's 64-bit extension to the original instruction set. In long mode, any opcode whose highest four bits are  (decimal 4) are considered to be a new prefix, the REX prefix. The lowest four bits of the prefix byte serve various purposes, including an extra bit for the REG and R/M fields of the ModR/M byte that follows. Among other changes, expanding these values from three bits to four doubles the number of available processor registers from eight to sixteen.

SIB byte
The SIB byte is an optional post-opcode byte in x86 assembly on the i386 and later, used for complex addressing.

SIB bytes are formatted similarly to ModR/M bytes, and take the form of, where the SCALE is 1, 2, 4, or 8. BASE and INDEX each encode a register. The displacement is a constant offset encoded after the SIB byte which is applied to the final address.

A REX prefix can optionally allow the SIB byte to use SSE registers.