dress errors or tracing. The trap (TRAP), traponoverflow
(TRAPV), check register against bounds (CHKl and divide
tDlVl instructions
all
can
generate exceptionsaspart of their
instruction execution.
In
addition, illegal instructions, word
fetches from odd addresses
and
privilege violations cause ex-
ceptions. Tracing behaves like avery high priority, internally
generated interrupt after
each
instruction execution.
EXCEPTION
PROCESSING
SEQUENCE.
Exception pro-
cessing occurs
in
four identifiable steps.Inthe first step,
an
internal copyismade of the status register. After the copy
is
made, the S-bitisasserted, putting the processor into
the·
supervisor privilege state. Also, the T-bitisnegated which
will allow the exception handler to execute unhindered by
tracing. For the reset and interrupt exceptions, the interrupt
priority mask
is
also updated.
In
the second step, the vector number of the exception
is
determined. For interrupts, the vector numberisobtained by
a processor fetch, classified
asaninterrupt acknowledge.
For
all
other exceptions, internal logic provides the vector
number. This vector number
is
then
used
to generate the ad-
dress of the exception vector.
The third step
istosave
the current processor status, ex-
cept for the reset exception.
The
current program counter
value and the
saved
copy of the status register
are
stacked
using the supervisor stack pointer. The program counter
value stacked usually points
to
the next unexecuted instruc-
tion, however for bus error
and
address error, the value
stacked for the program counter
is
unpredictable, and may
be
incremented from the address of the instruction which
caused the error. Additional information defining the current
context
is
stacked for the bus error
and
address error excep-
tions.
The last step
is
the
same
for
all
exceptions. The new pro-
gram counter value
is
fetched from the exception vector.
The processor then resumes instruction execution. The instruction at the address given
in
the exception vector
is
fetched, and normal instruction decoding and execution
is
started.
MULTIPLE EXCEPTIONS.
These
paragraphs
describe
the
processing which occurs
when
multiple exceptions arise
simul-
taneously.
Exceptions
canbegrouped
according to their occur-
rence
and
priority.
The
Group
1 exceptions
are
trace
and
inter-
rupt,aswellasthe
privilege violations
and
illegal instructions.
These
exceptions allow
the
current instructiontoexecute to
com-
pletion,
but
preempt
the
executionofthe
next
instructionbyforc-
ing
exception processingtooccur (privilege violations
and
illegal
instructions
are
detected
when
they
are
the
next
instructiontobe
executed).
The
Group
2 exceptions occur
as
partofthe
normal
processingofinstructions.
The
TRAP,
TRAPV,
CHK,
and
zero
divide
exceptions
areinthis
group.
For
these
exceptions,
the
nor-
mal
execution-ofaninstruction
may
leadtoexception processing.
Group 0 exceptions have highest priority, while Group 2
exceptions have lowest priority. Within Group0,reset
has
highest priority, followed by bus error and then address
er-
ror. Within Group1,trace
has
priority over external inter-
rupts, which
in
turn takes priority over illegal instruction
and
privilege violation. Since only one instruction
canbeex-
ecuted at a
tim~,
thereisno priority relation within Group
2.
The priorilY relation between
two
exceptions determines
which
is
taken, or taken first, if the conditions for both arise
simultaneously. Therefore, if a bus error occurs during a
TRAP instruction, the bus error takes precedence, and the
TRAP instruction processing
is
aborted.Inanother example,
if
an
interrupt request occurs during the execution ofanin-
struction while the T-bit
is
asserted, the trace exception
has
priority, andisprocessed first. Before instruction processing
resumes, however, the interrupt exception
is
also processed,
and
instruction processing cOl}'mences finplly in the inter-
rupt handler routine. A summary of exception grouping and
priority
is
given in Table
19.
TABLE
19 - EXCEPTION GROUPING
AND
PRIORITY
Group
Exception
Processing
Reset
Exception processing begins
0
Bus Error
Address Error
Trace
1
Interrupt
Exception processing begins before
Illegal
the next instruction
Privilege
TRAP, TRAPV,
Exception processing
is
started by
2
CHK,
normal instruction execution
Zero Divide
EXCEPTION
PROCESSING
DETAILED
DISCUSSION
Exceptions have anumber of sources, and each exception
has
processing whichispeculiar
to
it. The following
paragraphs detail the sources
of
exceptions, how each
arises, and how
eachisprocessed.
RESET.
The reset input provides the highest exception
level. The processing of the reset signal
is
designed for
system initiation, and recovery from catastrophic failure.
Any processing
in
progress at the timeofthe resetisaborted
and cannot
be
recovered. The processorisforced into the
supervisor state, and the trace state
is
forced off. The pro-
cessor interrupt priority mask
is
set at level seven. Thevector
number
is
internally generated to reference the reset excep-
tion vector at location 0
in
the supervisor program space.
Because no assumptions
Canbemade about the validity of
register contents,
in
particular the supervisor stack pointer,
neither the program counter nor the status register
is
saved.
The address contained
in
the first
two
wordsofthe reset ex-
ception vector
is
fetchedasthe initial supervisor stack
pointer, and the address
in
the last
two
wordsofthe reset
exception vector
is
fetchedasthe initial program counter.
Finally, instruction execution
is
started at the addressinthe
program counter. The power-up!restart code should
be
pointed to by the initial program counter.
The
RESET
instruction does notcause loading of the
reset
vector, but does assert the reset line to reset external
devices. This allows the software to reset the system to a
known state and then continue processing with the next in-
struction.
INTERRUPTS.
Seven
levels of interrupt priorities
are
pro-
vided. Devices may
be
chained externally within interrupt
priority levels, allowing
an
unlimited numberofperipheral
devices to interrupt the processor. Interrupt priority levels
1.---
®
MOTOROLA
Semiconductor
Products
Inc.