	.TITLE	MTMOV	ALL MAGTAPE MOVEMENT COMMANDS THAT DO NOT WRITE
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1976
/ 
/ 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) 1976, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
	.TITLE EDIT LEGEND
/
/	EDIT # 18
/								/(019)
/ 019	10-MAY-1976 (RCHM)	FIX FOR VARIOUS STATUS CHECKING	/(019)
/				PROBLEMS.			/(019)
/
/ COPYRIGHT 1971,1972,1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ MAGTAPE I/O HANDLER TASK		5 JUN 74	R. MCLEAN
/					M. HEBENSTREIT
/
/
/
/
/
	.GLOBL	MTMOV,FINREQ,FLSREQ,WFMT,MTEVAM,MTNODE,MTCAA,MTWCA,FMTDEN,FMTPAR
	.GLOBL	UNTTMP,MTEOTT,USREC,MTCMND,MTLABL,ERM12,MTPGET
/
/
WCA	32
CAA	33	/WORD COUNT ADDRESS
	.TITLE	PARAMETER DEFINITIONS
/
/
/
/
/
/	PARAMETER DEFINITIONS
/
R1=101
R2=102
R3=103
R4=104
R5=105
POOL=240	/POOL DEQUE LIST HEAD
PICK=120	/PICK A NODE
PDVL=252	/PHYSICAL DEVICE DEQUE LIST HEAD
NADD=107	/NODE ADD
SNAM=123	/SEARCH FOR A NAME
DQRQ=337	/DE-QUEUE A NODE FROM PDVL NODE
ALAD=325	/ATTACH LUN AND DEVICE
DLAD=332	/DETACH LUN AND DEVICE
VAJX=342	/VALADATE AND ADJUST
IOCD=345	/DECREMENT I/O PENDING COUNT
X10=10
X11=11
X12=12
/
.INH=705522
.ENB=705521
ECLA=641000
/
MTSF=707341	/SKIP ON ERROR FLAG OR MAGTAPE FLAG
MTCR=707321	/SKIP ON TAPE CONTROL READY
MTTR=707301	/SKIP ON TAPE TRANSPORT READY
MTAF=707322	/CLEAR THE STATUS AND COMMAND REGISTERS, EF AND MTF
		/IF TAPE CONTROL READ. IF NOT READY CLEAR EF AND MTF ONLY.
MTVM=707302	/OR COMMAND REGISTER INTO AC 0-11
MTCM=707324	/OR AC 0-5,9-11 INTO COMMAND REGISTER LOAD 6-8
		/INTO COMMAND REGISTER
MTLC=707326	/LOAD AC 0-11 INTO COMMAND REGISTER
MTVS=707342	/INCLUSIVELY OR STATUS REGISTER INTO AC 0-11
MTRS=707352	/READ THE CONTENTS OF STATUS REGISTER INTO AC 0-11
MTRC=707312	/READ THE CONTENTS OF COMMAND REGISTER INTO AC 0-11
MTGO=707304	/EXECUTE THE COMMAND REGISTER
/
EF=400000	/ERROR FLAG
RW=200000	/TAPE REWINDING
BT=100000	/BEGINNING OF TAPE
IC=040000	/ILLEGAL COMMAND
PE=020000	/PARITY ERROR
FI=010000	/EOF
ET=004000	/EOT
RE=002000	/READ-COMPARE ERROR
IL=001000	/RECORD LENGTH INCORRECT
DL=000400	/DATA REQUEST LATE
TB=000200	/BAD TAPE
EP=000000+1	/EVEN PARITY
OP=040000+1	/ODD PARITY
CD=020000+1	/CORE DUMP MODE
IG=010000	/INTER - RECORD GAP
NP=000000	/MT NOP
RI=001000	/REWIND
RD=002000	/READ
RC=003000	/READ - COMPARE
WR=004000	/WRITE
WF=005000	/WRITE END OF FILE
SF=006000	/SPACE FORWARD
SR=007000	/SPACE REVERSE
IE=000400	/INTERRUPT ENABLE
ID=000000	/INTERRUPT DISABLE
D2=000000+1	/DENSITY 200 BPI
D5=000100+1	/DENSITY 556 BPI
D8=000200+1	/DENSITY 800 BPI
D9=000300+1	/DENSITY 800 BPI 9 TRACK
/
	.TITLE	MTMOVE MAGTAPE MOVEMENT COMMANDS
