[comp.sources.amiga] Tools from Bryce Nesbitt

doc@j.cc.purdue.edu (Craig Norborg) (05/24/87)

    Below are the sources to echo, loadit, setlace and why written in
68000 assembly by Bryce Nesbitt.
    Enjoy,
	Craig Norborg

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	echo.asm
#	loadit.asm
#	setlace.asm
#	why.asm
# This archive created: Sun May 24 00:52:39 1987
# By:	Craig Norborg (Purdue University Computing Center)
cat << \SHAR_EOF > echo.asm
;tabs every 8
;
;SetLace implementation by Bryce Nesbitt, based on an example by Bob
;Pariseau of C-A. Public Domain.
;
;On most monitors a non-interlaced display will leave black bars between
;each scan line.  This is evident in all the 200 line display modes of the
;Amiga 1000.  For photographs or longer persistence displays this black is
;undesirable.  SetLace instructs the system to set interlace; on each
;successive field the same display data will be painted in between that of 
;the previous field.  This may be a necessity for use of the Amiga with
;some NTSC video gear and broadcast television equipment.  For most computer
;(non-broadcast) applications interlace will flicker unacceptably unless
;the contrast, brightness and room lighting are all turned way down.
;
;CLI Syntax:	SetLace		;Flip (XOR) interlace
;		SetLace 1	;Turn lace on
;		SetLace 0	;Turn lace off
;Workbench:			;Flip (XOR)
;ALL screens will be forced to interlace
;
;Author correspondence, bug or stupidity reports may be directed to:
;	Bryce Nesbitt
;	1712 Marin Ave.
;	Berkeley, Ca 94707-2902
*************************
	NOLIST
	INCLUDE 'exec/types.i'
	INCLUDE 'libraries/dosextens.i'
	INCLUDE 'graphics/display.i'
	INCLUDE 'graphics/gfxbase.i'
	;INCLUDE 'lib/exec_lib.i'	;eliminates link with amiga.lib
	;INCLUDE 'lib/dos_lib.i'	;non-standard, and very speedy!
	;INCLUDE 'lib/intuition_lib.i'	;Can be fabricated from the fd.files
	;INCLUDE 'lib/graphics_lib.i'	;directory. (see exec/exec_lib.i)
	LIST
jsrlib	macro
	xref	_LVO\1			;^Nuke for use as above^
	jsr	_LVO\1(a6)
	endm
jmplib	macro
	xref	_LVO\1
	jmp	_LVO\1(a6)
	endm
**************************
		CODE
startup:	move.l	a0,a4		;CLI line pointer
		move.l	d0,d4		;CLI line length
		move.l	4,a6
		suba.l	a1,a1		;Get THIS task
		jsrlib	FindTask
		move.l	d0,a5
		moveq	#0,d0		;Set zero for later
		move.l	pr_CLI(a5),d1	;Pointer to CLI only structure
		bne.s	fromCLI		;If not zero, then save a zero...
;
; If called from Workbench a message will be sent.  This waits for it,
;  and saves it's pointer to be returned to Workbench later.
;
		lea	pr_MsgPort(a5),a0
		jsrlib	WaitPort
		lea	pr_MsgPort(a5),a0
		jsrlib	GetMsg		;Message pointer in D0
		moveq	#0,d4		;clear CLI line pointer
fromCLI 	move.l	d0,-(a7)	;Save message for later...


******************************** [A6=ExecBase][a5=this task][a4=CLI line]
* [d4=CLI length]
returncode	equr	d7
ibase		equr	d6
gbase		equr	d5
* (d4,a4,a5)

		moveq	#20,returncode	;default to 'severe failure' code
		lea	IntuiName(pc),a1
		moveq	#0,d0
		jsrlib	OpenLibrary
		move.l	d0,ibase	 ;Error check. What a pain! Could we
		beq.s	e_Intui		 ;not agree that Intuition and a few
		lea	Graphname(pc),a1 ;other core libraries will always
		moveq	#0,d0		 ;be openable??
		jsrlib	OpenLibrary
		move.l	d0,gbase
		beq.s	e_Graph
