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

Worked example: Physical address

Given: CS = 2000H, IP = 0150H

Find: PA of the next instruction.

Answer: 20150H

Worked example: Segment range

Given: DS = 1234H

Find: Address range.

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 MAIN

LOOP uses CX as a counter automatically; [SI] is register-indirect addressing in the data segment. INT 21H calls DOS services.

Common mistakes

Applications

Key takeaways

Going further