Chapter 4 · Simulation

Addressing Modes

← Chapter 4

Addressing Modes

Goal: See step by step where the source operand of a MOV instruction lives and, if it is in memory, how the CPU finds its address: effective address (EA), segment, physical address and the value read.

How to use it

  1. Operand: memory, immediate (constant) or register. For memory you choose a base (BX/BP), an index (SI/DI) and a displacement; at most one from each group can be used, so only valid combinations can be built.
  2. The values of the segment and address registers can be changed by typing hexadecimal numbers into the boxes in the middle. The displacement can be decimal (-2, 300) or hexadecimal (1234h).
  3. Step ▶ (or →) shows the addition, the segment choice, the physical address and the memory read in turn.
  4. Try it yourself: you are asked for the EA, the segment and the physical address; correct and wrong answers are counted.

Rules

  • Modes: direct [1000h]; register indirect [BX], [SI], [DI]; based [BX+d], [BP+d]; indexed [SI+d], [DI+d]; base-indexed [BX+SI]…; base-indexed + displacement [BP+DI-2].
  • EA = base + index + displacement, computed in 16 bits; it wraps around if it exceeds FFFFh.
  • Default segment: SS if the address contains BP, otherwise DS. A segment prefix (ES:[BX]) overrides this choice.
  • Physical address = segment × 10h + EA (20 bits; wraps around if it exceeds FFFFFh).
  • When a word is read, the low byte comes from EA and the high byte from EA + 1 (little-endian). If EA = FFFFh, the second byte is read from offset 0000h of the same segment.
  • When [BP] is written alone, the assembler encodes it as [BP+0]; the displacement is 8 bits (d8) if it is in −128…127, otherwise 16 bits (d16).

The byte values in memory are for display only. The calculations were checked against an 8086 interpreter.

Related slides: Chapter 4.1 · Memory Access (the combination rule, forward displacement, addressing mode types, the effective address step by step, access with BP, segment prefix, little-endian layout).