Google
 

Trailing-Edge - PDP-10 Archives - QT020_T20_4.1_6.1_SWSKIT_851021 - swskit-hacks/binbo.mac
There are no other files named binbo.mac in the archive.
	TITLE	BINBOUT - SIMPLE FILE COPY PROGRAM WITH BYTE SIZES
	SUBTTL	J. G. Zima/JGZ	September 1985

	SEARCH MONSYM,MACSYM
	.DIRECT FLBLST
	.REQUIRE SYS:MACREL
	SALL


	STDAC.			;USE THE NORMAL SET OF ACS


EVEC:	JRST	BINBO		;START
	JRST	BINBO		;REENTER
	BYTE	(3)0(9)1(6)0(18)VI%DEC+0 ;VERSION NUMBER 1(0)


BINBO:	RESET			;THE WORLD
	MOVE	P,[IOWD PDLLEN,PDL] ;INITIALIZE A STACK

;GET THE INPUT FILE

GET.I:	TMSG	<Input file: >	;PROMPT
	MOVX	T1,GJ%SHT!GJ%OLD!GJ%FNS!GJ%CFM ;MUST EXIST
	MOVE	T2,[.PRIIN,,.PRIOU] ;READ FROM TERMINAL
	GTJFN			;GET THE FILE
	 ERJMP [PERSTR	<
?Failed to GTJFN input file: >
		JRST	GET.I]	;TRY AGAIN
	MOVEM	T1,IJFN		;SAVE FILE HANDLE
GET.IB:	TMSG	<Input byte size: > ;PROMPT
	MOVX	T1,.PRIIN	;SETUP TO READ
	MOVX	T3,^D10		; IN DECIMAL
	NIN			;GET BYTE SIZE
	 ERJMP [PERSTR	<
?Failed to get byte size: >
		JRST	GET.IB]	;TRY AGAIN
	MOVE	T4,T2		;COPY THE SIZE
	MOVE	T1,IJFN		;REFETCH JFN
	MOVX	T2,OF%RD	;OPEN FOR READ
	STOR	T4,OF%BSZ,T2	;SET THE BYTE SIZE
	OPENF			;OPEN THE INPUT SIDE
	 ERJMP [PERSTR	<
?Failed to OPENF input file: >
		JRST	GET.I]	;TRY AGAIN
	;...
	;...


;GET THE OUTPUT FILE

GET.O:	TMSG	<Output file: >	;PROMPT
	MOVX	T1,GJ%SHT!GJ%FOU!GJ%FNS!GJ%CFM ;FOR OUTPUT
	MOVE	T2,[.PRIIN,,.PRIOU] ;READ FROM TERMINAL
	GTJFN			;GET THE FILE
	 ERJMP [PERSTR	<
?Failed to GTJFN output file: >
		JRST	GET.O]	;TRY AGAIN
	MOVEM	T1,OJFN		;SAVE FILE HANDLE
GET.OB:	TMSG	<Ouput byte size: > ;PROMPT
	MOVX	T1,.PRIIN	;SETUP TO READ
	MOVX	T3,^D10		; IN DECIMAL
	NIN			;GET BYTE SIZE
	 ERJMP [PERSTR	<
?Failed to get byte size: >
		JRST	GET.OB]	;TRY AGAIN
	MOVE	T4,T2		;COPY THE SIZE
	MOVE	T1,OJFN		;REFETCH JFN
	MOVX	T2,OF%WR	;OPEN FOR WRITE
	STOR	T4,OF%BSZ,T2	;SET THE BYTE SIZE
	OPENF			;OPEN THE INPUT SIDE
	 ERJMP [PERSTR	<
?Failed to OPENF output file: >
		JRST	GET.O]	;TRY AGAIN

	;...

;THIS IS THE FILE COPY LOOP

COPY:	MOVE	T1,IJFN		;GET THE INPUT JFN
	BIN			; AND THE NEXT BYTE
	 ERJMP	EOFCHK		; UNTIL ERROR OR EOF
	MOVE	T1,OJFN		;GET THE OUTPUT JFN
	BOUT			; AND DO THE BYTE
	 ERJMP	IOERR		;UNLESS ERROR
	JRST	COPY		;AND LOOP FOR THEM ALL



;HERE TO SEE IF WE HAVE EOF ON INPUT.  IF SO, CLOSE FILES AND EXIT.

EOFCHK:	GTSTS			;GET THE FILE STATUS WORD
	TXNN	T2,GS%EOF	;EOF SET?
	 JRST	IOERR		; NO - SOME KIND OF ERROR

	MOVE	T1,OJFN		; YES - CLOSE OUTPUT SIDE FIRST
	CLOSF			;TRY TO CLOSE IT
	 ERMSG	<Failed to CLOSF output file>
	MOVE	T1,IJFN		;THEN THE INPUT SIDE
	CLOSF			;TRY TO CLOSE IT
	 ERMSG	<Failed to CLOSF input file>
	HALTF			;SUCCESS - RETURN TO THE EXEC
	JRST	BINBO		;AND RESTART ON CONTINUE



;WE GET HERE IF THERE WAS AN I/O ERROR OF SOME SORT

IOERR:	PERSTR	<
?I/O Error on file: >
	HALTF			;STOP
	JRST	.-1		; AND STAY THAT WAY



;STORAGE DEFINITIONS:

IJFN:	BLOCK	1		;INPUT FILE HANDLE
OJFN:	BLOCK	1		;OUTPUT FILE HANDLE
PDL:	BLOCK	<PDLLEN==20>	;STACK

	END	<3,,EVEC>