5.1.5 · D3Instruction Set Architecture (ISA)

Worked examples — x86 architecture overview

3,167 words14 min readBack to topic

Two prerequisite ideas we lean on, both built from zero below so you never meet a symbol cold:

  • A hex digit is one of — sixteen values, i.e. exactly 4 bits (because ). This is the reason x86 loves hex: one hex digit = one nibble = 4 wires.
  • A shift-left-by- written means "glue zero-bits onto the right end of 's binary form," which multiplies the value by . So is , i.e. "append one hex zero."

Two pieces of plain math shorthand appear below — here's what they mean so no symbol is a surprise:

  • (an interval) is shorthand for "every value from up to , endpoints included." So just means .
  • (modulo) means "the remainder left after removing whole copies of from " — i.e. what's left once has wrapped around a wheel of size . For example because it wraps exactly once back to the start.

The scenario matrix

Everything on this topic is one of these cells. Each worked example below is tagged with the cell it covers, so by the end no cell is left unseen.

# Case class What's special about it Example
A Address: ordinary case segment & offset both nonzero, no wrap Ex 1
B Address: zero degenerate offset , or segment Ex 2
C Address: overlap / aliasing two different (seg, off) pairs → same byte Ex 3
D Address: wrap-around / limit sum exceeds 20 bits ( 1 MB) Ex 4
E Register: ordinary window read pull EAX/AX/AL/AH out of RAX Ex 5
F Register: partial-write trap writing EAX zeroes upper 32; AL/AH/AX/RAX writes behave differently Ex 6
G Word problem (real world) "will this .COM file fit?" Ex 7
H Exam twist instruction-length reasoning + a "gotcha" address Ex 8

Below, all numbers with a 0x prefix are hexadecimal (base 16); everything else is decimal.


Cell A — the ordinary address

The figure below shows the assembly literally: watch the yellow box gain a trailing 0 (that's the ), then the green offset drop into the low nibbles, giving the red result 0x2F140.

Figure — x86 architecture overview

Cell B — the zero degenerate


Cell C — overlap / aliasing (the fossil's weirdest bug)

The figure below plots the single red target byte 0x12345 on a physical number line, with the blue pair (short +0x05 hop from base 0x12340) and the green pair (longer +0x45 hop from base 0x12300) both arriving at it — two arrows, one landing spot.

Figure — x86 architecture overview

Cell D — wrap-around / the 1 MB limit


Cell E — ordinary register window

The figure below stacks the 16 hex digits of RAX and brackets each name's window from the right: green EAX (8 digits), yellow AX (4), red AL (2), and — offset from the low end — the orange AH bracket, making vivid that AH is not at the bottom.

Figure — x86 architecture overview

Cell F — the partial-write trap (all four widths)


Cell G — real-world word problem


Cell H — exam twist (address + instruction length together)


Recall

Recall Answers
  1. e.g. segment 0x30A0 - 1 = 0x309F, offset 0x0008 + 0x10 = 0x00180x309F:0x0018 (both give 0x309A8).
  2. 0xFFFF0 + 0x11 = 0x100001 → wraps to 0x00001.
  3. mov eax, 1 zero-extends → 0x0000000000000001; mov ah, 2 merges byte 1 → 0x0000000000000201; mov al, 3 merges byte 0 → 0x0000000000000203.
  4. 0x10000 = 65536 bytes.

Cross-links: Instruction Set Architecture (ISA) · Registers and the Register File · Fetch-Decode-Execute Cycle · ARM Architecture · parent x86 overview.