	.TITLE	GET AND PUT FUNCTIONS
/ 
/ 
/                   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 # 7
/								/(008)
/ 008	10-MAY-76 (RCHM)	FIX DENSITY CHECKING AND EOT	/(008)
/				FLAGGING.			/(008)
/
/ COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ MAGTAPE I/O HANDLER TASK		20 NOV 71	R. MCLEAN
/
/
/
/	GET AND PUT HANDLER'S  ALLOW FOR TRANSFER OF
/		DATA GREATER THAN 177 WORD PAIR'S
/		THE STATUS IS RETURNED SO THE USER
/		CAN DETERMINE THE NUMBER OF CHARACTERS
/		ACTUALLY WRITTEN ON THE GIVEN TAPE
/		IT IS ALSO USEFUL IF USER ERROR RECOVERY
/		IS REQUESTED.  
/
/
	.GLOBL	MTPGET,FINREQ,FLSREQ,WFMT,MTEVAM,MTNODE,MTCAA,MTWCA,FMTDEN,FMTPAR
	.GLOBL	UNTTMP,MTEOTT,ERM12
/
/
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
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	MTPGET -- GET AND PUT ROUTINES
MTPGET	0
	DAC	RWFLAG	/SAVE THE REQUEST CODE 30 GET 31 PUT
	LAC	(MTPGET) /SET UP XADJ
	AND	(070000) /MASK OFF THE PAGE BITS
	TCA
	DAC	XADJ
	TAD*	MTNODE	/PICK UP THE ADDRESS OF THE NODE
	PAX		/SAVE IT IN XR
	LAC	7,X	/PICK UP THE USER'S BUFFER AREA
	DAC*	(R3)	/SET UP TO VALADATE AND ADJUST
	LAC*	MTNODE
	DAC*	(R2)
	LAC	(3)	/CHECK CONTROL TABLE FOR 3 WORDS LEGAL
	DAC*	(R4)
	JMS*	(VAJX)	/VALADATE AND ADJUST
	JMP	ERM30	/PROTECT ERROR
	LAC*	(R3)	/PICK UP CONTROL TABLE POINTER
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	DAC	XRSV	/SVE POINTER
	LAC	1,X	/PICK UP THE WORD COUNT
	TCA
	DAC*	WCA	/STORE IT IN THE MAGTAPE WORD COUNT REGITTERS
	DAC*	MTWCA	/SAVE IT IN CASE OF RETIRES
	TCA		/SET UP TO VALADATE AND ADJUST
	DAC*	(R4)
	LAC	0,X	/BUFFER POINTER
	DAC*	(R3)
	JMS*	(VAJX)	/VALADATE
	JMP	ERM30	/PROTECT ERROR
	LAC*	(R3)	/SET UP CURRENT ADDRESS POINTER
	AAC	-1
	DAC*	CAA
	DAC*	MTCAA	/SAVE IT INCASE OF ERRORS
	LAC*	UNTTMP	/PICK UP THE UNIT NUMBER
	PAX		/SAVE IT IN XR
	ALS	17	/MOVE IT TO UNIT POSITION FOR MAGTAPE REGISTER
	AND	(700000) /MASK OFF THE UNIT NUMBER
	LMQ		/SAVE IT IN MQ
	LAC*	MTEOTT,X /PICK UPTHE UNIT STATUS FLAGS
	SMA		/EOT STATUS?
	JMP	ERM21	/YES ERROR
	LAC	RWFLAG	/PICK UP THE READ WRITE CLAG
	SAD	(30)	/IS IT A GET?
	CLA!SKP		/YES ZERO AC
	LAC	(RD)	/NO BUILD A WRITE REQUEST
	TAD	(RD)	/ADD 2000 TO AC TO FORM READ OR WRITE REQUEST
	OMQ		/OR IT WITH MQ
	LMQ		/SAVE AC IN MT
	LAC*	FMTPAR,X /PICK UP THE PARITY
	SZA		/IS IT DEFAULT PARITY?
	JMP	NT9TRK	/NO USE SPECIFIED PARITY
	LAC* FMTDEN,X	/ PICK UP DENSITY FOR THIS UNIT.	/(008)
	AND	(D9-1)	/MASK OFF DENSITY
	SAD	(D9-1)	/IS IT 9 TRACK?
	SKP!CLA		/ YES, ADD IN CORE DUMP MODE BIT.	/(008)
	SKP!CLA		/NO ONLY ADD ODD PARITY
	LAC	(CD)	/APICK UP CORE DUMP MODE
	TAD	(OP)	/ADD ODD PARITY AND INTERRUPT ENABLED
