PadhaikoAll subjects

Segment:Offset Addressing, Pins & Addressing Modes

Microprocessors (ENEX 201)

Open in the Padhaiko app

3.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.

Definition

Logical Address, Segment Base, Offset, and Physical Address

Default Segment:Offset Register Pairs and Overrides
Memory Reference TypeDefault SegmentDefault Offset(s)Override Allowed?
Instruction FetchCSIPNo
Stack Operations (PUSH, POP, CALL, RET)SSSPNo
Stack Frame Access ([BP])SSBP + disp / indexYes (CS:, DS:, ES:)
General Data AccessDSBX, SI, DI, 16-bit dispYes (CS:, ES:, SS:)
String Source (MOVS, LODS, CMPS)DSSIYes (CS:, ES:, SS:)
String Destination (MOVS, STOS, SCAS)ESDINo (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).

Intel 8086 40-Pin DIP Configuration (Min / Max Modes)Text
                    +-------\_/-------+
            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)

Common 8086 Pin Signals
Pin(s)SignalDirectionFunction
2–16, 39AD0–AD15Bidir (3-state)Time-multiplexed Address (A0–A15 during T1) and Data (D0–D15 during T2–T4).
35–38A19/S6–A16/S3Out (3-state)Upper 4 address bits during T1; status bits S3–S6 during T2–T4 (S4,S3 encode active segment; S5 = IF; S6 = 0).
34BHE_bar / S7Out (3-state)Bus High Enable during T1 (low activates odd memory bank D8–D15); status S7 during T2–T4.
33MN / MX_barInputMode select: HIGH (+5V) = Minimum Mode; LOW (GND) = Maximum Mode.
32RD_barOut (3-state)Active-low read strobe for memory or I/O read cycles.
22READYInputHigh tells 8086 memory/IO is ready; low inserts Wait (Tw) states.
21RESETInputActive high (>= 4 clocks); clears flags, DS, SS, ES, IP = 0000H, and sets CS = FFFFH (boot at FFFF0H).
19CLKInputAsymmetric clock input (33% duty cycle) at 5, 8, or 10 MHz from 8284 clock generator.
18INTRInputLevel-triggered maskable interrupt request (gated by IF).
17NMIInputRising-edge-triggered Non-Maskable Interrupt (Type 2; cannot be masked by IF).
23TEST_barInputPolled by WAIT instruction; execution stalls while TEST_bar = 1 (used to sync with 8087).
1, 20, 40GND, VCCPowerTwo ground pins (1, 20) and +5 V supply (40).
Even/Odd Memory Bank Selection via BHE_bar and A0
BHE_barA0Memory Access TypeData Lines Used
00Whole 16-bit word from an even addressD15–D0 (both banks)
01High byte (8-bit) from an odd addressD15–D8 (odd bank)
10Low byte (8-bit) from an even addressD7–D0 (even bank)
11Idle / no transferNone

Minimum Mode vs. Maximum Mode (Pins 24–31)

AspectMinimum Mode (MN/MX_bar = 1)Maximum Mode (MN/MX_bar = 0)
System ArchitectureSingle-processor system; 8086 generates all control signals directlyMultiprocessor system (8086 + 8087/8089); uses 8288 Bus Controller to decode control signals
Pin 24INTA_bar — Interrupt Acknowledge pulseQS1 — Queue Status bit 1 (with QS0 shows prefetch queue action)
Pin 25ALE — 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 26DEN_bar — Data Enable (enables 8286 bidirectional data transceivers)S0_bar — Bus cycle status bit 0 (fed to 8288)
Pin 27DT/R_bar — Data Transmit (1) / Receive (0) direction for 8286S1_bar — Bus cycle status bit 1 (fed to 8288)
Pin 28M/IO_bar — Memory (1) vs. I/O (0) cycle indicatorS2_bar — Bus cycle status bit 2 (fed to 8288)
Pin 29WR_bar — Active-low write strobeLOCK_bar — Prevents other bus masters from seizing the bus (LOCK prefix)
Pin 30HLDA — Hold Acknowledge output to DMA controllerRQ_bar/GT1_bar — Bidirectional Request/Grant channel 1 (lower priority)
Pin 31HOLD — DMA Hold Request inputRQ_bar/GT0_bar — Bidirectional Request/Grant channel 0 (higher priority)
Maximum Mode Status Decoding (S2_bar, S1_bar, S0_bar -> 8288)
S2_barS1_barS0_barBus Cycle Indicated8288 Command Output
000Interrupt AcknowledgeINTA_bar
001Read I/O PortIORC_bar
010Write I/O PortIOWC_bar, AIOWC_bar
011HaltNone
100Code Access (Instruction Fetch)MRDC_bar
101Read MemoryMRDC_bar
110Write MemoryMWTC_bar, AMWC_bar
111Passive (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.

Definition

Data & Memory Addressing Modes of 8086

  1. 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
  2. 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
  3. Direct Addressing Mode: The 16-bit offset (effective address) of the operand within the data segment (DS by default) is written directly inside square brackets.
    • Examples: MOV AL, [2000H], MOV [1500H], BX (Physical Address = DS * 10H + offset)
  4. Register Indirect Addressing Mode: The 16-bit offset is held inside a base or index register (BX, SI, DI using DS; or BP using SS).
    • Examples: MOV AX, [BX], ADD AL, [SI], MOV [DI], CX
  5. Based Addressing Mode: Effective address equals a base register (BX in DS, or BP in SS) plus an 8-bit or 16-bit signed displacement.
    • Examples: MOV AL, [BX+04H], MOV AX, 10H[BP] (EA = BP + 10H, segment SS)
  6. Indexed Addressing Mode: Effective address equals an index register (SI or DI, default segment DS) plus an 8-bit or 16-bit displacement; ideal for 1D arrays.
    • Examples: MOV AL, [SI+20H], MOV BX, ARRAY[DI]
  7. Based-Indexed Addressing Mode: Effective address sums one base register (BX or BP) and one index register (SI or DI).
    • Examples: MOV AX, [BX+SI], MOV CL, [BP][DI] (DS for BX, SS for BP)
  8. 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]
