	.TITLE *** TDV FUNCTION TO TRANSFER & LIST FILES
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/	EDIT #25	15 JUNE 72	H. KREJCI
/	EDIT #26	2 FEB 73	G. COLE
/	EDIT #27	6 NOV 74	M. HEBENSTREIT
/					C. PROTEAU
/	OPTION FLAGS ADDED 		S. DELLER
/
/ COPYRIGHT 1971, 1972,1973, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ TDV (TASK DEVELOPMENT) FUNCTION USED TO TRANSFER SEQUENTIAL FILES FROM
/ ONE DEVICE TO ANOTHER. THE SOURCE CAN BE CONDITIONALLY ASSEMBLED TO
/ PRODUCE ONE OF THREE TASKS, EACH OF WHICH PERFORMS THE SAME FUNCTIONS
/ AS THE OTHERS BUT VIA DIFFERENT LUN'S.  THIS ALLOWS THE FOLLOWING
/ STANDARD SETUP TO EXIST WITHOUT NECESSITATING THE REASSIGNMENT OF LUN
/ SLOTS: FILES TRANSFERRED FROM DECTAPE TO DISK, FILES TRANSFERRED FROM
/ DISK TO DECTAPE, AND FILES TRANSFERRED FROM DISK TO LINE PRINTER.
/
/ ONLY THE IOPS ASCII AND IOPS BINARY DATA MODES ARE CONSIDERED.
/
/ THE 4 TASKS ARE AS FOLLOWS:
/
/	TASK NAME "FIN..." -- FILE(S) INPUT (NORMALLY DECTAPE TO DISK)
/	TASK NAME "FOU..." -- FILE(S) OUTPUT (NORMALLY DISK TO DECTAPE)
/	TASK NAME "LIS..." -- LIST FILE(S) (NORMALLY DISK TO LINE PRINTER)
/	TASK NAME DEC...   -- READ FILE FROM LUN 12 BATCH INPUT DEVICE
/
/ TWO FLAG OPTIONS ARE SUPPORTED BY VERSION 24, "F" AND "N". THE N
/ FLAG SUPPRESSES PARITY CHECK TYPEOUTS (I.E. NO PARITY CHECKING)
/ TO ALLOW INPUT OF NON-STANDARD PAPER TAPES WITH THE PR.... I/O
/ HANDLER TASK. THE F OPTION CAUSES 1) FORM FEEDS AFTER EVERY LINE
/ WHICH HAS ".EJECT" FOLLOWING ANY NUMBER OF TABS AND SPACES
/ (INCLUDING NONE) 2) FORM FEEDS BEFORE EVERY LINE WHICH HAS ".TITLE"
/ FOLLOWING ANY NUMBER OF TABS AND SPACES 3) FORM FEEDS EVERY
/ 56 LINES AFTER A PREVIOUS FORM FEED IF 1) OR 2) DO NOT OCCUR.
/ THE "F" OPTION IS RECOGNIZED ONLY BY LIS..., THE "N" OPTION
/ IS RECOGNIZED BY ALL THREE ROUTINES. THE OPTIONS ARE ENTERED
/ BY TYPING THE OPTION LETTER(S) FOLLOWED BY A BACK ARROW. THE LINE
/ IS SCANNED SUCH THAT COMMAS AND BACK ARROWS ARE DELIMITERS, WITH
/ COMMAS FOLLOWING FILE NAMES AND BACK ARROWS FOLLOWING OPTION
/ LETTERS (THE LAST CR IS THE SAME AS A COMMA). THUS THE
/ OPTIONS MAY BE CHANGED IN THE SAME LINE.
/////////////////////////////////////////////////////////
/							/
/ COMMAND STRING EXAMPLE:				/
/							/
/	TDV>FIN FILE1,FILE2,FILE3			/
/							/
/	TDV>FIN FILE1 SRC,FILE2 BIN,FILE3 003		/
/							/
/	TDV>FIN9 FILE1,FILE2				/
/							/
/	TDV>FIN N_NOCHEK,_CHECK,CHECK2 SRC
/							/
/	TDV>LIS F_FORMAT,FORMT2,_NOFMT,F_FORMT3		/
/							/
/	TDV>LIS AF_FMT,A_NOFMT			/
/							/
/ HERE THE EXAMPLES SHOW "FIN" AND "LIS" AS THE FIRST	/
/ CHARACTERS. "FIN", "FOU", OR "LIS" SHOULD BE USED	/
/ AS APPROPRIATE DEPENDING UPON WHICH VERSION OF THIS	/
/ TASK IS BEING USED.					/
/							/
/////////////////////////////////////////////////////////
/
/ IF THE INPUT OR OUTPUT DEVICE IS A MAGTAPE, IT IS ASSUMED TO BE A
/ 7-TRACK DRIVE UNLESS, AS IN THE ABOVE EXAMPLE, THE CHARACTER PRE-
/ CEDING THE FIRST SPACE CHARACTER IS A 9.
/
/ THE FILE NAME EXTENSION IS OPTIONAL -- "SRC" IS THE DEFAULT ASSUMPTION.
/
/ THE FILE IS ASSUMED TO BE IN IOPS ASCII MODE UNLESS THE EXTENSION IS
/ "BIN" OR "TSK" (IOPS BINARY).
/
/ THE OPTION SPECIFICATION IS OPTIONAL (DEFAULT IS NO FORMAT
/ CONTROL, DO PARITY CHECKING). ANY LETTERS IN THE OPTION LIST
/ WHICH ARE INCORRECT ARE IGNORED. "AF" IS THE SAME AS "F".
/
	.EJECT
/ THE COMMAND INPUT LINE IS READ BY THE RESIDENT TDV TASK ("TDV...") AND
/ IS TRANSFERRED TO THIS TASK BY MEANS OF THE XFRCMD DIRECTIVE.
/
/	COMMAND SYNTAX = 'XXX'$<NSP>(<9>/)<SP>
/			((<OPT><BA>)/)<FILE NAME>((<SP>EXT>)/)
/			 $(<COM>((<OPT><BA>)/)<FILE NAME>((<SP><EXT>)/))
/			(<CR>/<AM>)
/
/	'XXX' = 'FIN' OR 'FOU' OR 'LIS', AS APPROPRIATE
/	<NSP> = NON-SPACE CHARACTER
/	<SP>  = A SPACE CHARACTER
/	<FILE NAME> = 1 TO 6 ALPHANUMERIC CHARACTERS
/	<EXT> = 1 TO 3 ALPHANUMERIC CHARACTERS
/	<COM> = A COMMA
/	<CR>  = A CARRIAGE RETURN
/	<AM>  = AN ALTMODE
/	<OPT> = 0 TO 2 OPTION LETTERS ("F"=FORMAT,"N"=NO PARITY CHECK)
/	<BA>  = A BACK ARROW
/	$<..> OR $(..) = ANY NUMBER, INCLUDING NONE, OF THE ITEM <..> OR (..).
/
/ AT COMPLETION OF THE TRANSFER FUNCTION, THE TERMINATING CHARACTER OF THE
/ COMMAND LINE IS EXAMINED. IF IT IS A CARRIAGE RETURN, THE RESIDENT TDV
/ TASK IS 'REQUESTED' AND THIS TASK EXITS. IF THE LINE IS TERMINATED BY AN
/ ALTMODE, THIS TASK EXITS WITHOUT 'REQUESTING' 'TDV...'. A CTRL T TYPEIN
/ IS THEN NECESSARY TO RE-ESTABLISH TDV DIALOGUE.
/
	.EJECT
