Difference between revisions of "How RL78 manages named address spaces"

From GNU Tools - Wiki
Jump to: navigation, search
(Created page with "RL78 contains 2 address spaces: '''Near address space''' - qualifier '''__near''' - 16 bit addresses - saved in the topmost 64 kB of the address space '''Far address spac...")
(No difference)

Revision as of 06:03, 27 April 2017

RL78 contains 2 address spaces:

Near address space

- qualifier __near

- 16 bit addresses

- saved in the topmost 64 kB of the address space

Far address space

- qualifier __far

- 20 bit addresses


The default (generic) address space for the RL78 targets is the __near address space. For now there is no option available to make the __far address space the default one.

Below are a few examples of the way __far address space can be used:

Examples:

 __far char a, b, c;
 // Declares three characters in address space __far
 struct { int a; char b; } * __far q;
 // Declares a pointer in address space __far that points to a structure in the generic space (__near)

There are some constraints on the use of address-space type qualifiers:

Since address space __far encloses address space __near, then every location (address) within __near is also within __far.

The most significant constraint is that an address space name cannot be used to qualify an object that has automatic storage duration. This implies, in particular, that variables declared inside a function cannot be allocated in a named address space unless they are also explicitly declared as static or extern.

 void X()
 {
 	__far char a;
 }
 //compilation errror

For the examples above, the declarations of a, b, c, and q would have to be outside any function to be valid.

As determined by its type, every pointer points into a specific address space, either the generic address space or a named address space. A pointer into an address space can only point to locations in that address space (including any subset address spaces).

Pointers into __far address spaces cannot be passed as arguments to library functions. Likewise, library functions such as malloc that allocate memory do so only for the generic address space (__near); there are no standard functions for allocating space in the __far address spaces.

More detailed information about named space addresses can be found here