OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 1





      1						.TITLE	OPNCLS

      2						.IDENT	/01/

      3					;

      4					; COPYRIGHT (C) 1976

      5					; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

      6					;

      7					; THIS SOFTWARE IS FURNISHED UNDER  A LICENSE FOR USE ONLY  ON  A

      8					; SINGLE COMPUTER SYSTEM AND MAY BE  COPIED ONLY WITH  THE INCLU-

      9					; SION OF  THE  ABOVE  COPYRIGHT NOTICE.  THIS SOFTWARE,  OR  ANY

     10					; OTHER COPIES THEREOF, MAY NOT BE  PROVIDED  OR  OTHERWISE  MADE

     11					; AVAILABLE TO ANY OTHER PERSON EXCEPT  FOR  USE  ON  SUCH SYSTEM

     12					; AND TO  ONE WHO AGREES  TO  THESE LICENSE  TERMS.  TITLE TO AND

     13					; OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

     14					;

     15					; THE INFORMATION IN THIS SOFTWARE  IS  SUBJECT TO CHANGE WITHOUT

     16					; NOTICE AND SHOULD NOT BE CONSTRUED  AS  A COMMITMENT BY DIGITAL

     17					; EQUIPMENT CORPORATION.

     18					;

     19					; DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS

     20					; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

     21					;

     22					; VERSION 01

     23					;

     24					; K. D. MORSE 1-AUG-76

     25					;

     26					; MODIFICATIONS:

     27					;

     28					; NO		DATE		PROGRAMMER		PURPOSE

     29					; --		----		----------		-------

     30					;

     31					;

     32					; MACRO LIBRARY CALLS

     33					;

     34						.MCALL OPEN$R,OPEN$W,FDAT$R,CLOSE$,DELET$,PRINT$,CSI$2

     35						.MCALL CSI$1

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 2





     37					;+

     38					;**-OPNFIL-OPEN FILE

     39					;

     40					; THIS ROUTINE OPENS THE REQUESTED FILE.  A MAXIMUM OF FOUR FILES MAY BE

     41					; OPEN AT ONE TIME.  AN ERROR CODE IS RETURNED IF THE FILE COULD NOT

     42					; BE OPENED.

     43					;

     44					; INPUTS:

     45					;

     46					;	2(R5) IS THE ADDRESS OF THE FILE SPECIFICATION TO BE OPENED

     47					;	4(R5) IS THE ADDRESS OF THE LENGTH OF THE FILE SPECIFICATION

     48					;	6(R5) IS THE ADDRESS OF THE LUN TO BE ASSIGNED

     49					;      10(R5) IS THE ADDRESS OF THE I/O BUFFER TO BE USED ON THIS FILE

     50					;      12(R5) IS THE ADDRESS OF THE LENGTH OF THE I/O BUFFER

     51					;      14(R5) IS THE ADDRESS OF THE INDICATOR FOR THE TYPE OF FILE TO BE OPENED

     52					;		0 = INPUT

     53					;		1 = OUTPUT

     54					;      16(R5) IS THE ADDRESS OF THE SUCCESS/ERROR CODE

     55					;

     56					; OUTPUTS:

     57					;

     58					;	IF SUCCESS:

     59					;		ALL INPUTS REMAIN UNCHANGED

     60					;

     61					;	IF FAILURE:

     62					;		@16(R5) CONTAINS ONE OF THE FOLLOWING ERROR CODES

     63					;			>0 = SUCCESS

     64					;			-1 = NO FILE SPECIFICATION PROVIDED

     65					;			-2 = FOUR FILES ALREADY OPEN

     66					;			-3 = SWITCH ERROR IN SCANNING FILE SPECIFICATION

     67					;			-4 = ILLEGAL FILE TYPE

     68					;			-5 = OPEN ERROR

     69					;			-6 = INCORRECT SYNTAX IN FILE SPECIFICATION

     70					;

     71					;		@2(R5) CONTAINS THE SYNTACTICALLY INCORRECT PART

     72					;			(ONLY FOR ERROR CODE = -6)

     73					;		@4(R5) CONTAINS THE LENGTH OF THE SYNTACTICALLY INCORRECT PART

     74					;			(ONLY FOR ERROR CODE = -6)

     75					;		@10(R5) CONTAINS THE STANDARD SYSTEM ERROR CODE

     76					;			(ONLY FOR ERROR CODE = -5)

     77					;

     78					;-

     79					;

     80	000000	012775 	000001 	000016 	OPNFIL:: MOV	#1,@16(R5)	;ASSUME SUCCESS

     81	000006	012701 	000000G			MOV	#LUNMAP,R1	;GET ADDRESS OF TABLE MAPPING LUNS TO FDB'S

     82	000012	012702 	000004 			MOV	#4,R2		;COUNT UP TO FOUR POSSIBLE FILES BEING OPEN

     83	000016	005721 			10$:	TST	(R1)+		;IS THIS FDB IN USE?

     84	000020	001402 				BEQ	20$		;NO, GO USE IT

     85	000022	077203 				SOB	R2,10$		;YES, CHECK THE NEXT FDB

     86	000024	000536 				BR	90$		;ERROR, FOUR FILES ALREADY OPEN

     87	000026	162701 	000000G		20$:	SUB	#LUNMAP,R1	;COMPUTE OFFSET INTO LIST OF FDB'S

     88	000032	162701 	000002 			SUB	#2,R1		;SUBTRACT EXTRA INCREMENT

     89	000036	010167 	000000G			MOV	R1,OFFSET	;SAVE OFFSET VALUE

     90	000042					CSI$1	#CSIBLK,2(R5),@4(R5) ;CHECK SYNTAX OF FILE SPECIFICATION

     91	000066	103540 				BCS	94$		;BRANCH ON SYNTACTICAL ERROR

     92	000070	112767 	000002 	000000G		MOVB	#CS.OUT,CSIBLK+C.TYPR ;INITIALIZE CSI CONTROL BLOCK

     93	000076	016775 	000002G	000004 		MOV	CSIBLK+C.CMLD,@4(R5) ;GET LENGTH OF FILE SPECIFICATION

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 2-1





     94	000104	001531 				BEQ	94$		;ERROR AS NO FILE SPECIFICATION PROVIDED

     95	000106					CSI$2	#CSIBLK,,#SWTBL	;SET UP FILE DESCRIPTOR

     96	000124	103502 				BCS	91$		;ERROR IN FILE SPECIFICATION

     97	000126	012701 	000000G			MOV	#FDBADR,R1	;GET FIRST FDB ADDRESS

     98	000132	066701 	000000G			ADD	OFFSET,R1	;COMPUTE LOCATION OF FDB ADDRESS TO USE

     99	000136	011100 				MOV	(R1),R0		;GET FDB ADDRESS

    100	000140	027527 	000014 	000001 		CMP	@14(R5),#1	;OPEN FOR OUTPUT?

    101	000146	001426 				BEQ	30$		;YES, BRANCH

    102	000150	005775 	000014 			TST	@14(R5)		;NO, OPEN FOR INPUT?

    103	000154	001072 				BNE	92$		;NO, ERROR

    104	000156					OPEN$R	R0,@6(R5),#CSIBLK+C.DSDS,,10(R5),@12(R5) ;OPEN FOR OUTPUT

    105	000220	103454 				BCS	93$		;ERROR, RETURN

    106	000222	103030 				BCC	40$		;GO SET LUNMAP TO INDICATE FDB IN USE

    107	000224				30$:	FDAT$R	R0,#R.VAR,#FD.FTN ;INTITAIALIZE FORTRAN ATTRIBUTES

    108	000240					OPEN$W	R0,@6(R5),#CSIBLK+C.DSDS,,10(R5),@12(R5) ;OPEN FOR INPUT

    109	000302	103423 				BCS	93$		;ERROR, RETURN

    110	000304	012700 	000000G		40$:	MOV	#LUNMAP,R0	;GET MAPPING TABLE ADDRESS

    111	000310	066700 	000000G			ADD	OFFSET,R0	;FOR THIS LUN

    112	000314	017510 	000006 			MOV	@6(R5),(R0) 	;SET LUN VALUE INTO TABLE INDICATING FDB BUSY

    113	000320	103043 				BCC	100$		;DONE, RETURN

    114					;

    115					; ERROR CODE RETURNS

    116					;

    117	000322	012775 	177776 	000016 	90$:	MOV	#-2,@16(R5)	;FOUR FILES ALREADY OPEN

    118	000330	000437 				BR	100$		;RETURN

    119	000332	012775 	177775 	000016 	91$:	MOV	#-3,@16(R5)	;SWITCH OR EOF ERROR (CSI ERROR)

    120	000340	000433 				BR	100$		;RETURN

    121	000342	012775 	177774 	000016 	92$:	MOV	#-4,@16(R5)	;ILLEGAL FILE TYPE

    122	000350	000427 				BR	100$		;RETURN

    123	000352	012775 	177773 	000016 	93$:	MOV	#-5,@16(R5)	;OPEN ERROR

    124	000360	116075 	000000G	000010 		MOVB	F.ERR(R0),@10(R5) ;GET DIRECTIVE STATUS WORD ERROR CODE

    125	000366	000420 				BR	100$		;RETURN

    126	000370	005475 	000016 		94$:	NEG	@16(R5)		;SET ERROR CODE FOR NO FILE SPECIFIED

    127	000374	016002 	000016 			MOV	C.FILD(R0),R2	;INCORRECT FILE SPECIFICATION SYNTAX

    128	000400	010275 	000004 			MOV	R2,@4(R5)	;RETURN LENGTH OF INCORRECT PART

    129	000404	001411 				BEQ	100$		;IF EMPTY SPECIFICATION, RETURN

    130	000406	012775 	177772 	000016 		MOV	#-6,@16(R5)	;SET ERROR CODE TO INCORRECT SYNTAX

    131	000414	016003 	000020 			MOV	C.FILD+2(R0),R3	;GET ADDRESS OF INCORRECT PART

    132	000420	016504 	000002 			MOV	2(R5),R4	;GET RETURN ADDRESS FOR INCORRECT PART

    133	000424	112324 			95$:	MOVB	(R3)+,(R4)+	;MOVE IN INCORRECT PART

    134	000426	077202 				SOB	R2,95$		;REPEAT FOR LENGTH OF INCORRECT PART

    135	000430	000207 			100$:	RETURN

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 3





    137					;+

    138					;**-CLSFIL-CLOSE FILE

    139					;

    140					; THIS ROUTINE ACCEPTS AS INPUT A LOGICAL UNIT NUMBER AND CLOSES THE

    141					; FILE OPEN ON THAT LUN.  IF THE STATUS OF THE FILE SPECIFIES

    142					; THAT THE FILE IS TEMPORARY, THEN THE FILE IS DELETED AFTER IT IS CLOSED.

    143					;

    144					; INPUTS:

    145					;

    146					;	2(R5) IS THE ADDRESS OF THE LUN

    147					;	4(R5) IS THE STATUS OF THE CLOSE

    148					;		0 = CLOSE AND SAVE FILE

    149					;		1 = CLOSE AND DELETE FILE

    150					;		2 = CLOSE, SPOOL AND SAVE FILE

    151					;		3 = CLOSE, SPOOL AND DELETE FILE

    152					;	6(R5) IS THE ADDRESS OF THE SUCCESS/ERROR CODE

    153					;

    154					; OUTPUTS:

    155					;

    156					;	@6(R5) CONTAINS THE FAILURE/SUCCESS CODES FOR THE ROUTINE

    157					;		 >0 = SUCCESS, FILE ON LUN SPECIFIED CLOSED

    158					;		 -1 = ERROR, THE FILE WAS NOT OPEN

    159					;		 -2 = ERROR, UNABLE TO CLOSE AND DELETE FILE

    160					;		 -3 = ERROR, UNABLE TO CLOSE AND SAVE FILE

    161					;		 -4 = ERROR, UNABLE TO SPOOL FILE

    162					;		 -5 = ERROR, UNABLE TO DELETE SPOOLED FILE

    163					;		 -6 = ILLEGAL STATUS FOR CLOSE

    164					;

    165					;	@4(R5) CONTAINS THE FOLLOWING IF THE FAILURE CODE WAS -5 OR -6:

    166					;		<0 = STANDARD SYSTEM ERROR CODE OR DIRECTIVE STATUS WORD

    167					;

    168					;-

    169	000432	012775 	000001 	000006 	CLSFIL:: MOV	#1,@6(R5)	;ASSUME SUCCESS

    170	000440					CALL	LUNFDB		;GET FDB ADDRESS FOR THIS LUN

    171	000444	103420 				BCS	10$		;ERROR, FILE NOT OPEN

    172	000446	027527 	000004 	000003 		CMP	@4(R5),#3	;CHECK FOR LEGAL CLOSE STATUS

    173	000454	003016 				BGT	20$		;TOO LARGE, ERROR

    174	000456	027527 	000004 	000002 		CMP	@4(R5),#2	;SPOOL FILE?

    175	000464	002024 				BGE	50$		;YES, BRANCH

    176	000466	005775 	000004 			TST	@4(R5)		;NO, SAVE FILE?

    177	000472	001411 				BEQ	30$		;YES, BRANCH

    178	000474	002406 				BLT	20$		;NEGATIVE CODE, ERROR

    179	000476					DELET$	R0		;NO, CLOSE AND DELETE FILE

    180	000502	103525 				BCS	91$		;ERROR

    181	000504	000407 				BR	40$		;RETURN

    182	000506	000167 	000236 		10$:	JMP	90$		;ERROR RETURN

    183	000512	000167 	000316 		20$:	JMP	95$		;ERROR RETURN

    184	000516				30$:	CLOSE$	R0		;CLOSE AND SAVE FILE

    185	000522	103521 				BCS	92$		;ERROR

    186	000524	062701 	000000G		40$:	ADD	#LUNMAP,R1	;GET LUN MAPPING LOCATION

    187	000530	005011 				CLR	(R1)		;CLEAR LUN MAPPING ENTRY

    188	000532	000167 	000304 			JMP	100$		;RETURN

    189					;

    190					; SPOOL FILE

    191					;

    192	000536				50$:	PRINT$	R0		;SPOOL FILE

    193	000726	103423 				BCS	93$		;ERROR

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 3-1





    194	000730	022775 	000003 	000004 		CMP	#3,@4(R5)	;DELETE FILE?

    195	000736	001272 				BNE	40$		;NO, GO CLEAR LUN MAPPING

    196	000740					DELET$	R0		;DELETE THE SPOOLED FILE

    197	000744	103420 				BCS	94$		;ERROR

    198	000746	000666 				BR	40$		;RETURN

    199					;

    200					; ERROR CODES

    201					;

    202	000750	005475 	000006 		90$:	NEG	@6(R5)		;ERROR, FILE NOT OPEN

    203	000754	000432 				BR	100$		;RETURN

    204	000756	012775 	177776 	000006 	91$:	MOV	#-2,@6(R5)	;UNABLE TO CLOSE AND DELETE FILE

    205	000764	000426 				BR	100$		;RETURN

    206	000766	012775 	177775 	000006 	92$:	MOV	#-3,@6(R5)	;UNABLE TO CLOSE AND SAVE FILE

    207	000774	000422 				BR	100$		;RETURN

    208	000776	012775 	177774 	000006 	93$:	MOV	#-4,@6(R5)	;UNABLE TO SPOOL FILE

    209	001004	000416 				BR	100$		;RETURN

    210	001006	012775 	177773 	000006 	94$:	MOV	#-5,@6(R5)	;UNABLE TO DELETE SPOOLED FILE

    211	001014	016075 	000000G	000004 		MOV	F.ERR(R0),@4(R5) ;GET ERROR CODE

    212	001022	002407 				BLT	100$		;RETURN IF ERROR CODE IS NEGATIVE

    213	001024	016775 	000000G	000004 		MOV	$DSW,@4(R5)	;SEND/REQUEST ERROR, RETURN DIR. STATUS WORD

    214	001032	000403 				BR	100$		;RETURN

    215	001034	012775 	177772 	000006 	95$:	MOV	#-6,@6(R5)	;ILLEGAL STATUS FOR CLOSE

    216	001042	000207 			100$:	RETURN			;RETURN

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 4





    218					;+

    219					;**-LUNFDB-FIND FDB FOR A GIVEN LUN

    220					;

    221					; THIS ROUTINE ACCEPTS AS INPUT A LOGICAL UNIT NUMBER AND RETURNS THE

    222					; ADDRESS OF THE FDB ASSOCIATED WITH THIS LUN.

    223					;

    224					; INPUTS:

    225					;

    226					;	2(R5) IS THE ADDRESS OF THE LUN

    227					;

    228					; OUTPUTS:

    229					;

    230					;	R0 CONTAINS THE ADDRESS OF THE FDB

    231					;	R1 CONTAINS THE OFFSET INTO LUNMAP

    232					;

    233					;-

    234	001044	012701 	000000G		LUNFDB:: MOV	#LUNMAP,R1	;FIND ADDRESS OF LUNS IN USE

    235	001050	012702 	000004 			MOV	#4,R2		;CHECK ALL FOUR FDB'S

    236	001054	022175 	000002 		10$:	CMP	(R1)+,@2(R5)	;DOES LUN MATCH?

    237	001060	001402 				BEQ	20$		;YES, BRANCH

    238	001062	077204 				SOB	R2,10$		;NO, CHECK NEXT ONE

    239	001064	000412 				BR	90$		;NO MATCH, ERROR, FILE NOT OPEN

    240	001066	162701 	000002 		20$:	SUB	#2,R1		;SUBTRACT OFF EXTRA INCREMENT AND MAPPING

    241	001072	162701 	000000G			SUB	#LUNMAP,R1	;TABLE ADDRESS TO GET OFFSET TO FDB ADDR.

    242	001076	012702 	000000G			MOV	#FDBADR,R2	;GET ADDRESS OF FDB TABLE OF ADDRESSES

    243	001102	060102 				ADD	R1,R2		;GET ADDRESS OF FDB ADDRESS

    244	001104	011200 				MOV	(R2),R0		;GET FDB ADDRESS

    245	001106	000241 				CLC			;CLEAR CARRY, AS SUCCESS

    246	001110	000401 				BR	100$		;RETURN

    247	001112	000261 			90$:	SEC			;SET CARRY, AS FAILURE FILE NOT OPEN

    248	001114	000207 			100$:	RETURN			;RETURN

    249		000001 				.END

