Google
 

Trailing-Edge - PDP-10 Archives - cust_sup_cusp_bb-x130c-sb - 10,7/unscsp/mtcopy/mtcopy.mac
There are 10 other files named mtcopy.mac in the archive. Click here to see a list.
	TITLE	MTCOPY    COPY AND VERIFY MAG TAPES  %3A(64)
	SUBTTL	T.WACHS/PFC		13-OCT-74



;COPYRIGHT (C) 1972,1978,1979,1987 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

CUSTVR==0		;CUSTOMER VERSION
DECVER==3		;DEC VERSION
DECMVR==1		;DEC MINOR VERSION
DECEVR==64		;DEC EDIT VERSION


	SEARCH	C
	SALL


;PROGRAM TO COPY MAG TAPES.  IT WILL POSITION THEM.  IT CAN
;COPY N FILES OR TO DOUBLE EOF.  USER CAN SPECIFY DENSITY AND
;IBM VS. DEC MODE.  VERIFICATION CAN BE DONE IF NEEDED.


ND	MAXSIZ,^D700	;MAX RECORD SIZE			[60]
ND	NUMBUF,6	;NUM BUFS/CHANNEL
ND	LN$PDL,40	;PD LIST

	LOC	137
.JBVER:	BYTE	(3)CUSTVR (9)DECVER (6)DECMVR (18)DECEVR
	RELOC
;	REVISION HISTORY

;%0	UNRELEASED

;A)  CONVERT TO BUFFERED I/O
;B)  IMPROVE MESSAGES
;C)  ALLOW = <ALT><ESC>, ETC.
;D)  TYPE OUT DENSITY
;E)  ADD HELP TEXT
;%1(50)	RELEASED JAN, 1972  (UNSUPPORTED)

;A)  ALLOW SPACES, TABS, COMMENTS
;B)  ADD /A/B/C:N/R/U/N
;C)  IMPROVE COMMAND SCAN DIAGNOSTICS
;D)  USE HELPER
;E)  ADD DEFAULTS ACROSS COMMANDS
;F)  DETECT RECORDS TOO LARGE
;%2(57)	UNRELEASED MAR, 1972  (UNSUPPORTED)

;60	EXPAND BUFFER SIZE TO HANDLE FRS, ETC.
;61	HANDLE .RUN MTCOPY (...)
;62	SUPPORT ERROR MESSAGE STANDARD
;63	HANDLE DEV:MTCOPY (...)
;64	INCREASE THE PUSH DOWN LIST FOR THOSE WHO BUILD MTCOPY WITH THE 
;	LATEST HELPER.
F=0
A=1
B=2
C=3
D=4

RDX=13
TOT=14		;BLOCK COUNTER
LOC=15		;FILE COUNTER,,BLOCK IN FILE COUNTER
INI=16		;OUT,,IN	SWITCHES
P=17

;CHANS
T==1		;TTY
I==2		;INPUT
O==3		;OUTPUT

;FLAGS IN F

CSWT==1B0
VSWT==1B1
GSWT==1B2
AROBIT==1B4
OUTSP==1B5
INSP==1B6
MULSWT==1B7
ANYSWT==1B8

;FLAGS IN INI

IBMCOM==4000
REWCOM==2000
;	1000	EVEN
;	600	DENSITY
UNLCOM==100
START:	JFCL			;DEFEND AGAINST CCL CALL
	RESET			;CLEAR PROGRAM			[61]
	MOVE	P,[IOWD LN$PDL,PDLIST] ;INITIALIZE PDL		[61]
	INIT	T,1		;OPEN TTY:			[61]
	  SIXBIT  /TTY/
	  XWD	TOB,TIB
	  HALT	START
	SETZM	NOREWS		;CLEAR NO REWIND SWITCH
	SETOM	OUTLP		;PRESET TO INDICATE LOAD POINT
	SETOM	INLP		; ..
	SETZM	INISAV		;CLEAR DENSITY MEMORY
	SETZM	INDEV		;CLEAR INPUT DEVICE
	SETZM	OUDEV		;CLEAR OUTPUT DEVICE
	MOVE	LOC,[POINT 6,NAMDEV] ;GET COMMAND NAME		[63]
	SETZM	NAMDEV		; ..				[63]
	SETZM	RUNCMD		;CLEAR .RUN FLAG		[61]
	RESCAN	1		;TRY FOR .RUN			[61]
	  SKPINC		;SEE IF SOMETHING THERE		[61]
	    JRST STAR		;NO--SKIP ON			[61]
	INPUT	T,		;GET FIRST LINE			[63]
