how can i access general registers in mikroC?
e.g. this does not work clrf 6;
but this does clrf portb;
it's ok for special registers because they have names... but how do i access general register??
how to program in assembly in mikroC?
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: how to program in assembly in mikroC?
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):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:
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:
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,
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
}
Code: Select all
asm assembly instruction;
Code: Select all
asm assembly instruction
Code: Select all
asm
{
block of assembly instructions
}
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.
Best regards,
mikroElektronika [Support team]