__asm__
directive. The syntax of this extension mimics gcc __asm__
extension.
void f() { __asm__("mylabel") ; __asm__("\tmovlw 0\n" "\tmovwf INDF0,0" ) ; }
The __asm__
directive does not insert leading blank, so you can
use it to insert labels.
On the other hand, a trailing newline is automatically appended to asm code.
Prior version 0.7.3, the inserted code had to leave the stack pointer (FSR0) unchanged. Violate this rule made the compiler unable to access the local variables properly.
However, it is now possible to specify that the inserted code change the stack pointer,
so the compiler is not fooled anymore. The following code shows how to use __asm__()
with an extra parameter
that gives the number of byte pushed on to the stack.
int g() { int a,b,c ; // ... __asm__("\tmovff PRODL,PREINC0", 1) ; // one byte pushed on to the stack __asm__("\tmovff PRODH,PREINC0", 1) ; // one more byte pushed on to the stack a = b+c ; __asm__("\tmovff POSTDEC0,PRODH" ) ; __asm__("\tmovff POSTDEC0,PRODL", -2)) ; // two bytes popped return a ; }
This feature allows the user to insert a more sophisticated assembler code in C code.