Skip to content
Advanced Microprocessor

8259 PIC: Priority Resolver, Cascading & ICW/OCW Words

IRR, ISR, IMR registers, cascading up to 64 priority interrupt inputs, Initialization Words (ICW1–4), and End of Interrupt (EOI).

Knova editors12 min readQuick checkSources

The 8259 Priority Interrupt Controller (PIC)

The Intel 8259A is a dedicated, programmable hardware interrupt controller designed to manage up to 8 prioritized vectored interrupts for the 8085 and 8086 microprocessors.

By cascading up to eight slave 8259 chips into a single master 8259, a system can expand its hardware interrupt handling capacity to 64 prioritized interrupt levels.

Internal Block Architecture

The internal structure of the 8259 comprises eight functional blocks:

  1. Interrupt Request Register (IRR): An 8-bit register that stores the status of all pending interrupt requests applied to input pins IR0−IR7IR_0-IR_7.
  2. Interrupt Mask Register (IMR): An 8-bit register programmed via software to individually enable or disable (mask) any of the eight interrupt inputs (IR0−IR7IR_0-IR_7). A 11 in any bit position masks the corresponding request.
  3. Priority Resolver (PR): A high-speed combinational logic block that compares the unmasked bits in the IRR with the currently active interrupts in the ISR to identify the highest-priority request.
  4. In-Service Register (ISR): An 8-bit register that stores the interrupt level currently being serviced by the CPU. When an interrupt is acknowledged, its corresponding bit in the ISR is set to 11, where it remains until cleared by an End of Interrupt (EOI) command.
  5. Cascade Buffer / Comparator: Generates and compares chip-identification codes over the three cascade lines (CAS2−CAS0CAS_2-CAS_0), coordinating master-slave operations.
  6. Data Bus Buffer, Read/Write Logic, and Control Logic: Manages data bus transactions and generates the primary interrupt signal (INT) and acknowledge handshaking ($\overline{INTA}$).

Cascaded Architecture: Master and Slave Interfacing

In a cascaded configuration:

  • The Master 8259 has its INT output connected directly to the CPU's INTR pin.
  • Peripheral interrupt lines from up to eight Slave 8259 units connect to the Master's IR0−IR7IR_0-IR_7 inputs.
  • Lines CAS2,CAS1,CAS_2, CAS_1, and CAS0CAS_0 act as outputs from the Master and inputs to all Slaves. When the Master receives an interrupt on input IRnIR_n, it outputs the binary code of nn (000000 to 111111) on the cascade lines during the first INTA‾\overline{INTA} pulse.
  • The Slave whose programmed ID matches CAS2−CAS0CAS_2-CAS_0 is activated to supply the interrupt vector byte across the data bus during the second INTA‾\overline{INTA} pulse.

Initialization Command Words (ICW1 - ICW4)

Before the 8259 can service interrupts, it must receive a sequential programming sequence of 2 to 4 Initialization Command Words (ICWs):

  1. ICW1 (A0=0A_0 = 0):
    • Triggering mode: Level-triggered (LTIM=1LTIM = 1) or Edge-triggered (LTIM=0LTIM = 0).
    • System architecture: Single 8259 (SNGL=1SNGL = 1) or Cascaded master/slave system (SNGL=0SNGL = 0).
    • ICW4 indicator: Set to 11 if ICW4 is required (mandatory for 8086/8088 systems).
  2. ICW2 (A0=1A_0 = 1): Selects the Interrupt Vector Base Address. For an 8086 system, bits D7−D3D_7-D_3 define the high 5 bits of the interrupt type number (e.g. Type 08H08\text{H} for IR0IR_0, Type 09H09\text{H} for IR1IR_1, up to Type 0FH0\text{F}\text{H} for IR7IR_7).
  3. ICW3 (A0=1A_0 = 1): Configures cascade interconnections:
    • Master Mode: Each bit represents one of the IR7−IR0IR_7-IR_0 inputs (1=Slave connected to that pin,0=Direct I/O device1 = \text{Slave connected to that pin}, 0 = \text{Direct I/O device}).
    • Slave Mode: Lower 3 bits (D2−D0D_2-D_0) encode the slave's unique identification number (00 to 77).
  4. ICW4 (A0=1A_0 = 1): Environmental controls:
    • Microprocessor mode: 8086/8088 mode (μPM=1\mu\text{PM} = 1) or 8085 mode (μPM=0\mu\text{PM} = 0).
    • End of Interrupt mode: Automatic EOI (AEOI=1AEOI = 1) or Normal EOI (AEOI=0AEOI = 0).
    • Buffering mode: Buffered mode (BUF=1BUF = 1) with Master/Slave designation (M/SM/S).
    • Fully Nested Mode: Special Fully Nested Mode (SFNM=1SFNM = 1) for priority preservation in cascaded systems.

Operational Command Words (OCW1 - OCW3)

During normal system operation, the CPU modifies 8259 behavior using three Operational Command Words:

  • OCW1 (A0=1A_0 = 1): Directly sets or clears individual bits in the Interrupt Mask Register (IMR).
  • OCW2 (A0=0A_0 = 0): Issues End of Interrupt (EOI) commands and controls priority rotation:
    • Non-Specific EOI: Clears the highest priority bit currently set in the In-Service Register (ISR).
    • Specific EOI: Clears a specific ISR level designated by bits L2−L0L_2-L_0.
    • Automatic Rotation: Rotates priority so the most recently serviced device becomes lowest priority.
  • OCW3 (A0=0A_0 = 0): Reads the status of the Interrupt Request Register (IRR) or In-Service Register (ISR), and controls Special Mask Mode.