;
;Modifying the system-wide bplcon0.  From here we can change all screens
;to INTERLACE and turn tricks like disabling colorburst.  The Forbid/
;Permit pair is used for saftey while modifying this stuff.
;
		jsrlib	Forbid
		move.l	gbase,a6	;gbase

		subq.l	#2,d4		;0=wb 1=cli no args 2=1 arg
		bmi.s	flip		;wb, or cli flip
		bne.s	toomanychars
		cmpi.b	#'0',(a4)
		beq.s	clear
		cmpi.b	#'1',(a4)
		bne.s	badargs

setlace		ori.w	#INTERLACE,gb_system_bplcon0(a6)	;Set lace
		bra.s	break
clear		andi.w	#$ffff-INTERLACE,gb_system_bplcon0(a6)	;Clear lace
		bra.s	break
flip		eori.w	#INTERLACE,gb_system_bplcon0(a6) 	;Flip lace

break		move.l	ibase,a6
		jsrlib	RemakeDisplay	;The big one! Rethink ALL displays
		moveq	#0,returncode	;Everything is OK!
		bra.s	goodexit
badargs
toomanychars	move.l	#120,pr_Result2(a5) ;'arg line invalid or too long'
		moveq	#10,d7		;return code 10, less serious error
goodexit	move.l	4,a6
		jsrlib	Permit
;
;RemakeDisplay() is spec'ed to do a Forbid() and then Permit() around it's
; lengthy operation. This is just a saftey valve in case it did not...
;
		move.l	gbase,a1
		jsrlib	CloseLibrary
e_Graph		move.l	ibase,a1
		jsrlib	CloseLibrary
e_Intui
******************************** (a7)+=message d7=return code
ExitToDOS	move.l	(a7)+,d6
		beq.s	NotWB	;If saved pointer is zero, exit to CLI...
;
; Return the startup message to the parent Workbench tool. The forbid
; is needed so workbench can't UnLoadSeg() the code too early.
;
		move.l	4,a6
		jsrlib	Forbid
		move.l	d6,a1		;message pointer
		jsrlib	ReplyMsg
NotWB		move.l	d7,d0		;Set "failat" code
		rts
IntuiName	dc.b   'intuition.library',0
Graphname	dc.b  'graphics.library',0
MyName		dc.b 'Bryce Nesbitt'
;-- this is the end --
SHAR_EOF
cat << \SHAR_EOF > loadit.asm
;
; LoadIt (C)1987 Bryce Nesbitt.  Revokable, free, non-exclusive licence
; hereby granted to any sentient being to use or abuse this code in any way
; whatsoever provided that this and any other copyright notices remain fully
; attached, and with the exception that, without prior written permission,
; it not be utilized by any entity that has been commonly referred to as
; Robert W. Skyles, Skyles Electric Works, Jim Drew, Regie Warren or any
; organization founded by, controlled, employing or profiting any such
; entity, it's offspring or spouses.  FISH use ok.
;
; Author correspondence, bug or stupidity reports may be directed to:
; Bryce Nesbitt 	;bryce@cogsci.Berkeley.EDU
; 1712 Marin Ave.
; Berkeley, Ca 96034-9412
;
; USAGE:     LoadIt <file>
;
; FUNCTION:  Loads a file into memory, and reports the address.  The
;	     file remains at that address until a re-boot.
;
; EXAMPLES:  LoadIt c:install
;	     LoadIt Read Me    ;No parsing is done. Quotes not needed
;
; BUGS:      If there is an error during the read the allocated memory will
;	     not be returned.
;
; Proper size when assembled with the Metacompost assembler
; and BLINK'ed is 424 bytes
;
; RETURN CODE CONVENTION:
;
; FAIL	(20) - serious error, no DOS, memory etc.
; ERROR (10) - user caused error. (file not found, syntax)
; WARN	(5)  - technicality such as file not found on DELETE.
;
**************************
	NOLIST
	INCLUDE 'libraries/dosextens.i'
	;INCLUDE 'lib/exec_lib.i'        ;eliminates link with amiga.lib
	;INCLUDE 'lib/dos_lib.i'         ;non-standard, but very speedy!
	LIST
jsrlib	macro
	xref	_LVO\1
	jsr	_LVO\1(a6)
	endm
