ARM Cortex R4F User Manual

Page 333

Advertising
background image

Debug

ARM DDI 0363E

Copyright © 2009 ARM Limited. All rights reserved.

11-64

ID013010

Non-Confidential, Unrestricted Access

}

Reading the PC in debug state

Example 11-15 shows the code to read the PC.

Example 11-15 Reading the PC

ReadPC()
{

// Step 1. Save R0
saved_r0 := ReadRegister(0);
// Step 2. Execute the instruction MOV r0, pc through the ITR.
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;

}

Note

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 11-16 shows the code for reading the CPSR.

Example 11-16 Reading the CPSR

ReadCPSR()
{

// Step 1. Save R0.
saved_r0 := ReadRegister(0);
// Step 2. Execute instruction MRS R0, CPSR through the ITR.
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;

}

Note

You can use similar sequences to read the SPSR in Privileged modes.

Writing the CPSR in debug state

Example 11-17 on page 11-65 shows the code for writing the CPSR.

Advertising
This manual is related to the following products: