RET / RETI
You may have noticed that the interrupt routine ends with
RETI rather than the standard RET, this is for completeness and not
specifically required, you can end with RET if you prefer. The main
reason RETI was added to the instruction set is to allow hardware to detect
when the end of the interrupt routine and to pass control onto the next
interrupt in a dasiy chained system. The hardware could specifically
check the opcode for RETI. If it checked RET it could get confused when
coming to the end of a function rather than the entire interrupt routine.
To my knowledge no devices for the spectrum use this feature.
EI but not DI?
There is another oddity in the interrupt routine, we have an
EI at the end but we never do a DI. This
is due to the fact the Z80 will do an internal DI when it starts processing the
interrupts. The reason for this is to
stop multiple interrupts triggering on top of each other and overrunning the
system stack. You can do an EI before
the end of your interrupt routine if you wish but general practice is to wait
until you have finished then enable them, that way there is no chance of you
starting a new interrupt routine before the old one has finished.
No comments:
Post a Comment