179
|
1 #!/bin/sh
|
|
2 #
|
|
3 # Copyright 2009 by William Astle <lost@l-w.ca>
|
|
4 #
|
|
5 #This file is part of LWASM.
|
|
6 #
|
|
7 #LWASM is free software: you can redistribute it and/or modify it under the
|
|
8 #terms of the GNU General Public License as published by the Free Software
|
|
9 #Foundation, either version 3 of the License, or (at your option) any later
|
|
10 #version.
|
|
11 #
|
|
12 #This program is distributed in the hope that it will be useful, but WITHOUT
|
|
13 #ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 #FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
15 #more details.
|
|
16 #
|
|
17 #You should have received a copy of the GNU General Public License along with
|
|
18 #this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
|
20 # this was based somewhat on the "as" script from gcc6809
|
|
21
|
|
22 #echo "LWASM-as $0 $*"
|
|
23
|
|
24 show_version () {
|
|
25 cat <<END
|
|
26 LWASM (GNU assembler frontend) 2.3
|
|
27 This program is free software; you may redistribute it under the terms of
|
|
28 the GNU General Public License. This program has absolutely no warranty.
|
|
29 END
|
|
30 }
|
|
31
|
|
32 fatal_error () {
|
|
33 echo $* 1>&2
|
|
34 exit 1
|
|
35 }
|
|
36
|
|
37 # Assume nothing.
|
|
38
|
|
39 input_file=
|
|
40 output_file=
|
|
41 list_file=
|
|
42 options=
|
|
43 list_file_enabled=n
|
|
44
|
|
45 # Parse the command-line options. See the GNU 'as' man page for
|
|
46 # an explanation of all these options. Our goal is to translate
|
|
47 # them into lwasm form.
|
|
48
|
|
49 while [ "$1" != "" ]; do
|
|
50 arg=$1; shift
|
|
51 case $arg in
|
|
52 -m6809)
|
|
53 true
|
|
54 ;;
|
|
55 -gn)
|
|
56 # Generate NoICE debug symbols
|
|
57 # ignored - no output formats support debugging symbols
|
|
58 ;;
|
|
59 -gs)
|
|
60 # Generate SDCC debug symbols
|
|
61 # ignored - no output formats supprt debugging symbols
|
|
62 ;;
|
|
63 # --globalize-symbols)
|
|
64 # # Make all symbols global
|
|
65 # # lwasm does not support globalizing everything by default
|
|
66 # ;;
|
|
67 -m*)
|
|
68 fatal_error "invalid CPU option '$arg'"
|
|
69 ;;
|
|
70 --)
|
|
71 fatal_error "standard input not supported"
|
|
72 ;;
|
|
73 # -a*)
|
|
74 # options="${options}lc"
|
|
75 # list_file_enabled=y
|
|
76 # ;;
|
|
77 -I*)
|
|
78 #include_file=${arg#-I}
|
|
79 #echo "warning: include path '$include_file' ignored"
|
|
80 ;;
|
|
81 -MD)
|
|
82 fatal_error "assembler option '$arg' not supported"
|
|
83 ;;
|
|
84 -o)
|
|
85 output_file=$1; shift
|
|
86 ;;
|
|
87 -v|-version)
|
|
88 show_version
|
|
89 ;;
|
|
90 --version)
|
|
91 show_version
|
|
92 exit 0
|
|
93 ;;
|
|
94 -D|-f|-K|--traditional-format|-w|-x|-Z|-W|--no-warn)
|
|
95 # These options are accepted but ignored by GNU as.
|
|
96 true
|
|
97 ;;
|
|
98 # =*)
|
|
99 # # Set the name of the listing file
|
|
100 # list_file=${arg#=}
|
|
101 # ;;
|
|
102 -*)
|
|
103 echo "as (m6809): unrecognized option $arg"
|
|
104 exit 1
|
|
105 ;;
|
|
106 *)
|
|
107 input_file=$arg
|
|
108 ;;
|
|
109 esac
|
|
110 done
|
|
111
|
|
112 # Complain if no input files given. We don't support redirecting
|
|
113 # from standard input.
|
|
114
|
|
115 if [ "x$input_file" = "x" ]; then
|
|
116 fatal_error "no input file specified"
|
|
117 fi
|
|
118
|
|
119 # Invoke the real (lwasm) assembler.
|
|
120 # The -o option specifies the output file name
|
|
121 # --obj creates object files
|
|
122 # --pragma=undefextern causes undefined symbols to be assumed external
|
|
123 # --pragma=cescapes allows C escape syntax in strings
|
|
124 #echo lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes $input_file
|
|
125 lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes $input_file
|
|
126 rc=$?
|
|
127
|
|
128 # OK, see if the assembler succeeded or not.
|
|
129 # If it failed, the source is copied to /tmp/as6809_error.s
|
|
130 # so that it can be inspected. GCC will normally delete any
|
|
131 # temporary .s files that it generates. This makes debugging
|
|
132 # the compiler easier.
|
|
133 #
|
|
134 # lwasm does not create an output file if it errors out but it also doesn't
|
|
135 # remove an existing file if it fails so we remove it anyway...
|
|
136
|
|
137 if [ "$rc" != "0" ]; then
|
|
138 cp -p $input_file /tmp/as6809_error.s
|
|
139 rm -f $asoutput_file
|
|
140 exit $rc
|
|
141 fi
|
|
142
|
|
143 # we don't need anything fancy here since lwasm supports specifying output
|
|
144 # file names....
|