annotate extra/as @ 216:11a2b63bbdce

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