mikroC
making it simple...
asm DeclarationmikroC - C Compiler for Microchip PIC microcontrollers
C allows embedding assembly in the source code by means of asm declaration. Declarations _asm and __asm are also allowed in mikroC, and have the same meaning. Note that you cannot use numerals as absolute addresses for SFR or GPR variables in assembly instructions. You may use symbolic names instead (listing will display these names as well as addresses).
You can group assembly instructions by the asm keyword (or _asm, or __asm):
asm {
block of assembly instructions
}
C comments (both
If you plan to use a certain C variable in embedded assembly only, be sure to at least initialize it in C code; otherwise, linker will issue an error. This does not apply to predefined globals such as PORTB.
For example, the following code will not be compiled, as linker won’t be able to recognize variable myvar:
unsigned myvar;
void main() {
asm {
MOVLW 10 // just a test
MOVLW test_main_global_myvar_1
}
}
Adding the following line (or similar) above asm block would let linker know that variable is used:
myvar := 0;
Note: mikroC will not check if the banks are set appropriately for your variable. You need to set the banks manually in assembly code.
|
| page |
MikroElektronika: Development tools - Books - Compilers | 93 | |
|