STARC1:	SKIPG	TIB+2		;SEE IF MORE			[63]
	JRST	STAR		;NO--SKIP ON			[63]
	PUSHJ	P,INCHR		;GET NEXT CHAR			[61]
	CAIGE	A,40		;SEE IF END YET			[61]
	JRST	STAR		;YES--PROCEED			[61]
	CAIL	A,"0"		;IF				[63]
	CAILE	A,"Z"		; ALPHA-			[63]
	JRST	STARC2		; NUMERIC,			[63]
	CAILE	A,"9"		; BUILD				[63]
	CAIL	A,"A"		; COMMAND			[63]
	JRST	[TRC  A,40	; NAME				[63]
		 TLNE LOC,(77B5) ; ..				[63]
		 IDPB A,LOC	; ..				[63]
		 JRST STARC1]	; ..				[63]
STARC2:	CAIN	A,":"		;SEE IF DEVICE:			[63]
	JRST	[SETZM NAMDEV	;YES--START			[63]
		 MOVE  LOC,[POINT 6,NAMDEV] ;			[63]
		 JRST  STARC1]	; OVER				[63]
	MOVE	B,['MTCOPY']	;GET MATCH NAME			[63]
	EXCH	B,NAMDEV	;PUT IN EASY PLACE		[63]
	MOVEI	C,0		;GET A NULL		[63]
STARC3:	TLNE	LOC,(77B5)	;CLEAR				[63]
	JRST	[IDPB C,LOC	; OUT				[63]
		 JRST STARC3]	; MATCH				[63]
	CAMN	B,NAMDEV	;COMPARE			[63]
	JRST	STARC5		;YES--GO SET FLAG		[63]
STARC4:	CAIN	A,"("		;SEE IF (...)			[61]
	JRST	STARC5		;YES--PROCEED			[65]
	SKIPG	TIB+2		;SEE IF MORE			[63]
	  JRST	STAR		;NO--ALL DONE			[63]
	PUSHJ	P,INCHR		;YES--GET IT			[63]
	CAIGE	A,40		;SEE IF END OF LINE		[63]
	JRST	STAR		;YES--ALL DONE			[63]
	JRST	STARC4		;NO--LOOP ON			[63]
STARC5:	AOS	RUNCMD		;YES--SET FLAG			[61]
	JRST	STAR1		;AND ENTER AFTER LOOP TEST	[61]
;HERE TO TYPE *

STAR:	SOSN	RUNCMD		;SEE IF DONE WITH .RUN (...)	[61]
	JRST	ALLOVR		;YES--ALL OVER			[61]
	RESET
	MOVE	P,[IOWD LN$PDL,PDLIST]
	INIT	T,1
	  SIXBIT  /TTY/
	  XWD	TOB,TIB
	  HALT	START
	OUTPUT	T,
	MOVEI	A,"*"
	IDPB	A,TOB+1
	OUTPUT	T,
STAR1:	SETZB	F,POSVAL
	SETZB	INI,POSVAL+1
	SETZM	POSVAL+2
	SETZM	POSVAL+3
	SETOM	NUMCOP		;PRESET TO COPY TO EOF
	MOVE	A,[600,,600]	;KEEP JUST
	ANDM	A,INISAV	;  DENSITIES
DCODEM:	MOVE	LOC,[POINT 6,NAMDEV]
	SETZM	NAMDEV
	JRST	DCODE1
