Inline Assembly
MPLAB C18 provides an internal assembler using a syntax similar to the MPASM assembler. The block of assembly code must begin with _asm and end with _endasm. The syntax within the block is:
[label:] [<instruction> [arg1[, arg2[, arg3]]]]
The internal assembler differs from the MPASM assembler as follows:
No directive support
Comments must be C or C++ notation
Full text mnemonics must be used for table reads/writes. i.e.,
TBLRD
TBLRDPOSTDEC
TBLRDPOSTINC
TBLRDPREINC
TBLWT
TBLWTPOSTDEC
TBLWTPOSTINC
TBLWTPREINC
No defaults for instruction operands - all operands must be fully specified
Default radix is decimal
Literals are specified using C radix notation, not MPASM assembler notation. For example, a hex number should be specified as 0x1234, not H'1234'.
Label must include colon
Indexed addressing syntax (i.e., []) is not supported - must specify literal and access bit (e.g., specify as CLRF 2,0, not CLRF [2])
For example:
_asm
/* User assembly code */
MOVLW 10 // Move decimal 10 to count
MOVWF count, 0
/* Loop until count is 0 */
start:
DECFSZ count, 1, 0
GOTO done
BRA start
done:
_endasm
It is generally recommended to limit the use of inline assembly to a minimum. Any functions containing inline assembly will not be optimized by the compiler. To write large fragments of assembly code, use the MPASM assembler and link the modules to the C modules using the MPLINK linker.
--------------------------------------------------------------------------------
Microchip Technology Inc.
Microchip Web Site
Voice: (480) 792-7200
Fax: (480) 792-7277
Microchip Technical Support
Help Updated: 07/09/09
14:13:39
Popup