ARM R4F, r1p3 manual Reading the PC in debug state, Example 11-15shows the code to read the PC

Models: R4F r1p3 R4

1 456
Download 456 pages 40.06 Kb
Page 333
Image 333

Debug

}

Reading the PC in debug state

Example 11-15shows 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-16shows 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-65shows the code for writing the CPSR.

ARM DDI 0363E

Copyright © 2009 ARM Limited. All rights reserved.

11-64

ID013010

Non-Confidential, Unrestricted Access

 

Page 333
Image 333
ARM R4F, r1p3 Reading the PC in debug state, Example 11-15shows the code to read the PC, Reading the Cpsr in debug state