Next Previous Contents

10. Absolute addressing.

Data items can be assigned an absolute address with the at <address> keyword, in addition to a storage class.

eg. xdata at 0x8000 unsigned char PORTA_8255 ;
 

In the above example the PORTA_8255 will be allocated to the location 0x8000 of the external ram.

Note that is this feature is provided to give the programmer access to memory mapped devices attached to the controller. The compiler does not actually reserve any space for variables declared in this way (they are implemented with an equate in the assembler), thus it is left to the programmer to make sure there are no overlaps with other variables that are declared without the absolute address, the assembler listing file (.lst) and the linker output files (<filename>.rst) and (<filename>.map) are a good places to look for such overlaps.

Absolute address can be specified for variables in all storage classes.

eg.bit at 0x02 bvar;
 

The above example will allocate the variable at offset 0x02 in the bit-addressable space. There is no real advantage to assigning absolute addresses to variables in this manner , unless you want strict control over all the variables allocated.


Next Previous Contents