
DocID13284 Rev 2
547/564
UM0404
System programming
Whenever a multiply or divide instruction is interrupted while in progress, the address of the
interrupted instruction is pushed onto the stack and the MULIP flag in the PSW of the
interrupting routine is set. When the interrupt routine is exited with the RETI instruction, this
bit is implicitly tested before the old PSW is popped from the stack. If MULIP = ‘1’ the
multiply/divide instruction is re-read from the location popped from the stack (return
address) and will be completed after the RETI instruction has been executed.
Note:
The MULIP flag is part of the
context of the interrupted task
. When the interrupting
routine does not return to the interrupted task (for example when a scheduler switches to
another task) the MULIP flag must be set or cleared according to the context of the task that
is switched to.
BCD calculations
No direct support for BCD calculations is provided in the ST10F276. BCD calculations are
performed by converting BCD data to binary data, performing the desired calculations using
standard data types, and converting the result back to BCD data. Due to the enhanced
performance of division instructions binary data is quickly converted to BCD data through
division by 10d. Conversion from BCD data to binary data is enhanced by multiple bit shift
instructions. This provides similar performance compared to instructions directly supporting
BCD data types, while no additional hardware is required.
27.1 Stack
operations
The ST10F276 supports two types of stacks. The system stack is used implicitly by the
controller and is located in the IRAM. 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.
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.
Note:
The system stack allows the storage of words only. Byte must either be converted to word 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.