User manual
mikroBasic PRO for PIC32
MikroElektronika
235
Explicit Path
mikroBasic PRO for PIC32 uses internal algorithm to distribute objects within memory. If you need to have a variable
or routine at the specic predened address, use the linker directives absolute and org.
When using these directives, be sure to use them in proper memory segments, i.e. for functions it is the KSEG0 and
for variables it is the KSEG1. Linker directives are used with the virtual addresses.
Directive absolute
Directive absolute species the starting address in RAM for a variable. If the variable is multi-byte, higher bytes will
be stored at the consecutive locations.
Directive absolute is appended to declaration of a variable:
‘ Variable x will occupy 1 word (16 bits) at address 0xA0000000
dim x as word absolute 0xA0000000
‘ Variable y will occupy 2 words at addresses 0xA0000000 and 0xA0000002
dim y as longint absolute 0xA0000000
Be careful when using the absolute directive, as you may overlap two variables by accident. For example:
dim i as word absolute 0xA0000002
‘ Variable i will occupy 1 word at address 0xA00000002
dim jj as longint absolute 0xA0000000
‘ Variable will occupy 2 words at 0xA0000000 and 0xA0000002; thus,
‘ changing i changes jj at the same time and vice versa
Directive org
Directive org species the starting address of a constant or a routine in ROM. It is appended to the constant or a
routine declaration.
To place a constant array in Flash memory, write the following:
‘ Constant array MONTHS will be placed starting from the address 0x9D000000
const MONTHS as byte[12] = (31,28,31,30,31,30,31,31,30,31,30,31) org 0x9D000000
If you want to place simple type constant into Flash memory, instead of following declaration:
const SimpleConstant as byte = 0xAA org 0x9D000000
use an array consisting of single element :
const SimpleConstant as byte[1] = (0xAA) org 0x9D000000