OPNCLS	MACRO M1110  22-AUG-78 02:22  PAGE 4-1

SYMBOL TABLE



CLSFIL  000432RG 	C.DIRD= 000012   	FD.REC= ****** GX	G.LUCW= 000004   	PAR$$$= 000000

CSIBLK= ****** GX	C.DSDS= 000006   	FO.RD = ****** GX	G.LUFB= 000003   	R.VAR = ****** GX

CS.DIF= 000002   	C.FILD= 000016   	FO.WRT= ****** GX	G.LUNA= 000000   	SWTBL = ****** GX

CS.DVF= 000004   	C.MKW1= 000024   	F.BDB = ****** GX	G.LUNU= 000002   	$DSPAT= ****** GX

CS.EQU= 000040   	C.MKW2= 000026   	F.DSPT= ****** GX	LUNFDB  001044RG 	$DSW  = ****** GX

CS.INP= 000001   	C.SIZE= 000054   	F.ERR = ****** GX	LUNMAP= ****** GX	$$$OST= 000014

CS.MOR= 000020   	C.STAT= 000001   	F.FACC= ****** GX	N.DID = ****** GX	.CLOSE= ****** G

CS.NMF= 000001   	C.SWAD= 000022   	F.FNB = ****** GX	N.FID = ****** GX	.CSI1 = ****** G

CS.OUT= 000002   	C.TYPR= 000000   	F.LUN = ****** GX	N.FVER= ****** GX	.CSI2 = ****** G

CS.WLD= 000010   	FDBADR= ****** GX	F.RATT= ****** GX	OFFSET= ****** GX	.DELET= ****** G

C.CMLD= 000002   	FD.FTN= ****** GX	F.RTYP= ****** GX	OPNFIL  000000RG 	.OPEN = ****** G

C.DEVD= 000006   	FD.OSP= ****** GX	F.URBD= ****** GX



. ABS.	000000	   000

      	001116	   001

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  3172 WORDS  ( 13 PAGES)

DYNAMIC MEMORY:  3828 WORDS  ( 14 PAGES)

ELAPSED TIME:  00:00:11

OBJ$:OPNCLS.OBI,LIS$:OPNCLS.LST/-SP=SRC$:OPNCLS.MAC

