Keil Logo

C51: XDATA OVERLAYING


Information in this article applies to:

  • C51 Version 6.10a

QUESTION

Is it possible to overlay XDATA variables in a way which is similar to how DATA and IDATA variables are overlaid?

ANSWER

Yes. XDATA overlaying is supported in C51 V6.x and later. To enable XDATA overlaying, compile your programs in the LARGE memory model or explicitly declare functions as LARGE model functions. For example:

unsigned char func_a (unsigned long var1) large
{
unsigned char x;
.
.
.

The LARGE keyword at the end of the function declaration specifies that function arguments and automatics are stored in XDATA and may, therefore, be overlaid.

If you only want the automatic variables inside the routines to be overlaid in XDATA, declare the function as normal (without explicitly specifying the LARGE memory model) but declare local variables using the XDATA keyword. These variables will be overlaid by the linker.

unsigned char func_a (unsigned long var1)
{
xdata unsigned char x;
.
.
.

If you do not wish for your function's XDATA variables to be overlaid, you must declare them as static variables using the STATIC keyword. For example:

unsigned char func_a (unsigned long var1)
{
static xdata unsigned char x;
.
.
.

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, August 1, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.