| |||
| Home > Altering the Target Execution Environment > Changing memory contents > Changing the value in a memory location | |||
To change memory contents:
Display the Memory pane, if it is not visible, and set the start address of the memory area you want to view (see Examining memory in the Memory pane). Figure 13.13 shows and example.
Right-click on the value at the required memory location to display the context menu.
Select Set Value... from the context menu. The memory value dialog box is displayed, shown in Figure 13.14.
Enter the new value for the location.
You can enter data values in a format that is different from the display format.
You can also use the drop-down arrow to select from a browser or to re-use a value that you entered previously. The drop-down also gives access to your list of personal favorites where you can store a data value for re-use in this, or future, debugging sessions.
Click Set to update the Memory pane, shown in Figure 13.15. See Display colors in the Memory pane for a description of the display colors used in the Memory pane.
The following procedure demonstrates how you can change memory locations in the Memory pane:
Load the debug
version of the dhrystone.axf image.
Click on the Src tab to view
the source file dhry_1.c.
Double-click in the gray margin at line 301 of dhry_1.c.
This sets a simple breakpoint (see Setting a simple breakpoint).
Click Run to start execution.
Enter 5000 when asked for the
number of runs.
The program starts and then stops when execution reaches the breakpoint at line 301. The red box marks the location of the PC when execution stops.
Use the Pane menu, in the
Memory pane, to set the start address to 0x883A and display
the ASCII values, shown in Figure 13.16.
The memory locations 0000889B-0000889E contain
the four hexadecimal values 0x33, 0x27, 0x52,
and 0x44 corresponding to the string 3’RD.
Change the contents of location 0000889B as
follows:
Right-click in the value at 0000889B,
that is 0x33, to display the context menu.
Select Set Value... from the context menu to display the address value dialog box, shown in Figure 13.14.
Enter the character 'N' (or the
equivalent hexadecimal value 0x4E).
If you enter the value as a character, you must include the quotes.
Click Set to update the memory display.
The new value is displayed in blue and the ASCII value changes
from 3 to N.
Change the value at location 0000889C,
as follows:
Double-click on the value
at location 0000889C. In-place editing is enabled for
the location.
Change the value from 0x27 to 0x6F (or
enter lowercase 'o', including the quotes)
Press Enter to apply the change:
the new value is displayed in blue
the value at location 0000889B is
colored light blue to show that it was changed on the a previous
update, shown in Figure 13.17.
If you press Esc instead of Enter, then any changes you made in the highlighted field are ignored.
Change the value at location 0000889D,
as follows:
Click on the value at location 0000889D.
Enter the decimal value 32 (or
enter a space character ' ', including the quotes).
In-place editing is enabled for the location.
Press Enter to apply the change:
the new value is displayed in blue
the value at location 0000889C is
colored light blue to show that it was changed on the a previous
update
the value at location 0000889B is
now colored black, shown in Figure 13.18.
Change the value at location 0000889E,
as follows:
Click on the value at location 0000889E.
Enter the value 0x32 (or enter '2',
including the quotes). In-place editing is enabled for the location.
Press Enter to apply the change:
the new value is displayed in blue
the value at location 0000889D is
colored light blue to show that it was changed on the a previous
update
the value at location 0000889C is
now colored black.
The string 3’RD has now been replaced by No
2, shown in Figure 13.19.
Double-click on the red marker disc at line 301
of dhry_1.c. This clears the breakpoint.