
#
User
’
s Manual
20-9
1999-08
20.2
Register Banking
Register banking provides the user with an extremely fast method to switch user context.
A single machine cycle instruction saves the old bank and enters a new register bank.
Each register bank may assign up to 16 registers. Each register bank should be
allocated during coding based on the needs of each task. Once the internal memory has
been partitioned into a register bank space, internal stack space and a global internal
memory area, each bank pointer is then assigned. Thus, upon entry into a new task, the
appropriate bank pointer is used as the operand for the SCXT (switch context)
instruction. Upon exit from a task a simple POP instruction to the context pointer (CP)
restores the previous task
’
s register bank.
20.3
Procedure Call Entry and Exit
To support modular programming a procedure mechanism is provided to allow coding of
frequently used portions of code into subroutines. The CALL and RET instructions store
and restore the value of the instruction pointer (IP) on the system stack before and after
a subroutine is executed.
Procedures may be called conditionally with instructions CALLA or CALLI, or be called
unconditionally using instructions CALLR or CALLS.
Note: Any data pushed onto the system stack during execution of the subroutine must
be popped before the RET instruction is executed.
Passing Parameters on the System Stack
Parameters may be passed via the system stack through PUSH instructions before the
subroutine is called, and POP instructions during execution of the subroutine. Base plus
offset indirect addressing also permits access to parameters without popping these
parameters from the stack during execution of the subroutine. Indirect addressing
provides a mechanism of accessing data referenced by data pointers, which are passed
to the subroutine.
In addition, two instructions have been implemented to allow one parameter to be
passed on the system stack without additional software overhead.
The PCALL (push and call) instruction first pushes the
’
reg
’
operand and the IP contents
onto the system stack and then passes control to the subroutine specified by the
’
caddr
’
operand.
When exiting from the subroutine, the RETP (return and pop) instruction first pops the IP
and then the
’
reg
’
operand from the system stack and returns to the calling program.