Z80 Assembly 60: Interrupt Vector Table Management (IM 2 Dynamic Handlers)
The Interrupt Vector Table (IVT) The Interrupt Vector Table (IVT) is a critical data structure used exclusively when the Z80 is operating in Interrupt Mode 2 (IM 2). It is a simple array of 16-bit addresses that tells the CPU exactly where to jump when a specific hardware device signals an interrupt. How the IVT Address is Calculated: Base Address: The OS sets the Interrupt Vector Register (I) to point to the base (high byte) of the IVT. Hardware Vector: The interrupting hardware places an 8-bit value (the low byte of the address) on the data bus. Final Address: The Z80 combines the I register (High Byte) with the Hardware Vector (Low Byte) to form the 16-bit address of the IVT entry. Jump: The CPU reads the 16-bit address stored at the IVT entry and jumps to the device’s specific Interrupt Service Routine (ISR). Structuring the IVT The IVT must be aligned to a 256-byte boundary (e.g., C000H′, D000H′) and consists of 128 consecutive 16-bit addresses (256 bytes). ...