Page 321 - Programming Microcontrollers in C
P. 321
306 Chapter 6 Large Microcontrollers
Here the entries are fairly well explained by the comments. Note
that two additional input files are required by this link file. The vec
tor table vector.o is a compiled version of the vector listing given
in Listing 6-1. The crts.o object module is an assembled version
of the start-up routine for this machine. Both of these routines must
be written and compiled or assembled for the specific program. Oth
erwise, the link command file is as discussed in Chapter 5. A version
of crts.s is shown below:
;C STARTUP FOR 68HC16
;Copyright (c) 1991 by COSMIC (France)
;
.external _main, __memory
.external ._main, .__bss__
.public _exit, __stext
.psect _bss
sbss:
.psect _text
__stext:
ldk #.__bss__
tbek
tbxk
tbzk
ldab #0fh ; start of the i/o memory space
tbyk ; put it in y
ldx #sbss ; start of bss
clrd ; to be zeroed
bra mtest ; start loop
bcl:
std 0,x ; clear memory
aix #2 ; next word
mtest:
cpx #__memory ; end of memory ?
blo bcl ; no, continue
aix #1000h ; 4K stack
txs ; for instance
jsr _main,#._main ; call application
_exit:
bra _exit ; loop here if return