
C161U
System Programming
Data Sheet
404
2001-04-19
consumed by the system stack is defined via the STKUN and STKOV pointers. The
underflow and overflow traps in this case serve for fatal error detection only.
For the linear stack option all modifiable bits of register SP are used to access the
physical stack. Although the stack pointer may cover addresses from 00’F000
H
up to
00’FFFE
H
the (physical) system stack must be located within the internal RAM and
therefore may only use the address range 00’F600
H
to 00’FDFE
H
. It is the user’s
responsibility to restrict the system stack to the internal RAM range.
Note:
Avoid stack accesses below the IRAM area (ESFR space and reserved area) and
within address range 00’FE00
H
and 00’FFFE
H
(SFR space).
Otherwise unpredictable results will occur.
User Stacks
User stacks provide the ability to create task specific data stacks and to off-load data
from the system stack. The user may push both bytes and words onto a user stack, but
is responsible for using the appropriate instructions when popping data from the specific
user stack. No hardware detection of overflow or underflow of a user stack is provided.
The following addressing modes allow implementation of user stacks:
[– Rw], Rb or [– Rw], Rw
: Pre-decrement Indirect Addressing.
Used to push one byte or word onto a user stack. This mode is only available for MOV
instructions and can specify any GPR as the user stack pointer.
Rb, [Rw+] or Rw, [Rw+]
: Post-increment Index Register Indirect Addressing.
Used to pop one byte or word from a user stack. This mode is available to most
instructions, but only GPRs R0-R3 can be specified as the user stack pointer.
Rb, [Rw+] or Rw, [Rw+]
: Post-increment Indirect Addressing.
Used to pop one byte or word from a user stack. This mode is only available for MOV
instructions and can specify any GPR as the user stack pointer.
21.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.