
Calls, Traps, Branches, Jumps, and Returns
7-13
Program Flow Control
RETIcond
returns from traps or calls in the same way that RETScond
does with the addition that RETIcondalso copies the PGIE and PCF bit
values into the GIE and CF bits of the status register. The conditions for
RETIcondare the same as for the CALLcondinstruction.
RETIcondD
returns from traps or calls in the same way that RETIcond
does with the addition that RETIcondD first executesthe three instructions
immediately following RETIcondD. The conditions for RETIcondD are the
same as for the CALLcondinstruction.
Link and jump (
LAJ
), link and jump conditional
(LAJcond
), and link and
trap conditional (
LATcond
) each provide a return address in extended-
precision register R11.
After it executes the three instructions that follow it, LAJ jumps to an
address derived by a 24-bit PC-relative addressing mode (see sub-
section 6.6 for more information).
The LAJconddestination address is either PC-relative (a displace-
ment) or the contents of a specified register. If the condition is true,
LAJcondfirst executes the three instructions following the LAJcond
before making the jump. If the condition is not true, execution contin-
ues immediately after the LAJcondinstruction.
After it executes the three instructions that follow it, LATcondcalls one
of the 512 available trap vectors pointed to by the trap vector table
pointer (see Section 3.2, on page 3-17, for more information about the
TVTP).
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. Thus, traps are
usually terminated with a RETIcond or RETIcondD instruction to re-en-
able interrupts if the status register GIE bit was set previously.
You can use traps to indirectly call functions. This is particularly beneficial
when a kernel of code contains the basic subfunctions to be used by ap-
plications. In this case, you can modify the functions in the kernel and relo-
cate them without recompiling each application.