LmCast :: Stay tuned in

x86 prefixes and escape opcodes flowchart

Recorded: Jan. 20, 2026, 10:03 a.m.

Original Summarized

x86 prefixes and escape opcodes flowchart

Main content

 

Texts
Talks
Index

x86 prefixes and escape opcodes flowchart

Published on 2023-07-29. Last updated on 2025-04-27

start here
|
v ╔══════════════════════════════════════════════════╗
╔═══════════════════════════════════════════════╤══╗ ║ 2-byte instructions (legacy map 1) ║
║ 1-byte instructions (legacy map 0) │0F------------->║ ║
║ └──╢ ║ operand type specified ┌──┐ ┌──┐ ║
╟──────────────────────────────────────────────────╢ .------->║ via mandatory prefixes │38│ │3A--------------.
║ 40-4F ║ | ║ - none (packed single) └─|┘ └──┘ ║ |
╟───────────────────────────|──────────────────────╢ | .---->║ - 66 (packed double) | ║ |
║ ┌──┐ ┌──┬──┐ | ║ | | ║ - F2 (scalar single) | ║ |
║ .--62│ │66│67│ | ║ | | +->║ - F3 (scalar double) | ║ |
║ | └──┘ └─|┴─|┘ | ║ | | | ╚═══════════════════════════════|══════════════════╝ |
║ | | | | ┌──┬──┐ ║ | | | v |
║ | | | | │C4│C5-----. ║ | | | ╔══════════════════════════════════════════════════╗ |
║ | | | | └|─┼──┤ | ║ | | | ║ 3-byte instructions (legacy map 2) ║ |
╟──┐ | ┌──┬──┐ | | | | │D5│ | ║ | +---->║ ║ |
║F0│ | │F2│F3│ | | | | └─|┘ | ║ | | | ║ operand type specified ║ |
╚══╧═|═╧═|╧═|╧══════|══|════|══════|═══|═════|═════╝ | | +->║ via mandatory prefixes ║ |
| | | ^ ^ | | | ^ ^ | | ^ | | | | ║ - none (packed single) ║ |
| | | | | | | | | | | | +---|----------+ | | ║ - 66 (packed double) ║ |
v '--+--+ +--+--' v | | v v | v m bit | | | ║ - F2 (scalar single) ║ |
┏━━━━┓ | ┏━━━|┓┏|━━━┓┏━━|━┓┏━━━━┓ | | | ║ - F3 (scalar double) ║ |
┃EVEX┃ | ┃REX1┃┃VEX3┃┃REX2┃┃VEX2┃------' | | ╚══════════════════════════════════════════════════╝ |
┗━━|━┛ | ┗━━━━┛┗━━|━┛┗━━━━┛┗━━━━┛ | | |
| ^ | | | ╔══════════════════════════════════════════════════╗ |
| | +-------->--------------+---->║ 3-byte instructions (legacy map 3) ║<-+
| | m bits | ║ ║
'---------+---->-----------------------------------------+->║ operand type specified ║
| ║ via mandatory prefixes ║
| ║ - none (packed single) ║
| ║ - 66 (packed double) ║
| ║ - F2 (scalar single) ║
| ║ - F3 (scalar double) ║
| ╚══════════════════════════════════════════════════╝
|
| ╔══════════════════════════════════════════════════╗
+->║ "promoted" legacy instructions (map 4) ║
| ║ ║
| ║ instruction from legacy maps 1/2/3 ║
| ║ promoted to EVEX for use with APX ║
| ╚══════════════════════════════════════════════════╝
|
| ╔══════════════════════════════════════════════════╗
+->║ AVX512-Float16 instructions (map 5/6) ║
╚══════════════════════════════════════════════════╝

┏━┯━┯━┯━┯━┯━┯━┯━┓ ┏━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┓
┃0 1 0 0 W R X B┃ ┃1 1 0 1 0 1 0 1┃M R X B W R X B┃
┗━┷━┷━┷━┷━┷━┷━┷━┛ ┗━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┛
REX (1-byte prefix) AMD64 (1999/2003) REX (2-byte prefix) APX (2023/????)
- W extends operand size - M selects legacy map 0 or legacy map 1
- R extends register bits - R extends register bits
- X extends index in SIB byte - X extends index in SIB byte
- B extends base in SIB byte - B extends base in SIB byte
- W extends operand size