NT9TRK	TAD	(IE)
	OMQ		/OR IT WITH MQ 
	LMQ		/SAVE IT IN MQ
	LAC*	FMTDEN,X /PICK UP THE DENSITY
	SNA		/IS IT DEFAULT?
	LAC	(D8)	/YES -- MAKE IT 7 TRACK 800 BPI
	OMQ		/OR WITH THE REST OF THE REQUEST
	JMS*	WFMT	/GO EXECUTE THE REQUEST IN AC
	LAC	XRSV	/RESTORE THE POINTER TO THE REQUESTING NODE
	PAX
	LAC*	MTEVAM	/PICK UP THE STATUS OF THE READ
	DAC	2,X	/RETURN IT TO THE USER'S CPB
	LAC	RWFLAG	/PICK UP THE GET PUT FLAG
	SAD	(31)	/IS IT A PUT?
	JMP	TRANOK	/YES DON'T CHECK FOR ILLEGAL LENGTH
	LAC*	MTEVAM	/PICK UP THE ERROR STATUS AGAIN
	AND	(IL)	/MASK OFF ILLEGAL LENGTH
	SNA		/WAS IT CORRECT?
	JMP	TRANOK	/YES 
	LAC*	MTWCA	/NO PICK UP THE REQUESTED WORD COUNT
	TCA		/MAKE IT POSITIVE
	TAD*	WCA	/SUBTRACT WORDS NOT FOUND
	DAC	1,X	/RETURN COUNT TO USER
	LAC*	MTEVAM	/PICK UP THE TAPE STATUS
	AND	(ET)	/LOOK FOR END OF TAPE STATUS
	SZA
	JMP	EOT	/YES EOT STATUS FLAG IT
	LAC*	MTEVAM	/PICK UP THE TAPE STATUS
	AND	(FI)	/WAS IT END OF FILE CONDITION?
	SZA!CLA
	JMP	EOF	/YES RETURN +3
	JMP*	ERM12	/NO -- UNKNOWN ERROR
TRANOK	LAC*	MTEVAM	/PICK UP THE STATUS
	AND	(EF!ET!FI)/ MASK OFF END OF FILE AND END OF TAPE
	SNA		/IF NONE OCCUR REQUEST IS OK
	JMP*	FINREQ	/REQUEST FINISHED RETURN +1
	PAL		/SAVE STATUS
	AND	(ET)	/WAS IT END OF TAPE?
	SZA
	JMP	EOT	/YES RETURN END OF TAPE STATUS
	PLA		/NO -- PICK UP THE STATUS AGAIN
	AND	(FI)	/WAS IT 
	SNA!CLA		/END OF FILE STATUS
	JMP*	ERM12	/NO -- TAPE REQUEST FAILED
EOF	AAC	3	/SET AC = 3 TO INDICATE END OF FILE STATUS
	JMP*	FLSREQ
EOT	LAC* UNTTMP	/ FETCH UNIT NUMBER, IT'S NOT IN THE	/(008)
	PAX		/ XR NOW AND PUT IT INTO THE XR.	/(008)
	DZM* MTEOTT,X	/ INDICATE AN EOT CONDITION.		/(008)
	LAC	(4)
	JMP*	FLSREQ	/RETURN END OF TAPE STATUS
/
ERM21	LAW	-21	/END OF TAPE FORWARD MOTION REQUEST'S ARE ILLEGAL
	JMP*	FLSREQ	/RETURN TO CALLER
ERM30	LAW	-30
	JMP*	FLSREQ
/
XADJ	0	/XR ADJUSTMENT
XRSV	0	/XR SAVE OF REQUEST NODE
RWFLAG	0	/REQUEST TYPE
	.END	MTPGET
