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