Справочник Пользователя для Microchip Technology SW006021-2
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 246
2012 Microchip Technology Inc.
6.4
MPLAB XC8 ASSEMBLY LANGUAGE
The source language accepted by the macro assembler, ASPIC[18], is described
below. All opcode mnemonics and operand syntax are specific to the target device.
Although the PIC17 family instruction set is supported at the assembler level, the code
generator cannot produce code for these devices so no C projects can target these
devices.
below. All opcode mnemonics and operand syntax are specific to the target device.
Although the PIC17 family instruction set is supported at the assembler level, the code
generator cannot produce code for these devices so no C projects can target these
devices.
Additional mnemonics and assembler directives are documented in this section.
The same assembler application is used for compiler-generated intermediate
assembly and hand-written assembly source code.
assembly and hand-written assembly source code.
6.4.1
Assembly Instruction Deviations
The MPLAB XC8 assembler uses a slightly modified form of assembly language to that
specified by the Microchip data sheets. The following details changes to the instruction
format, and pseudo instructions that can be used in addition to the device instruction
set.
specified by the Microchip data sheets. The following details changes to the instruction
format, and pseudo instructions that can be used in addition to the device instruction
set.
These deviations can be used in assembly code in-line with C code or in hand-written
assembly modules.
assembly modules.
6.4.1.1
DESTINATION LOCATION
Certain PIC instructions use the operands ",0" or ",1" to specify the destination for the
result of that operation. ASPIC[18] uses the more-readable operands ",w" and ",f" to
specify the destination register.
result of that operation. ASPIC[18] uses the more-readable operands ",w" and ",f" to
specify the destination register.
The W register is selected as the destination when using the ",w" operand, and the file
register is selected when using the ",f" operand or if no destination operand is
specified. The case of the letter in the destination operand in not important. For
example:
register is selected when using the ",f" operand or if no destination operand is
specified. The case of the letter in the destination operand in not important. For
example:
MOVF
_foo,w
ADDWF
_foo,f
;the ,f destination is optional
The numerical destination operands cannot be used with ASPIC[18].
The assembler also uses the destination select operand ",b" to indicate that PIC18
instructions should use the bank select register (BSR) when accessing the specified
file register address. The ",c" operand indicates that the address is in the common
memory, which is known as the access bank on PIC18 devices. Alternatively, an oper-
and may be preceded by the characters "c:" to indicate that the address resides in
common memory. These operands and prefix affect the RAM access bit in the
instruction. For example:
instructions should use the bank select register (BSR) when accessing the specified
file register address. The ",c" operand indicates that the address is in the common
memory, which is known as the access bank on PIC18 devices. Alternatively, an oper-
and may be preceded by the characters "c:" to indicate that the address resides in
common memory. These operands and prefix affect the RAM access bit in the
instruction. For example:
ADDWF
_foo,c
BTFSC
c:_foo,3
If the instruction does not specify a destination select operand, or the common memory
prefix, the instruction will used banked access. These operands and prefix are not
applicable with operands to the MOVFF instruction, which takes two untruncated
addresses and which always works independently of the BSR.
prefix, the instruction will used banked access. These operands and prefix are not
applicable with operands to the MOVFF instruction, which takes two untruncated
addresses and which always works independently of the BSR.
If an instruction address is absolute and the address is within the access bank, the
common memory destination selectors ",c" or "c:" are not required. The assembler
will determine from the address that access bank memory is being accessed.
common memory destination selectors ",c" or "c:" are not required. The assembler
will determine from the address that access bank memory is being accessed.