4.4.16 In-line Assembly
The asm()
statement can be used to insert assembly code
in-line with C code. The argument is a C string literal that represents a single assembly
instruction. Obviously, the instructions contained in the argument are device specific.
Use the native keywords discussed in the Differences section to look up information on the semantics of this statement.
Example
The following shows a MOVLW
instruction being inserted
in-line.
asm("MOVLW _foobar");
Differences
The 8-bit compilers have used either the asm()
or
#asm
...#endasm
constructs to insert in-line assembly
code.
This is the same syntax used by the 16- and 32-bit compilers.
Migration to the CCI
For 8-bit compilers, change any instance of #asm ... #endasm
, so that each
instruction in the #asm
block is placed in its own asm()
statement, e.g., from:
#asm
MOVLW 20
MOVWF _i
CLRF Ii+1
#endasm
to:
asm("MOVLW20");
asm("MOVWF _i");
asm("CLRFIi+1");
No migration is required for the 16- or 32-bit compilers.
Caveats
None.