ARM Technical Support Knowledge Articles

MULTIPLE VARIABLES AT THE SAME ADDRESS

Applies to: C51 C Compiler

Answer

QUESTION

I have a project where several variables are assigned to the same XDATA memory address. I need to access the same memory location using different variable names. Is there a way to do this that doesn't generate the MEMORY SPACE OVERLAP linker warning?

ANSWER

Yes. You can create a small assembly file and assign several labels to the same physical address. The following code shows how to do that for var1, var2, and var3 at physical address 0x8000:

        PUBLIC  var1
        PUBLIC  var2
        PUBLIC  var3

        XSEG    AT      8000h

var1:
var2:
var3:
        DS      1

        END

To access these vars in your C code, you must declare them extern somewhere along with the appropriately sized type. For example:

extern xdata unsigned char var1, var2, var3;

void main (void)
{
var1 = 1;
var2 = 1;
var3 = 1;
}

Article last edited on: 2004-06-07 08:37:28

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