Interrupt and Exception Handling
MOTOROLA
MC68322 USER’S MANUAL
5-11
5.4.2.3 INSTRUCTION TRAPS. Traps are exceptions caused by instructions and they occur
when the core recognizes an abnormal condition during instruction execution or when an
instruction is executed that normally traps during execution. Exception processing for traps
is straightforward. The internal status register is copied, the supervisor mode is entered, and
tracing is turned off. The vector number is internally generated, but as the trap instruction,
part of the vector number comes from the instruction itself. The internal program counter and
the copy of the internal status register are saved on the supervisor stack. The saved value
of the internal program counter is the address of the instruction following the instruction that
generated the trap. Finally, instruction execution commences at the address in the
exception vector.
Some instructions are used specifically to generate traps. The trap instruction always forces
an exception and is useful for implementing system calls for user programs. The trapv and
chk instructions force an exception if the user program detects a run-time error, which can
be an arithmetic overflow or a subscript out of bounds. A signed divide (divs) or unsigned
divide (divu) instruction forces an exception if a division operation is attempted with a divisor
of zero.
5.4.2.4 ILLEGAL AND UNIMPLEMENTED INSTRUCTIONS. An illegal instruction refers to
any of the word bit patterns that do not match the bit pattern of the first word of a legal core
instruction. If such an instruction is fetched, an illegal instruction exception occurs. Motorola
reserves the right to define instructions using the opcodes of any of the illegal instructions.
Three bit patterns always force an illegal instruction trap on all M68000 Family-compatible
microprocessors. These patterns are: 4AFA
16, 4AFB16, and 4AFC16. Two of the patterns,
4AFA
16 and 4AFB16, are reserved for Motorola system products. The third pattern, 4AFC16,
is reserved for customer use (as the take illegal instruction trap—illegal—instruction).
Word patterns with bits 15–12 equaling 1010
2 or 11112 are distinguished as unimplemented
instructions and separate exception vectors are assigned to these patterns to permit
efficient emulation. Opcodes beginning with bit patterns equaling 1111
2 (F line) are
implemented in the MC68020 as coprocessor instructions. These separate vectors allow the
operating system to emulate unimplemented instructions in the software. Exception
processing for illegal instructions is similar to that for traps. After the instruction is fetched
and decoding is attempted, the core determines that execution of an illegal instruction is
being attempted and starts exception processing. The exception stack frame is then pushed
on the supervisor stack and the illegal instruction vector is fetched.
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.