Page 320 - Programming Microcontrollers in C
P. 320
Cosmic MC68HC16 Compiler 305
Cosmic MC68HC16 Compiler
The Cosmic compiler for the MC68HC16 is quite similar to the
MC68HC11 compiler. Its operation is the same. Several command
files are used in the course of executing a compilation, and these
files will be shown here. The first file is the program that completely
compiles and links the program. This file is shown below:
c -dlistcs +s +o %1.c
lnkh16 < %1.lnk
hexh16 -s -o %1.hex %1.h16
pause
This command file requires as an input a file with a .c extension.
For example, if you were to compile the program newpwm.c , you
would enter
c:\>comp newpwm
The first line will invoke the compiler and create a listing file, a
source assembly listing, and an object file named newpwm.o . The
second line invokes the linker named lnkh16, and requires an input
file named newpwm.lnk . The .lnk file is similar to that one dis
cussed in Chapter 5, and a listing of the one for this program is shown
below.
# Link command file for NEWPWM.c
+h # multi-segment output
-max 0xfffff # maximum size
-ps16 -pc. # set up banking options
-o newpwm.h16 # output file name
+text -b 0 # reset vectors start
address
vector.o # vectors
+text -b 0x400 # program start address
+data -b 0x700 # data start address
crts.o # startup routine
newpwm.o # application program
c:/cc16/lib/libi.h16 # C library (if needed)
c:/cc16/lib/libm.h16 # machine library
+def __memory=__bss__ # symbol used by library