Keil™, An ARM® Company

Cx51 User's Guide

The _at_ Keyword

The _at_ keyword allows you to specify the address for uninitialized variables in your C source files. The following example demonstrates how to locate several different variable types using the _at_ keyword.

struct link  {
  struct link idata *next;
  char        code  *test;
};

struct link idata list _at_ 0x40;     /* list at idata 0x40 */
char xdata text[256]   _at_ 0xE000;   /* array at xdata 0xE000 */
int xdata i1           _at_ 0x8000;   /* int at xdata 0x8000 */
char far ftext[256]    _at_ 0x02E000; /* array at xdata 0x03E000 */

void main ( void ) {
  link.next = (void *) 0;
  i1        = 0x1234;
  text [0]  = 'a';
  ftext[0]  = 'f';
}

Refer to Absolute Variable Location for more information about the _at_ keyword.

Note

  • With Dallas Contiguous Mode it is impossible to locate arrays above 0x7F0000.
  • If you use the _at_ keyword to declare a variable that accesses an XDATA peripheral, you may require the volatile keyword to ensure that the C compiler does not optimize out necessary memory accesses.
  • When the _at_ keyword is used to locate far variables, the most significant byte of the specified address is converted into a memory type byte to determine the location of the object.