User manual
mikroC PRO for dsPIC
MikroElektronika
147
Linker Directives
The mikroC PRO for dsPIC30/33 and PIC24 uses an internal algorithm to distribute objects within memory. If you need
to have a variable or routine at specic predened address, use the linker directives absolute and org.
Directive absolute
Directive absolute species the starting address in RAM for a variable or a starting address in ROM for a constant. If
the variable or constant is multi-byte, higher bytes will be stored at the consecutive locations.
Directive absolute is appended to declaration of a variable or constant :
// Variable x will occupy 1 byte at address 0x22 :
short x absolute 0x22;
// Variable y will occupy 2 bytes at addresses 0x23 and 0x24 :
int y absolute 0x23;
// Array elements will be placed on the consecutive locations starting from 0x1000 :
const short ConstantArray[] = {1,2,3} absolute 0x1000;
Note :
If you want to place simple type constant into Flash memory, instead of following declaration:
const short SimpeConstant = 0xAA absolute 0x2000;
use an array consisting of single element :
const short SimpleConstant[] = {0xAA} absolute 0x2000;
In rst case, compiler will recognize your attempt, but in order to save Flash space, and boost performance, it will
automatically replace all instances of this constant in code with it's literal value.
In the second case your constant will be placed in Flash in the exact location specied.
Be careful when using the absolute directive, as you may overlap two variables by accident. For example:
// Variable i will occupy 1 byte at address 0x33
char i absolute 0x33;
// Variable will occupy 4 bytes at 0x30, 0x31, 0x32, 0x33; thus,
// changing i changes jjjj highest byte at the same time, and vice versa
long jjjj absolute 0x30;
Directive orgall
If the user wants to place his routines, constants, etc, above a specied address in ROM, #pragma orgall directive
should be used:
#pragma orgall 0x200