Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 224
 2012 Microchip Technology Inc.
5.15.1.2.2
Boxes, Labels and Sections
In our analogy, the components for each order are placed in a box. In the same way, 
the assembly output generated is also placed into boxes, called program sections (or 
psects, for short).
There are several reasons why code is placed in a section.
• The generated assembly code is more manageable.
• The ordering of the code sequence within the section is preserved.
• The ordering of sections with the same name are preserved.
• Code is easily sorted based on where it needs to reside in memory.
• Only one command is required to locate an entire section into memory.
Any code sequence that must be contiguous is placed in the one section. The output 
of the compiler will typically appear in many different sections, but all sections with the 
same name will collate in the order in which they are produced.
The compiler has a list of section names and chooses a section based on the code it 
is generating, see 5.15.2 “Compiler-Generated Psects”.
A section is not a physical box, but rather a special directive is used in the assembly 
code to define the start of each section. The directive signifies the end of the previous 
box and the start of a new box. A section can hold any amount of assembly code and 
can even be empty.
Both the warehouse boxes and compiler sections are labeled and in both instances, 
the label indicates a destination rather than the contents. In Figure 5-4 color is used to 
identify the destination city of a box, or the name of a section.
Figure 5-5 shows what a typical box label might look like. The packing machine in the 
warehouse is only concerned with packing boxes in containers and so, other than the 
city and country, the customer’s actual address is not important here.
FIGURE 5-5:
A TYPICAL BOX LABEL
Figure 5-6 shows an example of the assembly directive that is used to start a new sec-
tion. The city name is now a section name and the destination country a linker class.
FIGURE 5-6:
THE SECTION DIRECTIVE AS A BOX LABEL
BOX
 
paris
,
country=FRANCE
,
fragile
PSECT
 
bss0
,
class=BANK0
,
space=1,reloc=4
close the previous box,
start a new box
the name of this box
the container this box
must be packed in
special packing instructions
for this box