       .TITLE AUXIO
/
/COPYRIGHT (C) 1975
/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
	.EJECT
/COPYRIGHT 1970,1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/EDIT #015  1-27-72	R. FOLK, W.A. DESIMONE, R MCLEAN.
/	016	XX
/
/EDIT #017  29-JUL-75  R. K. BLACKETT
/	THE NAME OF THE FIOPS DOUBLE BUFFER ADDRESS TABLE HAS BEEN
/	CHANGED FROM 'BTABLE' TO '.BTABL' TO AVOID POSSIBLE CONFLICT WITH
/	CUSTOMER SYMBOLS.  THIS CHANGE WAS DONE WITH THE 'CONVERT' COMMAND,
/	SO NO EDIT MARKS WILL APPEAR ON THE CHANGED LINES.
/	ALSO, REMOVE HIGH DESCRIPTOR BITS FROM THE BUFFER ADDRESS BEFORE
/	ISSUING THE .GVBUF IN THE MASS STORAGE 'END FILE' CASE.
/	ALSO, REMOVE THE '.END' STATEMENT FROM WITHIN CONDITIONALIZED
/	CODE TO PREVENT GETTING THE ASSEMBLERS 'Y' ERROR.
/ EDIT #018	20-AUG-75	M. HEBENSTREIT	DISCLAIMER
/
/EDIT #019  24-NOV-75  R. K. BLACKETT
/	ADD A NEW ASSEMBLY PARAMETER, '%NODBL', TO PREVENT
/	DOUBLE BUFFERING FOR DOS, AND MAKE DOUBLE BUFFERED DEFAULT.
/
/
/
/DEFINE %V5A FOR V5A SYSTEMS
/DEFINE RSX FOR RSX SYSTEMS.
/
	.IFUND	RSX
	.IFUND %V5A
%DOS15=0
	.ENDC
	.IFUND	%NODBL		/(RKB-019)
%DBL=0				/(RKB-019)
	.ENDC			/(RKB-019)
/4-23-68
/AUXILIARY I/O STATEMENT OBJECT-TIME PACKAGE.
/   INTERNAL GLOBALS --
       .GLOBL .FT		       /BACKSPACE STATEMENT.
       .GLOBL .FU		       /REWIND STATEMENT.
       .GLOBL .FV		       /ENDFILE STATEMENT.
	.GLOBL AUXIO