/ CONDITIONAL ASSEMBLY PARAMETERS:
/
	.DEC
/
/ DEFINE 'FIN' FOR FILE(S) INPUT.
/
	.IFDEF	FIN
ILUN=19				/FILE(S) INPUT LUN (NORMALLY ASSIGNED TO DECTAPE).
OLUN=17				/FILE(S) OUTPUT LUN (NORMALLY ASSIGNED TO DISK).
	.ENDC
	.IFDEF	DEC
ILUN=12
OLUN=17
	.ENDC
/
/ DEFINE 'FOU' FOR FILE(S) OUTPUT.
/
	.IFDEF	FOU
ILUN=17				/FILE(S) INPUT LUN (NORMALLY ASSIGNED TO THE DISK).
OLUN=19				/FILE(S) OUTPUT LUN (NORMALLY ASSIGNED TO DECTAPE).
	.ENDC
/
/ DEFINE 'LIS' FOR FILE(S) LISTING.
/
	.IFDEF	LIS
ILUN=17				/FILE(S) INPUT LUN (NORMALLY ASSIGNED TO THE DISK).
OLUN=16				/LISTING DEVICE LUN (NORMALLY ASSIGNED TO LINE PRINTER).
	.ENDC
/
/ IN CASE OF ERROR.
/
	.IFUND	ILUN
	.END -- 'FIN' OR 'FOU' OR 'LIS' MUST BE DEFINED
	.ENDC
/
TDVTTY=13			/TDV TTY ERROR LUN.
	.OCT
/
/ ID TRACE WORD: INPUT LUN/OUTPUT LUN.
/
	1000*ILUN+OLUN
/
X10=10				/AUTOINCREMENT REGISTER 10.
IDX=ISZ				/USED WHEN THE SKIP IS NOT INTENDED.
CBFSIZ=40			/SIZE OF THE COMMAND LINE BUFFER FOR UP
				/TO 80 CHARACTERS.
BUFSIZ=104			/SIZE OF THE FILE DATA BUFFER -- ENOUGH
				/FOR A 132 COLUMN LINE PRINTER PLUS
				/WHATEVER THE ASSEMBLER TACKS ON. THIS IS
				/ALSO SUFFICIENT TO HANDLE BINARY RECORDS
				/CREATED BY THE ASSEMBLER, COMPILER AND
				/TASK BUILDER.
/
	.EJECT
TRA	CAL	XFER		/TRANSFER THE COMMAND LINE READ BY 'TDV...'.
	CAL	WAITFR
	LAW	-16		/IS THE BUFFER TOO SMALL, I.E., IS THE
	SAD	EV		/COMMAND LINE TOO LONG?
	JMP	ERR1		/YES.
/
/ INITIALIZE THE FETCH-A-CHARACTER SUBROUTINE. THIS MUST BE DONE HERE,
/ RATHER THAN BEING ASSEMBLED IN, IN CASE THE TASK IS FIXED IN CORE AND
/ IS THUS NOT REINITIALIZED.
/
	LAC	(FACLB+2)
	DAC	FACLBX
	LAC	(FACCB+5)
	DAC	FACCBX
	DZM	TRACK9		/INITIALIZE THE 9-TRACK MAGTAPE FLAG
				/FOR 7-TRACK.
/
/ FLUSH COMMAND INPUT THROUGH THE FIRST BREAK CHARACTER.
/
FLUSH	JMS	FAC		/FETCH A CHARACTER FROM COMMAND LINE.
	SAD	(40)		/SPACE?
	JMP	NEXFIL
	SAD	(15)		/CARRIAGE RETURN?
	SKP
	SAD	(175)		/ALTMODE?
	JMP	ERR2		/SYNTAX ERROR.
	DAC	TRACK9		/SAVE THE CHARACTER. WILL BE USED TO
				/INDICATE 9-TRACK MAGTAPE OPERATION OR NOT.
	JMP	FLUSH
/
/ UNPACK THE FILE NAME.
/
NEXFIL	LAC	(BUF-1)		/INITIALIZE THE NAME BUFFER.
	DAC*	(X10)
	LAW	-7		/UNPACK FILE NAME (UP TO 6 CHARACTERS).
	JMS	UNPACK		/RETURN IF NO ERROR OCCURRED.
/
	LAC	CHAR	/CHECK FOR OPTIONS
	SAD	(137)	/BACK ARROW
	JMP	CHKFLG	/CHECK FOR OPTION FLAGS
	.EJECT
/ CONVERT FILE NAME TO .SIXBT AND STORE IT IN THE SEEK, DELETE, AND ENTER CPB'S.
/
	.DEC
	LAC	BUF+2
	LRS	6
	LAC	BUF+1
	LRS	6
	LAC	BUF+0
	LLS	12
	SNA
	JMP	ERR2		/SYNTAX ERROR -- NULL FILE NAME.
	DAC	SEEK+3
	DAC	ENTER+3
	DAC	DELETE+3
	LAC	BUF+5
	LRS	6
	LAC	BUF+4
	LRS	6
	LAC	BUF+3
	LLS	12
	DAC	SEEK+4
	DAC	ENTER+4
	DAC	DELETE+4
	.OCT
/
	.EJECT
/ THE FILE NAME EXTENSION IS OPTIONAL; THE DEFAULT EXTENSION IS 'SRC'.
/ VALIDATE THE DELIMITER.
/
	LAC	CHAR
	SAD	(15)		/CARRIAGE RETURN?
	SKP
	SAD	(175)		/ALTMODE?
	SKP
	SAD	(54)		/COMMA?
	JMP	USESRC		/ASSUME DEFAULT 'SRC' EXTENSION.
	SAD	(40)		/SPACE?
	JMP	FILEXT	/READ IN FILE EXTENSION
	JMP	ERR2		/NO -- ILLEGAL DELIMITER.
/
/ CHECK INPUT CHARACTERS FOR OPTION FLAGS (I.E. OPTION CHARS)
CHKFLG	DZM	NPFLG	/BACK ARROW FOUND, RESET DEFAULT OPTIONS
	DZM	FFFLG	/AND LIST DEFAULT OPTIONS
	LAW	-71	/AND LINE COUNT
	DAC	LINCNT
	LAC	BUF+0	/CHECK 1ST TWO CHARS SINCE LAST BREAK AND
	JMS	TSTFLG	/ BEFORE BACK ARROW
	LAC	BUF+1
	JMS	TSTFLG
	JMP	NEXFIL	/NOW GO GET A FILE NAME
TSTFLG	000	/SUBROUTINE TO CHECK FOR OPTION CHARS
	SAD	(106)	/CHAR F (FORM FEED)
	DAC	FFFLG	/FFFLG ONLY USED BY LIST
	SAD	(116)	/CHAR N (NO PARITY CHECK)
	DAC	NPFLG
	JMP*	TSTFLG