MTMOV	0
	AAC	-37	/CHECK LOWER LIMIT OF LEGAL FUNCTIONS
	SPA!SNA
	JMP	ERM6	/ERROR ILLEGAL FUNCTION
	AAC	-13	/CHECK UPPER LIMIT OF LEGAL FUNCTIONS
	SMA!SZA		/IS IT POSITIVE
	JMP	ERM6	/YES -- ERROR UNIMPLIMENTED FUNCTION
	AAC	13	/NO -- RETURN TO ORIGIONAL VALUE
	PAX		/SAVE IT IN THE XR FOR A JUMP TABLE
	LAC	(MTMOV)	/FIND THE XR ADJUSTMENT
	AND	(070000) /MASK OFF THE PAGE BITS
	TCA
	DAC	XADJ	/SAVE IN XADJ
	XCT	CMNDTB-1,X /JUMP TO PROPER ROUNTINE
CMNDTB	JMP	RDCOMP	/READ COMPARE
	JMP	REWIND	/REWIND
	JMP	BKSPRC	/BACKSPACE RECORDS
	JMP	BKSPFI	/BACKSPACE FILE
	JMP	WEOF	/WRITE END OF FILE
	JMP	SPREC	/SPACE RECORDS
	JMP	SPFIL	/SPACE FILES
	JMP	SPEOT	/SPACE TO LOGICAL EOT (2 SUCCESSIVE EOF'S)
	JMP	FMT	/CHANGE FORMAT SPECIFICATION
	JMP	UMOUNT	/UNMOUNT OR UNLOAD THE MAGTAPE REQUEST
	JMP	TAPMRK	/READ-WRITE TAPE MARK
/
RDCOMP	JMS	CKEOT	/CHECK FOR EOT STATUS BEFORE ATTEMPTING READ COMPARE
	LAC*	MTNODE	/PICK UP THE REQUESTING NODE
	DAC*	(R2)	/SAVE FOR VALADATE AND ADJUST
	TAD	XADJ	/ADD THE XR ADJUSTMENT
	PAX
	LAC	7,X	/PICK UP THE CURRENT ADDRESS POINTER
	DAC*	(R3)	/SAVE FOR VALADATE AND ADJUST
	LAC	(3)	/VALADATE CPB
	DAC*	(R4)
	JMS*	(VAJX)
	JMP	ERM30	/PROTECT VIOLATION
	LAC*	(R3)	/FIND CPB ADDRESS
	DAC	FILCNT	/SAVE IT
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	LAC	0,X	/PICK UP THE BUFFER ADDRESS
	DAC*	(R3)
	LAC	1,X	/PICKUP THE WORD COUNT
	DAC*	(R4)
	TCA
	DAC*	WCA	/SAVE IT IN THE TAPE WORD COUNT REGISTER
	DAC*	MTWCA	/SAVE IT INCASE OF ERROR RECOVERY
	JMS*	(VAJX)	/VALADATE AND ADJUST
	JMP	ERM30	/PROTECT VIOLATION
	LAC*	(R3)	/I/O ADDRESS
	AAC	-1	/SUBTRACT 1 FOR CURRENT ADDRESS POINTERS
	DAC*	CAA
	DAC*	MTCAA
	JMS	COMPDP	/PICK UP THE UNIT AND DENSITY AND PARITY
	XOR	(RC!IE)	/ADD IN READCOMPARE BITS
	JMS*	WFMT	/GO EXECUTE REQUEST
	LAC	FILCNT	/PICK UP THE REQUESTOR'S CPB ADDRESS
	TAD	XADJ
	PAX
	LAC*	MTEVAM	/PICK UP THE TAPE STATUS
	DAC	2,X	/RETURN IT TO THE USER'S CPB
	AND	(ET!FI)	/MASK OFF END OF TAPE AND EOF
	ALSS 5		/ MOVE IT TO BITS 0 AND 1. KEEP THE	/(019)
			/ REST OF THE AC 0.			/(019)
	SPA
	JMP	EOF	/EOF RETURN +3 STATUS
	SZA		/EOT?
	JMP	EOT	/YES -- RETURN EOT STATUS
	LAC*	MTEVAM
	SMA
	JMP*	FINREQ	/NO -- REQUEST OK?
	LAW	-17	/RETURN ERROR
	JMP*	FLSREQ
/
/
REWIND	JMS	CLREOT	/CLEAR THE EOT FLAGS
REWINU	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER
	ALS	17	/PUT IT IN BITS 0-2
	AND	(700000) /MASK OFF THE UNIT
	XOR	(RI!IE!ID) /PUT IN REWIND REQUEST-- REWIND INTERRUPT ENABLED
	JMS*	WFMT	/WAIT FOR REQUEST TO COMPLETE
	LAC*	MTEVAM	/LOOK TO SEE IF REWINDING STARTED
	AND	(BT!RW)	/MASK OFF REWIND - BEGINNING OF TAPE STATUS
	SZA		/IS IT EITHER?
	JMP*	FINREQ	/YES -- RETURN REQUEST OK
ERM12A	JMS	CLREOT	/CLEAR EOT FLAGS SOME MOVEMENT MUST HAVE OCCRUED
	JMP*	ERM12	/RETURN -12 EVENT VARIABLE
/
ERM6	LAW	-6
	JMP*	FLSREQ	/FLUSH REQUEST
/
ERM20	LAW	-20
	JMP*	FLSREQ
/
ERM21	LAW	-21
	JMP*	FLSREQ
/
ERM30	LAW	-30	/PROTECT VIOLATION
	JMP*	FLSREQ
/
ERM70	LAW	-70
	JMP*	FLSREQ
/
/
WEOF	JMS	CKEOT	/CHECK FOR EOT STATUS ON FORWARD MOVEMENT
	JMS	COMPDP	/PICK UP DENSITY AND PARITY
	AND	(737777)	/MASK OFF PARITY AND FUNCTION
	XOR	(WF!OP!IE)	/WRITE END OF FILE ODD PARITY INTERRUPT ENABLED
	JMS*	WFMT	/GO DO WRITE EOF REQUEST
	LAC*	MTEVAM	/PICK UP THE LAST I/O STATUS
	AND	(ET)	/WAS IT EOT?
	SZA
	JMP	EOT	/YES -- ON EOT STATUS WITH END OF FILE RETURN
			/THE EOT STATUS IN THE EVENT VARIABLE AND THE
			/EOF STATUS IN THE BUFFER
	LAC*	MTEVAM	/PICK UP THE STATUS AGAIN
	AND	(347600) /WAS THIS THE ONLY ERROR?
	SNA
	JMP*	FINREQ	/YES --EXIT
	JMP	ERM12A
/
/
EOT	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER
	PAX
	DZM*	MTEOTT,X /CLEAR THE MAGETAP EOT FLAGS
	LAC	(4)	/RETURN +4 TO INDICATE EOT
	JMP*	FLSREQ
/
/
FMT	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER OF THE REQUEST
	PAL		/SAVE IT IN THE LR
	LAC*	MTNODE	/PICK UP THE NODE TO DETERMINE REQEST TYPE
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	LAC	7,X	/PICK UP THE CODE
	PAX
	SPA!SNA		/IS IT LEGAL?
	JMP	ERM70	/NO ERROR
	AAC	-15	/GREATER THAN 15?
	SMA!SZA
	JMP	ERM6	/YES -- ERROR
	XCT	FMTJMP-1,X / NO -- EXECUTE CORRECT COMMAND
FMTJMP	JMP	F200	/FORMAT 7 TRACK 200 BPI
	JMP	F556	/FORMAT 7 TRACK 556 BPI
	JMP	F800	/FORMAT 7 TRACK 800 BPI
	JMP	F7E	/FORMAT 7 TRACK EVEN PARITY
	JMP	F7O	/FORMAT 7 TRACK ODD PARITY
	JMP	F9E	/FORMAT 9 TRACK EVEN PARITY
	JMP	F9O	/FORMAT 9 TRACK ODD PARITY
	JMP	F9ED	/FORMAT 9 TRACK EVEN PARITY DUMP MODE
	JMP	F9OD	/FORMAT 9 TRACK ODD PARITY DUMP MODE
	JMP	F9D	/FORMAT 9 TRACK DEFAULT PARITY
	JMP	F7D	/FORMAT 7 TRACK DEFAULT PARITY & DENSITY (800 BPI)
	JMP	HREC	/FORMAT HANDLER RECOVERY
	JMP	UREC	/FORMAT USER RECOVERY
/
F200	PLX
	LAC	(D2)	/SET UP DENSITY 200 BPI
	DAC*	FMTDEN,X /PUT IT IN THE TABLE
	JMP*	FINREQ	/REQUEST FINISHED RETURN
/
F556	PLX
	LAC	(D5)	/SET UP DENSITY 556 BPI
	DAC*	FMTDEN,X / PUT IT IN THE TABLE
	JMP*	FINREQ	/RETURN REQUEST FINISHED
/
F800	PLX
	LAC	(D8)	/SET UP DENSITY 800 BPI
	DAC*	FMTDEN,X / PUT IT IN THE TABLE
	JMP*	FINREQ	/REQUEST FINISHED RETURN
/
F7E	PLX
	LAC	(EP)	/SET UP EVEN PARITY
FMTEXT	DAC*	FMTPAR,X /SET UP THE PARITY
	LAC*	FMTDEN,X /PICK UP THE DENSITY
	SAD	(D9)	/IS THIS 9 TRACK?
	DZM*	FMTDEN,X /YES -- MAKE IT 7 TRACK 800 BPI	/(019)
	JMP*	FINREQ	/NO -- RETURN REQUEST OK
/
F7O	PLX
	LAC	(OP)	/SET UP TO INDICATE EVEN PARITY
	JMP	FMTEXT	/GO SET IN TABLE
/
F9E	PLX
	LAC	(EP)	/SET UP TO INDICATE EVEN PARITY
FMPARE	DAC*	FMTPAR,X /SET EVEN PARITY IN TABLE
	LAC	(D9)	/CHECK TO SEE IF DENSITY SET TO INDICATE 9 TRACK
	DAC*	FMTDEN,X /SET DENSITY
	JMP*	FINREQ	/RETURN REQUEST OK
/
F9ED	PLX
	LAC	(EP!CD)	/MODE EVEN PARITY CORE DUMP
	JMP	FMPARE	/ENTER COMMON ROUTINE TO SET UP FORMAT
/
F9OD	PLX
	LAC	(OP!CD)	/MODE ODD PARITY CORE DUMP
	JMP	FMPARE	/ENTER COMMON CODE ROUTINE TO SET UP FORMAT
/
F9O	PLX
	LAC	(OP)	/SET UP TO INDICATE EVEN PARITY
	JMP	FMPARE	/SET IT IN TABLE
/
F9D	PLX
	DZM*	FMTPAR,X /CLEAR THE PARITY TABLE
	LAC	(D9)	/SET UP 9 TRACK
	DAC*	FMTDEN,X / IN THE TABLE
	LAW	-1
	DAC*	USREC,X
	JMP*	FINREQ	/REQUEST FINISHED RETURN
/
F7D	PLX
	DZM*	FMTPAR,X /CLEAR THE PARITY INDICATOR'S
	DZM*	FMTDEN,X /CLEAR THE DENSITY INDICATOR(S IN THE TABLE
	LAW	-1
	DAC*	USREC,X
	JMP*	FINREQ	/RETURN REQUEST FINISHED
/
BKSPRC	JMS	CLREOT	/CLEAR  THE EOT FLAGS ON BACKSPACE
	LAC*	MTNODE	/PICK UP THE REQUEST NODE POINTER
	TAD	XADJ
	PAX		/STORE IT IN XR
	LAC	7,X	/PICK UP THE RECORD COUNT
	TCA		/MAKE IT NEGATIVE FOR WORD COUNT
	DAC*	WCA	/STORE IN THE MT WORD COUNT
	DAC*	MTWCA	/SAVE IT IN CASE OF RECOVERY
	JMS	COMPDP	/PICK UP THE DENSITY AND PARITY BITS
	XOR	(SR!IE)	/XOR IN THE SPACE REVERSE REQUEST
BKSPAE	JMS*	WFMT	/START UP THE MAGTAPE DRIVE
	LAC*	MTEVAM	/WAS THE REQUEST OK?
	SMA
	JMP*	FINREQ	/YES REQUEST FINISHED
	AND	(FI!BT)	/WAS THE ERROR FILEMARK OR BEGINNING OF TAPE?
	SNA!RTL		/OTHERS ARE ERRORS
	JMP	SPERR	/SPACE ERROR TRY ANOTHER PARITY
	SMA		/WAS IT EOF?
	JMP	EOF	/YES -- END OF FILE RETURNED
BOT	LAC*	WCA	/NO -- BEGINNING OF TAPE FOUND
	SNA		/DID THE REQUEST COMPLETE FIRST?
	JMP*	FINREQ	/YES -- REQUEST OK
	JMP	ERM20	/NO -- ERROR
/
/
SPERR	LAC*	WCA
	SNA		/IS THE REQUEST COMPLETE?
	JMP*	FINREQ	/YES RETURN REQUEST OK
	LAC*	MTCMND	/PICK UP THE LAST COMMAND
	XOR	(EP!OP)	/SWAP THE COMMAND PARITY
	JMP	BKSPAE	/TRY AGAIN
/
BKSPFI	JMS	CLREOT	/CLEAR THE EOT FLAGS ON BACKSPACE
	LAC*	MTNODE	/PICK UP THE REQUEST NODE POINTER
	TAD	XADJ
	PAX		/STORE IT IN XR
	LAC	7,X	/PICKUP THE FILE COUNT
	TCA		/COMPLEMENT IT FOR COUNT
	DAC	FILCNT	/SAVE FILES COUNT
BKSPF2	DZM*	WCA	/CLEAR WORD COUNT TO BACKSPACE N RECORDS
	DZM*	MTWCA	/CLEAR THE RETRY WORD COUNT ALSO
	JMS	COMPDP	/PICKUP THE DENSITY AND PARITY BITS
	XOR	(SR!IE)	/XOR IN THE SPACE REVERSE REQUEST
BKSPAG	JMS*	WFMT	/GO DO IT
	LAC*	MTEVAM	/PICK UP THE STATUS OF THE SPACING
	SMA		/IS IT NEGATIVE?
	JMP*	FINREQ	/NO BUT SOMETHING SCREWY HAPPENED EXIT
	AND	(FI!BT)	/CHECK FOR FILE MARK AND BEGINNING OF TAPE
	SNA!RTL	
	JMP	SPFERR	/SPACE ERROR
	SPA		/EOF?
	JMP	BTSPF	/CHECK IF BACKSPACE TOO FAR
	ISZ	FILCNT	/ENOUGH FILES?
	JMP	BKSPF2	/NO TRY AGAIN
	JMP*	FINREQ	/YES EXIT OK
/
BTSPF	ISZ	FILCNT	/FINISHED?
	JMP	ERM20	/NO BACKSPACE ERROR
	LAC*	MTEVAM	/IF TAPE AT START OF TAPE
	AND	(IC)	/AND FUNCTION NOT COMPLETE
	SZA		/RETURN EV OF -20
	JMP	ERM20
	JMP*	FINREQ	/YES REQUEST OK
/
SPFERR	LAC*	MTCMND
	XOR	(EP!OP)
	JMP	BKSPAG	/TRY AGAIN WITH OPPOSITE PARITY
/
COMPDP	0
	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER OF THIS REQUEST
	PAX		/SAVE IT IN XR
	ALS	17	/PUT IT IN UNIT NUMBER FOR MAGTAPE REGISTER
	AND	(700000) /MASK OFF UNIT NUMBER
	LMQ		/SAVE IT IN MQ
	LAC*	FMTDEN,X /PICKUP THE DENSITY
	SNA		/ISIT DEFAULT DENSITY?
	LAC	(D8)	/YES DEFAULT DENSITY 800 BPI
	OMQ		/OR IT WITH UNIT NUMBER
	LMQ		/SAVE IT BACK IN MQ
	LAC*	FMTPAR,X /PICK UP THE PARITY OF THE REQUEST
	SNA
	LAC	(OP)	/DEFAULT PARITY IS ODD PARITY
	OMQ		/COMPLETE REQUEST IN AC
	JMP*	COMPDP	/RETURN WITH REQUEST IN AC
/
SPREC	JMS	CKEOT	/CHECK END OF TAPE STATUS
	LAC*	MTNODE	/PICK UP THE ADDRESS OF THE REQUEST NODE
	TAD	XADJ	/ADD THE XR ADJUSTMENT
	PAX
	LAC	7,X	/PICK UPTHE NUMBER OF RECORDS TO BE
			/SPACED COUNT
	TCA		/COMPLEMENT IT
	DAC*	WCA	/SAVE IT IN  THE MAGTAPE WORDCOUNT
	DAC*	MTWCA
	JMS	COMPDP	/PICK UP THE COMMAND UNIT DENSITY AND PARITY
	XOR	(SF!IE)	/OR IN THE SPACE FORWARD REQEST
SFREC	JMS*	WFMT	/GO START MAGTAPE
	LAC*	MTEVAM	/PICK UP THE STATUS OF THE SPACE COMMAND
	SMA		/WAS THERE AN ERROR?
	JMP*	FINREQ	/NO -- REQUEST MUST HAVE BEEN OK
	AND	(FI!ET)	/CHECK FOR END OF FILE OR END OF TAPE
	ALS	5
	SPA!RAL		/END OF FILE?
	JMP	EOF	/YES -- RETURN END OF FILE STATUS
	SPA		/NO -- END OF TAPE STATUS?
	JMP	EOT	/YES END OF TAPE STATUS
	LAC*	WCA	/NO -- REAL ERROR
	SNA		/WAS THE REQUEST COMPLETE WITH THIS ERROR?
	JMP*	FINREQ	/YES -- RETURN TO USER REQUEST MUST BE OK
	LAC*	MTCMND	/PICK UP THE COMMAND REQUESTED
	XOR	(EP!OP)	/CHANGE THE PARITY OF THE REQUEST AND
	JMP	SFREC	/TRY AGAIN
/
SPFIL	JMS	CKEOT	/CHECK TO SEE IF FORWARD MOTION IS LEGAL
	LAC*	MTNODE	/PICK UP THE ADDRESS OF THE REQUEST NODE
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	LAC	7,X	/PICK UP THE FILE COUNT
	TCA		/MAKE IT NEGATIVE TO COUNT
	DAC	FILCNT
	DZM	LEOTFL	/CLDAR THE LOGICAL EOT FLAG
SPFILA	DZM*	WCA	/SPACE N RECORDS
	DZM*	MTWCA	/SETUP RETRY WORD COUNT
	JMS	COMPDP	/GET PARITY ETC
	XOR	(SF!IE)	/SPACE FORWARD INTERRUPT ENABLED
SPFILB	JMS*	WFMT	/START TAPE
	LAC*	MTEVAM	/PICK UP STATUS OF MOVE
	SMA		/WASI IT OK?
	JMP*	ERM12	/YES -- BUT IT CAN'T BE MUST BE SOME UNKNOWN ERROR
	AND	(ET!FI)	/CHECK FOR END OF TAPE OR END OF FILE
	ALS	5
	SPA!RAL		/EOF?
	JMP	EOFSFI	/YES COUNT 1 FILE
	SPA		/EOT?
	JMP	EOT	/YES EOT ERROR
	LAC*	MTCMND	/NONE OF ABLVE MUST BE PARITY SWITCH
	XOR	(EP!OP)
	JMP	SPFILB	/TRY AGAIN
/
SPEOT	JMS	CKEOT	/CHECK TO SEE IF AT EOT
	DZM	LEOTFL	/CLEAR THE LOGICAL EOT FLAG
	DZM	FILCNT	/CLEAR FILE COUNT
	JMP	SPFILA	/GO SPACE
/
EOFSFI	LAC*	MTWCA	/CHECK FOR LOGICAL END OF TAPE FOUND
	IAC
	SAD*	WCA	/ONLY 1 RECORD FOUND (EOF)?
	SKP		/YES  CHECK FOR LOGICAL EOF
	JMP	NOTSPF	/NOT LOGICAL EOF ALL OK
	LAC	LEOTFL	/EOT JUST FOUND?
	SNA
	JMP	NOTSPF	/NO ALL OK 1ST EOF
	LAC	(4)	/NOT OK LOGICAL EOF FOUND
	JMP*	FLSREQ	/RETURN +4 EV
/
NOTSPF	CLA!IAC	/SET UP LOGICAL EOT FLAG
	DAC	LEOTFL
	ISZ	FILCNT	/UPDATE FILE COUNT
	JMP	SPFILA	/CONTINUE
	LAC	(3)	/RETURN EOF STATUS
	JMP*	FLSREQ	/FINISHED EXIT
/
UMOUNT	LAC*	MTNODE	/PICK UP THE ADDRESS OF THE NODE
	TAD	XADJ	/ADD IN XR ADJUSTMENT
	PAX
	LAC	7,X	/PICK UP THE REQUEST TYPE
	SAD	(3)	/IS IT UNMOUNT?
	JMP	UNMNT	/YES GO UNMOUNT THE TAPE
	SAD	(2)	/IS IT MOUNT UNLABELED TAPE?
	JMP	UNLBL	/YES
	SAD	(1)	/IS IT MOUNT LABELED TAPE?
	SKP
	JMP	ERM70	/UNIMPLEMENTED FUNCTION
	LAC*	UNTTMP	/FIND THE UNIT NUMBER
	PAX
	CLA!IAC		/SET THE LABELED TAPE FLAG
	DAC*	MTLABL,X
	LAC	(2)
	DAC*	MTEOTT,X	/SET EOT FFLAG TO MOUNT
	JMP	LABLMS	/REQUEST OPERATOR MOUNT TAPE
/
UNLBL	LAC*	UNTTMP	/UNLABELED TAPE REQUEST PICK UP UNIT NUMBER
	PAX
	DZM*	MTLABL,X /CLEAR THE LABLED FLAG
	LAC	(2)
	DAC*	MTEOTT,X
LABLMS	PXA		/GET THE UNIT NUMBER
	CLL!RAL		/MOVE OVER 1 BIT
	XOR	UNTNO+1	/ADD IT INTO THE MESSAGE
	DAC	MSGUNT+1	/STORE IT INT THE MESSAGE
	CAL	WRTTY	/WRITE MESSAGE ON TTY
	CAL	WFEV	/WAIT FOR MESSAGE
	JMP*	FINREQ	/RETURN MOUNT FINISHED
UNMNT	LAC*	UNTTMP
	PAX		/PUT THE UNIT NUMBER IN XR
	CLA!IAC		/SET TO BUNMOUNT TAPE
	DAC*	MTEOTT,X
	JMP	REWIND	/REWIND THE TAPE
/
TAPMRK	JMS	CLREOT	/CLEAR THE EOT FLAG
	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER
	ALS	17	/SET UP REWIND REQUEST
	AND	(700000)
	XOR	(RI!IE!ID)	/REWIND TAPE
	JMS*	WFMT	/START TAPE
	LAC*	MTEVAM	/CHECK STATUS
	AND	(BT!RW)	/REWIND OR BEGINNING OF TAPE?
	SNA
	JMP	ERM12A	/NO ERROR
	LAC*	MTNODE	/PICK UP THE REQUESTING NODE
	TAD	XADJ
	PAX
	LAC	11,X	/WORD COUNT
	DAC	5,X
	DAC*	(R4)
	LAC*	MTNODE	/SET UP FOR VALADATE AND ADJUST
	DAC*	(R2)
	LAC	10,X
	DAC*	(R3)
	JMS*	(VAJX)
	JMP	ERM30	/PROTECT ERROR
	LAC*	MTNODE	/I/O RUNDOWN IS DONE HERE AS A SPECIAL CASE
	DAC*	(R2)	/TO ALLOW NODE TO BE USED AS CONTROL TABLE
	JMS*	(IOCD)	/I/O RUNDOWN CAN STILL BE DONE AND IT DOESN'T
			/HURT AT THIS POINT TO SET THE EVENT VARIABLE
	LAC*	MTNODE	/PICK UP NODE ADDRESS AGAIN
	TAD	XADJ
	PAX
	LAC	7,X	/SAVE THE MODE TYPE
	RAR
	LAC*	MTNODE
	AAC	4
	DAC	7,X	/SET CPB ADDRESS
	LAC*	(R3)
	DAC	4,X	/SET CORE ADDRESS
	DZM	3,X	/DON'T VALADATE AND ADJUST AGAIN
	PXL		/SAVE XR
	LAC*	UNTTMP
	PAX
	SZL!CLA!IAC
	DAC*	MTLABL,X
	PLX
	SNL		/READ OR WRITE?
	CLA
	AAC	30
	JMS*	MTPGET
/
/
WRTTY	2700	/WRITE MOUNT MESSAGE
	EVA
	3
	2
	MTMSG
MTMSG	MTMSGE-MTMSG/2*1000+2
	0
	.ASCII	'  *** MOUNT TAP'
MSGUNT	.ASCII	 'E MT0'<15>
MTMSGE=.
UNTNO	.ASCII	'E MT0'
WFEV	20
	EVA
EVA	0
/
EOF	LAC	(3)	/RETURN +3 FOR EOF
	JMP*	FLSREQ	/RETURN TO USER
/
UREC	LAC*	UNTTMP	/PICK UP UNIT NUMBER
	PAX
	DZM*	USREC,X	/CLEAR USER RECOVERY FLAG
	JMP*	FINREQ	/RETURN REQUEST FINISHED
/
HREC	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER
	PAX
	LAW	-1	/SET HANDLER RECOVERY IN FLAG
	DAC*	USREC,X
	JMP*	FINREQ	/RETURN REQUEST FINISHED
CKEOT	0
	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER OF THIS REQUEST
	PAX
	LAC*	MTEOTT,X /PICK UP THE UNIT STATUS FLAGS
	SPA		/EOT?
	JMP*	CKEOT	/NO -- REQUEST IS LEGAL
	JMP	ERM21	/YES -- ILLEGAL REQUEST CAN'T SPACE PAST EOT
/
CLREOT	0
	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER OF THIS REQUEST
	PAX
	LAC* MTEOTT,X /CHECK FOR POSITIVE FOR UNMOUNT REQUEST	/(019)
	SZA!CLA!CMA
	JMP*	CLREOT	/POSITIVE JUST REWIND
	DAC*	MTEOTT,X /SET THE EOT FLAG TO EOT NOT FOUND
	JMP*	CLREOT	/RETURN
XADJ	0
FILCNT	0
LEOTFL	0
	.END	MTMOV
