25.4.3 Far Objects and Functions

The __far qualifier can be used to indicate that variables or functions are located in ‘far memory’. Exactly what constitutes far memory is dependent on the target device, but it is typically memory that requires more complex code to access. Expressions involving far-qualified objects usually generate slower and larger 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 __far specifier.

Example

The following shows a variable and function qualified using __far.

__far int serialNo;

__far int ext_getCond(int selector);

Differences

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

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

The 32-bit compilers have used the far attribute with functions, only.

Migration to the CCI

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

far char template[20];

to:

__far, that is, __far char template[20];

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

void bar(void) __attribute__ ((far));

int tblIdx __attribute__ ((far));

to:

void __far bar(void);

int __far tblIdx;

Caveats

None.