Debug
ARM DDI 0363G Copyright © 2006-2011 ARM Limited. All rights reserved. 12-67
ID073015 Non-Confidential
// Step 2. Execute instruction MRC p14, 0, Rd, c0, c5, 0 to the DBGITR.
ExecuteARMInstruction(0xEE100E15 + (Rd<<12));
}
Reading the PC in debug state
Example 12-15 shows the code to read the PC.
Example 12-15 Reading the PC
ReadPC()
{
// Step 1. Save R0
saved_r0 := ReadRegister(0);
// Step 2. Execute the instruction MOV r0, pc through the DBGITR.
ExecuteARMInstruction(0xE1A0000F);
// Step 3. Read the value of R0 that now contains the PC.
pc := ReadRegister(0);
// Step 4. Restore the value of R0.
WriteRegister(0, saved_r0);
return pc;
}
You can use a similar sequence to write to the PC to set the return address when leaving debug
state.
Reading the CPSR in debug state
Example 12-16 shows the code for reading the CPSR.
Example 12-16 Reading the CPSR
ReadCPSR()
{
// Step 1. Save R0.
saved_r0 := ReadRegister(0);
// Step 2. Execute instruction MRS R0, CPSR through the DBGITR.
ExecuteARMInstruction(0xE10F0000);
// Step 3. Read the value of R0 that now contains the CPSR
cpsr_val := ReadRegister(0);
// Step 4. Restore the value of R0.
WriteRegister(0, saved_r0);
return cpsr_val;
}
You can use similar sequences to read the SPSR in Privileged modes.