1#! /usr/bin/awk -f 2# 3# create dos_strerror() from dos_errno.h 4# 5# written by Yasha (ITOH Yasufumi) 6# public domain 7# 8# $NetBSD: makestrerror.awk,v 1.2 1999/11/11 08:14:43 itohy Exp $ 9 10/^\/\* dos_errlist begin \*\/$/,/^\/\* dos_errlist end \*\/$/ { 11 if ($0 ~ /^\/\* dos_errlist begin \*\/$/) { 12 # assembly code 13 print "| This file is automatically generated. DO NOT EDIT." 14 print "#include \"dos_asm.h\"" 15 print "#include \"dos_errno.h\"" 16 print " .text" 17 print " .even" 18 print "GLOBAL(dos_nerr)" 19 print " .long DOS_ELAST+1" 20 print "" 21 print "ENTRY_NOPROFILE(dos_strerror)" 22 print " movel %sp@(4),%d0" 23 print " moveq #80,%d1" 24 print " cmpl %d0,%d1" 25 print " bnes Lnot80" 26 print " moveq #DOS_EEXIST,%d0" 27 print "Lnot80: moveq #DOS_ELAST+1,%d1" 28 print " cmpl %d1,%d0" 29 print " bcss Lnotuk" 30 print " movel %d1,%d0" 31 print "Lnotuk: lslw #1,%d0" 32 print "Lh1:\tmovew\t%pc@(Lerrtbl-Lh1-2:B,%d0:W),%d0\t| 303B 000A" 33 print "Lh2:\tlea\t%pc@(Lerrtbl-Lh2-2:B,%d0:W),%a0\t| 41FB 0006" 34 print " movel %a0,%d0" 35 print " rts" 36 print "" 37 print "Lerrtbl:" 38 nmsg = 0 39 } else if ($0 ~ /^\/\* dos_errlist end \*\/$/) { 40 print "\t.word\tLukmsg-Lerrtbl | default message" 41 print "" 42 # error strings 43 for (i = 0; i < nmsg; i++) 44 print "Lmsg" i ":\t.asciz\t\"" msg[i] "\"" 45 46 print "Lukmsg:\t.asciz\t\"Unknown error\"" 47 exit 48 } else { 49 if ($3 != nmsg || $4 != "/*") { 50 printf FILENAME ":" NR ": format error" 51 exit(1); 52 } 53 # offset table 54 print "\t.word\tLmsg" nmsg "-Lerrtbl" 55 $1 = "" 56 $2 = "" 57 $3 = "" 58 $4 = "" 59 msg[nmsg] = substr($0, 5, length - 7) 60 nmsg++ 61 } 62} 63