Syntax
pagesel label
Description
An instruction to the linker to generate page selecting code to set the page bits to the page containing the designated label. Only one label should be specified. No operations can be performed on label. label must have been previously defined.
The linker will generate the appropriate page selecting code. For 12-bit instruction width (PIC10F, some PIC12/PIC16) devices, the appropriate bit set/clear instructions on the STATUS register will be generated. For 14-bit instruction width (most PIC12/PIC16) devices, a combination of BSF and BCF commands will be used to adjust bits 3 and 4 of the PCLATH register. If the device contains only one page of program memory, no code will be generated.
For PIC18 devices, this command will do nothing as these devices do not use paging.
Usage
This directive is used in the following types of code: relocatable. For informaciónrmation on types of code, see Assembler Operation.
This directive saves you from having to manually code page bit changes. Also, since it automatically generates code, the code is much more portable.
If you are using relocatable code and your device has more than 2k program memory (or 0.5K for 12-bit instruction width devices), it is recommended that you use this directive, especially when code must jump between two or more code sections.
If you wish to indicate the start address of a RETLW table or a jump table for computed GOTOs, you must use the pageselw directive.
See Also
bankisel banksel
Simple Example
pagesel GotoDest
goto GotoDest
:
pagesel CallDest
call CallDest
Application Example - pagesel
This program demonstrates the pagesel directive, which generates the appropriate code to set/clear PCLATH bits. This allows easier use of paged memory such as found on PIC16 devices.
#include p16f877a.inc ;Include standard header file
;for the selected device.
RST CODE 0x0 ;The code section named RST
;is placed at program memory
;location 0x0. The next two
;instructions are placed in
;code section RST.
pagesel start ;Jumps to the location labelled
goto start ;'start'.
PGM0 CODE 0x500 ;The code section named PGM1 is
;placed at 0x500.
start
pagesel page1_pgm ;address bits 12 & 11 of
;page1_pgm are copied to PCLATH
;4 & 3 respectively.
goto page1_pgm
PGM1 CODE 0x900 ;The code section named PGM1 is
;placed at 0x900. Label
;page1_pgm is located in this
page1_pgm ;code section.
goto $ ;Go to current line (loop here)
end