blink	macro
	bchg.b #1, $bfe001
	endm
**************************
	CODE
;
reserved1	equr a7
reserved2	equr a6
lock		equr a5
handle		equr a4
block		equr a3
reserved3	equr a2

returncode	equr d7
resultcode	equr d6
size		equr d5
inline		equr d4
reserved4	equr d3
reserved5	equr d2

;-- "parse" the string --
		clr.b	-1(a0,d0)	;null terminate string
		move.l	a0,inline	;the quick and dirty way.
;-- Set defaults --
		suba.l	lock,lock
		suba.l	handle,handle
		moveq	#10,returncode	;default ERROR code
;-- Open DOS --
		move.l	4,a6
		lea	DOSName(pc),a1
		jsrlib	OldOpenLibrary	;1.0 compatible
		move.l	d0,a6		;Look Ma, no error check!
;-- Get a lock --
		move.l	inline,d1
		moveq	#ACCESS_READ,d2
		jsrlib	Lock
		move.l	d0,d1
		move.l	d0,lock
		beq.s	e_lock
;-- Examine locked object [d1-lock] --
		suba.l	#fib_SIZEOF,a7
		move.l	a7,d2
		;[lock in d1]
		jsrlib	Examine
		tst.l	d0	;grrr
		beq.s	e_examine
		move.l	fib_Size(a7),d0
		adda.l	#fib_SIZEOF,a7
		move.l	d0,size
		beq	e_nosize
;-- Get enough memory to fit [d0-size] --
		move.l	a6,-(a7)
		;[size in d0]
		moveq	#0,d1	;Any type of memory
		move.l	4,a6
		jsrlib	AllocMem
		move.l	(a7)+,a6
		move.l	d0,block
		tst.l	d0	;grrr
		beq.s	e_memory
;-- Open object --
		move.l	inline,d1
		move.l	#MODE_OLDFILE,d2
		jsrlib	Open
		move.l	d0,handle
		move.l	d0,d1
		beq.s	e_open
;-- Read entire thing --
		;[handle in d1]
		move.l	block,d2
		move.l	size,d3
		jsrlib	Read
		cmp.l	d0,d3
		bne.s	e_read
;-- Play leapfrog with deallocation --
		moveq	#0,returncode	;OK
e_read
e_open
e_examine
e_lock
e_stuff 	jsrlib	IoErr
		move.l	d0,resultcode
errorentry	move.l	handle,d1
		beq.s	noclose
		jsrlib	Close
noclose 	move.l	lock,d1
		beq.s	nounlock
		jsrlib	UnLock
nounlock	tst.l	returncode
		beq.s	noerrors
;-- print error --
		lea	nocans(pc),a2
		moveq	#nocane-nocans,d3
		bsr.s	DOWRITE      ;error handling?
		bra.s	closeup
;-- print stats --
noerrors	lea	itsats(pc),a2
		moveq	#itsate-itsats,d3
		bsr.s	DOWRITE      ;error handling?
		move.l	block,d0
		moveq	#',',d3
		bsr.s	PRINTLONGHEX ;error handling?
		lea	sizes(pc),a2
		moveq	#sizee-sizes,d3
		bsr.s	DOWRITE      ;error handling?
		move.l	size,d0
		moveq	#10,d3
		bsr.s	PRINTLONGHEX ;error handling?
;-- Close up --
closeup 	move.l	a6,a1	;a6 had DosBase
		move.l	4,a6
		jsrlib	CloseLibrary
		suba.l	a1,a1	;zero out a1
		jsrlib	FindTask	;Find THIS task
		move.l	d0,a0
		move.l	resultcode,pr_Result2(a0) ;set WHY (or RESULT) code
		move.l	returncode,d0
		rts
;-- Handle out of memory --
e_memory	moveq	#20,returncode	;upgrade to FAIL
		moveq	#ERROR_NO_FREE_STORE,resultcode
		bra.s	errorentry
;-- Set misleading error message for zero byte length file --
e_nosize	moveq	#ERROR_FILE_NOT_OBJECT,resultcode
		bra.s	errorentry
