PIC, 8086 Interrupts & Interrupt Vector Table
Open in the Padhaiko app5.7 Using programmable interrupt controllers (PIC)
When designing complex microprocessor systems with multiple peripheral devices (keyboards, serial communication ports, disk drives, system timers, network adapters), the processor single interrupt pin (INTR) is insufficient to manage numerous independent interrupt sources.
The Intel 8259A Programmable Interrupt Controller (PIC) is a 28-pin dedicated LSI chip designed specifically to manage, prioritize, and arbitrate up to eight vectored hardware interrupt inputs for the 8085 and 8086 microprocessors.
+------------------------------------+
| INTEL 8259A PIC |
| |
D7–D0 <======>| Data Bus Buffer |
+------------------------------------+
||
+------------------------------------+
CS_bar ---->| Read / Write & |
RD_bar ---->| Control Logic |
WR_bar ---->| |
A0 ---->| |---> INT (To CPU INTR)
INTA_bar ---->| |<--- INTA_bar (From CPU)
+------------------------------------+
||
+------------------------------------+
CAS2–CAS0 <==>| Cascade Buffer / Comparator |
SP_bar / ---->| |
EN_bar +------------------------------------+
||
+---------------------------+---------------------------+
| | |
+-------v--------+ +-------v--------+ +-------v--------+
| Interrupt | | In-Service | | Interrupt |
| Request Reg | | Register (ISR) | | Mask Reg (IMR) |
| (IRR) | | | | |
+-------+--------+ +-------+--------+ +-------+--------+
| | |
+------------------->+------v--------+<-----------------+
| Priority |
| Resolver (PR) |
+-------+-------+
|
IR0 through IR7 ====+ (8 Interrupt Inputs)Internal Functional Architecture of 8259A
The 8259A consists of eight major internal functional blocks:
- Interrupt Request Register (IRR): An 8-bit register that stores status for the eight interrupt request lines (
IR0throughIR7). When an external device asserts an IR line, the corresponding bit in the IRR is set to 1. - In-Service Register (ISR): An 8-bit register that stores the status of the interrupt requests currently being serviced by the CPU. When an interrupt is acknowledged by the processor, the Priority Resolver sets the corresponding bit in the ISR to 1. It remains 1 until an End-of-Interrupt (EOI) command is issued.
- Interrupt Mask Register (IMR): An 8-bit register that stores the mask bits for the eight interrupt lines. If bit
M_iin the IMR is set to 1 via software (OCW1), the corresponding interrupt requestIR_iis masked (disabled) and ignored by the Priority Resolver. - Priority Resolver (PR): A hardware combinational logic block that continuously inspects the IRR, IMR, and ISR registers to determine whether an active unmasked request has a higher priority than the interrupt currently in service. If so, it asserts the
INToutput pin to alert the CPU. - Read/Write and Control Logic: Interfaces the 8259A to the CPU system bus:
CS_bar: Chip Select (active LOW).WR_bar: Write strobe (active LOW).RD_bar: Read strobe (active LOW).A0: Address line (used in conjunction with CS_bar to select command and status registers).INT: Interrupt Request output (connects directly to 8085/8086INTRpin).INTA_bar: Interrupt Acknowledge input (receives pulse pairs from 8086).
- Data Bus Buffer: An 8-bit bidirectional tri-state buffer that transfers control words, status registers, and interrupt vector bytes onto data bus lines D7–D0.
- Cascade Buffer / Comparator: Used when multiple 8259A chips are cascaded together. The three bidirectional cascade lines (
CAS2,CAS1,CAS0) allow a Master 8259A to transmit the 3-bit binary ID of the active Slave device during the interrupt acknowledge cycle.
Cascading Master-Slave Configuration
A single 8259A manages up to 8 interrupt inputs. To accommodate systems with more than 8 devices, up to eight Slave 8259A chips can be connected to one Master 8259A, expanding system capacity up to 64 prioritized interrupt inputs.
- Hardware Interconnections:
- The
INToutput of each Slave 8259A connects to an individualIRinput line (IR0–IR7) of the Master 8259A. - The
INToutput of the Master 8259A connects to the CPUINTRpin. - The
INTA_baroutput from the CPU connects in parallel to all Master and Slave 8259A chips. - The three cascade lines (
CAS2,CAS1,CAS0) are wired in parallel from the Master to all Slaves. - The
SP_bar / EN_barpin is tied to +5V (Vcc) for the Master (identifying it as Master) and tied to Ground (0V) for all Slaves.
- The
- Cascaded Acknowledge Sequence:
- An external device asserts an interrupt line on Slave 2.
- Slave 2 asserts its
INToutput, which drives lineIR2of the Master. - The Master asserts its
INToutput to the CPU. - The CPU accepts the interrupt and pulses
INTA_barLOW. - During the first
INTA_barpulse, the Master outputs the binary address of the active Slave (010Bfor Slave 2) on linesCAS2–CAS0. - All Slaves inspect
CAS2–CAS0. Only Slave 2 detects a match with its pre-programmed cascade ID. - During the second
INTA_barpulse, Slave 2 places its 8-bit vector number onto data bus D7–D0 for the CPU.
8259A Command Words
The 8259A is programmed using two categories of control words:
- Initialization Command Words (ICW1 through ICW4): Written once after system reset to define operational architecture.
- Operation Command Words (OCW1 through OCW3): Written dynamically during runtime to control masks, EOI modes, and status reading.
Initialization Command Words (ICW)
The ICWs must be written in strict sequential order:
- ICW1 (Initialization / Edge-Level Select): Written to address
A0 = 0with bit D4 = 1. Selects edge or level triggering for IR inputs, single or cascaded mode, and calls for ICW4 if required. - ICW2 (Interrupt Vector Base): Written to address
A0 = 1. In 8086 systems, bits D7–D3 define the high 5 bits of the interrupt type number (the 8259A automatically inserts the lower 3 bits 000B–111B corresponding to IR0–IR7). - ICW3 (Cascade Configuration): Written to address
A0 = 1only if ICW1 specifies cascade mode.- For Master: each bit (S7–S0) indicates whether a Slave is attached to that IR pin (1 = Slave present).
- For Slave: bits D2–D0 specify the Slave's 3-bit binary ID (000B to 111B).
- ICW4 (Microprocessor Mode and EOI Select): Written to address
A0 = 1if bit D0 of ICW1 is set. Configures 8086/8088 mode (bit D0 = 1) or 8085 mode (bit D0 = 0), Automatic EOI (AEOI) or Normal EOI, and Buffered mode.
Operation Command Words (OCW)
- OCW1 (Interrupt Masking): Written to address
A0 = 1. Bits D7–D0 directly set or clear the corresponding mask bits in the IMR (1 = Masked, 0 = Enabled). - OCW2 (End of Interrupt Commands): Written to address
A0 = 0with D4=0, D3=0. Issues EOI commands to clear the in-service bit in the ISR:- Non-Specific EOI: Automatically clears the highest-priority bit in the ISR.
- Specific EOI: Clears the specific ISR bit specified by bits D2–D0.
- OCW3 (Special Mask Mode & Status Read): Written to address
A0 = 0with D4=0, D3=1. Configures Special Mask Mode and allows reading the IRR or ISR onto the data bus.
5.8 Interrupt in 8086 and interrupt vector table
The Intel 8086 microprocessor features a comprehensive interrupt architecture supporting 256 distinct interrupt types, numbered from Type 0 to Type 255 (00H to FFH).
Structure of the Interrupt Vector Table (IVT)
The 8086 allocates the lowest 1024 bytes of physical memory—from physical address 00000H to 003FFH—exclusively to store the starting addresses of the Interrupt Service Routines. This memory block is called the Interrupt Vector Table (IVT).
Physical Memory
003FFH +-----------------------------+
| Type 255 Vector (4 Bytes) |
003FCH +-----------------------------+
| ... |
00010H +-----------------------------+
| Type 4 Vector (INTO) |
0000CH +-----------------------------+
| Type 3 Vector (Breakpoint) |
00008H +-----------------------------+
| Type 2 Vector (NMI) |
00004H +-----------------------------+
| Type 1 Vector (Single Step) |
00000H +-----------------------------+
| Type 0 Vector (Divide Error)|
+-----------------------------+Vector Representation in Memory
Each interrupt vector requires exactly 4 bytes of memory:
- Lower Two Bytes (Offset / IP): Contain the 16-bit offset address (
IP) of the ISR.- Low byte of IP is stored at address
4 x Type - High byte of IP is stored at address
4 x Type + 1
- Low byte of IP is stored at address
- Upper Two Bytes (Base / CS): Contain the 16-bit segment address (
CS) of the ISR.- Low byte of CS is stored at address
4 x Type + 2 - High byte of CS is stored at address
4 x Type + 3
- Low byte of CS is stored at address
Starting Physical Address = Type Number x 4
Total memory consumed by 256 interrupt vectors: Total IVT Memory = 256 x 4 bytes = 1024 bytes = 1 KB
Dedicated / Predefined 8086 Interrupts (Types 0 to 4)
The first five interrupt types (Type 0 through Type 4) are hardwired and reserved for processor exceptions and internal operations:
| Interrupt Type | Dedicated Function | Trigger Source | IVT Address Range | Priority Rank |
|---|---|---|---|---|
| Type 0 | Divide Error (Divide by Zero) | Generated automatically by CPU during DIV or IDIV if quotient exceeds destination register | 00000H – 00003H | Highest internal exception |
| Type 1 | Single Step (Trace Flag) | Generated after every instruction when Trap Flag (TF = 1) | 00004H – 00007H | Evaluated after instruction |
| Type 2 | Non-Maskable Interrupt (NMI) | Hardware rising edge on external NMI pin | 00008H – 0000BH | Highest hardware priority |
| Type 3 | Breakpoint Interrupt | Single-byte instruction INT 3 (Opcode CCH) | 0000CH – 0000FH | Execution of INT 3 |
| Type 4 | Overflow Interrupt | Executing INTO instruction when Overflow Flag (OF = 1) | 00010H – 00013H | Execution of INTO |
- Reserved Types (Types 5 to 31): Reserved by Intel for hardware coprocessor exceptions, bound checks (
BOUND), and future architectural expansion (addresses00014Hthrough0007FH). - User-Available Types (Types 32 to 255): A total of 224 interrupt vectors (addresses
00080Hthrough003FFH) available for hardware interrupts (interfaced via 8259A) and software interrupts (INT n).
5.9 Interrupt processing in 8086
The 8086 handles all interrupts—whether caused by software instructions (INT n), internal exceptions (Divide Error, Overflow), or external hardware pins (NMI, INTR)—through a unified execution sequence:
8086 Ten-Step Interrupt Execution Cycle
- Instruction Completion: The 8086 finishes executing the current instruction.
- Fetch Interrupt Type (N):
- For internal exceptions: The CPU hardwires type 0, 1, 3, or 4.
- For software interrupts (
INT n): The byte operandnis fetched from the instruction stream. - For external hardware interrupts on
INTR: The 8086 issues two consecutive active-lowINTA_barpulses. During the secondINTA_barpulse, the external 8259A places the 8-bit vector numberNonto data bus D7–D0.
- Push Flags Register onto Stack: The CPU decrements the Stack Pointer by 2 and pushes the 16-bit Flags register onto the stack:
SP = SP - 2; [SS:SP] = FLAGS - Clear Interrupt and Trap Flags: The 8086 automatically clears the Interrupt Flag (
IF = 0) to disable further maskable interrupts on INTR, and clears the Trap Flag (TF = 0) to prevent single-step tracing inside the ISR. - Push Current Code Segment (CS) onto Stack:
SP = SP - 2; [SS:SP] = CS - Push Current Instruction Pointer (IP) onto Stack:
SP = SP - 2; [SS:SP] = IP(stores return address of next instruction). - Calculate IVT Memory Location: The CPU multiplies the interrupt type number
Nby 4: Vector Memory Address = 4 x N - Load New IP from IVT: The CPU reads 2 bytes from address
4 x Nand4 x N + 1into the Instruction Pointer register (IP). - Load New CS from IVT: The CPU reads 2 bytes from address
4 x N + 2and4 x N + 3into the Code Segment register (CS). - Execute ISR and Return via IRET: The CPU fetches instructions from the new
CS:IP. Upon completion, the ISR concludes with anIRET(Interrupt Return) instruction:- Pops 16-bit IP from stack
- Pops 16-bit CS from stack
- Pops 16-bit Flags from stack (restoring the original
IFandTFflag states).
Worked Examples
8086 Interrupt Vector Table Physical Memory Address Calculations
The Intel 8086 microprocessor uses an Interrupt Vector Table (IVT) in memory from 00000H to 003FFH.
- Calculate the starting physical memory address and the 4-byte address range for each of the following interrupt types:
- Type 0 (Divide by Zero)
- Type 2 (Non-Maskable Interrupt)
- Type 25H (User Hardware Interrupt)
- Type 80H (System Service)
- Suppose the Interrupt Service Routine for Type 25H is located at segment address 1200H and offset address 0450H. Show the exact byte-by-byte memory layout in the IVT.
Compute Vector Memory Address Ranges: The starting address for any interrupt Type N is given by: Starting Address = N x 4
- Type 0: Starting Address = 0 x 4 = 0 = 00000H Address Range = 00000H to 00003H
- Type 2 (NMI): Starting Address = 2 x 4 = 8 = 00008H Address Range = 00008H to 0000BH
- Type 25H (decimal 37): Starting Address = 37 x 4 = 148 = 00094H Address Range = 00094H to 00097H
- Type 80H (decimal 128): Starting Address = 128 x 4 = 512 = 00200H Address Range = 00200H to 00203H
Map Type 25H Vector Bytes in Memory: The ISR target is CS = 1200H and IP = 0450H. In the 8086 architecture, multi-byte words are stored in little-endian order (lower byte at lower address):
- IP Low Byte (50H): Stored at
00094H - IP High Byte (04H): Stored at
00095H - CS Low Byte (00H): Stored at
00096H - CS High Byte (12H): Stored at
00097H
Memory Layout Table:
| Physical Memory Address | Stored Content | Description |
|---|---|---|
| 00094H | 50H | Low byte of Offset Address (IP) |
| 00095H | 04H | High byte of Offset Address (IP) |
| 00096H | 00H | Low byte of Segment Address (CS) |
| 00097H | 12H | High byte of Segment Address (CS) |
Type 0 spans 00000H–00003H; Type 2 spans 00008H–0000BH; Type 25H spans 00094H–00097H; Type 80H spans 00200H–00203H. For Type 25H with CS:IP = 1200:0450H, the bytes stored at 00094H–00097H are 50H, 04H, 00H, and 12H.
8259A Initialization Command Words for 8086 Microprocessor System
Design the initialization sequence for an Intel 8259A Programmable Interrupt Controller (PIC) interfaced as a single interrupt controller in an 8086 microprocessor system.
- Port addresses are: Control Port = 20H (
A0 = 0), Data Port = 21H (A0 = 1). - Operational requirements:
- Edge-triggered interrupt inputs on IR0–IR7
- Single 8259A (no cascading slaves)
- Base interrupt type number = 40H (decimal 64); IR0 = Type 40H, IR1 = Type 41H, ..., IR7 = Type 47H
- Normal End of Interrupt (Normal EOI)
- 8086 mode operation
Formulate the binary and hexadecimal values for ICW1, ICW2, and ICW4. Write the 8086 assembly initialization routine.
Formulate ICW1 (Address A0 = 0, Port 20H): Bit format:
D0(IC4):1(ICW4 is required)D1(SNGL):1(Single mode; no cascading slaves)D2(ADI):0(Call address interval; ignored in 8086 mode)D3(LTIM):0(Edge-triggered mode)D4:1(Must be 1 to identify ICW1)D5, D6, D7:0 0 0(Ignored in 8086 mode)
ICW1 = 0 0 0 1 0 0 1 1 B = 13H
Formulate ICW2 (Address A0 = 1, Port 21H): In 8086 mode, bits D7–D3 define the base interrupt type number:
- Base type = 40H = 0100 0000B
D7 down to D3=0 1 0 0 0D2, D1, D0=0 0 0(8259A automatically inserts IR input number 0–7)
ICW2 = 0 1 0 0 0 0 0 0 B = 40H
Formulate ICW4 (Address A0 = 1, Port 21H): Bit format:
D0(uPM):1(8086/8088 microprocessor mode)D1(AEOI):0(Normal End of Interrupt mode; requires explicit EOI command)D2(M/S):0(Ignored in non-buffered mode)D3(BUF):0(Non-buffered mode)D4(SFNM):0(Special Fully Nested Mode disabled)D5, D6, D7:0 0 0(Unused)
ICW4 = 0 0 0 0 0 0 0 1 B = 01H
Assembly Language Initialization Routine:
MOV AL, 13H
OUT 20H, AL
MOV AL, 40H
OUT 21H, AL
MOV AL, 01H
OUT 21H, ALICW1 = 13H (written to port 20H); ICW2 = 40H (written to port 21H); ICW4 = 01H (written to port 21H). ICW3 is skipped because single mode is selected.
Installing and Invoking a Custom 8086 Software Interrupt Service Routine
Write an 8086 assembly language program that installs an Interrupt Service Routine (MY_ISR) for interrupt Type 60H into the Interrupt Vector Table.
- The ISR is located in code segment 1000H at offset 0200H.
- The routine must safely set up the vector table in memory (at 0000:0180H).
- Invoke the interrupt using the
INT 60Hinstruction. - The ISR must save working registers, increment the byte counter in AL, restore registers, and return via
IRET. Show register status.
Calculate Vector Table Address for Type 60H: Type 60H = decimal 96. Physical Vector Address = 96 x 4 = 384 = 0180H. The vector is located in segment 0000H at offset 0180H:
- Offset (IP) bytes stored at 0000:0180H (low byte = 00H, high byte = 02H)
- Segment (CS) bytes stored at 0000:0182H (low byte = 00H, high byte = 10H)
Assembly Program (Vector Installation and Invocation):
CLI
XOR AX, AX
MOV ES, AX
MOV WORD PTR ES:[0180H], 0200H
MOV WORD PTR ES:[0182H], 1000H
STI
MOV AL, 05H
INT 60H
HLT
ORG 0200H
MY_ISR:
INC AL
IRETInstruction Trace and Execution:
CLIdisables maskable interrupts during vector table writing to prevent race conditions.XOR AX,AX; MOV ES,AXsets Extra Segment (ES) to 0000H (base of the IVT).MOV WORD PTR ES:[0180H], 0200Hstores IP offset 0200H at 0000:0180H.MOV WORD PTR ES:[0182H], 1000Hstores CS base 1000H at 0000:0182H.STIre-enables interrupts.MOV AL, 05Hinitializes AL = 05H.INT 60H:- Pushes Flags, CS, and IP onto stack.
- Clears IF and TF.
- Loads CS:IP with 1000:0200H.
- In
MY_ISR,INC ALincrements AL from 05H to 06H. IRETpops IP, CS, and Flags from the stack, returning execution toHLT. BecauseIRETrestores the flags saved byINT 60H, the flags set byINC ALare discarded. The saved flags come fromXOR AX, AX(ZF = 1,PF = 1,SF = CF = OF = 0) plusIF = 1fromSTI;AX = 0006HbecauseAHis still00H.
Type 60H vector occupies memory 0000:0180H to 0000:0183H. The installation writes offset 0200H and segment 1000H into these locations. Executing INT 60H vectors to MY_ISR, increments AL from 05H to 06H, and returns via IRET.
Exercises
Exercises
Describe the internal architecture and functional block diagram of the Intel 8259A Programmable Interrupt Controller (PIC). Explain the roles of the Interrupt Request Register (IRR), In-Service Register (ISR), Interrupt Mask Register (IMR), and Priority Resolver (PR).
Functional Block Architecture: The Intel 8259A PIC contains eight primary internal blocks:
- Data Bus Buffer: 8-bit bidirectional tri-state buffer that transfers data, control words, and vector numbers between CPU and 8259A.
- Read/Write and Control Logic: Coordinates command writes, status reads, and acknowledges using
CS_bar,RD_bar,WR_bar,A0, andINTA_bar. - Cascade Buffer/Comparator: Drives lines
CAS2–CAS0to arbitrate up to 8 slave PICs. - Interrupt Request Register (IRR): An 8-bit register that stores pending interrupt requests received on pins
IR0throughIR7. - In-Service Register (ISR): An 8-bit register that stores the status of the interrupt currently being serviced by the CPU.
- Interrupt Mask Register (IMR): An 8-bit register programmed via OCW1 to mask or unmask individual IR inputs.
- Priority Resolver (PR): Determines the highest priority unmasked request by evaluating IRR, IMR, and ISR.
- Control Logic: Asserts
INToutput to alert CPU.
Detailed Roles of Key Registers:
- IRR: Latches incoming external requests. If an external signal goes active, the corresponding IRR bit becomes 1.
- IMR: Acts as a programmable gate. If an IMR bit is 1, the corresponding request in IRR is blocked from reaching the Priority Resolver.
- Priority Resolver: Evaluates active, unmasked requests against current in-service bits. If a higher priority request exists, it drives
INTHIGH. - ISR: Tracks active routines. When the CPU acknowledges the interrupt, the Priority Resolver clears the bit in IRR and sets the corresponding bit in ISR. The bit remains 1 until an End of Interrupt (EOI) command clears it.
The 8259A contains an IRR (latches pending requests), IMR (masks unwanted interrupts), Priority Resolver (selects the highest priority unmasked request), and ISR (tracks the interrupt currently being serviced until an EOI command).
Explain the organization of the Interrupt Vector Table (IVT) in the Intel 8086 microprocessor. Describe the five dedicated interrupts (Types 0 through 4), and calculate the exact physical memory address range occupied by the vector pointers for:
- Type 15H
- Type 82H
Organization of the IVT: The 8086 IVT occupies the lowest 1 KB of memory (00000H to 003FFH). It contains 256 vector pointers (Type 0 to Type 255). Each pointer consists of 4 bytes:
- Bytes 0 and 1: 16-bit offset address (
IP), stored low byte first. - Bytes 2 and 3: 16-bit segment address (
CS), stored low byte first.
Base physical address for Type N is N x 4.
Five Dedicated Interrupts:
- Type 0 (Divide Error): Triggered automatically when a
DIV/IDIVquotient exceeds destination register capacity. - Type 1 (Single Step): Triggered after every instruction when Trap Flag
TF = 1. - Type 2 (NMI): Triggered by an external rising edge on the NMI pin; non-maskable.
- Type 3 (Breakpoint): Single-byte instruction
INT 3(opcode CCH) used by debuggers. - Type 4 (Overflow): Generated by executing
INTOif Overflow FlagOF = 1.
Address Range Calculations:
- Type 15H (decimal 21): Starting Address = 21 x 4 = 84 = 00054H Memory Range = 00054H to 00057H
- Type 82H (decimal 130): Starting Address = 130 x 4 = 520 = 00208H Memory Range = 00208H to 0020BH
The 8086 IVT occupies 00000H–003FFH (1 KB) holding 256 4-byte CS:IP pointers. Types 0–4 are Divide Error, Single Step, NMI, Breakpoint, and Overflow. Type 15H occupies 00054H–00057H; Type 82H occupies 00208H–0020BH.
Compare the interrupt architectures of the Intel 8085 and Intel 8086 microprocessors across six architectural parameters: total interrupt capacity, vector table location and size, vector format, software interrupt instructions, non-maskable interrupt features, and hardware acknowledge protocol.
Comparison Table:
| Parameter | Intel 8085 Microprocessor | Intel 8086 Microprocessor |
|---|---|---|
| 1. Total Interrupt Capacity | 5 hardware pins (TRAP, RST 7.5, 6.5, 5.5, INTR) + 8 software restarts (RST 0–7) | 256 total interrupt types (Type 0 to Type 255) |
| 2. Vector Table Location & Size | 64 bytes at 0000H to 003FH (vectors separated by 4 or 8 bytes) | 1024 bytes (1 KB) at 00000H to 003FFH |
| 3. Vector Format | Each vector is a memory location containing executable code or a JMP instruction | Each vector contains a 4-byte pointer: 2 bytes offset (IP) + 2 bytes segment (CS) |
| 4. Software Interrupts | 8 single-byte instructions (RST 0 to RST 7) | 256 two-byte instructions (INT n, n = 0 to 255) plus single-byte INT 3 |
| 5. Non-Maskable Interrupt | TRAP (both level and edge sensitive; vectors to 0024H) | NMI (edge-sensitive only; vectors to Type 2 at 00008H) |
| 6. Hardware Acknowledge Protocol | Single INTA_bar pulse; external hardware supplies an opcode (RST n or CALL) | Two consecutive INTA_bar pulses; external 8259A supplies an 8-bit vector type byte |
The 8085 supports 5 hardware pins and 8 software restarts in a 64-byte vector table, requiring executable instructions at vector locations. The 8086 supports 256 interrupt types in a 1 KB table using 4-byte CS:IP pointers, software INT n, and a two-pulse INTA_bar protocol.
Describe the hardware interaction between the Intel 8086 microprocessor and an external Intel 8259A PIC when an interrupt arrives on the INTR pin. What specific operations occur during the two consecutive INTA_bar machine cycles?
External Handshake Sequence:
- A peripheral asserts an
IRline on the 8259A. - The 8259A evaluates priorities and asserts its
INToutput to the 8086INTRpin. - If interrupts are enabled (
IF = 1), the 8086 completes its current instruction and enters an Interrupt Acknowledge bus cycle.
Operations During the Two INTA_bar Pulses:
- First INTA_bar Pulse:
- The 8086 asserts the first active-low
INTA_barpulse to signal the 8259A that its request has been accepted. - The 8259A sets the corresponding in-service bit in the ISR register and clears the bit in the IRR register.
- In cascaded systems, the Master 8259A outputs the 3-bit binary ID of the active Slave onto lines
CAS2–CAS0. - The 8086 data bus remains in a floating (high-impedance) state during this first pulse.
- The 8086 asserts the first active-low
- Second INTA_bar Pulse:
- The 8086 asserts the second active-low
INTA_barpulse. - The active 8259A (or selected Slave) places an 8-bit interrupt type number
N(e.g., 20H–27H) onto data bus lines D7–D0. - The 8086 reads byte
Nfrom the bus, terminates the acknowledge cycle, and proceeds to save Flags, CS, and IP before vectoring to4 x N.
- The 8086 asserts the second active-low
The 8086 pulses INTA_bar twice: the first pulse locks priority, updates the 8259A ISR, and asserts cascade lines CAS2–CAS0; the second pulse commands the active 8259A to place the 8-bit interrupt type number N on data bus D7–D0.
Write an 8086 assembly language program that installs an Interrupt Service Routine for Type 40H into the Interrupt Vector Table.
- The ISR is named
TIMER_ISRand is located at offset 0300H in code segment 2000H. - Show the complete instructions to calculate the IVT offset, safely write the vector into memory, trigger the interrupt using
INT 40H, and return viaIRET.
Calculate IVT Physical Address for Type 40H: Type 40H = decimal 64. Starting address in IVT = 64 x 4 = 256 = 0100H. The vector pointer is stored at 0000:0100H:
0000:0100H: Low byte of IP = 00H0000:0101H: High byte of IP = 03H0000:0102H: Low byte of CS = 00H0000:0103H: High byte of CS = 20H
Assembly Language Implementation:
CLI
XOR AX, AX
MOV ES, AX
MOV WORD PTR ES:[0100H], 0300H
MOV WORD PTR ES:[0102H], 2000H
STI
INT 40H
HLT
ORG 0300H
TIMER_ISR:
NOP
IRETExecution Summary:
CLIdisables interrupts during vector table update.ESis set to 0000H (segment base of the IVT).MOV WORD PTR ES:[0100H], 0300Hstores IP offset 0300H.MOV WORD PTR ES:[0102H], 2000Hstores CS base 2000H.STIenables interrupts.INT 40Hpushes Flags, CS, and IP, clears IF and TF, and branches to2000:0300H.TIMER_ISRexecutes and returns viaIRET.
Type 40H vector is stored at 0000:0100H (IP = 0300H, CS = 2000H). The program points ES to 0000H, writes the two 16-bit words under CLI, re-enables interrupts via STI, and executes INT 40H.