Technical information
AN2216/D
CodeWarrior Linker
MOTOROLA MC9S12DP256 Software Development Using Metrowerkâs Codewarrior 11
$C000 to $FFFF corresponds to the same physical memory as $3F8000 to
$3FBFFF. For the reasons described above, code is linked to $C000 to $FFFF
in preference to $3F8000 to $3FBFFF.
Linker Command
File
The allocation of the defined code and data segments to memory addresses is
controlled by the linker command file. This file may be recognised by the file
extension '.prm'. Within this file, the SECTIONS command block is used to
define physical regions of memory. An example of the SECTIONS command
block for the BANKED memory model on the MC9S12DP256 is given in Figure
10.
SECTIONS
EEPROM = READ_WRITE 0x0400 TO 0x0FFF;
RAM = READ_WRITE 0x1000 TO 0x3FFF;
/* non-paged FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;
ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF;
/* paged FLASH ROM */
PAGE_30 = READ_ONLY 0x308000 TO 0x30BFFF;
PAGE_31 = READ_ONLY 0x318000 TO 0x31BFFF;
PAGE_32 = READ_ONLY 0x328000 TO 0x32BFFF;
PAGE_33 = READ_ONLY 0x338000 TO 0x33BFFF;
PAGE_34 = READ_ONLY 0x348000 TO 0x34BFFF;
PAGE_35 = READ_ONLY 0x358000 TO 0x35BFFF;
PAGE_36 = READ_ONLY 0x368000 TO 0x36BFFF;
PAGE_37 = READ_ONLY 0x378000 TO 0x37BFFF;
PAGE_38 = READ_ONLY 0x388000 TO 0x38BFFF;
PAGE_39 = READ_ONLY 0x398000 TO 0x39BFFF;
PAGE_3A = READ_ONLY 0x3A8000 TO 0x3ABFFF;
PAGE_3B = READ_ONLY 0x3B8000 TO 0x3BBFFF;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
END
Figure 10. Example of Linker Sections Command Block
Within the SECTIONS command block, each separate section of physical
memory is described with a name, an attribute and an address range. Each
page of flash memory is listed, except for PPAGE values $3E and $3F. Instead
this memory is allocated through the equivalent non-paged address, described
as ROM_4000 and ROM_C000. Note that ROM_C000 ends at $FEFF. $FF00
to $FF0F cannot be used for code as the Flash protection and security registers
are located here. Also $FF8C to $FFFF are occupied by the interrupt vectors
and cannot be used for code.
Once the SECTIONS are defined, the code and data segments are allocated to
memory using the PLACEMENT command block.