Segment:Offset Addressing, Pins & Addressing Modes
Open in the Padhaiko app3.3 Segment and offset address
Although the 8086 addresses 1 MB (2^20 bytes) of physical memory using a 20-bit address bus (00000H to FFFFFH), every internal register (CS, DS, SS, ES, IP, SP, BP, SI, DI, BX) is only 16 bits wide and can hold at most 64 KB (0000H–FFFFH). Memory segmentation bridges this gap by specifying every memory location with a 32-bit logical pair Segment:Offset.
Logical Address, Segment Base, Offset, and Physical Address
- Segment Base Address (16-bit): Held in one of the four segment registers (
CS,DS,SS,ES). Because the BIU automatically appends four trailing binary zeros (one hex digit0H), every 64 KB segment starts on a 16-byte paragraph boundary (physical addresses ending in0H). - Offset / Effective Address (
EA, 16-bit): The byte distance from the start of the segment (0000HtoFFFFH, i.e.,0to65,535bytes). - 20-Bit Physical Address Formula: Computed by the BIU's dedicated 20-bit adder:
Physical Address = (Segment Register * 10H) + Offset(Equivalently in decimal:Segment * 16 + Offset). - Segment Range: A segment starting at
Segment * 10Hspans64 KB, ending at(Segment * 10H) + FFFFH.
| Memory Reference Type | Default Segment | Default Offset(s) | Override Allowed? |
|---|---|---|---|
| Instruction Fetch | CS | IP | No |
Stack Operations (PUSH, POP, CALL, RET) | SS | SP | No |
Stack Frame Access ([BP]) | SS | BP + disp / index | Yes (CS:, DS:, ES:) |
| General Data Access | DS | BX, SI, DI, 16-bit disp | Yes (CS:, ES:, SS:) |
String Source (MOVS, LODS, CMPS) | DS | SI | Yes (CS:, ES:, SS:) |
String Destination (MOVS, STOS, SCAS) | ES | DI | No (always ES:DI) |
3.4 Pin configurations of 8086
The Intel 8086 is housed in a 40-pin Dual In-line Package (DIP) operating on a single +5 V supply. To fit a 20-bit address bus, 16-bit data bus, and control signals into 40 pins, the 8086 uses time-division multiplexing on pins AD0–AD15, A16/S3–A19/S6, and BHE_bar/S7, and switches pins 24–31 between Minimum Mode (MN/MX_bar = 1) and Maximum Mode (MN/MX_bar = 0).
+-------\_/-------+
GND 1 | | 40 VCC (+5V)
AD14 2 | | 39 AD15
AD13 3 | | 38 A16 / S3
AD12 4 | | 37 A17 / S4
AD11 5 | | 36 A18 / S5
AD10 6 | | 35 A19 / S6
AD9 7 | | 34 BHE_bar / S7
AD8 8 | | 33 MN / MX_bar
AD7 9 | INTEL 8086 | 32 RD_bar
AD6 10 | 40-Pin DIP | 31 HOLD / (RQ_bar/GT0_bar)
AD5 11 | | 30 HLDA / (RQ_bar/GT1_bar)
AD4 12 | Min / (Max) | 29 WR_bar / (LOCK_bar)
AD3 13 | | 28 M/IO_bar / (S2_bar)
AD2 14 | | 27 DT/R_bar / (S1_bar)
AD1 15 | | 26 DEN_bar / (S0_bar)
AD0 16 | | 25 ALE / (QS0)
NMI 17 | | 24 INTA_bar / (QS1)
INTR 18 | | 23 TEST_bar
CLK 19 | | 22 READY
GND 20 | | 21 RESET
+-----------------+Common Signals (Both Minimum and Maximum Modes)
| Pin(s) | Signal | Direction | Function |
|---|---|---|---|
2–16, 39 | AD0–AD15 | Bidir (3-state) | Time-multiplexed Address (A0–A15 during T1) and Data (D0–D15 during T2–T4). |
35–38 | A19/S6–A16/S3 | Out (3-state) | Upper 4 address bits during T1; status bits S3–S6 during T2–T4 (S4,S3 encode active segment; S5 = IF; S6 = 0). |
34 | BHE_bar / S7 | Out (3-state) | Bus High Enable during T1 (low activates odd memory bank D8–D15); status S7 during T2–T4. |
33 | MN / MX_bar | Input | Mode select: HIGH (+5V) = Minimum Mode; LOW (GND) = Maximum Mode. |
32 | RD_bar | Out (3-state) | Active-low read strobe for memory or I/O read cycles. |
22 | READY | Input | High tells 8086 memory/IO is ready; low inserts Wait (Tw) states. |
21 | RESET | Input | Active high (>= 4 clocks); clears flags, DS, SS, ES, IP = 0000H, and sets CS = FFFFH (boot at FFFF0H). |
19 | CLK | Input | Asymmetric clock input (33% duty cycle) at 5, 8, or 10 MHz from 8284 clock generator. |
18 | INTR | Input | Level-triggered maskable interrupt request (gated by IF). |
17 | NMI | Input | Rising-edge-triggered Non-Maskable Interrupt (Type 2; cannot be masked by IF). |
23 | TEST_bar | Input | Polled by WAIT instruction; execution stalls while TEST_bar = 1 (used to sync with 8087). |
1, 20, 40 | GND, VCC | Power | Two ground pins (1, 20) and +5 V supply (40). |
BHE_bar | A0 | Memory Access Type | Data Lines Used |
|---|---|---|---|
0 | 0 | Whole 16-bit word from an even address | D15–D0 (both banks) |
0 | 1 | High byte (8-bit) from an odd address | D15–D8 (odd bank) |
1 | 0 | Low byte (8-bit) from an even address | D7–D0 (even bank) |
1 | 1 | Idle / no transfer | None |
Minimum Mode vs. Maximum Mode (Pins 24–31)
| Aspect | Minimum Mode (MN/MX_bar = 1) | Maximum Mode (MN/MX_bar = 0) |
|---|---|---|
| System Architecture | Single-processor system; 8086 generates all control signals directly | Multiprocessor system (8086 + 8087/8089); uses 8288 Bus Controller to decode control signals |
| Pin 24 | INTA_bar — Interrupt Acknowledge pulse | QS1 — Queue Status bit 1 (with QS0 shows prefetch queue action) |
| Pin 25 | ALE — Address Latch Enable (latches A0–A19, BHE_bar into 8282/74LS373 during T1) | QS0 — Queue Status bit 0 (00 no op, 01 1st opcode byte, 10 flush, 11 subsequent byte) |
| Pin 26 | DEN_bar — Data Enable (enables 8286 bidirectional data transceivers) | S0_bar — Bus cycle status bit 0 (fed to 8288) |
| Pin 27 | DT/R_bar — Data Transmit (1) / Receive (0) direction for 8286 | S1_bar — Bus cycle status bit 1 (fed to 8288) |
| Pin 28 | M/IO_bar — Memory (1) vs. I/O (0) cycle indicator | S2_bar — Bus cycle status bit 2 (fed to 8288) |
| Pin 29 | WR_bar — Active-low write strobe | LOCK_bar — Prevents other bus masters from seizing the bus (LOCK prefix) |
| Pin 30 | HLDA — Hold Acknowledge output to DMA controller | RQ_bar/GT1_bar — Bidirectional Request/Grant channel 1 (lower priority) |
| Pin 31 | HOLD — DMA Hold Request input | RQ_bar/GT0_bar — Bidirectional Request/Grant channel 0 (higher priority) |
S2_bar | S1_bar | S0_bar | Bus Cycle Indicated | 8288 Command Output |
|---|---|---|---|---|
0 | 0 | 0 | Interrupt Acknowledge | INTA_bar |
0 | 0 | 1 | Read I/O Port | IORC_bar |
0 | 1 | 0 | Write I/O Port | IOWC_bar, AIOWC_bar |
0 | 1 | 1 | Halt | None |
1 | 0 | 0 | Code Access (Instruction Fetch) | MRDC_bar |
1 | 0 | 1 | Read Memory | MRDC_bar |
1 | 1 | 0 | Write Memory | MWTC_bar, AMWC_bar |
1 | 1 | 1 | Passive (Inactive) | None |
3.5 Addressing modes of 8086
An addressing mode is the rule by which an instruction specifies the location of its source and/or destination operand(s). The 8086 provides data-memory, I/O port, string, and program-control addressing modes.
Data & Memory Addressing Modes of 8086
- Immediate Addressing Mode: The 8-bit or 16-bit source operand is encoded directly inside the instruction bytes.
- Examples:
MOV AL, 45H,MOV BX, 1234H,ADD CX, 0010H
- Examples:
- Register Addressing Mode: Both operands (or the single operand) reside in internal CPU registers; no memory bus cycle is needed.
- Examples:
MOV AX, BX,ADD CL, DL
- Examples:
- Direct Addressing Mode: The 16-bit offset (effective address) of the operand within the data segment (
DSby default) is written directly inside square brackets.- Examples:
MOV AL, [2000H],MOV [1500H], BX(Physical Address =DS * 10H + offset)
- Examples:
- Register Indirect Addressing Mode: The 16-bit offset is held inside a base or index register (
BX,SI,DIusingDS; orBPusingSS).- Examples:
MOV AX, [BX],ADD AL, [SI],MOV [DI], CX
- Examples:
- Based Addressing Mode: Effective address equals a base register (
BXinDS, orBPinSS) plus an 8-bit or 16-bit signed displacement.- Examples:
MOV AL, [BX+04H],MOV AX, 10H[BP](EA = BP + 10H, segmentSS)
- Examples:
- Indexed Addressing Mode: Effective address equals an index register (
SIorDI, default segmentDS) plus an 8-bit or 16-bit displacement; ideal for 1D arrays.- Examples:
MOV AL, [SI+20H],MOV BX, ARRAY[DI]
- Examples:
- Based-Indexed Addressing Mode: Effective address sums one base register (
BXorBP) and one index register (SIorDI).- Examples:
MOV AX, [BX+SI],MOV CL, [BP][DI](DSforBX,SSforBP)
- Examples:
- Based-Indexed with Displacement Mode: Effective address sums a base register, an index register, and an 8-bit or 16-bit displacement; ideal for 2D arrays or structs within arrays.
- Examples:
MOV AX, [BX+SI+08H],MOV DL, TABLE[BP][DI]
- Examples:
| Category | Addressing Mode | How Operand / Target Is Specified | Example |
|---|---|---|---|
| String | Implied String Addressing | Source at DS:SI, destination at ES:DI (auto-updated per DF) | MOVSB, CMPSW, SCASB |
| I/O Port | Fixed (Direct) Port | 8-bit port number (00H–FFH) in instruction | IN AL, 60H, OUT 80H, AX |
| I/O Port | Variable (Indirect) Port | 16-bit port address (0000H–FFFFH) held in DX | IN AL, DX, OUT DX, AX |
| Branch | Intra-Segment Direct | Relative signed offset added to IP (same CS) | JMP SHORT NEXT, JE LOOP1 |
| Branch | Intra-Segment Indirect | New IP read from register or memory word | JMP BX, CALL WORD PTR [SI] |
| Branch | Inter-Segment Direct | Both new IP and new CS encoded in instruction | JMP FAR PTR TARGET |
| Branch | Inter-Segment Indirect | Four bytes (new IP, then new CS) read from memory | CALL DWORD PTR [BX] |
1
If DS = 3200H and SS = 3A00H: (a) Find the starting and ending physical addresses of the Data Segment. (b) Calculate the physical address of an operand at DS:14A0H. (c) Determine whether this Data Segment and Stack Segment overlap.
Starting and Ending Addresses of DS:
- Segment Base =
3200H, soStarting Physical Address = 3200H * 10H = 32000H. - A 64 KB segment has maximum offset
FFFFH, so:Ending Physical Address = 32000H + FFFFH = 41FFFH.
Physical Address at DS:14A0H:
Physical Address = (3200H * 10H) + 14A0H = 32000H + 14A0H = 334A0H.
Overlap Check with SS = 3A00H:
- Stack Segment starts at
3A00H * 10H = 3A000Hand ends at3A000H + FFFFH = 49FFFH. - Since
3A000H <= 41FFFH, the two segments overlap across the physical range3A000Hto41FFFH(32 KBof shared addresses).
(a) 32000H to 41FFFH; (b) 334A0H; (c) Yes, DS and SS overlap from 3A000H through 41FFFH.
2
Given DS = 2000H, SS = 5000H, BX = 0300H, BP = 0100H, SI = 0040H, DI = 0020H, and DX = 0378H, identify the addressing mode, default segment, effective address (EA), and 20-bit physical address (where applicable) for each instruction:
MOV CX, 4500HMOV AL, [1200H]MOV AX, [BX+SI]ADD DL, [BP+DI+08H]OUT DX, AL
1. MOV CX, 4500H:
- Mode: Immediate Addressing Mode (16-bit constant
4500His part of the instruction). - EA / Physical Address: No data memory reference (
CS:IPfetches the instruction itself). After execution,CX = 4500H.
2. MOV AL, [1200H]:
- Mode: Direct Addressing Mode.
- Default Segment:
DS = 2000H. - Effective Address (
EA):1200H. - Physical Address:
(2000H * 10H) + 1200H = 21200H.
3. MOV AX, [BX+SI]:
- Mode: Based-Indexed Addressing Mode.
- Default Segment:
DS = 2000H(since base register isBX). - Effective Address (
EA):BX + SI = 0300H + 0040H = 0340H. - Physical Address:
(2000H * 10H) + 0340H = 20340H.
4. ADD DL, [BP+DI+08H]:
- Mode: Based-Indexed with Displacement Addressing Mode.
- Default Segment:
SS = 5000H(becauseBPdefaults to the Stack Segment!). - Effective Address (
EA):BP + DI + 08H = 0100H + 0020H + 0008H = 0128H. - Physical Address:
(5000H * 10H) + 0128H = 50128H.
5. OUT DX, AL:
- Mode: Variable (Indirect) I/O Port Addressing Mode.
- Port Address: Held in
DX = 0378H(I/O address space, no segment register used).
- Immediate (
CX=4500H); 2. Direct (DS,EA=1200H,PA=21200H); 3. Based-Indexed (DS,EA=0340H,PA=20340H); 4. Based-Indexed with Displacement (SS,EA=0128H,PA=50128H); 5. Variable I/O Port (DX=0378H).
3
In a Maximum-Mode 8086 system, the processor reads a 16-bit word from physical address 24001H (an odd address). How many memory read bus cycles does the BIU perform, and what are the states of BHE_bar, A0, and (S2_bar, S1_bar, S0_bar) during each cycle?
Aligned vs. Misaligned Word Access:
- Cycle 1 (Read low byte of word at
24001H):A0 = 1,BHE_bar = 0-> reads odd bank overD15–D8. - Cycle 2 (Read high byte of word at
24002H):A0 = 0,BHE_bar = 1-> reads even bank overD7–D0.
Maximum-Mode Status Lines (S2_bar, S1_bar, S0_bar): During both data memory read cycles, the 8086 outputs (S2_bar, S1_bar, S0_bar) = (1, 0, 1), which the 8288 Bus Controller decodes to assert MRDC_bar (Memory Read Command).
The BIU performs 2 memory read bus cycles: Cycle 1 at 24001H with BHE_bar=0, A0=1 (D15–D8), and Cycle 2 at 24002H with BHE_bar=1, A0=0 (D7–D0), both with (S2_bar, S1_bar, S0_bar) = (1, 0, 1).
Exercises
If CS = 4B20H and IP = 2105H, calculate: (a) the 20-bit physical address of the next instruction byte, and (b) the starting and ending physical addresses of this Code Segment.
20-Bit Physical Address (CS:IP):
Physical Address = (CS * 10H) + IP = (4B20H * 10H) + 2105H = 4B200H + 2105H = 4D305H.
Code Segment Physical Boundaries:
Start Address = 4B20H * 10H + 0000H = 4B200H.End Address = 4B200H + FFFFH = 5B1FFH.
(a) 4D305H; (b) Segment runs from 4B200H to 5B1FFH.
State the purpose of pins ALE, AD0–AD15, BHE_bar/S7, and MN/MX_bar on the 8086, and list the eight signals assigned to pins 24–31 in Minimum Mode versus Maximum Mode.
Common Signal Roles:
ALE(Address Latch Enable, Pin 25 Min Mode): Pulses high duringT1so external latches (74LS373/8282) captureA0–A19andBHE_barbefore the lines switch to data/status inT2–T4.AD0–AD15(Pins 2–16, 39): Time-multiplexed lower 16 address lines (T1) and 16-bit bidirectional data bus (T2–T4).BHE_bar/S7(Pin 34): Bus High Enable duringT1(low enables odd data bankD15–D8); status bitS7duringT2–T4.MN/MX_bar(Pin 33): Selects Minimum Mode when tied to+5V(1) or Maximum Mode when tied toGND(0).
Pins 24–31 in Minimum vs. Maximum Mode:
- Pin 24:
INTA_bar(Min) /QS1(Max) - Pin 25:
ALE(Min) /QS0(Max) - Pin 26:
DEN_bar(Min) /S0_bar(Max) - Pin 27:
DT/R_bar(Min) /S1_bar(Max) - Pin 28:
M/IO_bar(Min) /S2_bar(Max) - Pin 29:
WR_bar(Min) /LOCK_bar(Max) - Pin 30:
HLDA(Min) /RQ_bar/GT1_bar(Max) - Pin 31:
HOLD(Min) /RQ_bar/GT0_bar(Max)
ALE latches addresses in T1; AD0–AD15 multiplex address and 16-bit data; BHE_bar/S7 enables the upper data bank; MN/MX_bar selects single-CPU Minimum mode (1) or multiprocessor Maximum mode (0), reassigning pins 24–31 from direct control strobes (INTA_bar, ALE, DEN_bar, DT/R_bar, M/IO_bar, WR_bar, HLDA, HOLD) to status/queue/bus-grant signals (QS1, QS0, S0_bar–S2_bar, LOCK_bar, RQ_bar/GT1_bar, RQ_bar/GT0_bar).
Given CS = 1000H, DS = 2000H, SS = 3000H, ES = 4000H, BX = 0200H, SI = 0050H, and BP = 0100H, compute the effective address and 20-bit physical address accessed by: (a) MOV AL, [BX+SI+12H] (b) MOV AL, ES:[BX+SI+12H] (c) MOV AL, CS:[BX+SI+12H]
Effective Address (Common to All Three):
EA = BX + SI + 12H = 0200H + 0050H + 0012H = 0262H.
Physical Address With Default vs. Segment Override Prefixes:
- (a) Default segment
DS = 2000H:PA = (2000H * 10H) + 0262H = 20262H. - (b) Override
ES = 4000H:PA = (4000H * 10H) + 0262H = 40262H. - (c) Override
CS = 1000H:PA = (1000H * 10H) + 0262H = 10262H.
All three have EA = 0262H; the physical addresses are (a) 20262H, (b) 40262H, and (c) 10262H.
Classify the addressing mode of each 8086 instruction below: (a) MOV AX, [BX] (b) ADD BL, 0FH (c) MOV CX, [SI+1000H] (d) IN AL, 64H (e) MOVSB
Addressing Mode Identification:
- (a)
MOV AX, [BX]: Register Indirect Addressing Mode (destinationAXis Register, source[BX]is Register Indirect viaDS:BX). - (b)
ADD BL, 0FH: Immediate Addressing Mode (source0FHis an 8-bit constant encoded in the instruction). - (c)
MOV CX, [SI+1000H]: Indexed Addressing Mode (source offset =SI + 1000HinDS). - (d)
IN AL, 64H: Direct (Fixed) I/O Port Addressing Mode (8-bit port64Hspecified in instruction). - (e)
MOVSB: Implied String Addressing Mode (transfers byte fromDS:SItoES:DIand updatesSI,DIperDF).
(a) Register Indirect; (b) Immediate; (c) Indexed; (d) Direct (Fixed) I/O Port; (e) Implied String Addressing.
Why can an 8086 access a 16-bit word at 70350H in 1 bus cycle, whereas a 16-bit word at 70351H requires 2 bus cycles? State the values of BHE_bar and A0 for 70350H.
Even vs. Odd Memory Banking:
- The 1 MB memory of the 8086 is physically wired as two 512 KB banks: an Even Bank (even addresses, connected to
D7–D0, selected whenA0 = 0) and an Odd Bank (odd addresses, connected toD15–D8, selected whenBHE_bar = 0). - At
70350H(A0 = 0), the low byte lies in the even bank (70350H) and the high byte lies in the odd bank (70351H) at the same word row. Pulling bothBHE_bar = 0andA0 = 0reads all 16 bits (D15–D0) in 1 bus cycle. - At
70351H(A0 = 1), the low byte is in the odd bank (70351H) and the high byte is in the next word's even bank (70352H), which have differentA19–A1row addresses; therefore the BIU must execute 2 separate bus cycles.
70350H is an even-aligned word spanning both banks at the same A19–A1 address, so BHE_bar = 0, A0 = 0 transfers both bytes in 1 cycle; 70351H is misaligned across two row addresses and takes 2 cycles.