
Debug in depth
ARM DDI 0165B
Copyright 2000 ARM Limited. All rights reserved.
C-19
Note
The use of r0 as the base register for the STM is only for illustration, and you can use any
register.
After you have determined the values in the bank of registers available in the current
mode, you might want to access the other banked registers. To do this, 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 can occur from any mode into any
other mode.
The debugger must restore the original mode before exiting debug state. For example,
if the debugger has been requested to return the state of the User mode registers and FIQ
mode registers, and debug state is entered in Supervisor mode, the instruction sequence
Example C-1 Determining the core state
STMIA 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
STMIA R0, {R13,R14}; Save registers not previously visible
ORR
R0, 0x01; Select FIQ mode
MSR
CPSR, R0; Enter FIQ mode
STMIA R0, {R8-R14}; Save banked FIQ registers
All these instructions execute at debug speed. Debug speed is much slower than system
speed. This is because between each core clock, 67 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 ARM9E-S is fully static. However, you cannot use
this method for determining the state of the rest of the system.
While in debug state, you can only scan the following ARM or Thumb instructions into
the instruction pipeline for execution:
all data processing operations
all load, store, load multiple, and store multiple instructions
MSR
and MRS
B
, BL, and BX.