Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Linker Directives
mikroPascal PRO for AVR uses internal algorithm to distribute objects within mem-
ory. If you need to have a variable or a 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
Directive 
absolute
specifies the starting address in RAM for a variable. If the vari-
able spans more than 1 word (16-bit), the higher words will be stored at the consec-
utive locations.
Directive absolute is appended to the declaration of a variable:
var x : word; absolute $32;
// Variable x will occupy 1 word (16 bits) at address $32
y : longint; 
absolute $34;
// Variable y will occupy 2 words at addresses $34 and $36
Be careful when using the absolute directive because you may overlap two vari-
ables by accident. For example:
var
i : word; 
absolute $42;
// Variable i will occupy 1 word at address $42;
jj : longint; 
absolute $40;
// Variable will occupy 2 words at $40 and $42; thus,
// changing i changes jj at the same time and vice versa
Note: You must specify an even address when using the absolute directive.
Directive org
Directive org specifies the starting address of a routine in ROM. It is appended to
the declaration of a routine. For example:
procedure proc(par : byte); org $200;
begin
// Procedure will start at address $200;
...
end;
179
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5