English
Language : 

GMS30C2216 Datasheet, PDF (114/320 Pages) Hynix Semiconductor – 16/32 BIT RISC/DSP
4-4
CHAPTER 4
4.2.6 Trace Exception
A Trace exception occurs after each execution of an instruction except a Delayed Branch
instruction when the trace mode is enabled (trace flag T = 1) and the trace pending flag P is
one. After a Call instruction, a Trace exception is suppressed until the next instruction is
executed regardless of the trace mode being enabled; the T flag is not affected.
The P flag in the saved return status register SR must be cleared by the trace handler to
prevent tracing the same instruction again.
The instruction preceding the Trace exception cannot be backtracked since only potentially
error-causing instructions can and need be backtracked.
4.3 Exception Backtracking
In the case of a Pointer, Frame, Privilege and Range Error exception caused by a delay
instruction succeeding a delayed branch taken, the location of the saved PC contains the
address of the delay instruction and the saved instruction length code ILC contains the
length of the Delayed Branch instruction (in half-words).
In the case of all other exceptions, the location of the saved PC contains the return address,
that is, the address of the instruction that would have been executed next if the exception
had not occurred. The saved ILC contains the length of the last instruction except when the
last instruction executed was a branch taken; a Return instruction clears the ILC and thus,
the saved ILC after a Return instruction contains zero.
An exception caused by a Pointer, Frame, Privilege or Range Error, except following a
Return instruction, can be backtracked. For backtracking, the content of the adjusted saved
ILC is subtracted from the address contained in the location of the saved PC.
If the backtrack-address calculated in this way points to a Delayed Branch instruction, the
error-causing instruction is a delay instruction with a preceding delayed branch taken and
the address contained in the location of the saved PC points to the address of this delay
instruction.
If the backtrack-address calculated does not point to a Delayed Branch instruction, it points
directly to the error-causing instruction. This instruction is then either not a delay
instruction or a delay instruction with the preceding delayed branch not taken.
The error-causing instruction can then be inspected and the cause of an error analyzed in
detail.
In the case of a Privilege Error, the ILC must be tested for zero to single out an exception
caused by a Return instruction before backtracking. Thus, an exception caused by a Return
instruction can be identified. However, it cannot be backtracked to the instruction address
of the Return instruction because the return address saved does not succeed the address of
the Return instruction. All other branching instructions cannot be backtracked either. Since
these instructions cause no errors, backtracking is not required.