Hello,
The mikroC PRO for PIC allows embedding assembly in the source code by means of the asm declaration.
The declarations _asm and __asm are also allowed in the mikroC PRO for PIC and have the same meaning.
Assembly instructions can be grouped by the asm keyword
(or _asm, or __asm):
Code: Select all
asm {
block of assembly instructions
}
There are two ways to embeding single assembly instruction to C code:
and
Semicolon and LF are terminating asm scope for single assembly instructions. This is the reason why the following syntax is not asm block:
Code: Select all
asm
{
block of assembly instructions
}
This code will be interpreted as single empty asm line followed by C compound statement.
The mikroC PRO for PIC comments (both single-line and multi-line) are allowed in embedded assembly code.
if you have a global variable "g_var", that is of type long (i.e. 4 bytes), you are to access it like this:
Code: Select all
MOVF _g_var+0, 0 ;puts least-significant byte of g_var in W register
MOVF _g_var+1, 0 ;second byte of _g_var; corresponds to Hi(g_var)
MOVF _g_var+2, 0 ;Higher(g_var)
MOVF _g_var+3, 0 ;Highest(g_var)
... etc.
If you want to know details about asm syntax supported by mikroC PRO for PIC it is recomended to study asm and lst files generated by compiler.
Best regards,