/IOPEN SUBROUTINE                          OS8 FORTRAN II LIBRARY
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1974,1977 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/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 RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS MANUAL.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED 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 PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/	VERSION 21A
/	VERSION NUMBER IS AVAILABLE AT ENTRY POINTS
/	SUBROUTINES TO MANIPULATE OS/8 FILES
/

	ENTRY	IOPEN	/OPEN AN INPUT FILE
	ENTRY	OOPEN	/OPEN AN OUTPUT FILE
	ENTRY	OCLOS	/CLOSE AN OUTPUT FILE
	ENTRY	CHAIN	/CHAIN TO A PROGRAM

	OPDEF	TADI	1400
	OPDEF	ISZI	2400
	OPDEF	DCAI	3400
	OPDEF	JMPI	5400

	LAP		/LEAVE AUTOMATIC PAGING - WE NEED THE 2 LOCATIONS

IOER,	1117;0522	/"IOER" ERROR MESSAGE
IOPEN,	BLOCK	1
	21
	TAD	ASDVM1
	JMS	SETUP	/PUT 2 WORDS OF FIRST ARGUMENT INTO "ASDEV"
	TADI	INHNDL	/DATA FIELD IS 0 HERE - GET INPUT HANDLER PAGE
	SNA
	JMP	IOERR	/NO /I GIVEN - ERROR
	DCAI	10	/STORE IN "ASPAGE"
	JMS	GFILNM	/MOVE FILE NAME INTO LOCS 00000-00003
	TAD	FLUKUP	/LOAD POINTER TO "FLUKUP" IN RUN-TIME ROUTINES
CALASN,	6202	/CIF 0
	JMS I	FASIGN	/SET DF=CURRENT AND GO LOOKUP FILE
	RETRN	IOPEN	/** FASIGN SKIPS BUT SECOND WORD IS SMALL **
IOERR,	CALL	1,ERROR	/I-O ERROR  - GIVE MESSAGE AND QUIT
	ARG	IOER

OOPEN,	BLOCK	1
	21
	JMS	OOCOMN
	TAD	FENTER
	JMP	CALASN	/SEE "IOPEN" FOR COMMENTS

OOCOMN,	0		/COMMON SUBR BETWEEN "OOPEN" AND "OCLOS"
	TAD	OOPEN
	DCA	IOPEN
	TAD	OOPEN#
	DCA	IOPEN#	/MOVE CALLING ADDRESS TO IOPEN
	TAD	ASDVM1
	JMS	SETUP	/SET UP DEVICE NAME IN FIELD 0
	TADI	OUHNDL
	SNA
	JMP	IOERR	/NO /O GIVEN - ERROR
	DCAI	10	/STORE IN "ASPAGE"
	JMS	GFILNM	/PUT FILE NAME INTO 00000-3
	JMPI	OOCOMN

OCLOS,	BLOCK	1
	21
	JMS	OOCOMN	/SET UP DEVICE AND FILE NAME
	TAD	OCLOS
	DCA	IOPEN
	TAD	OCLOS#
	DCA	IOPEN#	/SET UP IOPEN FOR RETURN
	TAD	CHAIN	/=7177
	DCA	OOCOMN
OCLOOP,	TAD	CHAIN#	/=1632 =^Z ON DEVICE 4 OUTPUT
	CALL	0,GENIO
	ISZ	OOCOMN
	JMP	OCLOOP	/FORCE OUT THE LAST BUFFER
	TAD	FCLOSE
	JMP	CALASN	/DO WORK AND LEAVE

SETUP,	0
	DCA	10
	TAD	IOPEN
	DCA	SETDF
SETDF,	0		/SET CALLING DATA FIELD
	TADI	IOPEN#
	DCA	GETWD#	/SAVE FIELD OF ARGUMENT
	INC	IOPEN#
	TADI	IOPEN#
	DCA	SETDF	/SAVE ADDRESS OF ARGUMENT
	INC	IOPEN#
	JMS	GETWD	/TRANSFER TWO WORDS FROM THE
	JMS	GETWD	/ARGUMENT LIST TO WHERE XR 10 POINTS
	JMPI	SETUP	/RETURN WITH DATA FIELD =0

GETWD,	0
	NOP		/SET ARGUMENT FIELD
	TADI	SETDF
	INC	SETDF
	6201		/CDF 00
	DCAI	10
	JMPI	GETWD	/DO NOT RESTORE DATA FIELD

GFILNM,	0
	CLA CMA
	JMS	SETUP	/MOVE TWO WORDS TO 00000 AND 00001
	JMS	GETWD	/MOVE THE THIRD WORD
	TAD	DA
	DCAI	10	/SUPPLY AN EXTENSION
	JMPI	GFILNM

DA,	0401		/.DA EXTENSION
INHNDL,	74
OUHNDL,	75
FASIGN,	541		/*****************
ASDVM1,	552		/		CAUTION!
FLUKUP,	567		/ALL THESE LOCATIONS ARE VERY VOLATILE!!
FENTER,	741		/WATCH OUT IF YOU REASSEMBLE THE LOADER!
FCLOSE,	757		/*****************

CHAIN,	7177		/USE "CHAIN" TO STORE CONSTANTS
	1632		/SINCE IT IS ONLY CALLED TERMINALLY
	TAD	CHAIN
	DCA	IOPEN
	CALL	0,CKIO	/WAIT FOR DEVICE
	TAD	CHAIN#
	DCA	IOPEN#
	JMS	GFILNM	/GET FILE NAME INTO 00000-00003
	ISZI	INHNDL	/FORCE INHNDL NONZERO SO IOPEN WONT FAIL
	TAD	SV	/CHANGE ASSUMED EXTENSION
	DCA	DA	/FROM .DA TO .SV
	TAD	(0310
	DCA	IOER	/IF IOPEN FAILS GIVE "CHER" MESSAGE
CALOPN,	CALL	1,IOPEN
	ARG	SYS	/CHAIN WORKS FROM THE SYSTEMS DEVICE ONLY
	6201
	0		/"ARG 0" POINTING TO 00000!
	TAD	(6
	6201		/SET DF TO 0
	DCAI	K2	/MODIFY "LOOKUP" INTO "CHAIN"
	DCAI	ZRONAM	/ALSO KILL LOC WHICH ZEROS FILE NAME PTR
	JMP	CALOPN	/GO BACK - THIS TIME IOPEN WILL CHAIN.

SYS,	2303		/***** 2303+2326 =4631 = "SYS"! WATCH IT!
SV,	2326
K2,	571		/**** SUPER VOLATILE LOCATION ****
ZRONAM,	557		/****     DITTO               ****

	END