;
;error=DOWRITE(buffer,length),dos
; z	       a2     d3<>0
;
DOWRITE 	jsrlib	Output
		move.l	d0,d1
		beq.s	e_noout
		move.l	a2,d2
		;[length in d3]
		jsrlib	Write
e_noout 	;cmp.l	 d0,d3	 ;check for mismatch
		rts
;
;PRINTLONGHEX(value,terminator),dos
;	      d0    d3.b
;
PRINTLONGHEX	;movem.l d0-d3/a0-a1,-(a7)
		subq.l	#5,a7	;Take 10 bytes from stack
		subq.l	#5,a7	;(it's smaller...)
		move.l	a7,a0
		moveq	#7,d2

1$		rol.l	#4,d0
		move.l	d0,d1
		andi.w	#$f,d1
		move.b	hextab2(pc,d1.w),(a0)+
		dbra	d2,1$

		move.b	d3,(a0)
		jsrlib	Output
		move.l	d0,d1
		beq.s	er_output
		move.l	a7,d2
		moveq	#9,d3
		jsrlib	Write
		addq.l	#5,a7
		addq.l	#5,a7
er_output
er_lib		;movem.l (a7)+,d0-d3/a0-a1
		rts

DOSName 	dc.b 'dos.library',0
nocans		dc.b 'Can',39,'t load file',10
nocane
itsats		dc.b 'File loaded at address $'
itsate
sizes		dc.b ' size $'
sizee
hextab2 	dc.b '0123456789ABCDEF'
		dc.b '(C)1987 Bryce Nesbitt'
		dc.b 1	     ;release 1
;-- That's all folks --
SHAR_EOF
cat << \SHAR_EOF > setlace.asm
;tabs every 8
;
;SetLace implementation by Bryce Nesbitt, based on an example by Bob
;Pariseau of C-A. Public Domain.
;
;On most monitors a non-interlaced display will leave black bars between
;each scan line.  This is evident in all the 200 line display modes of the
;Amiga 1000.  For photographs or longer persistence displays this black is
;undesirable.  SetLace instructs the system to set interlace; on each
;successive field the same display data will be painted in between that of 
;the previous field.  This may be a necessity for use of the Amiga with
;some NTSC video gear and broadcast television equipment.  For most computer
;(non-broadcast) applications interlace will flicker unacceptably unless
;the contrast, brightness and room lighting are all turned way down.
;
;CLI Syntax:	SetLace		;Flip (XOR) interlace
;		SetLace 1	;Turn lace on
;		SetLace 0	;Turn lace off
;Workbench:			;Flip (XOR)
;ALL screens will be forced to interlace
;
;Author correspondence, bug or stupidity reports may be directed to:
;	Bryce Nesbitt
;	1712 Marin Ave.
;	Berkeley, Ca 94707-2902
*************************
	NOLIST
	INCLUDE 'exec/types.i'
	INCLUDE 'libraries/dosextens.i'
	INCLUDE 'graphics/display.i'
	INCLUDE 'graphics/gfxbase.i'
	;INCLUDE 'lib/exec_lib.i'	;eliminates link with amiga.lib
	;INCLUDE 'lib/dos_lib.i'	;non-standard, and very speedy!
	;INCLUDE 'lib/intuition_lib.i'	;Can be fabricated from the fd.files
	;INCLUDE 'lib/graphics_lib.i'	;directory. (see exec/exec_lib.i)
	LIST
jsrlib	macro
	xref	_LVO\1			;^Nuke for use as above^
	jsr	_LVO\1(a6)
	endm
jmplib	macro
	xref	_LVO\1
	jmp	_LVO\1(a6)
	endm
**************************
		CODE
startup:	move.l	a0,a4		;CLI line pointer
		move.l	d0,d4		;CLI line length
		move.l	4,a6
		suba.l	a1,a1		;Get THIS task
		jsrlib	FindTask
		move.l	d0,a5
		moveq	#0,d0		;Set zero for later
		move.l	pr_CLI(a5),d1	;Pointer to CLI only structure
		bne.s	fromCLI		;If not zero, then save a zero...