String, I/O Port, and Branch Addressing Modes
CategoryAddressing ModeHow Operand / Target Is SpecifiedExample
StringImplied String AddressingSource at DS:SI, destination at ES:DI (auto-updated per DF)MOVSB, CMPSW, SCASB
I/O PortFixed (Direct) Port8-bit port number (00H–FFH) in instructionIN AL, 60H, OUT 80H, AX
I/O PortVariable (Indirect) Port16-bit port address (0000H–FFFFH) held in DXIN AL, DX, OUT DX, AX
BranchIntra-Segment DirectRelative signed offset added to IP (same CS)JMP SHORT NEXT, JE LOOP1
BranchIntra-Segment IndirectNew IP read from register or memory wordJMP BX, CALL WORD PTR [SI]
BranchInter-Segment DirectBoth new IP and new CS encoded in instructionJMP FAR PTR TARGET
BranchInter-Segment IndirectFour bytes (new IP, then new CS) read from memoryCALL DWORD PTR [BX]
Example 1

1 (4 marks)

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, so Starting 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 = 3A000H and ends at 3A000H + FFFFH = 49FFFH.
  • Since 3A000H <= 41FFFH, the two segments overlap across the physical range 3A000H to 41FFFH (32 KB of shared addresses).
Answer:

(a) 32000H to 41FFFH; (b) 334A0H; (c) Yes, DS and SS overlap from 3A000H through 41FFFH.

Example 2

2 (6 marks)

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:

  1. MOV CX, 4500H
  2. MOV AL, [1200H]
  3. MOV AX, [BX+SI]
  4. ADD DL, [BP+DI+08H]
  5. OUT DX, AL

1. MOV CX, 4500H:

  • Mode: Immediate Addressing Mode (16-bit constant 4500H is part of the instruction).
  • EA / Physical Address: No data memory reference (CS:IP fetches 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 is BX).
  • 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 (because BP defaults 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).
Registers Involved in Address Calculations
DS2000H
SS5000H
BX0300H
BP0100H
SI0040H
DI0020H
CX4500H
DX0378H
Answer:
  1. 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).
Example 3

3 (4 marks)

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 over D15–D8.
  • Cycle 2 (Read high byte of word at 24002H): A0 = 0, BHE_bar = 1 -> reads even bank over D7–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).

Answer:

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

Question 1

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.
Answer:

(a) 4D305H; (b) Segment runs from 4B200H to 5B1FFH.

Question 2

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 during T1 so external latches (74LS373/8282) capture A0–A19 and BHE_bar before the lines switch to data/status in T2–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 during T1 (low enables odd data bank D15–D8); status bit S7 during T2–T4.
  • MN/MX_bar (Pin 33): Selects Minimum Mode when tied to +5V (1) or Maximum Mode when tied to GND (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)
Answer:

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).

Question 3

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.
Answer:

All three have EA = 0262H; the physical addresses are (a) 20262H, (b) 40262H, and (c) 10262H.

Question 4

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 (destination AX is Register, source [BX] is Register Indirect via DS:BX).
  • (b) ADD BL, 0FH: Immediate Addressing Mode (source 0FH is an 8-bit constant encoded in the instruction).
  • (c) MOV CX, [SI+1000H]: Indexed Addressing Mode (source offset = SI + 1000H in DS).
  • (d) IN AL, 64H: Direct (Fixed) I/O Port Addressing Mode (8-bit port 64H specified in instruction).
  • (e) MOVSB: Implied String Addressing Mode (transfers byte from DS:SI to ES:DI and updates SI, DI per DF).
Answer:

(a) Register Indirect; (b) Immediate; (c) Indexed; (d) Direct (Fixed) I/O Port; (e) Implied String Addressing.

Question 5

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 when A0 = 0) and an Odd Bank (odd addresses, connected to D15–D8, selected when BHE_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 both BHE_bar = 0 and A0 = 0 reads 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 different A19–A1 row addresses; therefore the BIU must execute 2 separate bus cycles.
Answer:

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.

Past exam questions for Microprocessors

← 8086 Features & Architecture (BIU and EU)Assembly Language Programming, Syntax & Directives →