5.3 Indirect, Based, and Indexed Addressing
Direct addressing embeds one fixed offset in the instruction. Programs often need to walk through an array, select a record, or access a stack item whose location changes. The 8086 can calculate a memory offset from registers.
The calculated 16-bit offset is called the effective address (EA). Brackets mean memory is accessed at that EA.
The 8086 has a specific set of legal address expressions
The original 8086 can use BX or BP as a base, SI or DI as an index, and an optional constant displacement:
Not every register combination is encodable. The eight r/m memory patterns are:
| r/m | Address registers |
|---|---|
000 | BX + SI |
001 | BX + DI |
010 | BP + SI |
011 | BP + DI |
100 | SI |
101 | DI |
110 | BP, except mod=00 where it means direct address |
111 | BX |
The following are not ordinary 8086 effective-address forms: [AX], [DX], [SP], [BX+BP], and [SI+DI]. A register may hold a useful number without being legal in this encoding field.
“Indirect” means the instruction names a register that contributes to the address rather than embedding the final address alone. “Based” emphasizes BX or BP; “indexed” emphasizes SI or DI. A single expression can be both based and indexed.
Displacement changes the address and the encoding
The mod field controls displacement size:
mod=00: normally no displacement;
mod=01: one signed 8-bit displacement, from −128 through +127;
mod=10: one 16-bit displacement;
mod=11: register operand, not memory.
An 8-bit negative displacement is sign-extended before addition. If SI=1000H, then [SI-10H] has EA=0FF0H; displacement −16 is encoded as byte F0H.
The [BP] form needs special care. Because mod=00,r/m=110 is reserved for a direct 16-bit address, [BP] is encoded as [BP+0] with mod=01 and displacement byte 00H.
Lab 1 — build legal and illegal address expressions
Toggle all four candidate address registers and adjust a positive or negative displacement. The bench diagnoses illegal combinations and emits the exact mod/r/m/displacement fields for legal ones.
Check your understanding
Effective-address arithmetic wraps at 16 bits
EA is a 16-bit offset. If register addition exceeds FFFFH, only the low 16 bits remain. For example:
This is offset wraparound. Section 5.4 then combines the resulting EA with a segment value to form a 20-bit physical address.
Equivalent addresses can have different costs
Suppose BX=1000H, SI=0020H, and the target EA is 1020H:
[BX+SI]reaches the target with no displacement;
[BX+20H]can also reach1020H, but needs a displacement byte.
For a given instruction family, the first form is shorter because its ModR/M byte needs no following displacement.
Shorter is not always the only goal; the expression must also match which registers the program can safely use. Encoding cost is one engineering constraint alongside correctness and register availability.
Lab 2 — hit a target EA within a byte budget
Choose among all legal 8086 register routes and tune displacement. Some missions have one shortest solution; others deliberately accept several strategies as long as they reach the same EA within budget.
Check your understanding
Effective-address checklist
1. Verify that the register combination exists in the 8086 r/m table.
2. Add current register contents and the signed or 16-bit displacement.
3. Keep the low 16 bits as EA.
4. Choose the smallest displacement form that represents the required value.
5. Remember the [BP] encoding exception.
EA is only an offset. The next section decides which segment supplies its base and shows how a segment override can fix—or create—a memory-access bug.