Page 404 - Programming Microcontrollers in C
P. 404

Putting It All Together   389

                       clra                     ; reset the bss
                       clrb
                       ldx       #__sbss        ; start of bss
                       bra       loop           ; start loop
                   zbcl:
                       std       2,x+           ; clear word
                   loop:
                       cpx       #__memory ; up to the end
                       blo       zbcl           ; and loop
                       lds       #__stack  ; initialize stack pointer
                       jsr       _main          ; execute main
                   _exit:
                       bra       _exit          ; stay here
                   ;
                       end

                              Listing 7-19: Crts.s C Program Start-Up Function
                              Any linker for an embedded system requires some type of linker
                          command file. The command file for this application is as follows.
                   #  link command file for test program
                   #  Copyright (c) 1996 by COSMIC Software
                   #
                   +seg .text -b 0x8000 -n .text# program start address
                   +seg .const -a .text # constants follow program
                   +seg .data -b 0x800  # data start address
                   +seg .eeprom -b 0xd00 -m768 #identify EEPROM block
                   +def __sbss=@.bss              # start address of bss
                   crts.o                         # startup routine
                   monitor.o                      # applications programs
                   saveit.o
                   encode.o
                   decode.o
                   reset.o
                   numbdup.o
                   putbcd.o
                   priout.o
                   priafter.o
                   serial.o
   399   400   401   402   403   404   405   406   407   408   409