8086 Microprocessor
The 16-bit 8086 introduced the x86 architecture still used in PCs. Learn the BIU/EU split with instruction queue, segment registers and physical address calculation, general and pointer registers, flags, addressing modes, minimum/maximum modes, and 8086 assembly with MASM syntax.
The 8086 (1978) doubled the data width to 16 bits and extended memory to 1 MB using segmentation. Its instruction set evolved into today's x86-64 — so learning it explains much of how PCs work at the lowest level.
An analogy
Segmentation is like addressing a book by chapter and page: the segment register picks the chapter (64 KB block), the offset picks the page inside it.
BIU and EU
The Bus Interface Unit fetches instructions into a 6-byte prefetch queue and computes addresses; the Execution Unit decodes and executes. This overlap was an early form of pipelining.
Registers and flags
AX (accumulator), BX (base), CX (count), DX (data/I/O), SI/DI (string indexes), BP/SP (stack). Flags: CF, PF, AF, ZF, SF, OF plus control flags TF, IF, DF.
Addressing modes
Immediate, register, direct, register indirect, based, indexed, based-indexed, with displacements (e.g. [BX+SI+10H]). String instructions (MOVSB, REP) use SI/DI with DF direction.
System design
Minimum mode (single processor, generates control signals) vs maximum mode (with 8288 bus controller and 8087 coprocessor). 256 interrupt types via the interrupt vector table at 00000H–003FFH. Evolution: 80286 protected mode, 80386 32-bit, x86-64.
Formulas
- Physical address:
PA = segment × 16 + offset (segment × 10H + offset) - Address space:
2²⁰ = 1 MB - Segment size:
64 KB per segment
Worked example: Physical address
Given: CS = 2000H, IP = 0150H
Find: PA of the next instruction.
- 2000H × 10H = 20000H
- 20000H + 0150H = 20150H
Answer: 20150H
Worked example: Segment range
Given: DS = 1234H
Find: Address range.
- Start 12340H
- End 12340H + FFFFH = 2233FH
Answer: 12340H – 2233FH
Sum an array (8086 MASM)
.MODEL SMALL
.DATA
ARR DW 10, 20, 30, 40, 50
N EQU 5
SUM DW ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX ; initialise data segment
LEA SI, ARR ; SI -> first element
MOV CX, N ; loop counter
XOR AX, AX ; AX = 0
NEXT:
ADD AX, [SI] ; accumulate word
ADD SI, 2 ; next word
LOOP NEXT ; CX--, jump if CX != 0
MOV SUM, AX ; SUM = 150
MOV AH, 4CH
INT 21H ; return to DOS
MAIN ENDP
END MAINLOOP uses CX as a counter automatically; [SI] is register-indirect addressing in the data segment. INT 21H calls DOS services.
Common mistakes
- Wrong: Adding segment and offset directly. — Right: Shift segment left by 4 bits (× 16) first.
- Wrong: Forgetting to load DS. — Right: Initialise segment registers at start.
Applications
- PC heritage: x86 real mode, BIOS and bootloaders.
- Education: Assembly and segmentation.
- Reverse engineering: Understanding x86 machine code.
Key takeaways
- 16-bit data, 20-bit address (1 MB).
- PA = segment × 16 + offset.
- BIU prefetch + EU execute.
- Foundation of x86.
Going further
- Protected mode: Descriptors and paging in 80386+.
- 8087 coprocessor: Floating-point extension.
- x86-64: Modern 64-bit extensions.