/
/ UNPACK THE FILE NAME EXTENSION.
/
FILEXT	LAW	-4		/UNPACK EXTENSION (UP TO 3 CHARACTERS).
	JMS	UNPACK		/RETURN IF NO ERROR OCCURRED.
/
/ CONVERT THE FILE NAME EXTENSION TO .SIXBT AND STORE IT IN THE
/ SEEK, DELETE, AND ENTER CPB'S.
/
	.DEC
	LAC	BUF+8
	LRS	6
	LAC	BUF+7
	LRS	6
	LAC	BUF+6
	LLS	12
	.OCT
	SNA
	JMP	ERR2		/SYNTAX ERROR -- NULL EXTENSION.
	SKP
/
/ USE THE DEFAULT EXTENSION 'SRC'.
/
USESRC	LAC	(232203)	/.SIXBT 'SRC'.
	DAC	SEEK+5
	DAC	ENTER+5
	DAC	DELETE+5
/
/ IF THE FILE NAME EXTENSION IS 'BIN' OR 'TSK', THE DATA MODE IS 0 (IOPS BINARY).
/ OTHERWISE, IT IS 2 (IOPS ASCII).
/
	LAC	SEEK+5
	SAD	(021116)	/(.SIXBT "BIN")
	SKP
	SAD	(242313)	/(.SIXBT "TSK")
	CLA!SKP			/BINARY.
	LAC	(2)		/ASCII.
	SNA		/SKIP IF ASCII
	DZM	FFFLG	/NO FORM FEEDS IF BINARY MODE
	DAC	READ+3		/SET THE DATA MODE.
	DAC	WRITE+3
/
	.EJECT
/ DETERMINE THE CHARACTERISTICS OF THE INPUT AND OUTPUT DEVICES. THIS
/ IS DONE EACH TIME A FILE IS TRANSFERRED RATHER THAN ONLY ONCE AT THE
/ BEGINNING, IN CASE THE INPUT OR OUTPUT LUN IS REASSIGNED AT THE WRONG
/ TIME.
/
	CAL	I.HINF		/GET INPUT DEVICE INFORMATION.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	DAC	INDEV		/SAVE HINF VALUE.
	SPA!RAL
	JMP	ERR3		/HINF ERROR.
	SMA
	JMP	ERR4		/NOT AN INPUT DEVICE.
/
/ CHECK UP ON THE OUTPUT DEVICE.
/
	CAL	O.HINF		/GET OUTPUT DEVICE INFORMATION.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	DAC	OUTDEV		/SAVE HINF VALUE.
	SPA!RTL
	JMP	ERR3		/HINF ERROR.
	SMA
	JMP	ERR5		/NOT AN OUTPUT DEVICE.
/
/ DOES THE INPUT DEVICE HAVE A DIRECTORY?
/
	LAC	INDEV
	ALS	3
	SMA
	JMP	AT.IN		/NOT A DIRECTORIED DEVICE.
/
/ INPUT DEVICE HAS A DIRECTORY -- OPEN THE FILE.
/
	CAL	SEEK
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-13)
	JMP	ERR7		/FILE NOT FOUND.
	SAD	(-54)
	JMP	ERR19A		/FILE STILL OPEN.
	SPA
	JMP	ERR8		/ERROR DURING 'SEEK'.
	JMP	DO.OUT
/
	.EJECT
/ INPUT DEVICE HAS NO DIRECTORY -- TRY TO ATTACH IT.
/
AT.IN	CAL	ATCHIN		/ATTACH.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-6)
	JMP	I.MTAP		/ATTACH IGNORED.
	SPA
	JMP	ERR9B		/'ATTACH' ERROR.
/
/ IF THE INPUT DEVICE IS MAGTAPE, ISSUE A FORMAT REQUEST.
/
I.MTAP	LAC	INDEV
	AND	(077)
	SAD	(5)		/MAGTAPE?
	SKP			/YES.
	JMP	DO.OUT		/NO.
	JMS	FORMAT		/ISSUE A FORMAT REQUEST
	I.FMT			/TO THE INPUT LUN.
/
/ DOES THE OUTPUT DEVICE HAVE A DIRECTORY?
/
DO.OUT	LAC	OUTDEV
	ALS	3
	SMA
	JMP	AT.OUT		/NOT A DIRECTORIED DEVICE.
/
/ OUTPUT DEVICE HAS A DIRECTORY -- OPEN THE FILE.
/
	CAL	ENTER
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-54)
	JMP	ERR19B		/FILE STILL OPEN.
	SPA
	JMP	ERR10		/ERROR DURING 'ENTER'.
	JMP	LOOP
/
/ OUTPUT DEVICE HAS NO DIRECTORY -- TRY TO ATTACH IT.
/
AT.OUT	CAL	ATCHOU		/ATTACH.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-6)
	JMP	O.MTAP		/ATTACH IGNORED.
	SPA
	JMP	ERR9A		/"ATTACH" ERROR.
/
	.EJECT
/ IF THE OUTPUT DEVICE IS MAGTAPE, ISSUE A FORMAT REQUEST.
/
O.MTAP	LAC	OUTDEV
	AND	(077)
	SAD	(5)		/MAGTAPE?
	SKP			/YES.
	JMP	O.LPT		/NO.
	JMS	FORMAT		/ISSUE A FORMAT REQUEST
	O.FMT			/TO THE OUTPUT LUN.
/
/ IF THE OUTPUT DEVICE IS A LINE PRINTER OR A TTY, EJECT A PAGE BEFORE PRINTING.
/
O.LPT	LAC	OUTDEV
	AND	(077)
	SAD	(11)		/LINE PRINTER?
	SKP
	SAD	(1)		/TTY?
	CAL	EJECT		/YES -- EJECT PAGE.
/
	.EJECT
/ READ THE RECORD.
/
LOOP	CAL	READ
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SPA
	JMP	ERR11		/'READ' ERROR.
	JMS	CHKEOT		/CHECK FOR END-OF-TAPE. IF SO, DISMOUNT.
	ILUN			/ARG. 1 = INPUT LUN #.
	INDEV			/ARG. 2 = WORD CONTAINING INPUT HINF.
	LAC	BUF+0
	AND	(60)
	SAD	(20)
	JMP	ERR12		/INPUT PARITY ERROR.
	SAD	(40)
	JMP	ERR13		/INPUT CHECKSUM ERROR.
	SAD	(60)
	JMP	ERR14		/BUFFER OVERFLOW ERROR.
	JMP	CHKEOF
/
/ THE FOLLOWING ERRORS, WHICH INDICATE ALTERED DATA, ARE NOT FATAL. AN
/ ERROR MESSAGE IS PRINTED INDICATING THE CAUSE OF THE ERROR. THE ERRON-
/ EOUS LINE OR RECORD IS STILL TRANSFERRED TO THE OUTPUT DEVICE SINCE
/ IT MAY BE POSSIBLE FOR THE USER TO CORRECT THE ERROR.
/
ERR12	LAC	NPFLG
	SZA	/SKIP IF PARITY TEST IS TO BE DONE
	JMP	CHKEOF	/NO PARITY MESSAGE IF "N" OPTION
	LAC	(MES12)	/INPUT PARITY ERROR
	SKP
