Keil Logo

The _at_ Keyword

The best method for accessing absolute memory locations is to use the _at_ keyword when you declare variables in your C source files. The _at_ keyword also reserves the memory required for the object. In cases where you do not want to reserve memory, you may use the Absolute Access Macros.

The _at_ keyword allows you to specify the address for 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 list idata _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 ) { = (void *) 0;
  i1        = 0x1234;
  text [0]  = 'a';
  ftext[0]  = 'f';

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


  • If you use the _at_ keyword to declare a variable that accesses a peripheral, you may require the volatile keyword to ensure that the C compiler does not optimize out necessary memory accesses.
  • Variables with the data type bit cannot be located with the _at_ keyword.
  • For the memory types data, bdata, idata, xdata, and code, the address specified with _at_ is an offset to the base address of the memory class. The compiler creates segments with the relocation type OFFS. Refer to the L251 User's Guide, CLASSES Linker Directive for information on how to sepcify addresses for OFFS Segments.
  • The _at_ keyword can be only used at file level. It is not possible to define the absolute location of variables that are declared inside a function.
  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.