eZ8 CPU
User Manual
UM012811-0904
Illegal
Instruction
Traps
34
Illegal Instruction Traps
Description
The instruction set of the eZ8 CPU does not cover all possible sequences of binary values.
Binary values and sequences for which no operation is defined are illegal instructions.
When the eZ8 CPU fetches one of these illegal instructions, it performs an Illegal Instruc-
tion Trap operation.
The Illegal Instruction Trap functions similarly to a TRAP #%3 instruction (object code
F2H
03H
). The Flags and Program Counter are pushed on the stack. When the Program
Counter detects an illegal instruction it does not increment. The Program Counter value
that is pushed onto the stack points to the illegal instruction.
The most significant byte (MSB) of the Illegal Instruction Trap Vector is stored at Pro-
gram Memory address
0006H
. The least significant byte (LSB) of the Illegal Instruction
Trap Vector is stored at Program Memory address
0007H
. The 16-bit Illegal Instruction
Trap Vector replaces the value in the Program Counter (PC). Program execution resumes
from the new value in the Program Counter.
An IRET instruction must not
be performed following an Illegal Instruction Trap
service routine. Because the stack contains the Program Counter value of the il-
legal instruction, the IRET instruction returns the code execution to this illegal
instruction.
Symbolic Operation of an Illegal Instruction Trap
SP
←
SP - 2
@SP
←
PC
SP
←
SP - 1
@SP
←
Flags
PC
←
Vector
Linear Programs that do not Employ the Stack
The Stack Pointer must point to a section of the Register File that does not overwrite user
program data. Even for linear program code that may not employ the stack for Call and/or
Interrupt routines, set the Stack Pointer to prepare for possible Illegal Instruction Traps.
Caution: