Mikroelektronika MIKROE-724 データシート

ページ / 726
238
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Directive org
Directive 
org
 specifies 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 0x800
const MONTHS as byte[12] = (31,28,31,30,31,30,31,31,30,31,30,31) org 0x800
If you want to place simple type constant into Flash memory, instead of following declaration:
const SimpleConstant as byte = 0xAA org 0x2000
use an array consisting of single element:
const SimpleConstant as byte[1] = (0xAA) org 0x800
In first 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 specified.
To place a routine on a specific address in Flash memory you should write the following:
sub procedure proc(dim par as wordorg 0x200
‘ Procedure will start at the address 0x200;
...
end sub
org
 directive can be used with 
main
 routine too. For example:
program Led_Blinking 
main: org 0x800             ‘ main procedure starts at 0x800
...
end
Directive orgall
Use the 
orgall
 directive to specify the address above which all routines and constants will be placed. Example:
main:
  orgall(0x200) ‘ All the routines, constants in main program will be above the address 
0x200
  ...
end.