DCODE:	TXO	F,ANYSWT
DCODE1:	PUSHJ	P,INCHR
DCODEC:	CAIL	A,"0"
	CAILE	A,"Z"
	JRST	DLIM
	CAILE	A,"9"
	CAIL	A,"A"
	JRST	NAMPRT
DLIM:	MOVEI	D,NOCHRS
	LDB	C,[XWD 350700+D,CHRLST]
	CAMN	C,A
	JRST	@CHRLST(D)
	SOJGE	D,.-3
	CAIN	A,")"		;SEE IF END			[61]
	SKIPG	RUNCMD		; OF .RUN (...) COMMAND		[61]
	SKIPA			;NO				[61]
	JRST	COMENT		;YES--DONE			[61]
				;FALL INTO BADCOM
				;FALL HERE FROM ABOVE
BADCOM:	PUSHJ	P,OUMES
	ASCIZ	/? Illegal command
/
ZAPIT:	CLRBFI
	JRST	STAR

	DEFINE	XPR(A,B)
<	BYTE	(7)A (29)B >

CHRLST:	XPR	":",DVICE
	XPR	"_",ARROW
	XPR	"=",ARROW
	XPR	"/",SWIT
	XPR	 11,DCODE1	;TAB
	XPR	 12,RETURN
	XPR	 13,RETURN
	XPR	 14,RETURN
	XPR	 40,DCODE1	;SPACE
	XPR	 50,SWITS	;(
	XPR	 73,COMENT	;;
	XPR	"!",COMENT

NOCHRS==.-CHRLST-1

NAMPRT:	TRC	A,40
	TLNE	LOC,(77B5)
	IDPB	A,LOC
	JRST	DCODE
;HERE WHEN ; SEEN
COMENT:	PUSHJ	P,INCHR
	CAIL	A,40		;EAT UNTIL BREAK SEEN
	JRST	COMENT		; ..
	JRST	RETURN		;THEN GO PROCESS COMMAND

ARROW:	TXOE	F,AROBIT
	JRST	BADCOM
	MOVSS	INI
	JRST	DCODER

DVICE:	MOVE	B,NAMDEV
	JUMPE	B,BADCOM
	DEVCHR	B,
	JUMPE	B,NODEV
	TXNN	B,DV.MTA
	JRST	MTPLSE
	MOVE	B,NAMDEV
	TXNE	F,AROBIT
	JRST	INDVSP
	CAME	B,OUDEV		;SEE IF SAME AS LAST TIME
	SETOM	OUTLP		;NO--FLAG LOAD POINT
	MOVEM	B,OUDEV
	TXOE	F,OUTSP
	JRST	BADCOM
	JRST	DCODER

INDVSP:	CAME	B,INDEV		;SEE IF SAME AS LAST TIME
	SETOM	INLP		;NO--FLAG LOAD POINT
	MOVEM	B,INDEV
	TXOE	F,INSP
	JRST	BADCOM
DCODER:	TXO	F,ANYSWT
	JRST	DCODEM
NODEV:	PUSHJ	P,OUFMES
E$$NSD:	'NSD'
	ASCIZ	/No such device
/
	JRST	ZAPIT

MTPLSE:	PUSHJ	P,OUFMES
E$$MAR:	'MAR'
	ASCIZ	/Magtapes are required
/
	JRST	ZAPIT
SWITS:	TXO	F,MULSWT	;SET () FLAG
SWIT:	PUSHJ	P,INCHR		;GET SWITCH
SWITC:	MOVSI	D,-NUMSWT	;SCAN SWITCH TABLE
	LDB	C,[POINT 7,SWTCHS(D),6]
	CAME	C,A		;SEE IF MATCH
	AOBJN	D,.-2		;LOOP UNTIL DONE
	JUMPGE	D,UNKSWT	;ERROR IF UNKNOWN SWITCH
	LDB	C,[POINT 6,SWTCHS(D),12]
	LSH	C,6		;POSITION FILE FLAG IF ANY
	JRST	@SWTCHS(D)	;DISPATCH TO HANDLER

UNKSWT:	PUSHJ	P,OUFMES	;GIVE UNKNOWN SWITCH MESSAGE
E$$UKS:	'UKS'
	ASCIZ	/Unknown switch
/
	JRST	ZAPIT

	DEFINE	SET(A,B,C)
<	BYTE	(7)"A" (6)<C>/100 (23)B >

SWTCHS:	BYTE	(7)11 (6)0 (23)SWIT	;TAB
	BYTE	(7)40 (6)0 (23)SWIT	;SPACE
	BYTE	(7)51 (6)0 (23)CLSPAR	;)
	SET	2,INISET,200
	SET	5,INISET,400
	SET	8,INISET,600
	SET	A,ADVCOM
	SET	B,BAKCOM
	SET	C,CSET
	SET	E,INISET,1000
	SET	G,GSET
	SET	H,HELP
	SET	I,INISET,IBMCOM
	SET	N,NORCOM
	SET	R,INISET,REWCOM
	SET	U,INISET,UNLCOM
	SET	V,VSET