;
; If called from Workbench a message will be sent.  This waits for it,
;  and saves it's pointer to be returned to Workbench later.
;
		lea	pr_MsgPort(a5),a0
		jsrlib	WaitPort
		lea	pr_MsgPort(a5),a0
		jsrlib	GetMsg		;Message pointer in D0
		moveq	#0,d4		;clear CLI line pointer
fromCLI 	move.l	d0,-(a7)	;Save message for later...


******************************** [A6=ExecBase][a5=this task][a4=CLI line]
* [d4=CLI length]
returncode	equr	d7
ibase		equr	d6
gbase		equr	d5
* (d4,a4,a5)

		moveq	#20,returncode	;default to 'severe failure' code
		lea	IntuiName(pc),a1
		moveq	#0,d0
		jsrlib	OpenLibrary
		move.l	d0,ibase	 ;Error check. What a pain! Could we
		beq.s	e_Intui		 ;not agree that Intuition and a few
		lea	Graphname(pc),a1 ;other core libraries will always
		moveq	#0,d0		 ;be openable??
		jsrlib	OpenLibrary
		move.l	d0,gbase
		beq.s	e_Graph
;
;Modifying the system-wide bplcon0.  From here we can change all screens
;to INTERLACE and turn tricks like disabling colorburst.  The Forbid/
;Permit pair is used for saftey while modifying this stuff.
;
		jsrlib	Forbid
		move.l	gbase,a6	;gbase

		subq.l	#2,d4		;0=wb 1=cli no args 2=1 arg
		bmi.s	flip		;wb, or cli flip
		bne.s	toomanychars
		cmpi.b	#'0',(a4)
		beq.s	clear
		cmpi.b	#'1',(a4)
		bne.s	badargs

setlace		ori.w	#INTERLACE,gb_system_bplcon0(a6)	;Set lace
		bra.s	break
clear		andi.w	#$ffff-INTERLACE,gb_system_bplcon0(a6)	;Clear lace
		bra.s	break
flip		eori.w	#INTERLACE,gb_system_bplcon0(a6) 	;Flip lace

break		move.l	ibase,a6
		jsrlib	RemakeDisplay	;The big one! Rethink ALL displays
		moveq	#0,returncode	;Everything is OK!
		bra.s	goodexit
badargs
toomanychars	move.l	#120,pr_Result2(a5) ;'arg line invalid or too long'
		moveq	#10,d7		;return code 10, less serious error
goodexit	move.l	4,a6
		jsrlib	Permit
;
;RemakeDisplay() is spec'ed to do a Forbid() and then Permit() around it's
; lengthy operation. This is just a saftey valve in case it did not...
;
		move.l	gbase,a1
		jsrlib	CloseLibrary
e_Graph		move.l	ibase,a1
		jsrlib	CloseLibrary
e_Intui
******************************** (a7)+=message d7=return code
ExitToDOS	move.l	(a7)+,d6
		beq.s	NotWB	;If saved pointer is zero, exit to CLI...
;
; Return the startup message to the parent Workbench tool. The forbid
; is needed so workbench can't UnLoadSeg() the code too early.
;
		move.l	4,a6
		jsrlib	Forbid
		move.l	d6,a1		;message pointer
		jsrlib	ReplyMsg
NotWB		move.l	d7,d0		;Set "failat" code
		rts
