25.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 legacy syntax used by MPLAB XC8 when targeting PIC MCUs has been an @ symbol to specify an absolute address.

When targeting AVR MCUs, MPLAB XC8 has used the address attribute to specify an object’s address. This attribute has also been used by the other compilers.

Migration to the CCI

Avoid making objects and functions absolute if possible.

If any source code uses the legacy MPLAB XC8 syntax, for example:
int scanMode @ 0x200;
change this to:
int scanMode __at(0x200);
When building for AVR MCUs with the MPLAB XC8 compiler or when using any other compiler, change code, for example, from:
int scanMode __attribute__((address(0x200)));
to:
int scanMode __at(0x200);

Caveats

If building for PIC device using MPLAB XC8 and the __at() and __section() specifiers have both been applied to an object, the __section() specifier is currently ignored.

The MPLAB XC32 compiler for PIC32C/SAM devices supports only 4-byte aligned absolute addresses.