Home | History | Annotate | Line # | Download | only in libdos
makestrerror.awk revision 1.1
      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.1 1998/09/01 19:53:26 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_errno.h\""
     15 		print "	.text"
     16 		print "	.even"
     17 		print "	.globl	_dos_nerr"
     18 		print "_dos_nerr:"
     19 		print "	.long	DOS_ELAST+1"
     20 		print ""
     21 		print "	.globl	_dos_strerror"
     22 		print "_dos_strerror:"
     23 		print "	movel	sp@(4),d0"
     24 		print "	moveq	#80,d1"
     25 		print "	cmpl	d0,d1"
     26 		print "	bnes	Lnot80"
     27 		print "	moveq	#DOS_EEXIST,d0"
     28 		print "Lnot80:	moveq	#DOS_ELAST+1,d1"
     29 		print "	cmpl	d1,d0"
     30 		print "	bcss	Lnotuk"
     31 		print "	movel	d1,d0"
     32 		print "Lnotuk:	lslw	#1,d0"
     33 		print "Lh1:\tmovew\tpc@(Lerrtbl-Lh1-2:B,d0:W),d0\t| 303B 000A"
     34 		print "Lh2:\tlea\tpc@(Lerrtbl-Lh2-2:B,d0:W),a0\t| 41FB 0006"
     35 		print "	movel	a0,d0"
     36 		print "	rts"
     37 		print ""
     38 		print "Lerrtbl:"
     39 		nmsg = 0
     40 	} else if ($0 ~ /^\/\* dos_errlist end \*\/$/) {
     41 		print "\t.word\tLukmsg-Lerrtbl		| default message"
     42 		print ""
     43 		# error strings
     44 		for (i = 0; i < nmsg; i++)
     45 			print "Lmsg" i ":\t.asciz\t\"" msg[i] "\""
     46 
     47 		print "Lukmsg:\t.asciz\t\"Unknown error\""
     48 		exit
     49 	} else {
     50 		if ($3 != nmsg || $4 != "/*") {
     51 			printf FILENAME ":" NR ": format error"
     52 			exit(1);
     53 		}
     54 		# offset table
     55 		print "\t.word\tLmsg" nmsg "-Lerrtbl"
     56 		$1 = ""
     57 		$2 = ""
     58 		$3 = ""
     59 		$4 = ""
     60 		msg[nmsg] = substr($0, 5, length - 7)
     61 		nmsg++
     62 	}
     63 }
     64