ERR13	LAC	(MES13)		/INPUT CHECKSUM ERROR.
	SKP
ERR14	LAC	(MES14)		/BUFFER OVERFLOW ERROR.
	JMS	TYPERR
/
/ CHECK FOR END-OF-FILE.
/
CHKEOF	LAC	BUF+0
	AND	(17)
	SAD	(5)
	JMP	EOF		/END-OF-FILE -- CLOSE FILES.
/
/ IF IOPS ASCII INPUT FROM TTY, CHECK FOR 'CTRL D-CARRIAGE RETURN' OR
/ 'CTRL D-ALTMODE' AT THE BEGINNING OF THE BUFFER. THIS IS THE RSX
/ STANDARD EOF INDICATION FROM TTY.
/
	LAC	INDEV		/IS THE INPUT DEVICE A TTY?
	AND	(77)
	SAD	(1)
	SKP
	JMP	DOWRIT		/NO.
/
	.EJECT
/ NOTE -- READ FROM TTY WAS SUCCESSFUL; THEREFORE, THE DATA MODE MUST
/ BE IOPS ASCII.
/
	777760			/EXAMINE THE 1ST TWO BUFFER CHARACTERS.
	AND	BUF+2
	SAD	(020320)	/CTRL D-CARRIAGE RETURN?
	SKP
	SAD	(023720)	/CTRL D-ALTMODE?
	JMP	EOF		/YES -- END-OF-FILE.
