Keil™, An ARM® Company

Technical Support

DSCOPE: USING MEMSET WITH VARIABLE PARAMETERS


Information in this article applies to:

  • C166 Version 3.12
  • C166 Version 4.01
  • C251 Version 2.14
  • C51 Version 5.50

SYMPTOMS

I need to set a memory range to a specific value in D-Scope. I have a script that uses the following command:

memset(X: StartAdd, X: EndAdd, FillVal);

But, this does not work. I can use the following:

memset(X:0x4770, X:0x4780, 0Xff);

However, since the starting and ending adresses depend on previous parts of the script, this defeats the purpose of using the StartAdd and EndAdd variables. How can I get Memset to take variables as parameters?

CAUSE

dScope cannot combine a variable along with the memory type you have specified (X:). You may instead use the physical address segment for the memory area (which is 0x010000 for XDATA).

RESOLUTION

Set your starting and ending address variables as normal. Then, when you call the MEMSET function, do something like this:

memset (0x010000 | start_addr, 0x010000 | end_addr, fill_value);

The 0x010000 provides the memory area prefix that corresponds to XDATA. The value to use for CODE is 0xFF0000 and the value for DATA is 0x000000.

The prefix (or segment) is the upper byte of the 24-bit addresses. It is also known as the memory type byte (in C51 lingo). 0xFF is CODE, 0x01 is XDATA, 0x00 is DATA. These MAGICAL numbers come from the segments used on the MCS251.

MORE INFORMATION

Refer to your compiler manual or to the dScope manual for a complete description.

Last Reviewed: Tuesday, June 08, 2004


Did this article provide the answer you needed?
 
Yes