Traps
7-47
Program Flow Control
7.8
Traps
A trap is the equivalent of a software-triggered interrupt. In the ’C3x, traps and
interrupts are treated identically, except in the way in which they are triggered.
7.8.1
Initialization of Traps and Interrupts
Traps and interrupts are triggered differently in the ’C3x:
-
Traps are always triggered by a software mechanism, by the TRAP
cond
(conditional trap) instructions.
-
Interrupts are always triggered by hardware events (for example, by exter-
nal interrupts, DMA interrupts, or serial-port interrupts).
The GIE bit in the ST register and the mask bits in the IE do not apply to traps.
7.8.2
Operation of Traps
Figure 7–10 shows the general flow of traps which is similar to interrupts.
Figure 7–10. Flow of Traps
Trap executed
(TRAP
cond)
(1)
(2)
(3)
Trap or interrupt service routine
Return executed
(RETI
cond)
GIE
0
GIE
1