
Determining the Core and System State
Rev. A
Copyright 2000 by LSI Logic Corporation. All rights reserved.
B-15
The sequences of ARM instructions below can be used to determine the
processor’s state.
With the processor in the ARM state, typically the first instruction to
execute would be:
STM R0, {R0 R15}
This instruction causes the contents of the registers to appear on the
data bus. You can then sample and shift out these values.
Note:
The above use of r0 as the base register for the STM is
only for illustration. You can use any register.
After you have determined the values in the current bank of registers, you
might wish to access the banked registers. First, you must change mode.
Normally, a mode change can occur only if the core is already in a
privileged mode. However, while in debug state, a mode change from
one mode into any other mode can occur.
The debugger must restore the original mode before exiting debug state.
For example, if the debugger had been requested to return the state of
the user mode registers and FIQ mode registers, and debug state was
entered in supervisor mode, the instruction sequence could be:
STM R0, {R0 R15}; Save current registers
MRS R0, CPSR
STR R0, R0; Save CPSR to determine current mode
BIC R0, 0x1F; Clear mode bits
ORR R0, 0x10; Select user mode
MSR CPSR, R0; Enter USER mode
STM R0, {R13,R14}; Save register not previously visible
ORR R0, 0x01; Select FIQ mode
MSR CPSR, R0; Enter FIQ mode
STM R0, {R8 R14}; Save banked FIQ registers
All these instructions execute at debug speed. Debug speed is much
slower than system speed, because between each core clock, 33 clocks
occur in order to shift in an instruction or shift out data. Executing
instructions this slowly is acceptable for accessing the core state
because the ARM7TDMI-S core is fully static. However, you cannot use
this method for determining the state of the rest of the system.
While in debug state, only the following instructions can be scanned into
the instruction pipeline for execution: