3 # create IOCS call interface from iocs.h
5 # written by Yasha (ITOH Yasufumi)
8 # $NetBSD: makeiocscalls.awk,v 1.1 1998/09/01 19:53:54 itohy Exp $
11 argsiz
["l"] =
4; argsiz
["w"] =
2
12 argsiz
["lb31"] =
4; argsiz
["wb8"] =
2
14 for (i =
0; i
< 16; i
++) {
15 reg =
substr("d0d1d2d3d4d5d6d7a0a1a2a3a4a5a6a7", i
*2+1, 2)
18 print "#include <machine/asm.h>"
21 $
1 ==
"/*" && ($
2 ~
/^
[0-9a
-f
][0-9a
-f
]$
/ || $
2 ==
"(none)") {
36 for (i =
3; i
<=
NF && $i
!= "*/" && $i
!= ";"; i
++) {
42 for (i
++; i
<=
NF && $i
!= "*/"; i
++) {
45 else if ($i ==
"err_d0")
47 else if ($i ==
"noret")
49 else if ($i ==
"c_md")
51 else if ($i ==
"b_super")
53 else if ($i ==
"sp_regst")
55 else if ($i ==
"b_curmod")
57 else if ($i ==
"b_curpat")
59 else if ($i ==
"b_scroll")
61 else if ($i ==
"trap15")
64 print FILENAME ":" NR ": unknown opt", $i
70 print FILENAME ":" NR ": malformed input line:" $
0
76 for (i
++; i
<=
NF; i
++) {
78 if ($i ~
/^\
**IOCS_
[A
-Z0
-9_
]*$
/) {
80 while (funcnam ~
/^\
*/) {
81 funcnam =
substr(funcnam
, 2, length(funcnam
) -1)
88 print FILENAME ":" NR ": can't find function name"
92 # output assembly code
93 print "ENTRY_NOPROFILE(" funcnam
")"
96 for (i =
0; i
< 16; i
++) {
99 for (i =
0; i
< narg
; i
++) {
101 if (r ~
/^o
[ad
][0-7]$
/)
103 else if (r ~
/^d
[0-7]=
/)
105 if (r
!= "d0" && !regno
[r
]) {
106 print FILENAME ":" NR ": unknown arg type:", arg
[i
]
109 if (r !~
/^
[da
][01]$
/) # may not be saved
110 savereg
[regno
[r
]] = r
114 for (i =
0; i
< 16; i
++) {
120 print "\tmoveml\t%d2-%d7/%a2-%a6,%sp@-"
122 } else if (nsave ==
1 || nsave ==
2){
124 for (i =
0; i
< 16; i
++) {
126 print "\tmovel\t%" savereg[i] ",%sp@
-"
128 } else if (nsave > 2) {
131 for (i = 0; i < 16; i++) {
133 saveregs = saveregs "/%" savereg
[i
]
135 saveregs =
substr(saveregs
, 2, length(saveregs
) - 1)
136 print "\tmoveml\t" saveregs
",%sp@-"
140 # XXX this should be more intelligent
141 argoff = nsave
* 4 + 4
142 # input arguments for IOCS call
149 for (i =
0; i
< narg
&& arg
[i
] ~
/^
[ad
]/; i
++) {
151 if (a ~
/^d
[1-7]=
[0-9][0-9]*$
/) {
152 immarg = immarg
" " a
156 if (regno
[a1
] >= regno
[a
])
161 iargreglist = iargreglist
"/%" a
167 for ( ; i < narg; i++) {
168 if (arg[i] ~ /^[o]d[0-7]/) {
169 oarg = oarg " " arg[i]
172 print "unknown arg
:", arg[i]
176 # remove leading char
177 iarg = substr(iarg, 2, length(iarg) - 1);
178 iargreglist = substr(iargreglist, 2, length(iargreglist) - 1);
179 immarg = substr(immarg, 2, length(immarg) - 1);
180 oarg = substr(oarg, 2, length(oarg) - 1);
184 else if (niarg == 1 && iarg !~ /\=/) {
185 print "\tmovel
\t%sp@
(" argoff "),%" iarg
"\t| 1arg"
186 } else if (iarg_incorder
&& iarg !~
/\=
/) {
187 print "\tmoveml\t%sp@(" argoff
")," iargreglist
"\t| inc order"
188 } else if (iarg ==
"a1/d1") {
189 print "\tmoveal\t%sp@(" argoff
"),%a1"
190 print "\tmovel\t%sp@(" argoff
+ 4 "),%d1"
191 } else if (iarg ==
"d1/a1/d2") {
192 print "\tmoveml\t%sp@(" argoff
"),%d1-%d2/%a1"
193 print "\texg\t%d2,%a1"
194 } else if (iarg ==
"a1/a2/d1") {
195 print "\tmoveml\t%sp@(" argoff
"),%a1/%a2"
196 print "\tmovel\t%sp@(" argoff
+ 8 "),%d1"
197 } else if (iarg ==
"a1/a2/d1/d2") {
198 print "\tmoveml\t%sp@(" argoff
"),%d1-%d2/%a1-%a2"
199 print "\texg\t%d1,%a1"
200 print "\texg\t%d2,%a2"
201 } else if (iarg ==
"a1/d1/d2") {
202 print "\tmoveml\t%sp@(" argoff
"),%d0-%d2"
203 print "\tmovel\t%d0,%a1"
204 } else if (iarg ==
"d1=bb") {
205 print "\tmoveq\t#0,%d1"
206 print "\tmoveb\t%sp@(" argoff
+ 3 "),%d1"
207 print "\tlslw\t#8,%d1"
208 print "\tmoveb\t%sp@(" argoff
+ 7 "),%d1"
210 } else if (iarg ==
"d1=ww") {
211 print "\tmovew\t%sp@(" argoff
+ 2 "),%d1"
213 print "\tmovew\t%sp@(" argoff
+ 6 "),%d1"
215 } else if (iarg ==
"d1=hsv") {
216 print "\tmoveb\t%sp@(" argoff
+ 3 "),%d1"
218 print "\tmoveb\t%sp@(" argoff
+ 7 "),%d1"
219 print "\tlslw\t#8,%d1"
220 print "\tmoveb\t%sp@(" argoff
+ 11 "),%d1"
221 print "\tandl\t#0x00ff1f1f,%d1"
223 } else if (iarg ==
"a1/d1=bb") {
224 print "\tmoveal\t%sp@(" argoff
"),%a1"
225 print "\tmoveq\t#0,%d1"
226 print "\tmoveb\t%sp@(" argoff
+ 7 "),%d1"
227 print "\tlslw\t#8,%d1"
228 print "\tmoveb %sp@(" argoff
+ 11 "),%d1"
230 } else if (iarg ==
"d1/d2=ww") {
231 print "\tmovel\t%sp@(" argoff
"),%d1"
232 print "\tmovew\t%sp@(" argoff
+ 6 "),%d2"
234 print "\tmovew\t%sp@(" argoff
+ 10 "),%d2"
236 } else if (iarg ==
"d1=ww/a1") {
237 print "\tmoveml\t%sp@(" argoff
"),%d0-%d1/%a1"
239 print "\tmovew\t%d0,%d1"
242 } else if (iarg ==
"d1=ww/d2=ww") {
243 print "\tmoveml\t%sp@(" argoff
"),%d1-%d2"
245 print "\tmovew\t%d2,%d1"
246 print "\tmovew\t%sp@(" argoff
+ 10 "),%d2"
248 print "\tmovew\t%sp@(" argoff
+ 14 "),%d2"
251 print "unsupported iarg:", iarg
257 print "\tandl\t#0x80000000,%d1"
258 print "\tmoveb\t%d0,%d1"
262 print "\tmoveq\t#1,%d0"
263 print "\tcmpl\t%d1,%d0"
264 # print "\tbcss\tLerr"
270 # print "\tbeqs\tLerr"
275 print "\tmoval\t%sp@+,%a0"
276 print "\tmoval\t%sp@,%a1"
281 for (i =
0; i
< narg
&& arg
[i
] ~
/^
[ad
]/; i
++) {
283 if (a ~
/^d
[1-7]=
[0-9][0-9]*$
/) {
285 v =
substr(a
, 4, length(a
)-3)
286 print "\tmoveq\t#" v
",%" r
292 # -1: flush(3), -2: set default(2), other: set by the value(4)
293 print "\tmovel
\t%d2
,%d0
"
294 print "\taddql
\t#1,%d0"
295 print "\tbeqs\tLcachemd"
296 print "\tmoveq\t#2,%d1"
297 print "\taddql\t#1,%d0"
298 print "\tbnes\tLcachemd"
299 print "\tmoveq\t#4,%d1"
305 print "\tcmpl\t%d1,%d2"
306 print "\tbcss\tLscriocs"
307 print "\tmovel\t%d2,%d1"
312 print "\tmoveal\t%sp@(" argoff
"),%a0 | inregs"
313 print "\tmoveml\t%a0@,%d0-%d7/%a1-%a6"
317 if (iocsno
!= "(none)") {
318 if (iocsno ~
/^
[89abcdef
].
/)
319 iocsno =
"ffffff" iocsno
320 print "\tmoveq\t#0x" iocsno
",%d0"
325 print "\tmoveal\t%sp@(" argoff
"),%a0 | outregs"
326 print "\tmoveml\t%d0-%d7/%a1-%a6,%a0@"
329 if (err_d0
&& noarg
) {
331 # print "\tbnes\tLerr"
336 # XXX this should be more intelligent
339 else if (oarg ==
"od2") {
340 print "\tmoveal\t%sp@(" argoff
"),%a0"
342 print "\tmovel\t%d2,%a0@"
343 } else if (oarg ==
"od1 od2 od0") {
344 print "\tmoveml\t%sp@(" argoff
"),%a0/%a1"
346 print "\tmovel\t%d1,%a0@"
347 print "\tmovel\t%d2,%a1@"
348 print "\tmoveal\t%sp@(" argoff
"),%a0"
350 print "\tmovel\t%d0,%a0@"
351 } else if (oarg ==
"od2 od3") {
352 print "\tmoveml\t%sp@(" argoff
"),%a0/%a1"
354 print "\tmovel\t%d2,%a0@"
355 print "\tmovel\t%d3,%a1@"
356 } else if (oarg ==
"od2 od3 od4 od5") {
357 print "\tmoveml\t%sp@(" argoff
"),%a0/%a1"
359 print "\tmovel\t%d2,%a0@"
360 print "\tmovel\t%d3,%a1@"
361 print "\tmoveml\t%sp@(" argoff
"),%a0/%a1"
363 print "\tmovel\t%d4,%a0@"
364 print "\tmovel\t%d5,%a1@"
366 print "unsupported oarg:", oarg
370 if ((err_d0
&& noarg
) || b_curmod
|| b_curpat
)
376 print "\tmovel\t%d2,%d0"
380 print "\tmoveml\t%sp@+,%d2-%d7/%a2-%a6"
381 } else if (nsave ==
1 || nsave ==
2){
383 for (i =
16 - 1; i
>=
0; i
--) {
385 print "\tmovel\t%sp@+,%" savereg[i]
387 } else if (nsave > 2) {
389 print "\tmoveml
\t%sp@
+," saveregs
397 print "#ifdef __SVR4_ABI__\n\tmoveal\t%d0,%a0\n#endif"