┏━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┓ ┏━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┓
┃1 1 0 0 0 1 0 1┃Ṙ ⩒ ⩒ ⩒ ⩒ L p p┃ ┃1 1 0 0 0 1 0 0┃Ṙ Ẋ Ḃ m m m m m┃W ⩒ ⩒ ⩒ ⩒ L p p┃
┗━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┛ ┗━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┛
VEX (2-byte prefix) AVX (2008/2011) VEX (3-byte prefix) AVX (2008/2011)
- R extends register bits - R extends register bits
- v encodes additional source register - X extends index in SIB byte
- L selects vector length (0: 128bit | 1: 256bit) - B extends base in SIB byte
- p encodes mandatory prefixes - m selects instruction map (1: 0F | 2: 0F38 | 3: 0F3A)
(0: none | 1: 66 | 2: F2 | 3: F3) - W extends operand size
- instruction map 0F (legacy map 1) implied - v encodes additional source register
- L selects vector length (0: 128bit, 1: 256bit)
- p encodes mandatory prefixes
(0: none | 1: 66 | 2: F2 | 3: F3)

┏━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┳━┯━┯━┯━┯━┯━┯━┯━┓ Notes:
┃0 1 1 0 0 0 1 0┃Ṙ Ẋ Ḃ Ṙ B m m m┃W ⩒ ⩒ ⩒ ⩒ Ẋ p p┃z Ŀ L b ⩒ a a a┃ - years after the instruction set extension
┗━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┻━┷━┷━┷━┷━┷━┷━┷━┛ denote when it was first announced/shipped
EVEX (4-byte prefix) AVX-512 (2013/2017) - letters with a dot above denote that the
- R extends register bits prefix contains the bit in inverted form
- X extends index in SIB byte - the diagram elides escape bytes D8 til DF
- B extends base in SIB byte - the EVEX prefix has additional variations
- m selects instruction map (1: 0F | 2: 0F38 | 3: 0F3A | 4 | 5 | 6) not shown here for encoding
- W extends operand size - VEX instructions
- v encodes additional source register - legacy instructions
- p encodes mandatory prefixes (0: none | 1: 66 | 2: F2 | 3: F3) - conditional CMP/TEST
- z selects merge mode (0: zero | 1: merge)
- Ŀ selects vector length (512bit) or rounding control mode (with L)
- L selects vector length (256bit)
- b encodes source broadcast or rounding control (with Ŀ and L) or exception suppression

Vertical Tabs in Firefox

Intel's original 64bit extensions for x86

The document presents a visual and structural breakdown of x86 instruction encoding, focusing on the hierarchical relationships between instruction formats, prefixes, and escape opcodes. It outlines how different prefix types—REX, VEX, EVEX—interact with legacy and modern instruction maps to specify operand sizes, register extensions, vector lengths, and other architectural details. The flowchart begins with 1-byte instructions (legacy map 0) and branches into 2-byte (map 1), 3-byte (maps 2–3), and promoted legacy instructions (map 4), while also incorporating AVX512-Float16-specific mappings (maps 5–6). Each section emphasizes how mandatory prefixes like 66, F2, and F3 modify instruction behavior, particularly for floating-point operations, vectorized data types, and operand size extensions. The structure highlights the evolution of x86 architecture from early 16-bit and 32-bit designs to modern 64-bit extensions with AVX, AVX512, and APX, which introduce additional layers of complexity through extended prefixes and escape sequences.

The flowchart’s primary focus is on the encoding mechanisms that determine how instructions are interpreted by the CPU. For example, 1-byte instructions (legacy map 0) form the foundational set of machine code opcodes, while 2-byte instructions (map 1) rely on the 0F escape sequence to expand the instruction set. The document explains that certain operand types, such as packed single-precision or double-precision floating-point values, are explicitly defined through mandatory prefixes like 66 (for packed doubles), F2 (scalar singles), and F3 (scalar doubles). These prefixes alter the interpretation of subsequent opcodes, enabling finer control over data formats and execution modes. The interaction between these prefixes and the instruction maps is critical, as they determine how operands are accessed, whether vectorized operations are performed, and how memory addressing is handled through SIB (Scale-Index-Base) bytes.

The document also details how newer instruction sets, such as AVX and AVX512, build upon older architectures by introducing extended prefixes like VEX (2-byte) and EVEX (4-byte). These prefixes provide additional fields for specifying vector lengths (128-bit, 256-bit, or 512-bit), source registers, and rounding modes. For instance, the VEX prefix includes bits for selecting vector length (L), encoding additional source registers (v), and specifying mandatory prefixes (p) that override default operand sizes. The EVEX prefix further extends this by adding fields for merge modes (z), vector length selection (L and Ŀ), and broadcast controls (b). These extensions are essential for handling complex data operations, such as those required by modern applications in scientific computing, machine learning, and multimedia processing.

