13.07.2015 Views

Cortex-A8 R2P2.pdf - ARM Information Center

Cortex-A8 R2P2.pdf - ARM Information Center

Cortex-A8 R2P2.pdf - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DebugExample 12-17 Writing the CPSRWriteCPSR(uint32 cpsr_val){// Step 1. Save R0.saved_r0 := ReadRegister(0);// Step 2. Write the new CPSR value to r0.WriteRegister(0, cpsr_val);// Step 3. Execute instruction MSR r0, CPSR through the ITR.Execute<strong>ARM</strong>Instruction(0xE12FF000);// Step 4. Execute a PrefetchFlush instruction through the ITR.Execute<strong>ARM</strong>Instruction(9xEE070F95);// Step 5. Restore the value of r0.WriteRegister(0, saved_r0);}Reading memoryExample 12-18 shows the code for reading a byte of memory.Example 12-18 Reading a byte of memoryuint8 ReadByte(uint32 address, bool &aborted){// Step 1. Save the values of r0 and r1.saved_r0 := ReadRegister(0);saved_r1 := ReadRegister(1);// Step 2. Write the address to r0.WriteRegister(0, address);// Step 3. Execute the instruction LDRB r1,[r0] through the ITR.Execute<strong>ARM</strong>Instruction(0xE5D01000);// Step 4. Read the value of r1 that contains the data at the address.datum := ReadRegister(1);// Step 5. Restore the corrupted registers r0 and r1.WriteRegister(0, saved_r0);WriteRegister(1, saved_r1);// Step 6. Check the DSCR for a sticky abort.aborted := CheckForAborts();return datum;}Example 12-19 on page 12-109 shows the code for checking for aborts after a memoryaccess.12-108 Copyright © 2006-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0344E

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!