Mikroelektronika MIKROE-724 データシート

ページ / 726
234
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
asm Statement
mikroBasic 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 asm
The only types whose name remains the same in asm as it is in the mikroBasic PRO for dsPIC30/33 and PIC24 are 
registers, e.g. INTCON, PORTB, WREG, GIE, etc.
mikroBasic 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 file where it was declared): 
 
     
<source_file_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
 specifiers, 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
dim myvar as word absolute 0x2678
dim myvar1 as longword
const msg = “Hello” org 0x1234
sub procedure proc() org 0x2346
  asm
    nop
  end asm
end sub
main :
  myvar = 5
  myvar1 = 0xABCD1234