11.2.2.5 Data Memory Allocation Macros
Macros that may be used to allocate space in data memory are discussed below. There are two types: those that require an argument and those that do not.
The following macros require an argument N that specifies alignment. N must be a power of two, with a minimum value of 2.
#define _XBSS(N) __attribute__((space(xmemory), aligned(N)))
#define _XDATA(N) __attribute__((space(xmemory), aligned(N)))
#define _YBSS(N) __attribute__((space(ymemory), aligned(N)))
#define _YDATA(N) __attribute__((space(ymemory), aligned(N)))
#define _EEDATA(N) __attribute__((space(eedata), aligned(N)))
For example, to declare an uninitialized array in X memory that is aligned to a 32-byte address:
int _XBSS(32) xbuf[16];
To declare an initialized array in EEPROM Data (EEData) space without special alignment:
int _EEDATA(2) table1[] = {0, 1, 1, 2, 3, 5, 8, 13,
21};
The following macros do not require an argument. They can be used to locate a variable in persistent data memory or in near data memory.
#define _PERSISTENT __attribute__((persistent))
#define _NEAR __attribute__((near))
For example, to declare two variables that retain their values across a device Reset:
int _PERSISTENT var1,var2;