Calls, Traps, and Returns
7-12
-
RETI
cond returns from traps or calls like the RETScond, with the addition
that RETI
cond also sets the GIE bit of the status register, which enables
all interrupts whose enabling bit is set to 1. The conditions for RETI
cond
are the same as for the CALL
cond instruction.
Functionally, calls and traps accomplish the same task — a subfunction is
called and executed, and control is then returned to the calling function. Traps
offer two advantages over calls:
-
Interrupts are automatically disabled when a trap is executed. This allows
critical code to execute without risk of being interrupted. Traps are generally
terminated with a RETI
cond instruction to reenable interrupts.
-
You can use traps to indirectly call functions. This is particularly benefi-
cial when a kernel of code contains the basic subfunctions to be used by
applications. In this case, you can modify the functions in the kernel and
relocate them without recompiling each application.
Figure 7–1. CALL Response Timing
Read CALL
H3
H1
ADDR
Data
Fetch CALL
Fetch first
subroutine
instruction
Vector address
First instruction
address
Execute CALL
(store PC
on stack)
Decode CALL
PC
Inst 1