
!!"
User
’
s Manual
5-32
1999-08
External NMI Trap
Whenever a high to low transition on the dedicated external NMI pin (Non-Maskable
Interrupt) is detected, the NMI flag in register TFR is set and the CPU will enter the NMI
trap routine. The IP value pushed on the system stack is the address of the instruction
following the one after which normal processing was interrupted by the NMI trap.
Note: The NMI pin is sampled with every CPU clock cycle to detect transitions.
Stack Overflow Trap
Whenever the stack pointer is decremented to a value which is less than the value in the
stack overflow register STKOV, the STKOF flag in register TFR is set and the CPU will
enter the stack overflow trap routine. Which IP value will be pushed onto the system
stack depends on which operation caused the decrement of the SP. When an implicit
decrement of the SP is made through a PUSH or CALL instruction, or upon interrupt or
trap entry, the IP value pushed is the address of the following instruction. When the SP
is decremented by a subtract instruction, the IP value pushed represents the address of
the instruction after the instruction following the subtract instruction.
For recovery from stack overflow it must be ensured that there is enough excess space
on the stack for saving the current system state (PSW, IP, in segmented mode also CSP)
twice. Otherwise, a system reset should be generated.
Stack Underflow Trap
Whenever the stack pointer is incremented to a value which is greater than the value in
the stack underflow register STKUN, the STKUF flag is set in register TFR and the CPU
will enter the stack underflow trap routine. Again, which IP value will be pushed onto the
system stack depends on which operation caused the increment of the SP. When an
implicit increment of the SP is made through a POP or return instruction, the IP value
pushed is the address of the following instruction. When the SP is incremented by an
add instruction, the pushed IP value represents the address of the instruction after the
instruction following the add instruction.
Undefined Opcode Trap
When the instruction currently decoded by the CPU does not contain a valid C161PI
opcode, the UNDOPC flag is set in register TFR and the CPU enters the undefined
opcode trap routine. The IP value pushed onto the system stack is the address of the
instruction that caused the trap.
This can be used to emulate unimplemented instructions. The trap service routine can
examine the faulting instruction to decode operands for unimplemented opcodes based
on the stacked IP. In order to resume processing, the stacked IP value must be
incremented by the size of the undefined instruction, which is determined by the user,
before a RETI instruction is executed.