	.TITLE FILE
/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/EDIT 3  10-14-70
/
/
/FILE OPERATING SUBROUTINES
/	CALL FSTAT (N,A,I)
/	CALL DLETE (N,A,I)
/	CALL RENAM (N,A,B,I)
/	CALL ENTER (N,A)
/	CALL SEEK (N,A)
/	CALL CLOSE (N)
/	N = .DAT SLOT #
/	A,B = FILE ARRAY
/	I = COMPLETE SWITCH
/
	.GLOBL CLOSE,ENTER,SEEK,FSTAT,DLETE,RENAM
	.GLOBL .DA,.FH,.FC,.SS,.ER
	.GLOBL FILE
FILE=.
ENTER	0
	JMS* .DA		/GET ARGUMENT
	JMP .+3
EDAT	0		/ADDRESS OF SLOT # 
EFIL	0		/ADDRESS OF FILE ARRAY
	LAC (1		/TO INSURE .INIT FOR OUTPUT
	JMS INIT
	LAC EDAT		/.DAT ADDR.
	DAC ENT		/.DAT SLOT #
	LAC EFIL
	JMS BUILD		/BUILD FILE NAME
ENT	.ENTER 0,FILEN
	JMP* ENTER	/EXIT
SEEK	0
	JMS* .DA		/GET ARGUMENT
	JMP .+3
SDAT	0		/ADDRESS OF SLOT #
SFIL	0		/ADDRESS OF FILE ARRAY
	CLA		/TO INSURE .INIT FOR INPUT
	JMS INIT
	LAC SDAT		/.DAT ADDR.
	DAC SEE
	LAC SFIL
	JMS BUILD		/BUILD FILE NAME
SEE	.SEEK 0,FILEN
	JMP* SEEK
CLOSE	0
	JMS* .DA		/GET ARGUMENT
	JMP .+2
CDAT	0		/ADDRESS OF SLOT #
	LAC* CDAT		/.DAT #
	DAC CLS
CLS	.CLOSE 0
	JMP* CLOSE
FSTAT	0
	JMS* .DA		/GET ARGUMENT
	JMP .+4
FDAT	0		/ADDRESS OF SLOT #
FFIL	0		/ADDRESS OF FILE ARRAY
FOK	0		/ADDRESS OF COMPLETE SWITCH
	CLA
	JMS INIT
	LAC FDAT
	XOR (3000		/FOR .FSTAT
	DAC FST
	LAC FFIL
	JMS BUILD
FST	.FSTAT 0,FILEN
	SZA		/FOUND-?
	CLA!CMA		/YES-.TRUE.
	DAC* FOK		/NO - .FALSE.
	JMP* FSTAT
DLETE	0
	JMS* .DA		/GET ARGUMENT
	JMP .+4
DDAT	0		/ADDRESS OF SLOT #
DFIL	0		/ADDRESS OF FILE ARRRA//AY
DOK	0		/ADDRESS OF COMPLETE SWITCH
	LAC (1
	JMS INIT		/.INIT FOR OUUTPUT
	LAC DDAT
	XOR (1000		/FOR .LETE
	DAC DEL
	LAC DFIL
	JMS BUILD
DEL	.DLETE 0,FILEN
	SZA		/COMPLETED?
	CLA!CMA		/YES-.TRUE.
	DAC* DOK		/NO-.FALSE.
	JMP* DLETE
RENAM	0
	JMS* .DA		/GET  ARGUMENT
	JMP .+5
RDAT	0		/ADDRESS OF SLOT #
RFIL	0		/ADDRESS OF FILE ARRAY
RFILS	0		/ADDRESS OF SECOND FILE ARRAY
ROK	0		/ADDRESS OF COMPLETE SWITCH
	CLA
	JMS INIT
	LAC RDAT
	XOR (2000	/FOR .RENAM
	DAC REN
	LAC RFILS		/BUILD 2ND .SIXBIT NAME
	JMS BUILD
	LAC FILEN		/MOVE FILE NAME
	DAC FILENS
	LAC FILEN+1
	DAC FILENS+1
	LAC FILEN+2
	DAC FILENS+2
	LAC RFIL		/NOW FOR 1ST NAME
	JMS BUILD
REN	.RENAM 0,FILEN
	SZA		/FOUND?
	CLA!CMA		/YES-.TRUE.
	DAC* ROK		/NO-.FALSE.
	JMP* RENAM
FILEN	.BLOCK 3
FILENS	.BLOCK 3
BUILD	0
	DAC .+2		/TO COMPUTE ELEMENT ADDRESS
	JMS* .SS
	XX
	LAC (1
	DAC GETP		/START OF FILENAME
	LAW -1
	DAC GETC		/INITIALIZE UNPACK
	DAC PUTC
	LAC (FILEN-1	/FILE NAME AREA
	DAC PUTP
	LAW -11		/9 CHARACTERS
	DAC COUNT
	JMS GET		/MAKE FILE NAME FROM
	JMS PUT		/5/7 ASCII TO SIXBT
	ISZ COUNT
	JMP .-3
	JMP* BUILD	/EXIT
COUNT	0
GET	0		/UNPACK 5/7 ASCII
	ISZ GETC
	JMP GETS		/WORD
	LAC* GETP
	ISZ GETP
	DAC GET1		/FIRST PART
	LAC* GETP
	ISZ GETP
	DAC GET2		/LAST PART
	LAW -5
	DAC GETC		/RESET 5/7 COUNTER
GETS	LAW -10
	DAC GET3		/SHIFT LOOP 7+1/2 TIMES
GETL	LAC GET2
	RAL
	ISZ GET3
	JMP .+5
	AND (177		/GOT CHARACTER
	SAD (40
	CLA		/CHANGE SPACE TO NULL
	JMP* GET		/RETURN
	DAC GET2
	LAC GET1
	RAL
	DAC GET1
	JMP GETL		/BACK TO LOOP
GET1	0
GET2	0
GET3	0
GETP	0
GETC	0
PUT	0		/SIXBIT PACK
	ISZ PUTC
	JMP PUTS		/WORD BEGUN
	DAC PUT2		/SAVE CHAR
	ISZ PUTP
	LAW -3
	DAC PUTC		/RESET 3 CHAR CT.
	DZM* PUTP		/CLEAR WORD
	LAC PUT2
PUTS	AND (77		/SIXBIT TRIMMED
	DAC PUT2
	LAC* PUTP		/OLD CHARS
	CLL
	RTL
	RTL
	RTL
	XOR PUT2		/NEW CHAR
	DAC* PUTP
	JMP* PUT		/RETURN
PUTP	0
PUTC	0
PUT2	0
/MODIFICATIONS TO SLOT INITIALIZATION DECEMBER 1968
/
/THE FIRST STEP IS TO INITIALIZE THROUGH FIOPS.
/ASSOCIATED HANDLER WILL BE INITIALIZED ONLY IF
/FIOPS RECOGNIZES A CHANGE IN TRANSFER DIRECTION
/FROM ITS LAST ACTIVATION. HERE GOES...
/
INIT	0
	DAC* .FH		/XFR FLAG (0=READ;1=WRITE)
	XCT* INIT	/GET SLOT ADDRESS
	JMS* .FC		/CALL FIOPS
	DAC IN01		/SAVE SLOT #
/
/MUST NOW PERFORM OUR OWN INITIALIZATION SINCE
/FIOPS ".INIT'S" ONLY ON DIRECTION CHANGE.
/SUCCESSIVE .INIT-S IN THE SAME DIRECTION
/TO HANDLER ARE NOT HARMFUL...
/
	LAC* .FH		/GET XFR FLAG
	SZA		/BUILD .INIT CAL
	LAC (001000)	/001XXX IF WRITE
	XOR IN01		/000XXX IF READ
	DAC .+1
	.INIT	0,0,IN02	/ *** DDS JAN69 ***
	ISZ INIT
	LAC	IN01	/ *** DDS JAN69 ***
	JMP* INIT	/RETURN
IN01	0
IN02	JMS* .ER		/HERE IF BAD SLOT NUMBER
	.DSA 10		/UNRECOVERABLE OTS 10 ERROR
	.END
