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.

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. For example:
movlw 20
BANKSEL(_foobar)    ;select bank for next file instruction
movwf BANKMASK(_foobar)  ;write data and mask address
Note: The manual masking of addresses used as instruction operands (for example using the BANKMASK() or PAGEMASK() macros or ANDing the operand with a mask) is not necessary when using the -Wl,--fixupoverflow option and any of the ignore, warn, or lstwarn arguments.

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.

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. 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.