NUMSWT==.-SWTCHS
;HERE ON /G
GSET:	TXO	F,GSWT		;SET /G FLAG
	JRST	SWTDON		;RETURN

;HERE ON SWITCH WHICH SETS FILE FLAG
INISET:	TRNE	C,600		;SEE IF DENSITY
	TRZ	INI,600		;YES--CLEAR OLD DENSITY
	TRO	INI,(C)		;SET FLAG

;HERE WHEN END OF ONE SWITCH
SWTDON:	TXNN	F,MULSWT	;SEE IF ()
	JRST	DCODE		;NO--RESUME REGULAR SCAN
	JRST	SWIT		;YES--CONTINUE SWITCH SCAN

;HERE WHEN )
CLSPAR:	TXZE	F,MULSWT	;CLEAR () FLAG
	JRST	DCODE		;IF WAS SET, RESUME SCAN
	JRST	BADCOM		;ELSE, ERROR

;HERE ON /H
HELP:	HRROI	A,.GTPRG
	GETTAB	A,
	  MOVE	A,['MTCOPY']
	PUSHJ	P,.HELPR##
	JRST	STAR
;HERE ON /C:N OR /V:N
CSET:	TXOA	F,CSWT		;SET /C
VSET:	TXO	F,VSWT		;SET /V
	MOVEI	C,4		;SET OFFSET FOR COPY COUNT
	JRST	CVSCAN		;GO GET NUMBER

;HERE ON /A:N OR /B:N
ADVCOM:	TDZA	C,C		;SET OFFSET OF 0
BAKCOM:	MOVEI	C,1		;SET OFFSET OF 1
	SETOM	NOREWS		;CLEAR AUTO REWINDS
	TXNN	F,AROBIT	;SEE IF OUTPUT SIDE
	ADDI	C,2		;YES--SLIDE DOWN
CVSCAN:	PUSHJ	P,INCHR		;GET NEXT CHAR
	CAIE	A,":"		;SEE IF ARGUMENT
	JRST	[CAIGE	C,4
		 AOS	POSVAL(C)  ;NO JUST INCREMENT COUNTERS
		 JRST	ABLPRT]    ;COMPLETE

	SETOM	NOREWS		;/C:N OR /V:N IMPLIES /N
	MOVEI	B,0		;CLEAR COUNTER
ABLOOP:	PUSHJ	P,INCHR		;GET DIGIT
	CAIL	A,"0"		;SEE IF DECIMAL
	CAILE	A,"9"		; ..
	JRST	ABLPEX		;NO--STORE NUMBER
	IMULI	B,^D10		;YES--ADVANCE RESULT
	ADDI	B,-"0"(A)	;INCLUDE DIGIT
	JRST	ABLOOP		;AND TRY FOR ANOTHER
ABLPEX:	MOVEM	B,POSVAL(C)	;STORE AWAY
ABLPRT:	TXO	F,ANYSWT	;FLAG SOMETHING SEEN
	TXNN	F,MULSWT	;SEE IF MULT. SWIT.
	JRST	DCODEC		;NO--PROCEED ABOVE
	JRST	SWITC		;YES--CONTINUE SWITCHES

