#!/bin/sh # sh script -- linker for the Hawk, using the smal assembler # link [parameters] a b c d e ... # link -help -- gives more documentation # where is the SMAL assembler executable? # Where is monitor.o stored? smal="/space/jones/smalstuff/smal32.intel -U /space/jones/hawk" usepath="/space/jones/hawk/" if [ $# -lt 1 ] then echo "link requires parameters" echo "link -help is available" exit 1 fi if [ -help = $1 ] then echo "link [parameters] a b c d e ... links SMAL object and library files named a, b, c, d and e into a new loadable file called link.o no additional parameters are required, but the following are allowed:" echo " -r nnnn -- start relocatable code at nnnn (a hex address) -c nnnn -- start commons at nnnn (a hex address) -m -- suppress linking with standard monitor -o ffff -- direct output to file ffff.o instead of link.o " exit 1 fi # defaults for linkage origin=1000 common=10000 monitor=monitor.o outfile=link # parse options -- loop exits on first non-option while [ $# -gt 0 ] do case $1 in -c) if [ $# -gt 1 ] then common=$2 shift shift else echo "link -c nnn requires a hex number nnn" echo "link -help explains options" exit 1 fi ;; -r) if [ $# -gt 1 ] then origin=$2 shift shift else echo "link -r nnn requires a hex number nnn" echo "link -help explains options" exit 1 fi ;; -o) if [ $# -gt 1 ] then outfile=$2 shift shift else echo "link -o fff requires a file name fff" echo "link -help explains options" exit 1 fi ;; -m) monitor="" shift ;; -*) echo "link $1 option unknown" echo "link -help explains options" exit 1 ;; *) break ;; esac done if [ $# -lt 1 ] then echo "link found no object files" echo "link -help explains options" exit 1 fi # build linker control file header echo TITLE "smal $*" > ${outfile}.a echo ".=#${origin}" >> ${outfile}.a echo "C=#${common}" >> ${outfile}.a if [ \"${monitor}\" != \"\" ] then echo "USE \"${usepath}${monitor}\"" >> ${outfile}.a fi # build linker control file body while [ $# -gt 0 ] do case $1 in -*) rm ${outfile}.a echo "link $1 unexpected option" echo "link -help explains command format" exit 1 ;; *) if [ -r $1 ] then echo USE \"$1\" >> ${outfile}.a shift elif [ -r ${usepath}$1 ] then echo USE \"${usepath}$1\" >> ${outfile}.a shift else echo "link $1 unreadable object file" echo "link -help is available" exit 1 fi ;; esac done # build linker control file trailer echo RUNUSED=C >> ${outfile}.a echo RUNAVAIL=#20000 >> ${outfile}.a # actually do the linkage ${smal} -L ${outfile}.a rm ${outfile}.a