next up previous contents index
Next: 3.12 Startup Code Up: 3. Using SDCC Previous: 3.10 Functions using private   Contents   Index

3.11 Absolute Addressing

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

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 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 (.rst) and (.map) are a good places to look for such overlaps.

Absolute address can be specified for variables in all storage classes, e.g.:

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 up previous contents index
Next: 3.12 Startup Code Up: 3. Using SDCC Previous: 3.10 Functions using private   Contents   Index
Johan Knol
2001-07-13