ARM Cortex R4F User Manual

Page 335

Advertising
background image

Debug

ARM DDI 0363E

Copyright © 2009 ARM Limited. All rights reserved.

11-66

ID013010

Non-Confidential, Unrestricted Access

{

return false;

}

}

Note

You can use a similar sequence to read a halfword of memory and to write to memory.

To read or write blocks of memory, substitute the data instruction with one that uses
post-indexed addressing. For example:

LDRB R1, [R0],1

This prevents reloading the address value for each sequential word.

Example 11-20 shows the code for reading a block of bytes of memory.

Example 11-20 Reading a block of bytes of memory

ReadBytes(uint32 address, bool &aborted, uint8 *data, int nbytes)
{

// Step 1. Save the value of R0 and R1.
saved_r0 := ReadRegister(0);
saved_r1 := ReadRegister(1);
// Step 2. Write the address to R0
WriteRegister(0, address);
while (nbytes > 0)
{

// Step 3. Execute instruction LDRB R1,[R0],1 through the ITR.
ExecuteARMInstruction(0xE4D01001);

// Step 4. Read the value of R1 that contains the data at the
// address.

*data++ := ReadRegister(1);
--nbytes;

}
// 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 11-21 shows the sequence for reading a word of memory.

Note

A faster method is available for reading and writing words using the direct memory access
function of the DCC. See Fast memory read/write on page 11-68.

Example 11-21 Reading a word of memory

uint32 ReadWord(uint32 address, bool &aborted)
{

// Step 1. Save the value of R0.
saved_r0 := ReadRegister(0);

Advertising
This manual is related to the following products: