Far and Near Addressing

The compiler reserves the A5 address register to contain the base address of small static data at runtime. By default the compiler generates instructions that use addressing modes that are relative to the A5 register when referring to data in the sbss and sdata sections.

Use non-standard keywords to specify absolute addressing instead of A5-relative addressing. To specify that executable code should use absolute far addressing modes to refer to a variable, declare the variable with the far or __far keyword preceding its declaration. To specify that executable code should use near addressing modes to refer to a variable, declare the variable with near or __near preceding its declaration. The following listing shows an example.

Listing: Specifying addressing modes
static int i;
far static char c;

near static short j;

void f(void)

{

  i = 10; /* A5-relative addressing */

  c = '!'; /* 32-bit absolute addressing */

  j = 5; /* 16-bit absolute addressing */

}