Architecture of x86 Processors: Registers, Addressing Modes, and Instruction Format
The x86 family is a CISC architecture whose execution model can be understood as: a microarchitectural core executes decoded instructions, while the architectural state (registers, flags, control registers, segment/base/limit state, and memory addressing rules) defines program-visible behavior. At the instruction boundary, the CPU:
- fetches an instruction stream from memory using the current instruction pointer,
- decodes prefixes + opcode + ModR/M(+SIB)+displacement+immediate,
- computes effective addresses (EA) using x86 addressing modes,
- reads/writes operands via registers and memory, and
- updates architectural state (including flags).
A helpful mental model is that x86 “architecture rules” live in three interacting layers: (1) register file and flags, (2) segmentation/base-index addressing for effective addresses, and (3) variable-length instruction encoding that drives decoding. 3
Key x86 concepts (for this section)
- Effective Address (EA)
- ModR/M
- SIB
- Prefix
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (register overview, general instruction decoding concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
x86 instruction encoding overview (prefix, opcode, ModR/M, SIB)
Architectural register sets: what “registers” mean on x86
x86 exposes multiple register classes. Even if microarchitecture implements them differently internally, the architectural programmer-visible contract is what matters for understanding instruction semantics.
Common register groups:
- General-purpose registers (GPRs): arithmetic/data registers (e.g., EAX/RAX, EBX/RBX, ECX/RCX, EDX/RDX, ESI/RSI, EDI/RDI, EBP/RBP, ESP/RSP) 2
- Instruction pointer: EIP (32-bit) or RIP (64-bit)
- Flags register: EFLAGS/RFLAGS contains condition codes and control flags
- Control registers: CR0–CR4 (enable/disable features, paging, protection)
- Debug registers: DR0–DR7 (hardware breakpoints/watchpoints)
- Segment registers (legacy but still architecturally relevant): CS, DS, ES, SS, FS, GS with base/limit semantics in protected/compatibility modes
To avoid mixing concepts: segment registers primarily participate in address translation, while general-purpose registers primarily supply operand values and participate in effective address arithmetic.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (register overview, general instruction decoding concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (RIP and flags/general architectural state) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩ ↩2 ↩3
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 3 (control/debug register descriptions) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩ ↩2
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
General-purpose registers and aliasing (32-bit vs 64-bit)
x86 uses register families with architectural aliases:
- In 32-bit mode, registers are typically named EAX, EBX, ….
- In 64-bit mode, they become RAX, RBX, ….
- Many “lower 32-bit” operations have implicit zero-extension behavior on x86-64 (this affects how flags and dependencies behave).
This section focuses on architecture-level understanding of how registers map into the instruction format operands and address generation.
Examples of register naming (conceptual):
- GPR
- RIP
- EFLAGS
- RFLAGS
(Precise alias behaviors are specified in Intel/AMD manuals; the key takeaway for instruction format is that operand-size and addressing-size prefixes determine which register widths are used for a given instruction encoding.) 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (register overview, general instruction decoding concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (RIP and flags/general architectural state) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Flags: where the CPU records results
Condition codes are stored in EFLAGS/RFLAGS, while other bits control execution behavior. For the course goal here, you should know that instruction semantics often depend on flags and that many arithmetic/logic instructions both compute results and update flags.
Key flags concepts:
- CF
- ZF
- SF
- OF
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (RIP and flags/general architectural state) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Segment registers and how they relate to addressing
Legacy segmentation uses segment selectors held in segment registers, combined with an offset to form a linear address (in protected mode). Modern x86-64 uses a simplified view for many code/data accesses, but architectural rules and segment override prefixes still exist.
- Segment Override Prefix
Understanding segment override is crucial because the instruction encoding includes prefix bytes that affect the translation path of memory operands.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩ ↩2
Addressing modes: how x86 computes memory operands
x86 memory operands are described by encoding fields inside the instruction, most notably ModR/M and often SIB in 32/64-bit addressing.
Effective address formula (core idea)
A common x86 EA form can be represented as:
Where:
- Base and Index come from register fields (or may be absent depending on encoding),
- Scale is typically one of (encoded compactly),
- Displacement is an immediate value inside the instruction stream.
The exact availability of components (e.g., index absent, base omitted) depends on the ModR/M and SIB encodings.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Compute an x86 effective address from instruction bytes
- 1Step 1
From the opcode and ModR/M/reg fields, determine which operand(s) are registers and which are memory references.
- 2Step 2
Read any prefix bytes (e.g., segment override, address-size override). These affect which addressing rules apply.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
- 3Step 3
Use ModR/M fields to determine: (a) whether a memory EA is present, (b) the addressing form, and (c) the displacement size (none/8/32).
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
- 4Step 4
If the addressing form requires it, decode SIB to extract Scale, Index, and Base register selections.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
- 5Step 5
Read displacement bytes (and other immediate bytes, if required) from the instruction stream.
- 6Step 6
Apply the x86 EA arithmetic rules implied by the decoded fields.
- 7Step 7
If a segment override is present or the default segment applies, compute the translated address using architectural segment/translation rules.
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Common addressing-mode patterns (conceptual mapping)
Below is a simplified mapping between common assembly forms and the underlying encoded ingredients.
| Assembly-like form (conceptual) | Encoded ingredients (high-level) | Notes |
|---|---|---|
| ModR/M selects EA with Base; displacement may be 8/32 | Index absent | |
| ModR/M + SIB provide base/index/scale; displacement added | Most general base-index form | |
| Base may be encoded as absent depending on ModR/M/SIB | Requires careful encoding rules | |
| (32-bit absolute in some modes) | Displacement as address, no base/index | Depends on mode and encoding |
(Exact encoding legality depends on mode and specific opcode operand type; the manuals specify the ModR/M and SIB decoding rules.)
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Address-size and operand-size effects
x86 includes prefixes that can override default sizes:
- Address-Size Prefix
- Operand-Size Prefix
This matters because the instruction format uses different decoding paths depending on these sizes, which in turn determines whether SIB is used and how registers are selected for effective address computation. 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (register overview, general instruction decoding concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Instruction format: variable-length encoding anatomy
x86 instructions are variable-length. Decoding is driven by:
- Prefixes (repeatable categories; order rules apply),
- Opcode (1 or more bytes; often determines operand structure),
- ModR/M byte (when the opcode expects register/memory operand),
- SIB byte (when addressing needs base+index+scale in certain modes),
- Displacement (0, 8-bit, or 32-bit depending on addressing form),
- Immediate data (optional and opcode-dependent).
Prefix categories that matter for this course
Typical categories include:
- segment override prefix (affects memory translation),
- operand-size override prefix,
- address-size override prefix,
- and sometimes additional prefixes for specific instruction groups. 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
How to read instruction bytes (byte-level “grammar”)
A generic decode flow can be expressed as:
- Read zero or more prefixes.
- Read opcode byte(s).
- Determine whether an operand encoding byte is needed.
- If needed, read ModR/M:
- Extract
mod(addressing mode / displacement presence), - extract
reg(register operand extension), - extract
r/m(register or memory addressing selector).
- Extract
- If the addressing form calls for it, read SIB:
- Extract
scale,index,base.
- Extract
- Read displacement if indicated by
mod. - Read immediate if specified by the opcode form.
This is the core mechanism that connects instruction format to addressing modes. 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
ModR/M and SIB: why they exist
- ModR/M compactly encodes: (a) which register (or memory EA) is referenced and (b) which operand-extension field is used by the opcode.
- SIB extends the addressing vocabulary to support base+index*scale efficiently.
Therefore, “understanding x86 architecture” for a student means connecting these fields to effective address computation.
Key fields:
- Mod
- R/M
- Scale
- Index
- Base
(These interpretations are defined by x86 instruction encoding rules.)
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
From bytes to operands (execution-visible pipeline)
Read prefixes
Decode startIdentify overrides (segment/operand-size/address-size) that affect how the rest is interpreted. "
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Read opcode
NextOpcode determines instruction semantics and whether ModR/M and/or immediates are present. "
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (register overview, general instruction decoding concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Parse ModR/M
ThenSelect register vs memory addressing and determine displacement size class. "
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Parse SIB
If neededDecode Scale/Index/Base for complex effective addresses. "
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Compute EA and execute
FinallyCompute EA, translate address, read/write operands, then update register/flags state. 2"
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (RIP and flags/general architectural state) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Pro Tip: decode in a fixed order
When manually decoding x86, always parse in order: prefixes → opcode → ModR/M → SIB → displacement → immediate. This prevents common mistakes where you mis-read later bytes as earlier fields.
Warning: address-size vs operand-size are different
Address-size override changes how effective addresses are formed; operand-size override changes the width of the data operands. Confusing them leads to incorrect EA arithmetic or incorrect register width.
Visualizing the instruction layout
A simplified diagram for a ModR/M+SIB memory operand case:
Instruction encoding is therefore the “bridge” between the architectural rules for effective addressing and the programmer-visible assembly syntax. 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Summary map: architecture parts you must connect
- Registers: define operand sources/targets and control behavior (including flags, control/debug registers). 2
- Addressing modes: determine EA = Base + Index*Scale + Displacement.
- Instruction format: uses prefixes + opcode + ModR/M (+SIB) + displacement/immediate to drive decoding. 2
Footnotes
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (RIP and flags/general architectural state) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 3 (control/debug register descriptions) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (ModR/M, SIB, effective address computation) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩ ↩2
-
Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 (segment override/prefix and segmentation/translation concepts) - https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html ↩
Knowledge Check
In the x86 instruction encoding, which component most directly encodes the addressing mode for a memory operand (including whether a displacement is present)?
Explore Related Topics
Fundamentals of Microprocessors
Microprocessors are the central processing units of computers, built on the Von Neumann architecture and composed of an ALU, register array, and control unit that work together via internal and external buses. The course covers the instruction cycle, performance considerations, and contrasts CISC and RISC designs.
- ALU performs arithmetic/logic; registers provide sub‑clock‑cycle access; CU decodes instructions and generates control signals.
- Instruction cycle: Fetch (PC increments), Decode (opcode → control signals), Execute (ALU operation, write‑back, flag update).
- Registers are far faster than external RAM, so maximizing their use reduces latency.
- Pipelining speeds execution but branch instructions cause pipeline flushes, adding delay.
- CISC emphasizes complex, variable‑length instructions; RISC uses simple, fixed‑length, register‑centric instructions requiring more registers but enabling one‑cycle execution.
List Registers of a Non-Pipelined CPU and Their Purposes
x86 Architecture: Which Processor Family (RISC, CISC, EPIC, or ARM)?