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:
- Interrupt Request Register (IRR): An 8-bit register that stores the status of all pending interrupt requests applied to input pins .
- Interrupt Mask Register (IMR): An 8-bit register programmed via software to individually enable or disable (mask) any of the eight interrupt inputs (). A in any bit position masks the corresponding request.
- 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.
- 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 , where it remains until cleared by an End of Interrupt (EOI) command.
- Cascade Buffer / Comparator: Generates and compares chip-identification codes over the three cascade lines (), coordinating master-slave operations.
- 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
INToutput connected directly to the CPU'sINTRpin. - Peripheral interrupt lines from up to eight Slave 8259 units connect to the Master's inputs.
- Lines and act as outputs from the Master and inputs to all Slaves. When the Master receives an interrupt on input , it outputs the binary code of ( to ) on the cascade lines during the first pulse.
- The Slave whose programmed ID matches is activated to supply the interrupt vector byte across the data bus during the second 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):
- ICW1 ():
- Triggering mode: Level-triggered () or Edge-triggered ().
- System architecture: Single 8259 () or Cascaded master/slave system ().
- ICW4 indicator: Set to if ICW4 is required (mandatory for 8086/8088 systems).
- ICW2 (): Selects the Interrupt Vector Base Address. For an 8086 system, bits define the high 5 bits of the interrupt type number (e.g. Type for , Type for , up to Type for ).
- ICW3 (): Configures cascade interconnections:
- Master Mode: Each bit represents one of the inputs ().
- Slave Mode: Lower 3 bits () encode the slave's unique identification number ( to ).
- ICW4 (): Environmental controls:
- Microprocessor mode: 8086/8088 mode () or 8085 mode ().
- End of Interrupt mode: Automatic EOI () or Normal EOI ().
- Buffering mode: Buffered mode () with Master/Slave designation ().
- Fully Nested Mode: Special Fully Nested Mode () 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 (): Directly sets or clears individual bits in the Interrupt Mask Register (IMR).
- OCW2 (): 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 .
- Automatic Rotation: Rotates priority so the most recently serviced device becomes lowest priority.
- OCW3 (): 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)
- ICW1 (, ):
- : Interrupt vector address for 8080/8085 mode.
- : Must be (identifies ICW1).
- (): ; .
- (): Call address interval (; ).
- (): ; .
- (): ; .
- ICW2 (): Sets higher-order address bits () of the interrupt vector. In 8086 mode, bits determine the base interrupt vector number ().
- ICW3 (, Cascade Mode Only):
- Master: indicate which line has a Slave connected ().
- Slave: specify the Slave ID number () corresponding to the Master's input line.
- ICW4 ():
- (): .
- () & (): Buffered mode control (, , ).
- (): ; .
- (): ; .
Cascaded Architecture: Expanding to 64 Interrupts
In a large system, up to 8259 chips can be interconnected ( Master and Slaves) to expand the system from up to priority interrupt lines:
- The Master's output connects directly to the CPU's pin.
- Each Slave's output connects to one of the Master's input pins.
- The Master and Slaves share a 3-bit bidirectional cascade bus ():
- When a Slave generates an interrupt, the Master raises to the CPU.
- The CPU returns an pulse.
- During the first pulse, the Master outputs the 3-bit binary code of the active Slave on .
- The matching Slave recognizes its ID, enables its data bus buffer, and during the second 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 (highest) to (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.