NORCOM:	SETOM	NOREWS		;SET NO REWIND FLAG
	JRST	SWTDON		;LOOP FOR NEXT SWITCH
	SUBTTL	INITIALIZE

;HERE AT END OF COMMAND SCAN--COMPLETE DEFAULT HANDLING
RETURN:	TXNN	F,AROBIT	;SEE IF = SEEN
	MOVSS	INI		;NO--RESWITCH FLAGS
	TXNN	F,ANYSWT	;TEST IF ANYTHING TYPED
	JRST	STAR		;NO--GIVE UP GRACEFULLY
	SKIPE	POSVAL+2	;SEE IF OUTPUT /A
	SKIPN	POSVAL+3	;YES--CHECK /B
	JRST	.+2		;ONE OR NONE
	JRST	BADCOM		;BOTH, GIVE UP
	TXNN	F,AROBIT	;SEE IF = SEEN
	JRST	OUTINI		;NO--JUST SETUP OUTPUT FILE
	SKIPE	POSVAL		;SEE IF INPUT /A
	SKIPN	POSVAL+1	;YES--CHECK /B
	JRST	.+2		;ONE OR NONE
	JRST	BADCOM		;BOTH, GIVE UP
	PUSH	P,INI		;PRESERVE FILE FLAGS
	SKIPN	POSVAL		;SEE IF INPUT POSITIONING
	SKIPE	POSVAL+1	; ..
	TRZ	INI,REWCOM	;YES--CLEAR REWIND
	SKIPN	POSVAL+2	;SEE IF OUTPUT POSITIONING
	SKIPE	POSVAL+3	; ..
	TLZ	INI,REWCOM	;YES--CLEAR REWIND
	SKIPLE	NUMCOP		;SEE IF /C:N OR /V:N
	TDZ	INI,[REWCOM,,REWCOM]  ;YES--DON'T CLEAR /N
	TRNN	INI,REWCOM	;SEE IF /R LEFT
	TLNE	INI,REWCOM	;ON EITHER SIDE
	SETZM	NOREWS		;IF /R, THEN CLEAR /N
	POP	P,INI		;RESTORE USER'S SWITCHES
	SKIPE	NOREWS		;IF NOT /N
	SKIPE	OUTLP		; OR AT LOAD POINT,
	TLO	INI,REWCOM	; SET /R
	SKIPE	NOREWS		;IF NOT /N
	SKIPE	INLP		; OR AT LOAD POINT,
	TRO	INI,REWCOM	; SET /R
	MOVE	A,INISAV	;GET DEFAULT DENSITIES
	TRNN	INI,600		;SEE IF INPUT DENSITY
	TRO	INI,(A)		;NO--SET DEFAULT
	MOVSS	A		;DO OUTPUT
	TLNN	INI,600		;SEE IF OUTPUT DENSITY
	TLO	INI,(A)		;NO--SET DEFAULT
	MOVEM	INI,INISAV
	TRZ	INI,REWCOM!UNLCOM!IBMCOM
;INITIALIZE AND POSITION INPUT TAPE
	SKIPN	INDEV		;SEE IF A DEVICE
	JRST	BADCOM		;NO--GIVE UP
	INIT	I,34(INI)
INDEV:	  0
	  EXP	INHED
	  JSP	A,NOTAVL
	MOVE	A,INISAV
	TRNE	A,IBMCOM
	MTIND.	I,
	TRNE	A,REWCOM
	MTREW.	I,

	SKIPN	B,POSVAL	;SEE IF /A
	JRST	INDEVX		;NO--PROCEED
	MTSKF.	I,		;YES--SKIP FILE
	SOJG	B,.-1		; ENOUGH TIMES
INDEVX:	SKIPN	B,POSVAL+1	;SEE IF /B
	JRST	INDEVY		;NO--PROCEED
	MTBSF.	I,		;YES--BACK FILE
	SOJGE	B,.-1		; ENOUGH TIMES+1
	MTWAT.	I,		;WAIT TO FINISH
	STATO	I,IO.BOT	;SEE IF AT BEGINNING
	  MTSKF. I,		;NO--GO FORWARD ONE
