5.2 Assembler-provided Psects

The PIC Assembler provides psect definitions (tabulated below), can be used to hold code and data, if required. These psects are available once you include <xc.inc> into your source file and have names that resemble the MPASM directive that creates similar sections in the MPASM assembler. The following example shows instructions placed into the code psect and data in both banked and common data memory.
#include <xc.inc>

GLOBAL CR_osc,myBank2Obj

PSECT udata_shr         ;objects in common memory
CR_osc:
	DS	1	;reserve one byte for CR_osc

PSECT udata_bank2       ;objects in bank 2
myBank2Obj:
	DS	4	;reserve four bytes for this object

PSECT code
store:
	movlw    055h
	movwf    CR_osc
	movlw    0
	BANKSEL  myBank2Obj
	movwf    BANKMASK(myBank2Obj)
	movwf    BANKMASK(myBank2Obj+1)

The linker class associated with each of these psects and the device families for which they are defined are indicated in the table. The linker classes shown are also already predefined by the PIC Assembler, so you do not need to define them.

You can instead use psects and linker classes that you define, if required. In situations where a psect must reside at a specific location, you must use a unique psect so that it can be linked independently to others. See Psect Directive and P: Position Psect.

Table 5-2. Assembler-provided Psects and Linker Classes
Psect nameLinker classTarget device familiesPurpose
codeCODEAllTo hold executable code
edataEEDATAAllTo hold data in EEPROM
dataSTRCODEBaseline, Mid-rangeTo hold data in program memory
dataCONSTPIC18To hold data in program memory
udataRAMAllTo hold objects allocatable anywhere in GPR
udata_acsCOMRAMPIC18To hold objects allocatable in the Access bank GPR
udata_banknBANKNAllTo hold object allocatable in a particular data memory bank
udata_shrCOMMONBaseline, Mid-rangeTo hold objects allocatable in common memory