ABL electronic PIC12 Personal Computer User Manual


 
Linker Directives
mikroC uses internal algorithm to distribute objects within memory. If you need to
have variable or routine at specific predefined address, use linker directives
absolute and org.
Directive absolute
Directive absolute specifies the starting address in RAM for variable. If variable is
multi-byte, higher bytes are stored at consecutive locations. Directive absolute is
appended to the declaration of variable:
int foo absolute 0x23;
// Variable will occupy 2 bytes at addresses 0x23 and 0x24;
Be careful when using absolute directive, as you may overlap two variables by
mistake. 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,
// so changing i changes jjjj highest byte at the same time
Directive org
Directive
org specifies the starting address of routine in ROM.
Directive org is appended to the function definition. Directives applied to non-
defining declarations will be ignored, with an appropriate warning issued by link-
er. Directive
org cannot be applied to an interrupt routine.
Here is a simple example:
void func(char par) org 0x200 {
// Function will start at address 0x200
nop;
}
MikroElektronika:
Development
tools
-
Books
-
Compilers
35
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...