8- 10 M68040 USER’S MANUAL MOTOROLA
executing the instruction. As illustrated in Figure 8-1, the processor copies the SR, enters
the supervisor mode, and clears the trace bits. The processor generates vector number 8,
saves the privilege violation vector offset, the current PC value, and the internal copy of
the SR on the supervisor stack. The saved value of the PC is the logical address of the
first word of the instruction that caused the privilege violation. Instruction execution
resumes after the required prefetches from the address in the privilege violation exception
8.2.6 Trace Exception
To aid in program development, the M68000 family includes an instruction-by-instruction
tracing capability. The M68040 can be programmed to trace all instructions or only
instructions that change program flow. In the trace mode, an instruction generates a trace
exception after the instruction completes execution, allowing a debugging program to
monitor execution of a program.
In general terms, a trace exception is an extension to the function of any traced
instruction. The execution of a traced instruction is not complete until trace exception
processing is complete. If an instruction does not complete due to an access fault or
address error exception, trace exception processing is deferred until after execution of the
suspended instruction is resumed. If an interrupt is pending at the completion of an
instruction, trace exception processing occurs before interrupt exception processing starts.
If an instruction forces an exception as part of its normal execution, the forced exception
processing occurs before the trace exception is processed.
The T1 and T0 bits in the supervisor portion of the SR control tracing. The state of these
bits when an instruction begins execution determines whether the instruction generates a
trace exception after the instruction completes. T1 and T0 bit = $1 causes an instruction
that forces a change of flow to take a trace exception. The following instructions cause a
trace exception to be taken when trace on change of flow is enabled.
ANDI to SR CAS2 FBcc (Taken) JMP MOVES RTD
Bcc (Taken) CINV FDBcc (Always) JSR NOP RTE
BRA CPUSH FMOVEM MOVE to SR ORI to SR RTR
BSR DBcc (Taken) FRESTORE MOVE USP PFLUSH RTS
CAS EORI to SR FSAVE MOVEC PTEST STOP
Instructions that increment the PC normally do not take the trace exception. This mode
also includes SR manipulations because the processor must prefetch instruction words
again to fill the pipeline any time an instruction that modifies the SR is executed. Table 8-2
lists the different trace modes.