Mikroelektronika MIKROE-350 Ficha De Dados

Página de 526
ASM STATEMENT
mikroBasic PRO for AVR 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
mikroBasic PRO comments are not allowed in embedded assembly code. Instead,
you may use one-line assembly comments starting with semicolon.
If you plan to use a certain mikroBasic PRO variable in embedded assembly only, be sure
to at least initialize it (assign it initial value) in mikroBasic PRO code; otherwise, the linker
will issue an error. This is not applied to predefined globals such as P0.
For example, the following code will not be compiled because the linker won’t be
able to recognize the variable 
myvar
:
program test
dim myvar as word
main:
asm
MOV #10, W0
MOV W0, _myvar
end asm
end.
Adding the following line (or similar) above the asm block would let linker know that
variable is used:
myvar = 20
163
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5