Technical information

AN2216/D
CodeWarrior Linker
MOTOROLA MC9S12DP256 Software Development Using Metrowerk’s Codewarrior 19
PAGE_38 = READ_ONLY IBCC_FAR 0x388000 TO 0x38BFFF;
PAGE_39 = READ_ONLY IBCC_FAR 0x398000 TO 0x39BFFF;
PAGE_3A = READ_ONLY IBCC_FAR 0x3A8000 TO 0x3ABFFF;
PAGE_3B = READ_ONLY IBCC_FAR 0x3B8000 TO 0x3BBFFF;
PAGE_3C = READ_ONLY IBCC_FAR 0x3C8000 TO 0x3CBFFF;
PAGE_3D = READ_ONLY IBCC_FAR 0x3D8000 TO 0x3DBFFF;
END
PLACEMENT
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
NON_BANKED,
COPY INTO ROM_C000, ROM_4000;
DISTRIBUTE DISTRIBUTE_INTO PAGE_30, PAGE_31, PAGE_32, PAGE_33, PAGE_34, PAGE_35, PAGE_36,
PAGE_37, PAGE_38, PAGE_39, PAGE_3A, PAGE_3B;
EEPROM INTO EEPROM_AREA;
DEFAULT_RAM INTO RAM;
END
Figure 19. Example Linker Commands for the Distribute feature
The linker is now run with the -Dist option and if required, the -DistSeg option.
This option suppresses the generation of the normal absolute file, instead a
special header file is generated. This header file assigns each function to a
segment, along with the appropriate calling mechanism for each function. The
name of this header file can be specified with the -DistFile option. If this option
is not specified the default name 'distr.inc' is assigned. This file is created in the
project /bin sub-directory by default. This file requires another include file called
interseg.h, which can by found in the Metrowerks /Include sub-directory.
Now the second pass compilation and link can be performed. This time the
linker generated header file must be included in every compilation unit. This
can conveniently by done by defining 'PASS2' on the compiler command line
using the option -DPASS2, with the following code in every source file:
#ifdef PASS2
#include "distr.inc"
#endif
This time the compiler uses the optimized calling convention specified for each
function in the linker generated header file. The second pass linking is run
without any of the distribute feature specifiers: -DIST should not be included in
the command line. This ensures that the absolute file is generated.
This two pass process could easily be handled by a make file.