Bit-Level Command Word Structure

Initialization Command Words (ICW1 - ICW4)

  1. ICW1 (A0=0A_0 = 0, D4=1D_4 = 1):
    • D7−D5D_7-D_5: Interrupt vector address for 8080/8085 mode.
    • D4D_4: Must be 11 (identifies ICW1).
    • D3D_3 (LTIMLTIM): 1=Level-triggered1 = \text{Level-triggered}; 0=Edge-triggered0 = \text{Edge-triggered}.
    • D2D_2 (ADIADI): Call address interval (1=4 bytes1 = 4\text{ bytes}; 0=8 bytes0 = 8\text{ bytes}).
    • D1D_1 (SNGLSNGL): 1=Single 82591 = \text{Single 8259}; 0=Cascade mode (requires ICW3)0 = \text{Cascade mode (requires ICW3)}.
    • D0D_0 (IC4IC4): 1=ICW4 required1 = \text{ICW4 required}; 0=ICW4 not required0 = \text{ICW4 not required}.
  2. ICW2 (A0=1A_0 = 1): Sets higher-order address bits (T7−T3T_7-T_3) of the interrupt vector. In 8086 mode, bits D7−D3D_7-D_3 determine the base interrupt vector number (0−2550-255).
  3. ICW3 (A0=1A_0 = 1, Cascade Mode Only):
    • Master: S7−S0S_7-S_0 indicate which IRIR line has a Slave connected (1=Slave attached1 = \text{Slave attached}).
    • Slave: D2−D0D_2-D_0 specify the Slave ID number (000B−111B000\text{B}-111\text{B}) corresponding to the Master's IRIR input line.
  4. ICW4 (A0=1A_0 = 1):
    • D4D_4 (SFNMSFNM): 1=Special Fully Nested Mode enabled1 = \text{Special Fully Nested Mode enabled}.
    • D3D_3 (BUFBUF) & D2D_2 (M/SM/S): Buffered mode control (10=Buffered Master10 = \text{Buffered Master}, 11=Buffered Slave11 = \text{Buffered Slave}, 0X=Non-buffered0X = \text{Non-buffered}).
    • D1D_1 (AEOIAEOI): 1=Automatic End of Interrupt (no explicit EOI needed)1 = \text{Automatic End of Interrupt (no explicit EOI needed)}; 0=Normal EOI0 = \text{Normal EOI}.
    • D0D_0 (μPM\mu PM): 1=8086/8088 CPU1 = \text{8086/8088 CPU}; 0=8080/8085 CPU0 = \text{8080/8085 CPU}.

Cascaded Architecture: Expanding to 64 Interrupts

In a large system, up to 99 8259 chips can be interconnected (11 Master and 88 Slaves) to expand the system from 88 up to 6464 priority interrupt lines:

  1. The Master's INTINT output connects directly to the CPU's INTRINTR pin.
  2. Each Slave's INTINT output connects to one of the Master's IR0−IR7IR_0-IR_7 input pins.
  3. The Master and Slaves share a 3-bit bidirectional cascade bus (CAS2,CAS1,CAS0\text{CAS}_2, \text{CAS}_1, \text{CAS}_0):
    • When a Slave generates an interrupt, the Master raises INTRINTR to the CPU.
    • The CPU returns an INTA‾\overline{INTA} pulse.
    • During the first INTA‾\overline{INTA} pulse, the Master outputs the 3-bit binary code of the active Slave on CAS2−CAS0\text{CAS}_2-\text{CAS}_0.
    • The matching Slave recognizes its ID, enables its data bus buffer, and during the second INTA‾\overline{INTA} pulse places the interrupt vector directly onto the data bus.

Summary of 8259 Operating Modes

  • Fully Nested Mode (Default): Interrupt requests are ordered in priority from IR0IR_0 (highest) to IR7IR_7 (lowest). When an interrupt is serviced, higher-priority requests can preempt the ISR, while equal or lower requests are inhibited.
  • Special Fully Nested Mode: Used in cascaded systems. Allows a Master to recognize a higher-priority request arriving from the same Slave currently in-service.
  • Rotating Priority Mode: Priority rotates either automatically upon completion of service, or to a specific level via software command.
  • Polled Mode: CPU disables its own interrupt pin and polls the 8259 by writing a Poll Command in OCW3. The 8259 returns the priority level of the highest pending request.
  • Special Mask Mode: Allows the CPU to dynamically service lower-priority interrupts by selectively masking out higher-priority ones without disabling interrupts globally.
Try it
8259 In-Service Register Handling: Why must an End of Interrupt (EOI) command be issued at the conclusion of an Interrupt Service Routine in normal nested mode?

Sources

  1. 1.Intel 8259 PIC Documentation · reference · Intel (opens in a new tab)

Was this chapter useful?

Editors read every answer.

Star this chapter

Each star goes once to every reader who improved this chapter.

Finished reading?

Mark it to keep your place in the course.