comparison extra/as @ 72:84eb35251849

Added extra scripts that can be used to run gcc6809 with lwtools as its binutils
author lost@l-w.ca
date Tue, 12 Apr 2011 14:16:36 -0600
parents
children f5a88f147fae
comparison
equal deleted inserted replaced
71:6dafb4f0fa56 72:84eb35251849
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 -Qy)
103 # "identify in output" - ignore
104 true
105 ;;
106 -*)
107 echo "as (m6809): unrecognized option $arg"
108 exit 1
109 ;;
110 *)
111 input_file=$arg
112 ;;
113 esac
114 done
115
116 # Complain if no input files given. We don't support redirecting
117 # from standard input.
118
119 if [ "x$input_file" = "x" ]; then
120 fatal_error "no input file specified"
121 fi
122
123 # Invoke the real (lwasm) assembler.
124 # The -o option specifies the output file name
125 # --obj creates object files
126 # --pragma=undefextern causes undefined symbols to be assumed external
127 # --pragma=cescapes allows C escape syntax in strings
128 #echo lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes $input_file
129 lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes --pragma=importundefexport $input_file
130 rc=$?
131
132 # OK, see if the assembler succeeded or not.
133 # If it failed, the source is copied to /tmp/as6809_error.s
134 # so that it can be inspected. GCC will normally delete any
135 # temporary .s files that it generates. This makes debugging
136 # the compiler easier.
137 #
138 # lwasm does not create an output file if it errors out but it also doesn't
139 # remove an existing file if it fails so we remove it anyway...
140
141 if [ "$rc" != "0" ]; then
142 cp -p $input_file /tmp/as6809_error.s
143 rm -f $asoutput_file
144 exit $rc
145 fi
146
147 # we don't need anything fancy here since lwasm supports specifying output
148 # file names....