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