Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
LINKER DIRECTIVES
mikroBasic PRO for AVR uses internal algorithm to distribute objects within memo-
ry. If you need to have a variable or routine at the specific predefined address, use
the linker directives 
absolute
and 
org
.
Note: You must specify an even address when using the linker directives.
Directive absolute
The directive 
absolute
specifies the starting address in RAM for a variable. If the
variable spans more than 1 word (16-bit), higher words will be stored at the consec-
utive locations.
The 
absolute
directive is appended to the declaration of a variable:
dim as word absolute 0x32
' Variable x will occupy 1 word (16 bits) at address 0x32
dim as longint absolute 0x34
' Variable y will occupy 2 words at addresses 0x34 and 0x36
Be careful when using absolute directive, as you may overlap two variables by acci-
dent. For example:
dim  i as word absolute 0x42
' Variable i will occupy 1 word at address 0x42;
dim jj as longint absolute 0x40
' Variable will occupy 2 words at 0x40 and 0x42; thus,
' changing i changes jj at the same time and vice versa
Note: You must specify an even address when using the directive absolute.
Directive org
The directive 
org
specifies the starting address of a routine in ROM. It is appended
to the declaration of routine. For example:
sub procedure proc(dim par as wordorg 0x200
' Procedure will start at the address 0x200;
...
end sub
Note: You must specify an even address when using the directive 
org
.
94
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Specifics
mikroBasic PRO for AVR
CHAPTER 3