
#
User
’
s Manual
20-8
1999-08
Linear Stack
The C161PI also offers a linear stack option (STKSZ =
‘
111
B
’
), where the system stack
may use the complete internal RAM area. This provides a large system stack without
requiring procedures to handle data transfers for a circular stack. However, this method
also leaves less RAM space for variables or code. The RAM area that may effectively be
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
i
+] or Rw, [Rw
i
+]
: 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.