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.
| Psect name | Linker class | Target device families | Purpose |
|---|---|---|---|
code | CODE | All | To hold executable code |
edata | EEDATA | All | To hold data in EEPROM |
data | STRCODE | Baseline, Mid-range | To hold data in program memory |
data | CONST | PIC18 | To hold data in program memory |
udata | RAM | All | To hold objects allocatable anywhere in GPR |
udata_acs | COMRAM | PIC18 | To hold objects allocatable in the Access bank GPR |
udata_bankn | BANKN | All | To hold object allocatable in a particular data memory bank |
udata_shr | COMMON | Baseline, Mid-range | To hold objects allocatable in common memory |
