Microchip Technology SW006021-1N 사용자 설명서
MPLAB
®
XC8 C Compiler User’s Guide
DS52053A-page 38
2012 Microchip Technology Inc.
2.5.16
In-line Assembly
The asm() statement may be used to insert assembly code in-line with C code. The
argument is a C string literal which represents a single assembly instruction. Obviously,
the instructions contained in the argument are device specific.
argument is a C string literal which 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.
the semantics of this statement.
2.5.16.1
EXAMPLE
The following shows a MOVLW instruction being inserted in-line.
asm("MOVLW _foobar");
2.5.16.2
DIFFERENCES
The 8-bit compilers have used either the asm() or #asm ... #endasm constructs to
insert in-line assembly code.
insert in-line assembly code.
This is the same syntax used by the 16- and 32-bit compilers.
2.5.16.3
MIGRATION TO THE CCI
For 8-bit compilers change any instance of #asm ... #endasm so that each instruction
in this #asm block is placed in its own asm() statement, for example:
in this #asm block is placed in its own asm() statement, for example:
#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.
2.5.16.4
CAVEATS
None.