25.4.4 Near Objects

The __near qualifier can be used to indicate that variables or functions are located in ‘near memory’. Exactly what constitutes near memory is dependent on the target device, but it is typically memory that can be accessed with less complex code. Expressions involving near-qualified objects generally are faster and result in smaller code.

Use the native keywords discussed in the Differences section to look up information on the semantics of this qualifier.

Some devices may not have such memory implemented, in which case, use of this qualifier is ignored. Stack-based (auto and parameter) variables cannot use the __near specifier.

Example

The following shows a variable and function qualified using __near.

__near int serialNo;

__near int ext_getCond(int selector);

Differences

The 8-bit compilers have used the qualifier near to indicate this meaning. Functions could not be qualified as near.

The 16-bit compilers have used the near attribute with both variables and functions.

The 32-bit compilers have used the near attribute for functions, only.

Migration to the CCI

For 8-bit compilers, change any occurrence of the near qualifier to __near, for example, from:

near char template[20];

to:

__near char template[20];

In 16- and 32-bit compilers, change any occurrence of the near attribute to __near, for example, from:

void bar(void) __attribute__ ((near));

int tblIdx __attribute__ ((near));

to

void __near bar(void);

int __near tblIdx;

Caveats

None.