Atmel CAVR-4 사용자 설명서
CAVR-4
Part 1. Using the compiler
Placing code and data
47
In the linker command file it can look like this:
-Z(CODE)CODE=0-1FFF
USER-DEFINED SEGMENTS
If you create your own segments—see Controlling data and function placement, page
47—these must also be defined in the linker command file using the
47—these must also be defined in the linker command file using the
-Z
or
-P
segment
control directives. In the linker command file it can look like this:
-Z(CODE)MYSEGMENT=100-2FF
Compiler-generated segments
The compiler uses a set of internally generated segments, which are used for storing
information that is vital to the operation of the program.
information that is vital to the operation of the program.
●
The
SWITCH
segment which contains data statements used in the switch library
routines. These tables are encoded in such a way as to use as little space as possible.
●
The
INITTAB
segment contains the segment initialization description blocks that
are used by the
_ _segment_init
function which is called by
CSTARTUP
. This table
consist of a number of
SegmentInitBlock_Type
objects. This type is declared in
the
segment_init.h
file which is located in the
avr\src\lib
directory.
●
The
DIFUNCT
segment is only used when a source file has been compiled in C++
mode and the file contains global objects (class instances). The segment will then
contain a number of function pointers that point to constructor code that should be
performed for each object.
contain a number of function pointers that point to constructor code that should be
performed for each object.
In the linker command file it can look like this:
-Z(CODE)SWITCH,INITTAB,DIFUNCT=0-1FFF
Efficient usage of segments and memory
This section lists several features and methods to help you manage memory and
segments.
segments.
CONTROLLING DATA AND FUNCTION PLACEMENT
The
@
operator, alternatively the
#pragma location
directive, can be used for placing
global and static variables at absolute addresses. The syntax can also be used for placing
variables or functions in named segments. The variables must be declared either
variables or functions in named segments. The variables must be declared either
_ _no_init
or
const
. If declared
const
, it is legal for them to have initializers. The
named segment can either be a predefined segment, or a user-defined segment.