Atmel CAVR-4 ユーザーズマニュアル
CAVR-4
36
Placing segments in memory
AVR® IAR C/C++ Compiler
Reference Guide
See the IAR Linker and Library Tools Reference Guide for more details.
Using the -Z command for sequential placement
Use the -Z command when you need to keep a segment in one consecutive chunk, when
you need to preserve the order of segment parts in a segment, or, more unlikely, when
you need to put segments in a specific order.
you need to preserve the order of segment parts in a segment, or, more unlikely, when
you need to put segments in a specific order.
The following illustrates how to use the
-Z
command to place the segment
MYSEGMENTA
followed by the segment
MYSEGMENTB
in
DATA
memory (that is, external RAM) in the
memory range
0x1000-0xCFFF
.
-Z(DATA)MYSEGMENTA,MYSEGMENTB=1000-CFFF
Two segments of different types can be placed in the same memory area by not
specifying a range for the second segment. In the following example, the
specifying a range for the second segment. In the following example, the
MYSEGMENTA
segment is first located in memory. Then, the rest of the memory range could be used by
MYCODE
.
-Z(DATA)MYSEGMENTA=1000-CFFF
-Z(CODE)MYCODE
Two memory ranges may overlap. This allows segments with different placement
requirements to share parts of the memory space; for example:
requirements to share parts of the memory space; for example:
-Z(DATA)MYSMALLSEGMENT=1000-20FF
-Z(DATA)MYLARGESEGMENT=1000-CFFF
Even though it is not strictly required, make sure to always specify the end of each
memory range. If you do this, the IAR XLINK Linker will alert you if your segments do
not fit in the specified ranges.
memory range. If you do this, the IAR XLINK Linker will alert you if your segments do
not fit in the specified ranges.
Using the -P command for packed placement
The
-P
command differs from
-Z
in that it does not necessarily place the segments (or
segment parts) sequentially. With
-P
it is possible to put segment parts into holes left by
earlier placements.
The following example illustrates how the XLINK
-P
option can be used for making
efficient use of the memory area. The command will place the data segment
MYDATA
in
DATA memory (that is, in RAM) in the memory range:
-P(DATA)MYDATA=0-FFF,1000-1FFF
If your application has an additional RAM area in the memory range
0xF000-0xF7FF
,
you just add that to the original definition:
-P(DATA)MYDATA=0-FFF,1000
–1FFF,F000-F7FF