
210
Evaluating and Programming the 29K RISC Family
curs (e.g., a Timer Interrupt). When this happens, the second-level interrupt handler
is given control.
After completing its processing, execution of an IRET instruction causes the
processor to use the information in its CHC register to resume the interrupted load-
multiple instruction; but this is in the context of the first-level interrupt handler, rath-
er than in the main program where it was interrupted.
This CHC discussion is merely an explanation to stress that the CHC register
should not only be saved and restored in each interrupt level, but that CHC should
also be cleared before interrupts are enabled. This will ensure that only when the
proper copy of the CHC is restored will execution of an IRET instruction restart the
interrupted load- or store-multiple operation.
A problem, relating to clearing the CHC register, has been observed with a
number of 29K family members. The problem effects the last word of a LOADM
instruction reaching its destination register when the LOADM is interrupted. The
problem can be overcome by performing a LOADM or STOREM instruction in the
interrupt handler after coming off Freeze mode but before reenabling interrupts. The
LOADM or STOREM must use a CR value of one or greater. Processors have a
hidden internal
shadow
CHC which may not be cleared by a move of zero into the
CHC register. A LOADM or STOREM instruction causes the hidden CHC register to
be cleared. The problem can also be overcome by performing a STORE or LOAD
instruction while still in Freeze mode. If interrupts are not reenabled by the interrupt
handler, no special steps are required to deal with the interrupted LOADM difficulty.
The problem is of little importance, as interrupt handlers generally perform the
solutions
described without additional code being added.
Additionally, when a trap occurs as a result of a Data Exception Error (DERR)
the TF bit in the CHC will become set. It is important that the CHC register be cleared
rather than be restored for the context containing the violating data access. Otherwise
an interrupt handler loop will result.
4.3.9 Saving Registers
The following code illustrates saving the necessary registers, turning off Freeze
mode, and enabling interrupts.
;multi-level nested interrupt handler
;example code
;
intr0:
;save registers
msp,it0,pc0
msp,it0,pc1
msp,it0,alu
msp,it0,cha
msp,it0,chd
msp,it0,chc
pushsr
pushsr
pushsr
pushsr
pushsr
pushsr
;save PC0
;save PC1
;save ALU
;save CHA
;save CHD
;save CHC