INDEVY:	MOVEI	B,REWCOM	;GET /R SWITCH
	STATZ	I,IO.BOT	;SEE IF AT LOAD POINT
	  IORM	B,INISAV	;YES--SET FLAG
;INITIALIZE AND POSITION OUTPUT TAPE
OUTINI:	SKIPN	OUDEV		;SEE IF OUTPUT FILE
	JRST	BADCOM		;NO--GIVE UP
	HLRZS	INI		;SWITCH TO OUTPUT FILE
	HRLM	INI,INISAV	;SAVE OUTPUT SWITCHES
	TRZ	INI,REWCOM!UNLCOM!IBMCOM
	INIT	O,34(INI)
OUDEV:	  0
	  XWD	OUHED,OUHED
	  JSP	A,NOTAVL
	MOVS	A,INISAV
	TRNE	A,IBMCOM
	MTIND.	O,
	TRNE	A,REWCOM
	MTREW.	O,

	SKIPN	B,POSVAL+2		;SEE IF /A
	JRST	OUDEVX		;NO--PROCEED
	MTSKF.	O,		;YES--SKIP FORWARD
	SOJG	B,.-1		; ENOUGH
OUDEVX:	SKIPN	B,POSVAL+3	;SEE IF /B
	JRST	OUDEVY		;NO--PROCEED
	MTBSF.	O,		;YES--SKIP BACK
	SOJGE	B,.-1		; ENOUGH +1
	MTWAT.	O,		;WAIT TO COMPLETE
	STATO	O,IO.BOT	;SEE IF AT LOAD POINT
	  MTSKF. O,		;NO--SKIP FORWARD
OUDEVY:	MOVSI	B,REWCOM	;GET /R SWITCH
	STATZ	O,IO.BOT	;SEE IF AT LOAD POINT
	  IORM	B,INISAV	;YES--SET /R FLAG
	TXNN	F,AROBIT
	JRST	WRAPOU		;IF JUST POSITION, WE ARE DONE
;COMPLETE INITIALIZATION AND TELL USER DENSITIES
	TXNN	F,CSWT+VSWT
	TXO	F,CSWT+VSWT
	MOVE	A,[XWD 400000,BUF1+1]
	MOVEM	A,INHED
	HRRI	A,BUF2+1
	MOVEM	A,OUHED
	MOVE	A,NUMCOP	;GET NUMBER OF COPIES
	MOVEM	A,NUMVER	;SET AS NUMBER OF VERIFIES

	MOVEI	A,I
	MTCHR.	A,
	  JRST	NODENS
	ANDI	A,7
	PUSH	P,DENS(A)
	MOVEI	A,O
	MTCHR.	A,
	  JRST	NODENS
	ANDI	A,3
	PUSH	P,DENS(A)
	PUSHJ	P,OUMES
	ASCIZ	/Density out at /
	POP	P,.+2
	PUSHJ	P,OUMES
	ASCIZ	/XXX/
	PUSHJ	P,OUMES
	ASCIZ	/ BPI, in at /
	POP	P,.+2
	PUSHJ	P,OUMES
	ASCIZ	/XXX/
	PUSHJ	P,OUMES
	ASCIZ	/ BPI
/

NODENS:	TXNN	F,CSWT
	JRST	VERFY
	SETZB	TOT,LOC
	OUTPUT	O,
	SUBTTL	COPY TAPE
CPYLUP:	INPUT	I,
COPY1:	STATZ	I,760000
	  JRST	INERR
	HRLZ	A,INHED
	HRR	A,OUHED
	AOBJN	A,.+1
	HRRZ	B,INHED
	HRRZ	B,1(B)
	CAIL	B,MAXSIZ
	JRST	CTOLNG
	ADDI	B,(A)
	BLT	A,(B)

	OUTPUT	O,
	STATO	O,742000
	  AOJA	LOC,CPYLUP
	MOVE	INI,OUDEV
	GETSTS	O,A
	TRNE	A,400000
	JRST	WLKERR
	PUSHJ	P,OUSTS
	ASCIZ	/output/
	TRNE	A,2000
	JRST	EOTERR
	SETSTS	O,(A)
	AOJA	LOC,CPYLUP
