Egghead.page Logo

How Many Interrupt Modes Did the Z80 Support in the ZX Spectrum?

The Z80 processor found within the Sinclair ZX Spectrum supports three distinct interrupt modes, though the machine primarily utilizes only one for standard operation. This article explores the technical capabilities of the Z80 CPU regarding interrupts, details the specific mode employed by the Spectrum’s hardware, and explains why the system was designed to function primarily within a single interrupt framework despite the processor’s broader capabilities.

The Three Z80 Interrupt Modes

The Zilog Z80 microprocessor, which powers the Sinclair ZX Spectrum, was designed with flexibility in mind regarding hardware interrupts. It supports three specific interrupt modes known as IM 0, IM 1, and IM 2. In Interrupt Mode 0, the processor executes a call instruction provided by an external device on the data bus. Interrupt Mode 1 causes the processor to jump to a fixed memory address, typically used for simple reset or restart routines. Interrupt Mode 2 is the most flexible, allowing the processor to jump to an address determined by a vector table located anywhere in memory, enabling multiple interrupt sources to be handled efficiently.

Interrupt Usage in the ZX Spectrum

Despite the Z80 CPU supporting three modes, the Sinclair ZX Spectrum hardware and its original ROM software are configured to use Interrupt Mode 1 exclusively during normal operation. The Spectrum’s Uncommitted Logic Array (ULA) generates an interrupt signal 50 times per second for PAL machines or 60 times per second for NTSC units. This signal triggers the CPU to pause its current task and execute a routine located at a specific memory address, which handles video refresh timing and keyboard scanning. Because the ULA does not provide the specific data bus information required for IM 0 or the vector table indexing required for IM 2 during the standard interrupt cycle, IM 1 is the most reliable and straightforward choice for the system architecture.

Advanced Programming and Alternative Modes

While the standard operating environment relies on IM 1, advanced programmers and demo coders have historically utilized Interrupt Mode 2 on the ZX Spectrum to achieve precise timing effects. By carefully managing the interrupt vector table and accounting for the data value placed on the bus by the ULA during an interrupt acknowledge cycle, developers can harness IM 2 for split-screen effects or custom music players. However, this requires bypassing the standard ROM routines and taking full control of the hardware. Regardless of these advanced techniques, the fundamental support provided by the processor remains at three modes, with the system defaulting to one for stability and compatibility.

Conclusion

In summary, the Z80 processor inside the Sinclair ZX Spectrum supports three interrupt modes technically, but the computer itself is engineered to operate using Interrupt Mode 1. This design choice simplified the hardware interface and ensured consistent timing for video generation and input handling. Understanding this distinction is crucial for retro computing enthusiasts and developers looking to maximize the potential of the classic 8-bit architecture.