A key aspect of the flowchart is its emphasis on instruction maps, which categorize opcodes based on their encoding formats and associated prefixes. Legacy map 0 includes basic 1-byte instructions, while maps 1–3 represent 2-byte and 3-byte instructions that use escape sequences (e.g., 0F, 0F38, 0F3A) to access extended functionality. The document explains that these maps are not static but evolve with new architectural features, such as the promotion of legacy instructions to EVEX-encoded formats in APX (Advanced Vector Extensions). For example, certain older instructions that were originally part of maps 1–3 are "promoted" to map 4 through EVEX prefixes, allowing them to leverage AVX512’s wider registers and advanced capabilities. This promotes backward compatibility while enabling newer instructions to take advantage of enhanced performance features.

The text also addresses the role of escape opcodes in expanding the x86 instruction set. These are used to access instructions that do not fit into the primary opcode space, often requiring multiple bytes to encode complex operations. For example, the 0F escape sequence is commonly used in modern x86 architectures to access instructions related to floating-point operations, multimedia extensions (MMX), and advanced vector extensions. The document notes that while escape opcodes are a legacy feature, they remain integral to the x86 architecture’s ability to support a vast and evolving set of instructions. This is particularly relevant for AVX512, which includes numerous escape sequences to handle specialized operations like 16-bit floating-point arithmetic (Float16) and enhanced memory alignment controls.

The summary of the flowchart underscores the importance of prefix encoding in determining how instructions are executed. For example, REX (Register Extension) prefixes, introduced with AMD64 in 1999, allow for additional register bits (R, X, B) to access extended 64-bit registers. This is critical for modern applications that require more than the traditional 8 general-purpose registers (GPRs). Similarly, VEX and EVEX prefixes introduce additional fields for specifying vector lengths, source registers, and operand size extensions (W). These prefixes are essential for enabling vectorized operations on wide data types, such as 256-bit and 512-bit registers used in AVX and AVX512. The document highlights that these prefixes are not just syntactic conveniences but fundamental to the x86 architecture’s ability to scale with increasing computational demands.

Another critical aspect of the flowchart is its treatment of mandatory prefixes (66, F2, F3) and their role in modifying instruction behavior. These prefixes are used to override default operand sizes, specify scalar or packed operations, and enable specific execution modes. For instance, the 66 prefix typically extends operand sizes to 64 bits in 32-bit mode (or vice versa), while F2 and F3 are used to select scalar single-precision or double-precision floating-point operations. The document explains that these prefixes are often required for instructions that operate on non-default data types, such as 128-bit or 256-bit vectors. This mechanism allows the x86 architecture to maintain backward compatibility while supporting newer, more complex instruction sets.

The flowchart also touches on the role of escape bytes (D8–DF) in certain instruction encodings, though it notes that these are omitted for brevity. These escape bytes are used to access additional instruction sets, such as the x87 floating-point unit (FPU) instructions and some MMX or SSE extensions. While the document does not elaborate on these, it implies that their inclusion would complicate the flowchart further, emphasizing the need for a structured approach to instruction encoding. This aligns with the broader theme of the document: the x86 architecture’s complexity arises from its need to balance backward compatibility with forward-looking extensions, necessitating a hierarchical and modular encoding scheme.

Finally, the document provides context for the evolution of x86 instruction sets, noting that certain features were introduced in specific years (e.g., AVX in 2008, AVX512 in 2013). This timeline reflects the incremental development of the architecture, with each new extension building on previous ones. For example, the introduction of EVEX prefixes in AVX512 extended the capabilities of VEX prefixes used in AVX, allowing for even more complex operations on wider registers. The document also mentions APX (Advanced Vector Extensions), a newer extension introduced in 2023, which further modifies the encoding of legacy instructions to support advanced vector operations. This evolution highlights the x86 architecture’s adaptability, as it continues to evolve while maintaining a vast and diverse instruction set.

In summary, the flowchart serves as a comprehensive guide to the intricate relationships between x86 instruction encoding formats, prefixes, and escape opcodes. It illustrates how the architecture has expanded over time to support increasingly complex operations while maintaining compatibility with older instruction sets. The document emphasizes the importance of prefixes like REX, VEX, and EVEX in enabling modern features such as vectorized operations, extended registers, and advanced data types. By categorizing instructions into legacy maps and newer formats, the flowchart provides a structured framework for understanding how different prefixes interact with specific instruction sets to achieve desired computational outcomes. This level of detail is crucial for developers and researchers working with low-level x86 programming, as it helps them navigate the architecture’s complexity and leverage its full potential.