ST10R272L - SYSTEM PROGRAMMING
304/320
instructions. This provides similar performance compared to instructions directly supporting
BCD data types, while no additional hardware is required.
18.3
Stack operations
The ST10R272L supports two types of stacks. The system stack is used implicitly by the
controller and is located in the internal RAM. The user stack provides stack access to the
user in either the internal or external memory. Both stack types grow from high memory
addresses to low memory addresses.
18.3.1 Internal system stack
A system stack is provided to store return vectors, segment pointers, and processor status
for procedures and interrupt routines. A system register, SP, points to the top of the stack.
This pointer is decremented when data is pushed onto the stack, and incremented when
data is popped.
The internal system stack can also be used to temporarily store data or pass it between
subroutines or tasks. Instructions are provided to push or pop registers on/from the system
stack. However, in most cases the register banking scheme provides the best performance
for passing data between multiple tasks.
The system stack allows to store words only. Bytes must either be converted to words or the
respective other byte must be disregarded.
Register SP can only be loaded with even byte addresses (The LSB of SP is always ’0’).
Detection of stack overflow/underflow is supported by two registers, STKOV (Stack Overflow
Pointer) and STKUN (Stack Underflow Pointer). Specific system traps (Stack Overflow trap,
Stack Underflow trap) will be entered whenever the SP reaches either boundary specified in
these registers.
The contents of the stack pointer are compared to the contents of the overflow register,
whenever the SP is DECREMENTED either by a CALL, PUSH or SUB instruction. An
overflow trap will be entered, when the SP value is less than the value in the stack overflow
register.
The contents of the stack pointer are compared to the contents of the underflow register,
whenever the SP is INCREMENTED either by a RET, POP or ADD instruction. An underflow
trap will be entered, when the SP value is greater than the value in the stack underflow
register.
Note
When a value is MOVED into the stack pointer, NO check against the overflow/
underflow registers is performed.
In many cases the user will place a software reset instruction (SRST) into the stack
underflow and overflow trap service routines. This is an easy approach, which does not
require special programming. However, this approach assumes that the defined internal