Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル
製品コード
SW006021-1
C Language Features
2012 Microchip Technology Inc.
DS52053B-page 223
5.15.1.2
THE COMPILER EQUIVALENT
Let’s now look at the similarities and differences between this situation and the
compilation process. Both these processes are compared in Figure 5-4.
compilation process. Both these processes are compared in Figure 5-4.
FIGURE 5-4:
THE WAREHOUSE AND COMPILER SIDE BY SIDE
In this analogy, the warehouse is likened to the compiler. The robot is akin to the com-
piler’s code generator application, which turns the C code into assembly code, and the
packing machine, the linker, which is responsible for arranging how everything will
appear in memory.
piler’s code generator application, which turns the C code into assembly code, and the
packing machine, the linker, which is responsible for arranging how everything will
appear in memory.
The packing machine is not actually delivering the bundles of boxes; it is just putting
them into containers in the warehouse. In the same way, the linker is not actually plac-
ing sections in the device’s memory; it is arranging them in conceptual containers. This
analogy is not concerned with what happens outside the warehouse, nor after the
compilation process – that is another story.
them into containers in the warehouse. In the same way, the linker is not actually plac-
ing sections in the device’s memory; it is arranging them in conceptual containers. This
analogy is not concerned with what happens outside the warehouse, nor after the
compilation process – that is another story.
The following sections detail points relevant at different stages of the process.
5.15.1.2.1
Orders and Source Code
Both the warehouse and compiler take descriptions of something and use this to pro-
duce the final product: The warehouse receives orders, and assembles the compo-
nents to fulfill that order; the compiler reads (variable and function) definitions in a C
program and generates the assembly code to implement each definition.
duce the final product: The warehouse receives orders, and assembles the compo-
nents to fulfill that order; the compiler reads (variable and function) definitions in a C
program and generates the assembly code to implement each definition.
An order from a customer may be for any number of components. In the same way,
each C definition may require few or many assembly instructions or directives to be
produced.
each C definition may require few or many assembly instructions or directives to be
produced.
Orders arrive at the warehouse randomly, but the components are always shipped to
one of several countries. Source code (variables and functions) can also be written in
any order, but the compiled code is always allocated to one of several memory areas.
one of several countries. Source code (variables and functions) can also be written in
any order, but the compiled code is always allocated to one of several memory areas.
‧‧‧
if(in > 4)
scale = 0;
scale = 0;
‧‧‧
code
generator
int result;
float scale;
float scale;
int
getDat(void) {
...
getDat(void) {
...
ORDER 1
3 x TSC235
2 x RC123a
2 x RC123a
ORDER 2
1 x TSD87
2 x XAM99
10 x TD66
2 x XAM99
10 x TD66
R
P
linker
PSECT text,class=CODE
movlw (?_barrr2)&0ffh
movwf fsr0
movlw (?_srv)&0ffh
movwf (??_main+0+0)
movf fsr0,w
movwf (??_main+0+0+1)
movlw 12
movwf (??_main+0+0+2)
u60:
movf (??_main+0+0),w
PSECT bssBANK0,class=BANK0,space=1
global __pbssCOMMON
__pbssCOMMON:
_c:
ds 1
_more:
ds 8
PSECT cstackBANK0,class=BANK0,space=1
global __pcstackBANK0
__pcstackBANK0:
global ?___ftge
?___ftge: ;@ 0x0
global ?___ftmul
?___ftmul: ;@ 0x0
global ?_frexp
?_frexp: ;@ 0x0
global ___ftmul@f1
___ftmul@f1: ; 3 bytes @ 0x0
PSECT text,class=CODE
fcall _srv
movlw (?_barrr2)&0ffh
movwf fsr0
movlw (?_srv)&0ffh
movwf (??_main+0+0)
movf fsr0,w
movwf (??_main+0+0+1)
movlw 12
movwf (??_main+0+0+2)
u60:
movf (??_main+0+0),w
movwf fsr0