/
/ WRITE THE RECORD.
/
DOWRIT=.
	.IFDEF	LIS
	LAC	OUTDEV		/GET THE HINF CODE FOR THE OUTPUT DEVICE
	AND	(077		/MASK OFF THE OPERATIONS BITS TO GET CODE
	SAD	(1		/IS OUTPUT DEVICE A TTY?
	SKP
	JMP	DOWRT1		/NO -- PROCEED AS USUAL
	LAC	BUF+2		/YES -- GET THE 1ST WORD OF INPUT BUFFER
	AND	(774000		/EXAMINE THE 1ST CHARACTER
	SAD	(050000		/IS IT A LINE FEED?
	SKP
	JMP	DOWRT1		/NO -- PROCEED AS USUAL
	XOR	BUF+2		/YES -- CONVERT LF TO NULL
	DAC	BUF+2		/SAVE THE NULL IN THE BUFFER
	.ENDC
DOWRT1=.
	LAC	FFFLG
	SNA		/SKIP IF FORM FEED TESTS ARE TO BE DONE
	JMP	CALWRI	/NO FORM FEED TESTS (NO "F" OPTION)
	LAC	(C.TITL)
	JMS	TSTFF	/TEST FOR ".TITLE" (IGNORES SPACES,TABS,LF'S)
	ISZ	LINCNT
	JMP	CALWRI	/NOT 56 LINES YET
	JMP	DOFF	/56 LINES, DO "FF", RETURN TO ISZ (VIA TSTFF VECTOR)
CALWRI	CAL	WRITE	/NOW WRITE THE LINE
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SPA
	JMP	ERR15		/'WRITE' ERROR.
	JMS	CHKEOT		/CHECK FOR END-OF-TAPE. IF SO, DISMOUNT.
	OLUN			/ARG. 1 = OUTPUT LUN #.
	OUTDEV			/ARG. 2 = WORD CONTAINING OUTPUT HINF.
	LAC	FFFLG	/CHECK FOR FORM CONTROL OPTION
	SNA
	JMP	LOOP	/NO FORM CONTROL, READ NEXT LINE
	LAC	(C.EJEC)	/TEST FOR ".EJECT" (IGNORES SPACES,TABS,LF'S)
	JMS	TSTFF
	JMP	LOOP	/NOW READ NEXT LINE
/
/ SUBROUTINE TO TEST FOR A 6 CHAR STRING AT THE BUFFER
/ BEGINNING, AND IF FOUND, TO OUTPUT A FORM FEED AND
/ RESET THE LINE COUNT
TSTFF	000
	DAC	TEMP	/POINTER TO 6 COMPARISON CHARS
	LAW	-6	/CHECK 6 NON SPACING CHARS
	DAC	CNT2
	LAC	(BUF+2)	/CURRENT LINE BUFFER
	DAC	PNT
TFFLP	LAW	-5	/WORD PAIR LOOP
	DAC	CNT
	LAC*	PNT	/1ST WORD PAIR
	PAL		/SAVE IT
	ISZ	PNT
	LAC*	PNT
	LMQ		/2ND WORD PAIR TO MQ
	PLA
TFFNCH	AND	(774000)	/KEEP NEXT CHAR
	SAD	(050000)	/12=LF
	JMP	IGNOR
	SAD	(200000)	/40=SPACE
	JMP	IGNOR
	SAD	(044000)	/11=TAB
	JMP	IGNOR
	SAD*	TEMP	/CHECK NEXT CHAR
	JMP	TFFEQ
	JMP*	TSTFF	/NOT EQUAL, EXIT
IGNOR	PLA	/RESTORE AC
	LLS	7	/MOVE NEXT CHAR TO BITS 0-6
	PAL	/SAVE AC
	ISZ	CNT	/5 CHARS DONE?
	JMP	TFFNCH	/NO, DO NEXT CHAR IN WORD PAIR
	ISZ	PNT	/YES, GET NEXT WORD PAIR
	JMP	TFFLP
TFFEQ	ISZ	TEMP	/ANOTHER EQUAL CHAR, INDEX POINTER
	ISZ	CNT2	/ARE WE DONE?
	JMP	IGNOR	/NO, GET NEXT CHAR
			/YES, EQUAL TO TEST, DO FORM FEED
/ TIME TO DO A FORM FEED
/ THIS MAY ALSO BE ENTERED FROM OUTSIDE THE SUBROUTINE
/ WITH RETURN VECTOR IN TSTFF (E.G. LAST CALL RETURN ADDRESS)
DOFF	CAL	WRITFF	/WRITE A FORM FEED
	JMS	WAIT
	SPA
	JMP	ERR15	/"WRITE" ERROR
	JMS	CHKEOT	/CHECK FOR END-OF-TAPE, IF SO, DISMOUNT.
	OLUN		/ARG 1 = OUTPUT LUN #
	OUTDEV		/ARG 2 = WORD CONTAINING OUTPUT HINF
	LAW	-71	/RESET THE LINE COUNTER
	DAC	LINCNT
	JMP*	TSTFF	/RETURN VIA TSTFF
/
/ READ OR WRITE ERROR. PRINT AN ERROR MESSAGE AND THEN CLOSE OR DETACH
/ THE INPUT AND OUTPUT, AS APPROPRIATE.
/
ERR11	LAC	(MES11)		/'READ' ERROR.
	SKP
ERR15	LAC	(MES15)		/'WRITE' ERROR.
	JMS	TYPERR
/
/ END-OF-FILE. CLOSE THE OUTPUT.
/
EOF	CAL	CLOSOT
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-6)		/IGNORED FUNCTION?
	JMP	.+3		/YES.
	SPA
	JMP	ERR18		/ERROR DURING OUTPUT CLOSE.
	LAC	OUTDEV		/DOES THE OUTPUT DEVICE HAVE A DIRECTORY?
	ALS	3
	SPA
	JMP	INCLOS		/YES.
/
	.EJECT
/ IF THE OUTPUT DEVICE IS MAGTAPE, WRITE AN END-OF-FILE.
/
	LAC	OUTDEV
	AND	(077)
	SAD	(5)		/MAGTAPE?
	SKP			/YES.
	JMP	O.DTCH		/NO.
	CAL	WREOF		/WRITE AN END-OF-FILE MARK.
	JMS	WAIT		/WAITFOR COMPLETION AND RETURN THE EV
				/VALUE IN THE AC.
	SPA			/ERROR?
	JMP	ERR22		/YES.
	JMS	CHKEOT		/CHECK FOR END-OF-TAPE. IF SO, DISMOUNT.
	OLUN			/ARG. 1 = OUTPUT LUN #.
	OUTDEV			/ARG. 2 = WORD CONTAINING OUTPUT HINF.
	JMP	O.DTCH
ERR22	LAC	(MES22)		/ERROR DURING WRITE EOF.
	JMS	TYPERR
/
/ DETACH THE OUTPUT DEVICE.
/
O.DTCH	CAL	DTCHOU		/DETACH.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SPA
	SAD	(-6)
	JMP	INCLOS		/DETACH COMPLETED OR IGNORED.
	JMP	ERR17A		/DETACH ERROR.
/
	.EJECT
/ ERROR WHILE OPENING OR CLOSING THE OUTPUT FILE OR WHILE ATTACHING OR
/ DETACHING THE OUTPUT DEVICE. PRINT AN ERROR MESSAGE AND THEN CLOSE OR
/ DETACH THE INPUT.
/
ERR9A	LAC	(MES9)		/'ATTACH' ERROR.
	SKP
ERR10	LAC	(MES10)		/'ENTER' ERROR.
	SKP
ERR17A	LAC	(MES17)		/'DETACH' ERROR.
	JMP	ERR19B+1
ERR18	CAL	DELETE		/ERROR DURING OUTPUT 'CLOSE'; DELETE THE FILE
	LAC	(MES18)
	SKP
ERR19B	LAC	(MES19)		/FILE STILL OPEN.
	JMS	TYPERR
/
/ CLOSE THE INPUT.
/
INCLOS	CAL	CLOSIN
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-6)		/IGNORED FUNCTION?
	JMP	.+3		/YES.
	SPA
	JMP	ERR16		/ERROR DURING INPUT 'CLOSE'.
	LAC	INDEV		/DOES THE INPUT DEVICE HAVE A DIRECTORY?
	ALS	3
	SPA
	JMP	VAL		/YES.
/
/ DETACH THE INPUT DEVICE.
/
DETACH	CAL	DTCHIN		/DETACH.
	JMS	WAIT		/RETURN THE EV IN THE AC.
	SAD	(-6)
	JMP	VAL		/DETACH IGNORED.
	SPA
	JMP	ERR17B		/'DETACH' ERROR.
/
/ VALIDATE THE DELIMITER.
/
VAL	LAC	CHAR
	SAD	(54)		/COMMA?
	JMP	NEXFIL		/YES -- PROCESS THE NEXT FILE NAME.
	SAD	(175)		/ALTMODE?
	CAL	(10)		/YES -- SIMPLY EXIT.
	SAD	(15)		/CARRIAGE RETURN?
	SKP			/YES.
	JMP	ERR2		/NO -- ILLEGAL DELIMITER.
EXIT	CAL	REQTDV		/REQUEST 'TDV...'.
	CAL	(10)		/EXIT WITHOUT WAITING FOR RESULT.
/
	.EJECT
/ ERRORS -- PRINT THE ERROR MESSAGE AND THEN REQUEST 'TDV...' EVEN IF
/ THE LINE TERMINATOR IS AN ALTMODE.
/
ERR1	LAC	(MES1)		/COMMAND LINE TOO LONG.
	SKP
ERR2	LAC	(MES2)		/SYNTAX ERROR.
	SKP
ERR3	LAC	(MES3)		/HINF ERROR.
	SKP
ERR4	LAC	(MES4)		/NOT AN INPUT DEVICE.
	SKP
ERR5	LAC	(MES5)		/NOT AN OUTPUT DEVICE.
	SKP
ERR7	LAC	(MES7)		/FILE NOT FOUND.
	SKP
ERR8	LAC	(MES8)		/'SEEK' ERROR.
	SKP
ERR9B	LAC	(MES9)		/'ATTACH' ERROR.
	SKP
ERR16	LAC	(MES16)		/ERROR DURING INPUT 'CLOSE'.
	SKP
ERR17B	LAC	(MES17)		/'DETACH' ERROR.
	SKP
ERR19A	LAC	(MES19)		/FILE STILL OPEN.
	JMS	TYPERR		/TYPE THE MESSAGE.
	JMP	EXIT
/
	.EJECT
	.IFDEF	FIN
/
MES1	005002; 0; .ASCII 'FIN-LINE TOO LONG'<15>
MES2	004002; 0; .ASCII 'FIN-SYNTAX ERR'<15>
MES3	004002; 0; .ASCII 'FIN-HINF ERR'<15>
MES4	005002; 0; .ASCII 'FIN-NOT INPUT DEV'<15>
MES5	005002; 0; .ASCII 'FIN-NOT OUTPUT DEV'<15>
MES7	005002; 0; .ASCII 'FIN-FILE NOT FOUND'<15>
MES8	004002; 0; .ASCII 'FIN-SEEK ERR'<15>
MES9	004002; 0; .ASCII 'FIN-ATTACH ERR'<15>
MES10	004002; 0; .ASCII 'FIN-ENTER ERR'<15>
MES11	004002; 0; .ASCII 'FIN-READ ERR'<15>
MES12	004002; 0; .ASCII 'FIN-PARITY ERR'<15>
MES13	005002; 0; .ASCII 'FIN-CHECKSUM ERR'<15>
MES14	005002; 0; .ASCII 'FIN-BUF OVERFLOW'<15>
MES15	004002; 0; .ASCII 'FIN-WRITE ERR'<15>
MES16	005002; 0; .ASCII 'FIN-CLOSE INPUT ERR'<15>
MES17	004002; 0; .ASCII 'FIN-DETACH ERR'<15>
MES18	006002; 0; .ASCII 'FIN-CLOSE OUTPUT ERR'<15>
MES19	005002; 0; .ASCII 'FIN-FILE STILL OPEN'<15>
MES20	005002; 0; .ASCII 'FIN-DISMOUNT MT#'<15>
MES21	007002; 0; .ASCII 'FIN-THEN, "RESUME FIN..."'<15>
MES22	005002; 0; .ASCII 'FIN-WRITE EOF ERR'<15>
/
	.ENDC
/
	.IFDEF	FOU
/
MES1	005002; 0; .ASCII 'FOU-LINE TOO LONG'<15>
MES2	004002; 0; .ASCII 'FOU-SYNTAX ERR'<15>
MES3	004002; 0; .ASCII 'FOU-HINF ERR'<15>
MES4	005002; 0; .ASCII 'FOU-NOT INPUT DEV'<15>
MES5	005002; 0; .ASCII 'FOU-NOT OUTPUT DEV'<15>
MES7	005002; 0; .ASCII 'FOU-FILE NOT FOUND'<15>
MES8	004002; 0; .ASCII 'FOU-SEEK ERR'<15>
MES9	004002; 0; .ASCII 'FOU-ATTACH ERR'<15>
MES10	004002; 0; .ASCII 'FOU-ENTER ERR'<15>
MES11	004002; 0; .ASCII 'FOU-READ ERR'<15>
MES12	004002; 0; .ASCII 'FOU-PARITY ERR'<15>
MES13	005002; 0; .ASCII 'FOU-CHECKSUM ERR'<15>
MES14	005002; 0; .ASCII 'FOU-BUF OVERFLOW'<15>
MES15	004002; 0; .ASCII 'FOU-WRITE ERR'<15>
MES16	005002; 0; .ASCII 'FOU-CLOSE INPUT ERR'<15>
MES17	004002; 0; .ASCII 'FOU-DETACH ERR'<15>
MES18	006002; 0; .ASCII 'FOU-CLOSE OUTPUT ERR'<15>
MES19	005002; 0; .ASCII 'FOU-FILE STILL OPEN'<15>
MES20	005002; 0; .ASCII 'FOU-DISMOUNT MT#'<15>
MES21	007002; 0; .ASCII 'FOU-THEN, "RESUME FOU..."'<15>
MES22	005002; 0; .ASCII 'FOU-WRITE EOF ERR'<15>
/
	.ENDC
/
	.IFDEF	LIS
/
MES1	005002; 0; .ASCII 'LIS-LINE TOO LONG'<15>
MES2	004002; 0; .ASCII 'LIS-SYNTAX ERR'<15>
MES3	004002; 0; .ASCII 'LIS-HINF ERR'<15>
MES4	005002; 0; .ASCII 'LIS-NOT INPUT DEV'<15>
MES5	005002; 0; .ASCII 'LIS-NOT OUTPUT DEV'<15>
MES7	005002; 0; .ASCII 'LIS-FILE NOT FOUND'<15>
MES8	004002; 0; .ASCII 'LIS-SEEK ERR'<15>
MES9	004002; 0; .ASCII 'LIS-ATTACH ERR'<15>
MES10	004002; 0; .ASCII 'LIS-ENTER ERR'<15>
MES11	004002; 0; .ASCII 'LIS-READ ERR'<15>
MES12	004002; 0; .ASCII 'LIS-PARITY ERR'<15>
MES13	005002; 0; .ASCII 'LIS-CHECKSUM ERR'<15>
MES14	005002; 0; .ASCII 'LIS-BUF OVERFLOW'<15>
MES15	004002; 0; .ASCII 'LIS-WRITE ERR'<15>
MES16	005002; 0; .ASCII 'LIS-CLOSE INPUT ERR'<15>
MES17	004002; 0; .ASCII 'LIS-DETACH ERR'<15>
MES18	006002; 0; .ASCII 'LIS-CLOSE OUTPUT ERR'<15>
MES19	005002; 0; .ASCII 'LIS-FILE STILL OPEN'<15>
MES20	005002; 0; .ASCII 'LIS-DISMOUNT MT#'<15>
MES21	007002; 0; .ASCII 'LIS-THEN, "RESUME LIS..."'<15>
MES22	005002; 0; .ASCII 'LIS-WRITE EOF ERR'<15>
/
	.ENDC
/
	.EJECT
/ SUBROUTINE TYPERR -- TYPEOUT AND WAITFOR COMPLETION OF ERROR MESSAGE.
/
/ CALLING SEQUENCE:
/
/	MESSAGE ADDRESS IN AC
/	JMS	TYPERR
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	EFFECTIVELY ALL (DUE TO THE CAL)
/
TYPERR	0
	DAC	TYPE+4		/STORE MESSAGE ADDRESS.
	LAC	EV		/SAVE EV VALUE SO THAT SOMEONE MAY EXAMINE
	DAC	ERRCOD		/IT BY USING THE "OPEN" MCR FUNCTION.
	CAL	TYPE		/TYPE THE MESSAGE.
	CAL	WAITFR
	JMP*	TYPERR
/
TYPE	2700			/'WRITE' CPB.
	EV
	TDVTTY			/TDV TTY ERROR LUN.
	2			/IOPS ASCII.
	XX			/MESSAGE ADDRESS.
/
	.EJECT
/ SUBROUTINE FORMAT -- ISSUE FORMAT REQUEST TO MAGTAPE TO ESTABLISH ONE
/ OF THE FOLLOWING CONDITIONS:
/
/	9-TRACK ASCII:		9-TRACK; 800 BPI; ODD PARITY
/	9-TRACK BINARY:		9-TRACK; 800 BPI; ODD PARITY; CORE DUMP MODE
/	7-TRACK ASCII:		7-TRACK; 800 BPI; EVEN PARITY
/	7-TRACK BINARY:		7-TRACK; 800 BPI; ODD PARITY
/
/ CALLING SEQUENCE:
/
/	JMS	FORMAT
/	ADDRESS OF THE FORMAT CPB
/	(RETURN HERE UNCONDITIONALLY)
/
/ ALTERED REGISTERS:
/
/	ALL, DUE TO THE CAL INSTRUCTION
/
FORMAT	0
	LAC*	FORMAT		/PICK UP ADDRESS OF FORMAT CPB.
	IDX	FORMAT
	DAC	DO.FMT		/ADDRESS LOOKS LIKE A CAL INSTRUCTION.
	AAC	3
	DAC	TEMP		/SAVE ADDRESS OF FORMAT TYPE IN CPB.
	LAC	(13)		/INITIALLY ASSUME 7-TRACK TAPE (FORMAT
	DAC*	TEMP		/13 = 7-TRACK; 800 BPI; DEFAULT PARITY).
	LAC	TRACK9		/EXAMINE THE COMMAND CHARACTER PRECEDING
	SAD	(071)		/THE FIRST SPACE. IS IT A 9?
	SKP			/YES -- 9-TRACK TAPE.
	JMP	DO.FMT		/NO.
	LAC	READ+3		/IOPS ASCII OR IOPS BINARY?
	SZA			/0=BINARY; 2=ASCII.
	CLA!IAC			/FORMAT 12 FOR ASCII = 9-TRACK; 800 BPI;
				/DEFAULT PARITY.
	AAC	11		/FORMAT 11 FOR BINARY = 9-TRACK; 800 BPI;
				/ODD PARITY; CORE DUMP MODE.
	DAC*	TEMP
DO.FMT	XX			/CAL INPUT OR OUTPUT FORMAT.
	JMS	WAIT		/WAITFOR COMPLETION; DOES NOT INVOLVE
				/IOTS TO THE MAGTAPE CONTROLLER.
	JMP*	FORMAT
/
	.EJECT
/ SUBROUTINE CHKEOT -- CHECK FOR AN END-OF-TAPE CONDITION (EV=+4). IF SO,
/ DISMOUNT THE MAGTAPE, PRINT INSTRUCTIONS TO THE OPERATOR, AND THEN
/ SUSPEND EXECUTION.
/
/ CALLING SEQUENCE:
/
/	EV VALUE IN THE AC
/	JMS	CHKEOT
/	ILUN OR OLUN
/	INDEV OR OUTDEV
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	ALL, DUE TO THE CAL INSTRUCTION
/
CHKEOT	0
	SAD	(4)		/END-OF-TAPE?
	SKP			/YES.
	JMP	CHKOUT		/NO.
	LAC*	CHKEOT		/GET THE INPUT/OUTPUT LUN.
	DAC	DISMNT+2	/PREPARE THE DISMOUNT CPB.
	IDX	CHKEOT
	LAC*	CHKEOT		/ADDRESS OF INDEV/OUTDEV.
	DAC	TEMP
	LAC*	TEMP		/HINF VALUE.
	ALS	5		/SHIFT THE MAGTAPE UNIT NUMBER TO
	AND	(034000)	/CHARACTER POSITION 1, CONVERT TO ASCII,
	TAD	(300320)	/AND APPEND A CARRIAGE RETURN.
	DAC	MES20+10
	CAL	DISMNT		/REWIND, THEN SPACE FORWARD 1 RECORD.
	LAC	(MES20)		/DISMOUNT MTN.
	JMS	TYPERR
	LAC	(MES21)		/RESUME WHEN READY.
	JMS	TYPERR
	CAL	WFDSMT		/WAITFOR DISMOUNT TO COMPLETE.
	CAL	(6)		/SUSPEND EXECUTION.
	SKP
CHKOUT	IDX	CHKEOT
	IDX	CHKEOT
	JMP*	CHKEOT
/
	.EJECT
/ SUBROUTINE UNPACK -- UNPACK 7-BIT ASCII CHARACTERS FROM THE COMMAND
/ INPUT LINE AND STORE THEM SEQUENTIALLY IN 'BUF' VIA X10 (ALREADY SET UP).
/ THE NEGATIVE COUNT OF (MAXIMUM NUMBER OF CHARACTERS + 1) IS IN THE AC.
/
/ CALLING SEQUENCE:
/
/	-COUNT IN THE AC
/	JMS	UNPACK
/	(RETURN IF NO ERROR OCCURRED)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
UNPACK	0
	DAC	CNT		/SAVE COUNT.
LOOP1	JMS	FAC		/FETCH A CHARACTER.
	DAC	CHAR
	SAD	(54)		/COMMA?
	JMP	NOT6BT		/YES -- DELIMITER.
	AAC	-41
	SPA
	JMP	NOT6BT		/NOT .SIXBT. CHAR < 41.
	AAC	-76
	SMA
	JMP	NOT6BT		/NOT .SIXBT. CHAR > 136.
	ISZ	CNT
	SKP
	JMP	ERR2		/TOO MANY CHARACTERS.
	LAC	CHAR		/STORE CHARACTER.
	DAC*	X10
	JMP	LOOP1
/
/ FILL IN THE REMAINDER OF THE NAME WITH ZEROS.
/
	DZM*	X10
NOT6BT	ISZ	CNT	/NOTE, SPACE AND BACK ARROW COME HERE
	JMP	.-2
	JMP*	UNPACK
/
	.EJECT
/ SUBROUTINE FAC -- FETCH A CHARACTER FROM THE 5/7 ASCII LINE BUFFER 'FACLB'.
/ THE INDICIES 'FACLBX' AND 'FACCBX' MUST BE SET WHEN A NEW LINE IS READ.
/ CHARACTERS ARE NOT FETCHED BEYOND TERMINAL CHARACTERS.
/
/ CALLING SEQUENCE:
/
/	JMS	FAC
/	(UNCONDITIONAL RETURN WITH CHARACTER IN THE AC)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
FAC	0
	LAC*	FACCBX		/FETCH THE NEXT UNPACKED CHARACTER FROM 'FACCB'.
	SMA			/WAS THE CHARACTER BUFFER (FACCB) EMPTY?
	JMP	FAC2		/NO -- TEST FOR A TERMINAL CHARACTER.
	LAC	(FACCB-1)	/YES -- REFILL 'FACCB' FROM THE INPUT LINE.
	DAC	FACCBX
	LAC*	FACLBX		/(FIRST HALF OF WORD PAIR).
	IDX	FACLBX
	LMQ
	CLA!CLL
	JMS	FACUPS		/(FIRST CHARACTER).
	JMS	FACUPS		/(SECOND CHARACTER).
	JMS	FACUPS		/(FIRST 4 BITS OF THIRD CHARACTER).
	LAC*	FACLBX		/(SECOND HALF OF WORD PAIR).
	IDX	FACLBX
	LRS	17		/(LAST 3 BITS OF THIRD CHARACTER).
	XOR*	FACCBX
	DAC*	FACCBX
	CLA
	JMS	FACUPS		/(FOURTH CHARACTER).
	JMS	FACUPS		/(FIFTH CHARACTER).
	LAC	(FACCB)		/RESET THE CHARACTER BUFFER INDEX.
	DAC	FACCBX
	LAC*	FACCBX		/FETCH THE FIRST CHARACTER FROM THE
				/CHARACTER BUFFER.
/
FAC2	SAD	(015)		/IF IT IS A TERMINAL CHARACTER, CARRIAGE
	JMP*	FAC		/RETURN OR ALTMODE, RETURN WITH THE CHARACTER
	SAD	(175)		/IN THE AC BUT DO NOT AUGMENT THE CHARACTER
	JMP*	FAC		/BUFFER INDEX. THUS, REPEATED CALLS TO FAC
				/WILL RETURN THE TERMINAL CHARACTER.
/
	IDX	FACCBX		/IT IS NOT A TERMINAL CHARACTER -- AUGMENT
	JMP*	FAC		/THE CHARACTER BUFFER INDEX AND RETURN WITH
				/THE CHARACTER IN THE AC.
/
	.EJECT
/ SUBROUTINE FACUPS -- UNPACKING SUBROUTINE USED BY 'FAC'.
/
/ CALLING SEQUENCE:
/
/	AC & LINK MUST BE CLEARED.
/	NEXT CHARACTER MUST BE IN
/	THE HIGH-ORDER END OF THE MQ.
/	'FACCBX' MUST  POINT TO THE
/	WORD PRECEDING THE ONE IN
/	WHICH THE CHARACTER IS TO
/	BE STORED.
/	JMS	FACUPS
/	(UNCONDITIONAL RETURN WITH
/	'FACCBX' POINTING TO THE
/	STORED CHARACTER AND WITH
/	THE AC & LINK LEFT CLEARED)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
FACUPS	0
	LLS	7		/SHIFT THE CHARACTER INTO THE AC. THE LOW
	IDX	FACCBX		/ORDER BITS OF THE THIRD CHARACTER ARE ZERO
	DAC*	FACCBX		/BECAUSE THE LINK IS ZERO.
	CLA
	JMP*	FACUPS
/
FACLBX	XX			/LINE BUFFER INDEX.
FACCBX	XX			/CHARACTER BUFFER INDEX.
FACCB	.BLOCK	5		/CHARACTER BUFFER (5 IMAGE ALPHA CHARACTERS).
	-1			/END-OF-'FACCB' INDICATOR.
/
/ SUBROUTINE WAIT -- WAIT FOR THE EVENT VARIABLE TO BE SET, AND RETURN ITS
/ VALUE IN THE AC.
/
/ CALLING SEQUENCE:
/
/	JMS	WAIT
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	EFFECTIVELY ALL (DUE TO THE CAL)
/
WAIT	0
	CAL	WAITFR
	LAC	EV
	JMP*	WAIT
/
	.EJECT
REQTDV	1			/'REQUEST' CPB.
	0			/NO EVENT VARIABLE.
	.SIXBT	'TDV'
	.SIXBT	'...'
	0			/USE THE DEFAULT PRIORITY.
/
I.HINF	3600			/INPUT HINF CPB.
	EV
	ILUN
/
O.HINF	3600			/OUTPUT HINF CPB.
	EV
	OLUN
/
SEEK	3200			/'OPEN SEQUENTIAL INPUT FILE' CPB.
	EV
	ILUN
	.SIXBT	'---'		/FILE NAME -- 1ST HALF.
	.SIXBT	'---'		/FILE NAME -- 2ND HALF.
	.SIXBT	'---'		/FILE NAME -- EXTENSION.
/
ENTER	3300			/'OPEN SEQUENTIAL OUTPUT FILE' CPB.
	EV
	OLUN
	.SIXBT	'---'		/FILE NAME -- 1ST HALF.
	.SIXBT	'---'		/FILE NAME -- 2ND HALF.
	.SIXBT	'---'		/FILE NAME -- EXTENSION.
/
DELETE	3500			/'DELETE' CPB
	0
	OLUN
	.SIXBT	'---'		/FILE NAME -- 1ST HALF.
	.SIXBT	'---'		/FILE NAME -- 2ND HALF.
	.SIXBT	'---'		/FILE NAME -- EXTENSION.
/
READ	2600			/'READ' CPB.
	EV
	ILUN
	XX			/DATA MODE 0 OR 2.
	BUF
	BUFSIZ			/BUFFER SIZE.
/
EJECT	2700			/'PAGE EJECT' CPB.
	0
	OLUN
	3			/IMAGE ALPHA MODE.
	FF
/
FF	002003			/FORM FEED LINE BUFFER.
	000000
	000014			/A FORM FEED.
	000000			/A NULL CHARACTER
/
WRITE	2700			/'WRITE' CPB.
	EV
	OLUN
	XX			/DATA MODE 0 OR 2.
	BUF
/
	.EJECT
CLOSIN	3400			/CLOSE (INPUT) CPB.
	EV
	ILUN
/
CLOSOT	3400			/CLOSE (OUTPUT) CPB.
	EV
	OLUN
/
ATCHIN	2400			/'ATTACH INPUT' CPB.
	EV
	ILUN
/
ATCHOU	2400			/'ATTACH OUTPUT' CPB.
	EV
	OLUN
/
DTCHIN	2500			/'DETACH INPUT' CPB.
	EV
	ILUN
/
DTCHOU	2500			/'DETACH OUTPUT' CPB.
	EV
	OLUN
/
XFER	37			/'TRANSFER TDV COMMAND LINE' CPB.
	EV
	FACLB			/BUFFER ADDRESS.
	CBFSIZ			/BUFFER SIZE.
/
WAITFR	20			/'WAITFOR' CPB.
	EV
/
I.FMT	5000			/'FORMAT INPUT' CPB.
	EV
	ILUN
	XX			/FORMAT CODE.
/
O.FMT	5000			/'FORMAT OUTPUT' CPB.
	EV
	OLUN
	XX			/FORMAT CODE.
/
WREOF	4400			/'WRITE END-OF-FILE' CPB.
	EV
	OLUN
/
DISMNT	5100			/'MOUNT/DISMOUNT' CPB.
	EV1
	XX			/ILUN OR OLUN.
	3			/SUBFUNCTION = DISMOUNT.
/
WFDSMT	20			/WAITFOR DISMOUNT TO COMPLETE.
	EV1
EV	0			/EVENT VARIABLE.
EV1	0			/EVENT VARIABLE.
CNT	0			/COUNTER.
CHAR	0			/INPUT CHARACTER.
INDEV	0			/HINF EV FOR INPUT DEVICE.
OUTDEV	0			/HINF EV FOR OUTPUT DEVICE.
ERRCOD	0			/EV VALUE SAVED BEFORE ERROR PRINTOUT IN
				/CASE SOMEONE WANTS TO EXAMINE IT USING
				/THE "OPEN" MCR FUNCTION.
NPFLG	0		/NO-PARITY CHECK FLAG (NO CHECK IF .NE. 0)
FFFLG	0	/FORM CONTROL FLAG (56 LINES PER PAGE, FF AFTER A
		/LINE WITH .EJECT PRECEEDED BY TABS OR SPACES, FF BEFORE
		/A LINE WITH .TITLE PRECEEDED BY TABS OR SPACES.
LINCNT	-71	/LINE COUNTER USED IN CONJUNCTION WITH FFFLG
C.EJEC	56*4000	/"."(BITS0-6) ".EJECT" COMPARISON CHARS
	105*4000	/"E"
	112*4000	/"J"
	105*4000	/"E"
	103*4000	/"C"
	124*4000	/"T"
C.TITL	56*4000	/"."
	124*4000	/"T"
	111*4000	/"I"
	124*4000	/"T"
	114*4000	/"L"
	105*4000	/"E"
PNT	0	/POINTER FOR .EJECT,.TITLE COMPARISON LOOP
CNT2	0	/COUNTER FOR COMPARISON LOOP
WRITFF	2700	/OUTPUT A FORM FEED
	EV
	OLUN
	2	/ASCII ONLY, NO GENERATED FF'S IN BIN MODE
	.+1	/BUFFER IS NEXT 4 WORDS
	2002	/HEADER
	0
	.ASCII	<14><15>	/FF,CR
TEMP	0			/TEMPORARY STORAGE.
TRACK9	0			/CHARACTER FROM THE COMMAND STRING WHICH
				/PRECEDES THE FIRST SPACE. IF "9", IT
				/SIGNIFIES 9-TRACK MAGTAPE OPERATION.
/
BUF	.BLOCK BUFSIZ		/FILE NAME BUFFER AND FILE DATA LINE BUFFER.
/
FACLB	.BLOCK	CBFSIZ		/COMMAND INPUT BUFFER, OR
				/FETCH-A-CHARACTER BUFFER.
	064032			/GUARD WORD -- GUARANTEES FINDING A
				/CARRIAGE RETURN AT END OF BUFFER.
/
	.END	TRA
