Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Declare and define array at a certain fix memory

Status
Not open for further replies.

tom12sg

Member level 2
Joined
Feb 1, 2004
Messages
45
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
422
Hi,

How to declare an array at a certain fixed address of the program code in Keil which i can specify?

Regards,
Tom
 

This is from the keil C51 doc, hope it is useful for you :)

Absolute Variable Location
Variables may be located at absolute memory locations in your C program
source modules using the _at_ keyword. The usage for this feature is:
memory_space type variable_name _at_ constant;
where:
memory_space is the memory space for the variable. If missing from the
declaration, the default memory space is used. Refer to
“Memory Models” on page 89 for more information about
the default memory space.
type is the variable type.
variable_name is the variable name.
constant is the address at which to locate the variable.
The absolute address following _at_ must conform to the physical boundaries of
the memory space for the variable. Cx51 checks for invalid address
specifications.
The following restrictions apply to absolute variable location:
1. Absolute variables cannot be initialized.
2. Functions and variables of type bit cannot be located at an absolute address.

The following example demonstrates how to locate several different variable
types using the _at_ keyword.
struct link
{
struct link idata *next;
char code *test;
};
idata struct link list _at_ 0x40; /* list at idata 0x40 */
xdata char text[256] _at_ 0xE000; /* array at xdata 0xE000 */
xdata int i1 _at_ 0x8000; /* int at xdata 0x8000 */
void main ( void ) {
link.next = (void *) 0;
i1 = 0x1234;
text [0] = 'a';
}
Often, you may wish to declare your variables in one source module and access
them in another. Use the following external declarations to access the _at_
variables defined above in another source file.
struct link
{
struct link idata *next;
char code *test;
};
extern idata struct link list; /* list at idata 0x40 */
extern xdata char text[256]; /* array at xdata 0xE000 */
extern xdata int i1; /* int at xdata 0x8000 */
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top