4.4.2 Absolute Addressing

Variables and functions can be placed at an absolute address by using the __at() construct. Stack-based (auto and parameter) variables cannot use the __at() specifier.

Example

The following shows two variables and a function being made absolute.

int scanMode __at(0x200);
const char keys[] __at(124) = { ’r’, ’s’, ’u’, ’d’};

__at(0x1000) int modify(int x) { 
   return x * 2 + 3;
}

Differences

The 8-bit compilers have used an @ symbol to specify an absolute address. The 16- and 32-bit compilers have used the address attribute to specify an object’s address.

Migration to the CCI

Avoid making objects and functions absolute if possible.

In MPLAB XC8, change absolute object definitions, e.g., from:

int scanMode @ 0x200;

to:

int scanMode __at(0x200);

In MPLAB XC16 and XC32, change code, for example, from:

int scanMode __attribute__((address(0x200)));

to:

int scanMode __at(0x200);

Caveats

If the __at() and __section() specifiers are both applied to an object when using MPLAB XC8, the __section() specifier is currently ignored.

The __at() specifier must be placed at the beginning of function prototypes for the 16- and 32-bit compilers. If you prefer to use the specifier at the end of the prototype, use the specifier with a declaration and leave it off the definition, for example:

int modify(int x) __at(0x1000);

int modify(int x)

{ ... }