Debug
ARM DDI 0363G
Copyright © 2006-2011 ARM Limited. All rights reserved.
12-69
ID073015
Non-Confidential
WriteDebugRegister(36, 1<<2);
return true;
}
else
{
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.
shows the code for reading a block of bytes of memory.
Example 12-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 DBGITR.
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 DBGDSCR for a sticky abort.
aborted := CheckForAborts();
return datum;
}
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