5.1.5Instruction Set Architecture (ISA)

x86 architecture overview

2,156 words10 min readdifficulty · medium2 backlinks

WHY does x86 look the way it does?

WHAT this gives us / costs us:

  • ✅ A single binary runs on 40 years of hardware.
  • ❌ Instructions are variable length (1–15 bytes), making decoding hard.
  • ❌ The register set is small and irregular compared to RISC.

WHAT is x86, precisely?

The general-purpose registers grew by extension, which is why their names look layered:

64-bit 32-bit 16-bit 8-bit (low) traditional role
RAX EAX AX AL Accumulator
RBX EBX BX BL Base
RCX ECX CX CL Counter (loops)
RDX EDX DX DL Data
RSP ESP SP Stack Pointer
RBP EBP BP Base/Frame Pointer
RSI ESI SI Source Index
RDI EDI DI Dest Index
R8–R15 R8D… R8W… R8B… added in x86-64
Figure — x86 architecture overview

HOW an instruction actually flows

An x86 instruction is a sequence of fields, each optional except the opcode:

[Prefixes]    [Opcode]    [ModR/M]    [SIB]    [Displacement]    [Immediate]\text{[Prefixes]} \;\to\; \text{[Opcode]} \;\to\; \text{[ModR/M]} \;\to\; \text{[SIB]} \;\to\; \text{[Displacement]} \;\to\; \text{[Immediate]}

  • Prefix: modifiers (operand size, REX for 64-bit/extra registers, lock, repeat).
  • Opcode: what to do (ADD, MOV…).
  • ModR/M + SIB: encode which registers/memory operands and the addressing mode.
  • Displacement / Immediate: constants baked into the instruction.

Segmentation & addressing (the historical fossil)


Worked examples


Common mistakes (steel-manned)


Feynman

Recall Explain to a 12-year-old

Imagine a toy robot from 1978. Every year the company sold a better robot, but they promised: "all your old cassettes will still play." So they never removed old buttons, they only added new ones. Today's robot has 40 years of buttons stacked up — powerful, but a bit of a messy control panel. That's x86: super compatible, a little cluttered, and still going strong.


Recall


Flashcards

x86 belongs to which ISA design philosophy?
CISC (Complex Instruction Set Computer)
What is the defining design constraint of the whole x86 family?
Backward compatibility with the Intel 8086
How long can an x86 instruction be?
Variable length, 1 to 15 bytes
Formula for a real-mode physical address?
(Segment × 16) + Offset = (Segment << 4) + Offset
Why multiply the segment by 16?
To shift the 16-bit segment left by 4 bits, spanning a 20-bit (1 MB) address with a 16-bit offset
What is EAX relative to RAX?
EAX is the low 32 bits of the 64-bit RAX register
What is AL relative to AX?
AL is the low 8 bits of the 16-bit AX register
Who introduced 64-bit x86 and what is it called?
AMD, in 2003; called AMD64 / x86-64
Name the 8 legacy general-purpose 64-bit registers.
RAX, RBX, RCX, RDX, RSP, RBP, RSI, RDI
What does the REX prefix enable?
64-bit operand size and access to extra registers R8–R15
What does a modern x86 CPU do with a CISC instruction internally?
Decodes it into RISC-like micro-ops (µops) executed out-of-order
Why is variable-length encoding costly?
You can't locate instruction n+1 until you've fully decoded instruction n, complicating the decoder
The four fetch–execute stages?
Fetch, Decode, Execute, Write-back
In long (64-bit) mode, what happened to segmentation?
Mostly disabled — a flat memory model is used, though segment registers still exist

Connections

Concept Map

motivated

defines

forces

grows

has

has

produces

layered as

history of

causes

part of

runs via

Backward compatibility

CISC philosophy

Tiny expensive memory 1978

x86 ISA family

Extend never redesign

Variable length instructions

Small irregular register set

Nested register names RAX EAX AX AL

8086 to 80386 to x86-64

Hard decode step

Fetch decode execute writeback

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, x86 ka pura funda ek line mein: backward compatibility. 1978 mein Intel ka 8086 aaya, aur uske baad har naya chip purane ko todta nahi, balki usme feature add karta gaya. Isiliye aaj ka modern 64-bit CPU bhi 40 saal purana DOS program chala sakta hai. Yahi wajah hai ki x86 ek CISC architecture hai — matlab ek instruction bahut saara kaam karta hai, aur instructions ki length fixed nahi, 1 se 15 bytes tak variable hoti hai.

Registers ki nesting samajhna zaroori hai. RAX (64-bit) ke andar EAX (32-bit), uske andar AX (16-bit), aur uske andar AL (8-bit). Yeh ek hi physical register hai jise alag-alag naam se, alag-alag layer tak, access kar sakte ho. Yeh koi copy nahi hoti — bas low bits ka window hai. Isi tarah yeh sab historically evolve hua: 16-bit se 32-bit (80386, IA-32) se 64-bit (AMD64, jo 2003 mein AMD ne banaya, Intel ne nahi).

Ek important cheez: purane 8086 mein memory access ke liye segmentation thi, kyunki 16-bit register se 20-bit (1 MB) address point karna possible nahi tha. Formula tha: Physical Address = Segment × 16 + Offset. Yahan ×16 ka matlab hai left shift by 4 bits — hardware mein yeh basically free hai, koi mehenga multiply nahi.

Aur ek myth tod do: "CISC slow hai, RISC jeet gaya" — galat. Modern x86 chip andar-andar CISC instruction ko chhote micro-ops (µops) mein todta hai aur unhe RISC ki tarah out-of-order chalata hai. Toh x86 bahar se CISC, andar se RISC-jaisa hai. Exam mein yeh distinction — ISA vs microarchitecture — bahut kaam aata hai.

Go deeper — visual, from zero

Test yourself — Instruction Set Architecture (ISA)

Connections