User manual

MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 254 2012 Microchip Technology Inc.
6.4.8 Program Sections
Program sections, or psects, are simply a section of code or data. They are a way of
grouping together parts of a program (via the psect’s name) even though the source
code may not be physically adjacent in the source file, or even where spread over
several modules. For an introductory guide to psects, see Section 5.15.1 “Program
Sections”.
A psect is identified by a name and has several attributes. The PSECT assembler direc-
tive is used to define a psect. It takes as arguments a name and an optional
comma-separated list of flags. See Section 5.15.2 “Compiler-Generated Psects” for
a list of all psects that the code generator defines. Chapter 7. “Linker” has more infor-
mation on the operation of the linker and on options that can be used to control psect
placement in memory.
The assembler associates no significance to the name of a psect and the linker is also
not aware of which psects are compiler-generated or which are user-defined. Unless
defined as abs (absolute), psects are relocatable.
Code or data that is not explicitly placed into a psect will become part of the default
(unnamed) psect.
6.4.9 Assembler Directives
Assembler directives, or pseudo-ops, are used in a similar way to instruction mnemon-
ics. With the exception of PAGESEL and BANKSEL, these directives do not generate
instructions. The DB, DW and DDW directives place data bytes into the current psect. The
directives are listed in Table 6-5, and are detailed below in the following sections.
TABLE 6-5: ASPIC[18] ASSEMBLER DIRECTIVES
Directive Purpose
GLOBAL Make symbols accessible to other modules or allow reference to other
modules’ symbols
END End assembly
PSECT Declare or resume program section
ORG Set location counter within current psect
EQU Define symbol value
SET Define or re-define symbol value
DB Define constant byte(s)
DW Define constant word(s)
DDW Define double-width constant word(s) (PIC18 devices only)
DS Reserve storage
DABS Define absolute storage
IF Conditional assembly
ELSIF Alternate conditional assembly
ELSE Alternate conditional assembly
ENDIF End conditional assembly
FNCALL Inform the linker that one function calls another
FNROOT Inform the linker that a function is the “root” of a call graph
MACRO Macro definition
ENDM End macro definition
LOCAL Define local tabs
ALIGN Align output to the specified boundary
BANKSEL Generate code to select bank of operand