INTERRUPT OPERATIONS
The interrupt operations associated with the Z-80 system operation
are somewhat like the detailed I/O operations-rather difficult to
describe in the general case, without reference to a particular sys-
tem. The actual CPU instructions involved are the IM 0, IM 1, IM 2,
EI, and DI instructions which were discussed in earlier chapters in
conjunction with various interrupt modes. IM 0, IM 1, and IM 2 set
the appropriate interrupt mode, which is very much related to how
the system is configured for interrupts. Each device controller or
PIO will have its own address and hard-wired interrupt response
and probably only one of the three modes will be used for any given
system. DI and EI simply disable or enable interrupts, allowing
mmaskahle external interrupts to become active. When the interrupt
enable flip-flop is set, interrupts cause an interrupt action dependent
on the interrupt mode in force (see Chapter 7). Ultimately, any in-
terrupt transfers control to an interrupt processing routine, usually
unique for every kind of interrupt.
In the interrupt processing routine, the first order of business is to
ascertain that other interrupts are disabled until the contents of all
registers and flags that will be used in the interrupt routine can be
saved. All maskable interrupts are disabled on an interrupt until the
issuance of the next EI instruction, so the following sequence can be
executed:
PTAPE EQU $ PTAPE INTERRUPT ROUTINE
PUSH AF SAVE ALL
NO MASKABLE PUSH BC REGISTERS
INTERRUPT PUSH DE AND FLAGS
CAN OCCUR PUSH HL
IN THIS PUSH IX
SEQUENCE PUSH IY
El ENABLE INTERRUPTS
Here all registers except SP have been saved, indicating that the
interrupt processing will be quite extensive and will probably utilize
all registers. If the interrupt processing is relatively minor, and it is
known that certain registers will not be used, then those registers
need not be saved. It is hard to imagine an interrupt processing rou-
tine , however, in which flags would not somehow be affected, and
the PUSH AF (or EX AF,AF') must always be executed. Once the
environment has been saved, then higher priority interrupts are free
to occur and be processed.
Interrupt processing actions are virtually unlimited, except that
230
Need help?
Do you have a question about the Z80 and is the answer not in the manual?