AUXIO=.
/   VIRTUAL GLOBALS --
       .GLOBL .FH		       /READ/WRITE FLAG.
       .GLOBL .FC		       /I/O DEVICE INITIALIZER.
       .GLOBL .FQ		       /LINE BUFFER TRANSFER ROUTINE.
       .GLOBL .FN		       /LINE BUFFER
	.GLOBL	.CHKDL		/* CHK. DELETE BIT & DELETE IF NEC. (FIOPS)
	.IFDEF %DOS15
	.GLOBL .FLZW0,.FLZW,.DSK,.FLRA
	.ENDC
	.IFDEF  %DBL
	.GLOBL .BTABL
	.ENDC
/   CONSTANTS AND WORKING STORAGE--
C00001	.DSA	1
C00002 .DSA   2
V77777 .DSA   377777
S02000 .DSA   2000
IDLOC=.FU
CNT=FT00
SLOT=.FV
       .EJECT
/BACKSPACE
/  CALLING SEQUENCE -- JMS   .FT
/		   .DSA  ADDRESS OF SLOT NUMBER
.FT    CAL    0
       DZM*   .FH		       /SET READ/WRITE FLAG TO READ.
       LAC*   .FT		       /INITIALIZE DEVICE.
       JMS*   .FC
       DAC    SLOT	         /SAVE SLOT NUMBER.
       XOR    S02000         /SET .MTAPE FUNCTION 02.
       DAC    FT00
       DAC    FT01
	.IFDEF %DOS15
	DAC FT03
	.ENDC
       ISZ    .FT		       /BUMP RETURN ADDRESS.
	.IFDEF %DOS15
	LAC SLOT
	JMS* .FLRA	/FILE OPEN FOR RAND. ACC?
	JMP* .FT	/YES-IGNORE BACKSPACE
	.ENDC
       LAC    .FN		       /GET ADDRESS OF RECORD ID.
       TAD    C00002
       DAC    IDLOC
	DZM* IDLOC	/FOR BACKSPACE OVER EOF.
	.IFDEF %DBL
	LAC SLOT
	JMS SBTAB	/SET BIT 0 IN THE BUFFER ADDRESS TABLE IN FIOPS
	.ENDC
FT00   CAL    0		     /BACKSPACE ONE PHYSICAL RECORD, AND READ
       .DSA   7		     /   IT INTO LINE BUFFER.
       LAC    SLOT
	JMS* .FQ
	LAC* .FN
	AND (17
	XOR C00002
	SNA
	.IFUND %DOS15
	JMP FT02
	.ENDC
	.IFDEF %DOS15
	JMP FT03	/ASCII.  DONE
	.ENDC
       LAC*   IDLOC          /CLEAR OUT BIT ZERO OF ID AND IT IS NOW
       AND    V77777         /   ONE LESS THA5 THE 5UMBER OF PHYSICAL
FT02       CMA		/   RECORDS THAT MUST BE BACKSPACED.
       DAC    CNT		       /(-ID-1) TO COUNTER
FT01   CAL    0		     /BACKSPACE (ID+1) PHYSICAL RECORDS.
       .DSA   7
       ISZ    CNT
       JMP    FT01
       JMP*   .FT		       /EXIT
	.IFDEF %DOS15
FT03	0		/BACKSPACE TO UNDO .READ
	7
	JMP* .FT
	.ENDC
       .EJECT
/REWIND
/  CALLING SEQUENCE -- JMS   .FU
/		   .DSA  ADDRESS OF SLOT NUMBER
.FU    CAL    0
       DZM*   .FH		       /SET READ/WRITE FLAG TO READ.
       LAC*   .FU		       /INITIALIZE DEVICE.
       JMS*   .FC
       DAC    FU00
	.IFDEF %DOS15
	JMS* .FLRA	/FILE OPEN FOR RAND. ACC.?
	JMP FU02	/YES- IGNORE REWIND
	.ENDC
FU00   CAL    0		     /REWIND TAPE.
       .DSA   7
	.IFDEF %DOS15
	LAC FU00	/SLOT # INTO AC
	DAC FU03
	DAC FU04
	JMS* .DSK	/A DISK?
	SNA
	JMP FU02	/NO
	LAC FU00	/YES-
	JMS* .FLZW0	/ZERO FILE ACTIVE ACTIVE WORD AND
/PROCEED TO .CLOSE THE FILE
FU03	0		/.CLOSE
	6
FU04	0		/.WAIT
	12
	.ENDC
FU02       ISZ    .FU		       /BUMP RETURN ADDRESS.
	.IFDEF %DBL
	LAC FU00
	JMS SBTAB
	.ENDC
       JMP*   .FU		       /EXIT
       .EJECT
/WRITE END-OF-FILE
/  CALLING SEQUENCE -- JMS   .FV
/		   .DSA  ADDRESS OF SLOT NUMBER
.FV    CAL    0
       LAC    C00001         /SET READ/WRITE FLAG TO WRITE
       DAC*   .FH
       LAC*   .FV		       /INITIALIZE DEVICE.
       JMS*   .FC
       DAC    FV00
	DAC FV01
	JMS*	.CHKDL		/* CHK. DELETE AND DELETE IF NEC.
	.IFDEF %DOS15
	LAC FV00
	JMS* .FLZW	/ZERO FILE ENTRY
	.ENDC
FV00   CAL    0		     /CLOSE FILE.
       .DSA   6
FV01	0	/.WAIT
	12
       ISZ    .FV		       /BUMP RETURN ADDRESS.
	.IFDEF %DBL
	LAW -1
	TAD .BTABL
	TAD FV00
	DAC SBTAB1
	LAC* SBTAB1
	AND	(77777)	/(RKB-017) STRIP HIGH DESCRIPTOR BITS FROM BUF ADDR.
	DAC BUFADR
	SAD (-1
	JMP* .FV
	AND (100000	/CHECK FOR MASS STORAGE DEVICE
	SNA
	.ENDC
	JMP* .FV
	.IFDEF %DBL
	0
	22
BUFADR	0
	JMP* .FV
/
/
/
SBTAB	XX
	TAD .BTABL
	TAD (-1
	DAC SBTAB1
	LAC* SBTAB1
	AND (377777
	TAD (400000
	DAC* SBTAB1
	JMP* SBTAB
/
/
SBTAB1	XX
/
/
	.ENDC
	.ENDC
	.IFDEF	RSX
/AUXILIARY I/O STATEMENT OBJECT-TIME PACKAGE FOR RSX.
/ AUXIO HANDLES THE BACKSPACE, REWIND, AND ENDFILE
/ REQUESTS FOR FORTRAN OTS.
/   INTERNAL GLOBALS --
       .GLOBL .FT		       /BACKSPACE STATEMENT.
       .GLOBL .FU		       /REWIND STATEMENT.
       .GLOBL .FV		       /ENDFILE STATEMENT.
	.GLOBL AUXIO
AUXIO=.
/   VIRTUAL GLOBALS --
       .GLOBL .FH		       /READ/WRITE FLAG.
       .GLOBL .FC		       /I/O DEVICE INITIALIZER.
       .GLOBL .FQ		       /LINE BUFFER TRANSFER ROUTINE.
       .GLOBL .FN		       /LINE BUFFER
	.GLOBL .ER			/OTS ERROR ROUT.
	.GLOBL .XFLRA			/SUBR. TO DETERM. R.A. PROC. (FIOPS)
	.GLOBL .CHKDL			/SUBR. TO DEL. DEF. FILE ON ENDF. (FIOPS)
/   CONSTANTS AND WORKING STORAGE--
C00002 .DSA   2
V77777 .DSA   377777
EV	0			/QUEUE I/O REQ. EV.
IDLOC=.FU
SLOT=.FV
       .EJECT
/BACKSPACE
/  CALLING SEQUENCE -- JMS   .FT
/		   .DSA  ADDRESS OF LUN NUMBER
.FT    CAL    0
       DZM*   .FH		       /SET READ/WRITE FLAG TO READ.
       LAC*   .FT		       /INITIALIZE DEVICE.
       JMS*   .FC
       DAC    SLOT	         /SAVE LUN NUMBER.
	DAC	LUNS		/SET LOG. UNIT NO.
       ISZ    .FT		       /BUMP RETURN ADDRESS.
	JMS*	.XFLRA		/IF FILE BEING PROCESSED BY R.A.
	JMP*	.FT		/IGNORE BACKSPACE.  SUBR. RET. HERE IF YES.
       LAC    .FN		       /GET ADDRESS OF RECORD ID.
	AAC	2
       DAC    IDLOC
	DZM* IDLOC	/FOR BACKSPACE OVER EOF.
	CLA!IAC		/ALSO INIT. CNT TO 1 FOR SINGLE BACKSP.
	DAC	CNT
FT00	CAL	BKSP	/BACKSPACE ONE PHYSICAL RECORD, AND READ
	JMS	WFEVT	/WAIT FOR EV SETTING AND RETURN TO JMP IF ERROR.
	JMP	AUXERR	/RETURNS HERE IF ERROR.
       LAC    SLOT		/READ A RECORD.  IF BINARY, BACKSPACE
	JMS* .FQ		/ID+1 PHYS. RECORDS.  IF ASCII, BACKSPACE
	LAC* .FN		/ONE PHYSICAL RECORD.
	AND	(60)		/VALIDITY BITS SET?  IF CHKSM OR PARITY
	SZA!CLA			/,COULD BE DUE TO BINARY READ OF ASCII
				/DATA.  IF THIS THE CASE,ASSUME RECORD IS
				/ASCII AND PROCEED ACCORDINGLY.  IF IT WAS
				/A TRUE PARITY OR CHKSM OR SHORTLINE, ERROR
				/WILL BE CAUGHT LATER ON FORTRAN READ.
	JMP	FT02		/YES.  ASSUME ASCII.
       LAC*   IDLOC          /NO.(BINARY)  CLEAR OUT BIT ZERO OF ID AND IT IS NOW
       AND    V77777         /   ONE LESS THA5 THE 5UMBER OF PHYSICAL
FT02       IAC		/   RECORDS THAT MUST BE BACKSPACED. ADD 1 ID.
       DAC    CNT		       /(ID+1) TO COUNTER
FT01   CAL    BKSP		     /BACKSPACE (ID+1) PHYSICAL RECORDS.
	JMS	WFEVT	/WAIT FOR EV SETTING AND RET. TO JMP IF ERROR.
	JMP	AUXERR	/RETURNS HERE IF ERROR.
       JMP*   .FT		       /EXIT
/
/CAL PARAMETER BLOCKS
/
BKSP	4200		/BACKSPACE.
	EV
LUNS	0		/LOG. UNIT NO.
CNT	0		/BACKSPACE CNT.
/
WFEV	20		/WAITFOR.
	EV
/
/
       .EJECT
/REWIND
/  CALLING SEQUENCE -- JMS   .FU
/		   .DSA  ADDRESS OF LUN NUMBER
.FU    CAL    0
       DZM*   .FH		       /SET READ/WRITE FLAG TO READ.
       LAC*   .FU		       /INITIALIZE DEVICE.
       JMS*   .FC
       DAC    RLUN
	ISZ	.FU		/BUMP EXIT.
	JMS*	.XFLRA		/IF R.A. FILE BEING PROCESSED ON THIS LUN
	JMP*	.FU		/IGNORE REWIND.
FU00	CAL	REW		/REWIND TAPE
	JMS	WFEVT	/WAIT FOR EV SETTING.  RET. TO JMP IF ERROR.
	JMP	AUXERR	/RET. HERE IF ERROR.
       JMP*   .FU		       /EXIT
/
/CAL PARAMETER BLOCK.
REW	4100
	EV
RLUN	0		/LOGICAL UNIT NO.
/
/
/SUBR. TO CHECK FOR I/O ERROR AFTER A WAITFOR ON EV.
/CALLING SEQUENCE:
/	JMS	WFEVT		/EVENT VAR. ASSUMED TO BE EV.
/	JMP	ERROR		/RETURNS HERE IF NEG. EV.
/	NEXT INSTR.		/RETURNS HERE IF POS EV SETTING.
/
WFEVT	0			/SUBR. ENTRY.
	CAL	WFEV		/WAITFOR EV SETTING.
	LAC	EV
	DZM	EV		/REINIT. EV.
	SMA			/IF NEG., DON'T BUMP EXIT.
	ISZ	WFEVT		/BUMP EXIT.
	JMP*	WFEVT		/EXIT
/
/
AUXERR	JMS*	.ER		/ON NEG. EV SETTING,OUTPUT UNREC.
		20		/.OTS 20.
/
       .EJECT
/WRITE END-OF-FILE
/  CALLING SEQUENCE -- JMS   .FV
/		   .DSA  ADDRESS OF LUN NUMBER
.FV    CAL    0
       CLA!IAC         /SET READ/WRITE FLAG TO WRITE
       DAC*   .FH
       LAC*   .FV		       /INITIALIZE DEVICE.
	JMS*	.FC
	DAC	WFLUN			/LOG. UNIT NO.
	ISZ	.FV		/BUMP EXIT.
	JMS*	.XFLRA		/IF RAND ACC. FILE BEING PROCESSED ON
	JMP	FV1		/DON'T TREAT AS MAGTAPE.
	CAL	WEOF		/WRITE END OF FILE.
	JMS	WFEVT	/WAITFOR EV SETTING.  RET. TO JMP IF ERROR.
	JMP	AUXERR	/RETURNS HERE IF ERROR.
FV1	LAC	WFLUN		/FOR .CHKDL.
	JMS*	.CHKDL		/WON'T HURT IF MAGTAPE.  IF R.A. FILE
				/BEING PROCESSED ONNTHIS LUN,.CHKDL WILL
				/CLOSE OUT FILE AND DELETE IT IF IT WAS
				/A DEFAULT FILE AND THE DELETE OPTION WAS
				/SPEC. BY CALL DEFINE.  IN THE CASE OF
				/A LUN NOT PROC. A R.A. FILE, .CHKDL IS A NOP.
       JMP*   .FV		       /EXIT.
/
/CAL PARAMETER BLOCK.
WEOF	4400		/WRITE END-OF-FILE.
	EV
WFLUN	0		/LOGICAL UNIT. NO.
/
	.ENDC
	.END