IntuiName	dc.b   'intuition.library',0
Graphname	dc.b  'graphics.library',0
MyName		dc.b 'Bryce Nesbitt'
;-- this is the end --
SHAR_EOF
cat << \SHAR_EOF > why.asm
; Tabs set every 8.
;
;BETTERCLI(tm) "WHY" Command, release 1
;
;BETTERCLI WHY (C)1987 Bryce Nesbitt.  Unlimited free non-exclusive licence
;hereby	granted	to any sentient	being to use or	abuse this code	in any way
;whatsoever provided that this and any other copyright notices remain fully
;attached and are reproduced in	any simultaneously distributed printed matter
;and with the exception	that, without prior written permission,	it not
;be utilized by	any entity that	has been commonly referred to as Robert
;W. Skyles, Skyles Electric Works, Jim Drew, Regie Warren or any organization
;founded by, controlled, employing or profiting	any such entity, it's
;offspring or spouses.	ARP and	FISH use welcome.
;Author	correspondence,	bug or stupidity reports may be	directed to:
;	Bryce Nesbitt
;	1712 Marin Ave.
;	Berkeley, Ca 94707-2206
;
;This program replaces the CLI WHY command, providing faster execution and
;enhanced functionality.  The old WHY command was simply a stub	that called
;'C:FAULT', and thus could not be made properly RESIDENT.  This command was
;to replace FAULT as well, however the BCPL code does something	funky
;when calling FAULT, and I could not discover it's secret.
;
; Return code convention:
;  20  FAIL  -serious error, DOS will not open,	out of memory.
;  10  ERROR -user caused error	(syntax, file not found	etc.)
;	     -less serious than	FAIL.
;  5   WARN  -technicality (file not found on DELETE, for example)
;  0   OK    -command sucessful, operation completed.
;
;This code is REUSABLE,REENTRANT and fully RESIDENT COMPATIBLE.
;Stack 1600 ok.
*************************
jsrlib	macro
	xref	_LVO\1
	jsr	_LVO\1(a6)
	endm
jmplib	macro
	xref	_LVO\1
	jmp	_LVO\1(a6)
	endm
	;INCLUDE 'lib/exec_lib.i'	;You don't have these files
	;INCLUDE 'lib/dos_lib.i'	;so please ignore these lines.
	INCLUDE	'libraries/dosextens.i'
*************************
		CODE
outhand		equr	d6
failcode	equr	d5
proc		equr	a5
cli		equr	a4
;d0-d4 a0-a3 scratch
;-- Setup --
StartUp:	moveq	#20,failcode	;default-SEVERE	failure
		move.l	4,a6		;get exec library base pointer
		lea	dosname(pc),a1
		jsrlib	OldOpenLibrary	;get this... Compatability with	V1.0!
		move.l	d0,outhand	;temp for DOSBase
		beq.s	e_dos		;fail if it will not open
		suba.l	a1,a1		;find THIS task
		jsrlib	FindTask
		move.l	d0,proc
		move.l	pr_CLI(proc),cli
		adda.l	cli,cli		;ban the BPTR!!
		adda.l	cli,cli		;ban the BPTR!!
		move.l	outhand,a6	;DOSBase
		jsrlib	Output
		move.l	d0,outhand
		beq.s	e_output
;--
		lea	mes1s(pc),a0	;'Fail code '
		moveq	#mes1e-mes1s,d3
		bsr.s	DOWRITED
;-- Get	fail code --
		move.l	cli_ReturnCode(cli),d0
		bsr.s	PRINTDECIMAL
;--
		lea	mes2s(pc),a0	;'and error code '
		moveq	#mes2e-mes2s,d3
		bsr.s	DOWRITED
;-- Print error	number --
		move.l	cli_Result2(cli),d0
		bsr.s	PRINTDECIMAL
;--
		lea	mes3s(pc),a0	;';'
		moveq	#mes3e-mes3s,d3
		bsr.s	DOWRITED
;-- Print error	text --
		move.l	cli_Result2(cli),d0
		bsr.s	PCODE
		moveq	#0,failcode
e_error
e_output	move.l	a6,a1
		move.l	4,a6
		jsrlib	CloseLibrary
e_dos		move.l	failcode,d0
rts1		rts
;
;DOWRITED(pointer,length)
;	  a0	  d3
;Aborts	if error
;
DOWRITED	;[d3=length]
		move.l	a0,d2
		move.l	outhand,d1
		jsrlib	Write
		cmp.l	d0,d3
		beq.s	rts1
e_badwrite	addq.l	#4,a7	;pop return off	stack
		jsrlib	IoErr
		move.l	d0,pr_Result2(proc)
		bra.s	e_error	;(return code is set to	FAIL, 20)
;
;
;
PCODE		moveq	#10,d1
		lea	table(pc),a1
checknext	move.l	a1,a0		;Save pointer to this line
		moveq	#-1,d3
