Datasheet

LINKER DIRECTIVES
The mikroC PRO uses an internal algorithm to distribute objects within memory. If
you need to have a variable or routine at specific predefined address, use the link-
er directives
absolute and org.
Directive absolute
Directive absolute specifies the starting address in RAM for a variable. If the vari-
able is multi-byte, higher bytes will be stored at the consecutive locations.
Directive absolute is appended to declaration of a variable:
short x absolute 0x22;
// Variable x will occupy 1 byte at address 0x22
int y absolute 0x23;
// Variable y will occupy 2 bytes at addresses 0x23 and 0x24
Be careful when using the absolute directive, as you may overlap two variables by
accident. For example:
char i absolute 0x33;
// Variable i will occupy 1 byte at address 0x33
long jjjj absolute 0x30;
// Variable will occupy 4 bytes at 0x30, 0x31, 0x32, 0x33; thus,
// changing i changes jjjj highest byte at the same time, and vice
versa
Directive org
Directive org specifies a starting address of a routine in ROM.
Directive
org is appended to the function definition. Directives applied to non-defin-
ing declarations will be ignored, with an appropriate warning issued by the linker.
Here is a simple example:
void func(int par) org 0x200 {
// Function will start at address 0x200
nop;
}
It is possible to use org directive with functions that are defined externally (such as
library functions). Simply add org directive to function declaration:
void UART1_Write(char data) org 0x200;
Note: Directive org can be applied to any routin except for interrupt.
Note: See also funcall pragma.
104
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Specifics
mikroC PRO for AVR
CHAPTER 3