	.TITLE	UNIT	MAGTAPE HANDLING ROUTINE
/ 
/ 
/                   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
/COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/EDIT #001  4-15-71  *REF*
/
/FORTRAN CALLABLE ROUTINE TO CHECK CERTAIN CONDITIONS ON
/  MAGTAPE.
/  THE FORTRAN CALL IS OF THE FOLLOWING FORM:
/       CALL UNIT (D, @N1, @N2, @N3, @N4)
/    WHERE D IS .DAT SLOT NUM., AND
/    WHERE THE N'S ARE STATEMENT NUMBERS TO WHICH CONTROL IS
/    TO BE RETURNED ON THE FOLLOWING CONDITIONS:
/      N1: DEVICE NOT READY
/      N2: DEVICE READY AND NO PREVIOUS ERROR
/      N3: EOF SENSED ON LAST INPUT OPERATION
/      N4: PARITY OR CHECKSUM ERROR ON LAST INPUT OPERATION
/
/R.E.F.
/
/--INTERNAL GLOBALS
	.GLOBL	UNIT
/--EXTERNAL GLOBALS
	.GLOBL	.DA
	.GLOBL	.DTBL		/HDR. WD. 0 TABLE (FIOPS)
/CALLING SEQUENCE--
/	JMS*	UNIT
/	JMP	.+6
/	.DSA	(SLOT
/	.DSA	ST. NUM. 1 ADDR.
/	.DSA	ST. NUM. 2 ADDR.
/	.DSA	ST. NUM. 3 ADDR.
/	.DSA	ST. NUM. 4 ADDR.
UNIT	0
	JMS*	.DA
	JMP	UNIT01
ADDT	0			/ADDR. OF .DAT SLOT
NRSA	0			/NOT READY ST. ADDR.
RNESA	0			/READY, NO ERROR ST. ADDR.
EOFSA	0			/EOF ST. ADDR.
PCHSA	0			/PARITY, CHKSM. ST. ADDR.
UNIT01	LAC*	ADDT		/GET SLOT NUM.
	TAD	.DTBL
	DAC	UNIT02		/PROPER TABLE ENTRY ADDR.
	LAC*	EOFSA
	DAC	UNIT03
	LAC*	UNIT02		/GET ENTRY: HDR. WD. 0 FOR LAST INPUT
	AND	(17		/GET MODE BITS
	SAD	(5		/SKP IF NOT EOF
	JMP*	UNIT03		/EXIT IF EOF
	LAC*	PCHSA
	DAC	UNIT03
	LAC*	UNIT02
	AND	(60		/VALIDITY BITS
	SAD	(20		/SKP IF NO PARITY ERROR
	JMP*	UNIT03		/EXIT IF PARITY ERROR
	SAD	(40		/SKP IF NOT CHECKSUM ERROR
	JMP*	UNIT03		/EXIT IF CHKSM. ERROR
	LAC*	NRSA
	DAC	UNIT03
/NOW CHECK IF MAGTAPE CONTROL AND DRIVE READY
	MTCR			/SKP ON TAPE CONTROL READY
	JMP*	UNIT03		/EXIT IF NOT READY
/--DO .WAITR CAL TO GET UNIT ASSOCIATED WITH .DAT SLOT
	LAC*	ADDT		/GET SLOT
	XOR	(1000
	DAC	UNWTR0
UNWTR0	XX
UNWTR1	12			/.WAITR CAL CODE
UNWTR2	.+1			/FALL THRU IN ALL CASES
	LAC	UNWTR1
	AND	(700000		/GET UNIT NUM.
	MTLC			/AC TO COMMAND REGISTER
	MTTR			/SKP IF TAPE TRANSPORT READY
	JMP*	UNIT03		/EXIT IF NOT READY
	LAC*	RNESA
	DAC	UNIT03
	JMP*	UNIT03		/TAKE READY, NO ERROR EXIT
	JMP*	UNIT
UNIT02=UNWTR0
UNIT03	0
MTCR=707321
MTTR=707301
MTLC=707326
	.END
/--DO .WAITR CAL TO GET UNIT ASSOCIATED WITH .DAT SLOT
	LAC*	ADDT		/GET SLOT
	XOR	(1000
	DAC	UNWTR0
UNWTR0	XX
UNWTR1	12			/.WAITR CAL CODE
UNWTR2	.+1			/FALL THRU IN ALL CASES
	LAC	UNWTR1
	AND	(700000		/GET UNIT NUM.
	MTLC			/AC TO COMMAND REGISTER
	MTTR			/SKP IF TAPE TRANSPORT READY
	JMP*	UNIT03		/EXIT IF NOT READY
	LAC*	RNESA
	DAC	UNIT03
	JMP*	UNIT03		/TAKE READY, NO ERROR EXIT
	JMP*	UNIT
UNIT02=UNWTR0
UNIT03	0
MTCR=707321
MTTR=707301
MTLC=707326
	.END
