Indeed they were intended for fast interrupt reaction. In a simple, general way, this saved the time to push the main process'process's registers onto the stack and restore them again. They seveneven went so far to spend one of the very few available single byte-byte opcodes to get the absolute minimum execution time - likeas the Z80 Technical Manual states on p.26:
OP code 08H allows the programmer to switch between the two pairs of
accumulator flag registers while D9H allows the programmer to switch between
the duplicate set of six general purpose registers. These OP codes are only one
byte in length to absolutely minimize the time necessary to perform the
exchange so that the duplicate banks can be used to effect very fast interrupt
response times.
OP code
08H
allows the programmer to switch between the two pairs of accumulator flag registers whileD9H
allows the programmer to switch between the duplicate set of six general purpose registers. These OP codes are only one byte in length to absolutely minimize the time necessary to perform the exchange so that the duplicate banks can be used to effect very fast interrupt response times.
EX
and EXX
only take 4 T-cycles, while even just pushing a simple 16-bit register would take 11 cycles, plus another 15 to load it again. 8 T-cycles instead of 25 or more cycles is a considerably faster reaction, isn't it?
That's also why there are two EX*
instructioninstructions, as very simple routines may only (use and) need to preserve the flags and A
. This leaves the whole second set (except AF
) for other purposes. Like, such as being used in normal software, or for even more speedup in I/O.
If these values are placed in the second register set before the high speed interrupt driven-driven routine gets active, no loads and stores are to be executed. Interrupt service time gets reduced to the absolute minimum, not only causing less interruption of the main process but also working up to higher speeds.
It was quite common to use them either for interruptinterrupts (mostly in embedded systems) or 'dead end' routines.