ARM Technical Support Knowledge Articles

XDATA OVERLAYING

Applies to: C51 C Compiler

Answer


Information in this article applies to:


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;
.
.
.

Article last edited on: 2006-08-01 13:19:56

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential