| |||
| Home > RealView Debugger Commands > Alphabetical command reference > SETMEM | |||
Changes the contents of memory to a specified value.
SETMEM [{/8|/16|/32}] address [={expression | expressionlist}]
where:
/8Sets the access size to 8 bits.
/16Sets the access size to 16 bits.
/32Sets the access size to 32 bits.
If no access size is specified, the default is the native format for the debug target. For example, the ARM7TDMI processor naturally addresses 8 bits.
addressThe memory address where the contents are to be changed.
expressionAn expression to be evaluated to a value and placed into the specified memory address. The expression can be:
a decimal or hexadecimal number
a debugger expression, for example a math calculation
a string enclosed in single or double quotation marks.
If you use a quoted string:
each
character of the string is treated as a byte value in an expressionlist
no C-style zero terminator byte is written to memory.
Also, see Rules for specifying strings in the SETMEM command for more details on using strings with the SETMEM command.
expressionlistA list of expressions to be placed into memory starting
at the specified address. An expressionlist is
a sequence of expressions separated by commas, for example "Text",0,0x20.
All expressions in an expression list are padded or truncated to the size specified by the size qualifiers if they do not fit the specified size evenly. This also applies to each character of a string.
The SETMEM command changes the contents
of the specified memory location to the value or values defined
by or expression. SETMEM is
used to set assembly-level memory. For example, you can use it to
work around a section of code that is producing incorrect results by
changing variables to the correct values.expressionlist
Be aware of the following when using the SETMEM command:
The SETMEM command does not recognize variable typing, so you must ensure the expression size qualifier is compatible with the variable type.
All expressions in an expression string are padded or truncated to the size specified by the Size value if they do not fit the specified size evenly.
If a pattern is not specified, RealView Debugger displays the Interactive Memory Setting dialog box when running in GUI mode.
The SETMEM command runs synchronously unless background access to target memory is supported. Use the WAIT command to force it to run synchronously.
Follow these rules when specifying a string:
No C-style zero terminator byte is written to memory after a specified string. To write a NUL-terminated string, add a zero value expression after the string, for example:
"Test Message",0
You cannot use an empty string to write a NUL character.
Use the /8 qualifier if you want
to write the characters of a string to consecutive bytes of memory.
The following examples show how to use SETMEM:
To write a NUL-terminated string to consecutive
bytes at address 0x9000, specify the command:
setmem 0x9000="Test Message",0
To write 0xBA55FADE to the 32-bit memory location
starting at address 0x9004, specify the command:
setmem/32 0x9004=0xBA55FADE
The following command writes 0xFADE to the 16-bit
location starting at address 0x9008:
setmem/16 0x9008=0xBA55FADE
The following command writes each individual character
of "Test Message" to the lowest byte of consecutive
32-bit memory locations starting at address 0x900C:
setmem/32 0x900C="Test Message"
The remainder of each 32-bit memory location is set to zero.
Assuming the following definitions:
int count=2, buf[8];
int *ptr = buf;
And the following memory map:
0x10200 : 0x00000002 count 0x10204 : 0x00000000 buf 0x10224 : 0x00010204 ptr
The following two statements both set the value of count to
5:
setmem /32 &count=5 setmem /32 0x10200=5
The command setmem count=5 sets the memory
location addressed by the value of count to 5,
leaving the contents of count unchanged.