User manual

231
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
asm Statement
mikroPascal PRO for dsPIC30/33 and PIC24 allows embedding assembly in the source code by means of the asm
statement. Note that you cannot use numerals as absolute addresses for register variables in assembly instructions.
You may use symbolic names instead (listing will display these names as well as addresses).
You can group assembly instructions with the asm keyword:
asm
block of assembly instructions
end;
The only types whose name remains the same in asm as it is in the mikroPascal PRO for dsPIC30/33 and PIC24 are
registers, e.g. INTCON, PORTB, WREG, GIE, etc.
mikroPascal PRO for dsPIC30/33 and PIC24 comments are allowed in embedded assembly code.
Accessing variables
Depending on the place of declaration, accessing a variable can be done in several ways:
- Accessing global variable:
1. If declared under implementation section (visible only in the le where it was declared):
<source_le_name>_<variable_name>.
2. If declared in the interface section (visible throughout the whole project): _<variable_name>.
3. If accessing registers (declared through register, rx or sfr speciers, visible throughout the whole
project): <variable_name>.
- Accessing local variable: <routine_name>_<variable_name>.
- Accessing routine parameter: FARG_<routine_name>_<variable_name>.
Here is an example of using asm instructions:
program asm_example;
var myvar : word; absolute 0x2678;
const msg = ‘Hello’; org 0x3678;
var myvar1 : dword;
procedure proc(); org 0x1234;
begin
asm
nop
end;
end;
begin
myvar := 5;
myvar1 := 0xABCD1234;