CTOLNG:	PUSH	P,B
	JRST	TOOLNG

EOTERR:	PUSHJ	P,OUFMES
E$$OTS:	'OTS'
	ASCIZ	/Output tape too short
/
	JRST	WRAPUP

WLKERR:	PUSHJ	P,OUFMES
E$$OWL:	'OWL'
	ASCIZ	/Output tape write lock error
/
	JRST	WRAPUP

DENS:	ASCIZ	/???/
	ASCIZ	/200/
	ASCIZ	/556/
	ASCIZ	/800/
	ASCIZ	/1600/
	ASCIZ	/6250/
	ASCIZ	/(6)/
	ASCIZ	/(7)/
INERR:	STATO	I,740000
	  JRST	EOF
	MOVE	INI,INDEV
	GETSTS	I,A
	PUSHJ	P,OUSTS
	ASCIZ	/input/
	SETSTS	I,(A)
	JRST	COPY1

EOF:	CLOSE	O,
	CLOSE	I,
	ADDI	TOT,(LOC)
	HLRS	LOC
	MOVSI	LOC,1(LOC)
	SOSN	NUMCOP		;COUNT FILE COPIED
	JRST	EOFX		;IF THAT COMPLETES REQUEST, JUMP
	INPUT	I,
	OUTPUT	O,
	SKIPGE	NUMCOP		;SEE IF /C:N
	STATO	I,20000
	  JRST	COPY1
	CLOSE	I,
	CLOSE	O,
	HLRS	LOC		;COUNT THIS FILE
	MOVSI	LOC,1(LOC)	; FOR STATISTICS
EOFX:	PUSHJ	P,OUSTAT
	ASCIZ	/copied
/

	TXNN	F,VSWT		;SEE IF /V ALSO
	JRST	WRAPUP		;NO--GO DO FINAL WRAPUP
	MOVE	A,INISAV
	TRNE	A,REWCOM
	MTREW.	I,
	TRNE	A,REWCOM
	JRST	EOFOUT
	HLRZ	B,LOC		;CAN'T REWIND, MUST BACKSPACE
	MTBSF.	I,		;BACK FILE
	SOJGE	B,.-1		; ENOUGH +1
	MTWAT.	I,		;WAIT TO COMPLETE
	STATO	I,IO.BOT	;SEE IF AT LOAD POINT
	  MTSKF. I,		;NO--SKIP FILE

EOFOUT:	TLNE	A,REWCOM
	MTREW.	O,
	TLNE	A,REWCOM	;SEE IF /R
	JRST	VERFY		;YES--GO VERIFY
	HLRZ	B,LOC		;NO--MUST BACK UP
	MTBSF.	O,		;BACK FILE
	SOJGE	B,.-1		; ENOUGH +1
	MTWAT.	O,		;WAIT TO COMPLETE
	STATO	O,IO.BOT	;SEE IF AT LOAD POINT
	  MTSKF. O,		;NO--SKIP FILE
	SUBTTL	VERIFY TAPE
VERFY:	SETZB	TOT,LOC
	GETSTS	I,A
	TRZ	A,20
	SETSTS	I,(A)
	GETSTS	O,A
	TRZ	A,20
	SETSTS	O,(A)

VERLUP:	INPUT	I,
VERF:	STATZ	I,760000
	  JRST	IERR
VERF1:	INPUT	O,
	STATZ	O,760000
	  JRST	OERR
VERF2:	HRRZ	C,INHED
	HRRZ	D,OUHED
	ADD	C,[A,,1]
	ADD	D,[A,,1]
	MOVE	A,(C)
	CAME	A,(D)
	JRST	NGLEN
	CAIL	A,MAXSIZ
	JRST	VTOLNG
	MOVE	B,@C
	CAME	B,@D
	JRST	DIFRNT
	SOJG	A,.-3
	AOJA	LOC,VERLUP