findend		cmp.b	(a1)+,d1	;count length
		dbeq	d3,findend	;68010 loop mode!
		neg.l	d3		;compensate for	backwards count
		subq.l	#1,d3		;tweak
		cmp.b	#$ff,(a0)
		beq.s	gotit		;end of	list, use default
		cmp.b	(a0),d0
		bne.s	checknext
gotit		addq.l	#1,a0		;skip error #
		bra.s	DOWRITED	;[a0-string|d3-len]
;
;Bloated, slow, kludg-o 32 bit signed print decimal routine.
;destroys D2,D3
;
countvar	equr	d1
tableoffset	equr	d2

PRINTDECIMAL	moveq	#-4,tableoffset
		subq.l	#6,a7
		subq.l	#6,a7	;reserve 12 bytes for number
		move.l	a7,a0
		tst.l	d0
		beq.s	zero
		bpl.s	positive
		move.b	#'-',(a0)+
		neg.l	d0
positive	addq.l	#4,tableoffset
		cmp.l	table2(pc,tableoffset.l),d0
		bcs.s	positive	;BLO

doloop		move.l	table2(pc,tableoffset.w),countvar
		beq.s	endofnum
		moveq	#-1,countvar
subloop		addq.l	#1,countvar
		sub.l	table2(pc,tableoffset.w),d0
		bcc.s	subloop
		add.l	table2(pc,tableoffset.w),d0 ;Ooops! Too	far!!
		ori.b	#$30,countvar
		move.b	countvar,(a0)+
		addq.l	#4,tableoffset
		bra.s	doloop

zero		move.b	#$30,(a0)+
endofnum	suba.l	a7,a0
		move.l	a0,d3
		move.l	a7,d2
		move.l	outhand,d1
		jsrlib	Write
		addq.l	#6,a7
		addq.l	#6,a7
		cmp.l	d0,d3
		bne.s	e_badwrite
		rts

table2		dc.l	1000000000
		dc.l	100000000
		dc.l	10000000
		dc.l	1000000
		dc.l	100000
		dc.l	10000
		dc.l	1000
		dc.l	100
		dc.l	10
		dc.l	1
		dc.l	0
dosname		dc.b 'dos.library',0
mes1s		dc.b 'Fail code '
mes1e
mes2s		dc.b ', and error code '
mes2e
mes3s		dc.b '; '
mes3e
		dc.b '(C)1987 Bryce Nesbitt'
;
;Error message table. Feel free	to translate into other	languages such as
;German, Italian, or even English. Error numbers 200 and 201
;are unauthorized 'enhancments' to the standard.
;
table	dc.b 103,'insufficient free store',10
	dc.b 105,'task table full',10           ;!!Eliminate need!!
	dc.b 120,'argument line invalid or too long',10
	dc.b 121,'file is not an object module',10
	dc.b 122,'invalid resident library during load',10
       dc.b 200,'internal error',10
       dc.b 201,'newer operating system required',10
	dc.b 202,'object in use',10
	dc.b 203,'object already exists',10
	dc.b 204,'directory not found',10
	dc.b 205,'object not found',10
	dc.b 206,'invalid window description',10
       ;dc.b 207,'object too large',10              ;obsolete
	dc.b 209,'packet request type unknown',10
	dc.b 210,'stream name component invalid',10 ;what??
	dc.b 211,'invalid object lock',10
	dc.b 212,'object not of required type',10
	dc.b 213,'disk not validated',10
	dc.b 214,'disk write-protected',10
	dc.b 215,'rename across devices attempted',10
	dc.b 216,'directory not empty',10
       ;dc.b 217,'too many levels;,10               ;obsolete
	dc.b 218,'device (or volume) not mounted',10
	dc.b 219,'seek failure',10
	dc.b 220,'comment too big',10
	dc.b 221,'disk full',10
	dc.b 222,'file is protected from deletion',10
	dc.b 223,'file is write protected',10
	dc.b 224,'file is read protected',10
	dc.b 225,'not a valid DOS disk',10
	dc.b 226,'no disk in drive',10
	;dc.b 227,'can',$27,'t open window',10
	;dc.b 228,'can',$27,'t open screen',10
	dc.b 232,'no more entries in directory',10
	dc.b 255,'no error message',10
;-- end --
SHAR_EOF
#	End of shell archive
exit 0