Programming Considerations
7-26
7.6.2
Nested Interrupts
Generally, when the CPU enters an interrupt service routine, interrupts are
disabled. However, when the interrupt service routine is for one of the
maskable interrupts (INT4–INT15), an NMI can interrupt processing of the
maskable interrupt. In other words, an NMI can interrupt a maskable interrupt,
but neither an NMI nor a maskable interrupt can interrupt an NMI.
There may be times when you want to allow an interrupt service routine to be
interrupted by another (particularly higher priority) interrupt. Even though the
processor by default does not allow interrupt service routines to be interrupted
unless the source is an NMI, it is possible to nest interrupts under software
control. The process requires you to save the original IRP (or NRP) and IER
to memory or registers (either registers not used, or registers saved if they are
used by subsequent interrupts), and if you desire, to set up a new set of inter-
rupt enables once the ISR is entered, and save the CSR. Then you could set
the GIE bit, which would reenable interrupts inside the interrupt service
routine.
7.6.3
Manual Interrupt Processing
You can poll the IFR and IER to detect interrupts manually and then branch to
the value held in the ISTP as shown below in Example 7–12.
The code sequence begins by copying the address of the highest priority inter-
rupt from the ISTP to the register B2. The next instruction extracts the number
of the interrupt, which is used later to clear the interrupt. The branch to the in-
terrupt service routine comes next with a parallel instruction to set up the ICR
word.
The last five instructions fill the delay slots of the branch. First, the 32-bit return
address is stored in the B2 register and then copied to the interrupt return
pointer (IRP). Finally, the number of the highest priority interrupt, stored in B1,
is used to shift the ICR word in B1 to clear the interrupt.
Example 7–12. Manual Interrupt Processing
MVC
ISTP,B2
; get related ISFP address
EXTU
B2,23,27,B1
; extract HPEINT
[B1]
B
B2
; branch to interrupt
||
[B1]
MVK
1,A0
; setup ICR word
[B1]
MVK
RET_ADR,B2
; create return address
[B1]
MVKH
RET_ADR,B2
;
[B1]
MVC
B2,IRP
; save return address
[B1]
SHL
A0,B1,B1
; create ICR word
[B1]
MVC
B1,ICR
; clear interrupt flag
RET_ADR:
(Post interrupt service routine Code)