VTOLNG:	PUSH	P,A
TOOLNG:	MOVE	INI,INDEV
	PUSHJ	P,OUQUES
E$$BTL:	MOVEI	D,'BTL'
	PUSHJ	P,OUPFX
	PUSHJ	P,OULOC
	ASCIZ	/block length of /
	POP	P,A
	PUSHJ	P,OUNUM
	PUSHJ	P,OUMES
	ASCIZ	/ too long
/
	JRST	WRAPUP
IERR:	STATZ	I,20000
	  JRST	IEOF
	MOVE	INI,INDEV
	GETSTS	I,A
	PUSHJ	P,OUSTS
	ASCIZ	/input/
	SETSTS	I,(A)
	JRST	VERF1

OERR:	STATZ	O,20000
	  JRST	OEOF
	MOVE	INI,OUDEV
	GETSTS	O,A
	PUSHJ	P,OUSTS
	ASCIZ	/input/
	SETSTS	O,(A)
	JRST	VERF2

IEOF:	CLOSE	I,
	INPUT	O,
	MOVE	INI,OUDEV
	STATO	O,20000
	  JRST	O2BIGR
	CLOSE	O,
	ADDI	TOT,(LOC)
	HLRS	LOC
	MOVSI	LOC,1(LOC)
	SOSN	NUMVER		;COUNT AGAINST REQUEST
	JRST	IEOFX		;ALL DONE--FINISH UP
	INPUT	I,
	SKIPGE	NUMVER		;SEE IF /V:N
	STATO	I,20000
	  JRST	VERF
	INPUT	O,
	STATO	O,20000
	  JRST	O2BIGF
	HLRS	LOC		;COUNT THIS FILE
	MOVSI	LOC,1(LOC)	; FOR STATISTICS
IEOFX:	PUSHJ	P,OUSTAT
	ASCIZ	/verified
/
WRAPUP:	MOVE	A,INISAV
	SKIPN	NOREWS
	TRNE	A,UNLCOM
	TRZ	A,REWCOM
	TRNE	A,REWCOM
	MTREW.	I,
	TRNE	A,UNLCOM
	MTUNL.	I,
	TRNE	A,REWCOM!UNLCOM  ;SEE IF /R OR /U
	HLLZS	INISAV		;YES--CLEAR DENSITY
	SETZM	INLP		;CLEAR LOAD POINT INDICATOR
	TRNE	A,REWCOM!UNLCOM	;SEE IF /R OR /U AT END
	SETOM	INLP		;YES--SET LOAD POINT INDICATOR
	RELEAS	I,

WRAPOU:	MOVE	A,INISAV
	SKIPN	NOREWS		;SEE IF /N
	TLNE	A,UNLCOM
	TLZ	A,REWCOM
	TLNE	A,REWCOM
	MTREW.	O,
	TLNE	A,UNLCOM
	MTUNL.	O,
	TLNE	A,REWCOM!UNLCOM	;SEE IF /R OR /U
	HRRZS	INISAV		;YES--CLEAR DENSITY
	SETZM	OUTLP		;CLEAR LOAD POINT INDICATOR
	TLNE	A,REWCOM!UNLCOM	;SEE IF /R OR /U AT END
	SETOM	OUTLP		;YES--SET LOAD POINT INDICATOR
	RELEAS	O,
	JRST	STAR
OEOF:	MOVE	INI,OUDEV
	PUSHJ	P,OUQUES
E$$OBI:	MOVEI	D,'OBI'
	PUSHJ	P,OUPFX
	PUSHJ	P,OULOC
	ASCIZ	/output EOF before input EOF
/
	JRST	WRAPUP

O2BIGR:	PUSHJ	P,OUQUES
E$$IBO:	MOVEI	D,'IBO'
	PUSHJ	P,OUPFX
	PUSHJ	P,OULOC
	ASCIZ	/input EOF before output EOF
/
	JRST	WRAPUP

O2BI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