
DocID13284 Rev 2
129/564
UM0404
Interrupt and trap functions
5.8.1 Software
traps
The TRAP instruction is used to cause a software call to an interrupt service routine. The
trap number that is specified in the operand field of the trap instruction determines which
vector location in the address range from 00’0000h through 00’01FCh will be branched to.
Executing a TRAP instruction causes the same effect as servicing the interrupt at the same
vector. PSW, CSP (in segmentation mode), and IP are pushed on the internal system stack
and a jump is taken to the specified vector location.
When segmentation is enabled and a trap is executed, the CSP for the trap service routine
is set to code segment 0. No Interrupt Request flags are affected by the TRAP instruction.
The interrupt service routine called by a TRAP instruction must be terminated with a RETI
(return from interrupt) instruction to ensure correct operation.
Note:
The CPU level in register PSW is not modified by the TRAP instruction, so the service
routine is executed on the same priority level from which it was invoked. Therefore, the
service routine entered by the TRAP instruction can be interrupted by other traps or higher
priority interrupts, other than when triggered by a hardware trap.
5.8.2 Hardware
traps
Hardware traps are issued by faults or specific system states that occur during the runtime
of a program (not identified at assembly time). A hardware trap may also be triggered
intentionally, for example to emulate additional instructions by generating an Illegal Opcode
trap.
The ST10F276 distinguishes nine different hardware trap functions. When a hardware trap
condition has been detected, the CPU branches to the trap vector location for the respective
trap condition.
Depending on the trap condition, the instruction which caused the trap is either completed or
cancelled (it has no effect on the system state) before the trap handling routine is entered.
Hardware traps are non-maskable and always have priority over every other CPU activity. If
several hardware trap conditions are detected within the same instruction cycle, the highest
Class B Hardware Traps:
Undefined Opcode
MAC Interruption
Protected Instruction Fault
Illegal Word Operand
Access
Illegal Instruction Access
Illegal External Bus Access
UNDOPC
MACTRP
PRTFLT
ILLOPA
ILLINA
ILLBUS
BTRAP
BTRAP
BTRAP
BTRAP
BTRAP
BTRAP
00’0028h
00’0028h
00’0028h
00’0028h
00’0028h
00’0028h
0Ah
0Ah
0Ah
0Ah
0Ah
0Ah
I
I
I
I
I
I
MINIMAL
Reserved
[2Ch –3Ch]
[0Bh – 0Fh]
Software Traps
TRAP Instruction
Any
[00’0000h–
00’01FCh]
in steps of 4h
Any
[00h – 7Fh]
Current
CPU
Priority
Table 21. Trap priorities
Exception condition
Trap flag
Trap
vector
Vector
location
Trap
number
Trap
priority