Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual
Product codes
SW006021-1
Macro Assembler
2012 Microchip Technology Inc.
DS52053B-page 247
For example, the following instructions show the W register being moved to first, an
absolute location and then to an address represented by an identifier. The op codes for
these instructions, assuming that the address assigned to _foo is 0x516 and to _bar
is 0x55, are shown.
absolute location and then to an address represented by an identifier. The op codes for
these instructions, assuming that the address assigned to _foo is 0x516 and to _bar
is 0x55, are shown.
6EE5 MOVWF 0FE5h ;write to access bank location 0xFE5
6E55 MOVWF _bar,c ;write to access bank location 0x55
0105 BANKSEL(_foo) ;set up BSR to access _foo
6F16 MOVWF BANKMASK(_foo),b ;write to _foo (banked)
6F16 MOVWF BANKMASK(_foo) ;defaults to banked access
Notice that first two instruction have the RAM access bit (bit 8 of the op-code) cleared,
but that it is set in the last two instructions.
but that it is set in the last two instructions.
6.4.1.2
BANK AND PAGE SELECTION
The BANKSEL pseudo instruction can be used to generate instructions to select the
bank of the operand specified. The operand should be the symbol or address of an
object that resides in the data memory.
bank of the operand specified. The operand should be the symbol or address of an
object that resides in the data memory.
Depending on the target device, the generated code will either contain one or more bit
instructions to set/clear bits in the appropriate register, or use a MOVLB instruction (in
the case of enhanced mid-range or PIC18 devices). As this pseudo instruction can
expand to more than one instruction on mid-range or baseline parts, it should not
immediately follow a BTFSX instruction on those devices.
instructions to set/clear bits in the appropriate register, or use a MOVLB instruction (in
the case of enhanced mid-range or PIC18 devices). As this pseudo instruction can
expand to more than one instruction on mid-range or baseline parts, it should not
immediately follow a BTFSX instruction on those devices.
For example:
MOVLW 20
BANKSEL(_foobar) ;select bank for next file instruction
MOVWF _foobar&07fh ;write data and mask address
In the same way, the PAGESEL pseudo instruction can be used to generate code to
select the page of the address operand. For the current page, you can use the location
counter, $, as the operand.
select the page of the address operand. For the current page, you can use the location
counter, $, as the operand.
Depending on the target device, the generated code will either contain one or more
instructions to set/clear bits in the appropriate register, or use a MOVLP instruction in
the case of enhanced mid-range PIC devices. As the directive could expand to more
than one instruction, it should not immediately follow a BTFSX instruction.
instructions to set/clear bits in the appropriate register, or use a MOVLP instruction in
the case of enhanced mid-range PIC devices. As the directive could expand to more
than one instruction, it should not immediately follow a BTFSX instruction.
For example:
FCALL _getInput
PAGESEL $ ;select this page
This directive is accepted when compiling for PIC18 targets but has no effect and does
not generate any code. Support is purely to allow easy migration across the 8-bit
devices.
not generate any code. Support is purely to allow easy migration across the 8-bit
devices.
6.4.1.3
INTERRUPT RETURN MODE
The RETFIE PIC18 instruction may be followed by "f" (no comma) to indicate that the
shadow registers should be retrieved and copied to their corresponding registers on
execution. Without this modifier, the registers are not updated from the shadow
registers. This replaces the "0" and "1" operands indicated in the device data sheet.
shadow registers should be retrieved and copied to their corresponding registers on
execution. Without this modifier, the registers are not updated from the shadow
registers. This replaces the "0" and "1" operands indicated in the device data sheet.
The following examples show both forms and the opcodes they generate.
0011 RETFIE f ;shadow registers copied
0010 RETFIE ;return without copy
The baseline and mid-range devices do not allow such a syntax.