Google
 

Trailing-Edge - PDP-10 Archives - ap-c796e-sb - frs.mac
There are no other files named frs.mac in the archive.
TITLE	FRS - FILE RETRIEVAL SYSTEM - %15.104
SUBTTL	FRANK NATOLI/FJN	02-JUN-74

;***COPYRIGHT(C) 1972,1973,1974 APPLIED DATA RESEARCH, INC., PRINCETON, N.J.***

	VWHO==:2	;CUSTOMER VERSION
	VFRS==:15	;RELEASE VERSION
	VMINOR==:0	;MINOR
	VEDIT==:104	;EDIT

	.JBVER==:137	;LOC OF PROGRAM VERSION

	LOC	.JBVER
	EXP	<VWHO>B2+<VFRS>B11+<VMINOR>B17+<VEDIT>B35

	RELOC		;SWITCH BACK

;TABLE OF SIXBIT LOOKUP/ENTER/RENAME ERRORS

ERRTBL:	SIXBIT	/FNFIPP/
	SIXBIT	/PRTFBM/
	SIXBIT	/AEFISU/
	SIXBIT	/TRNNSF/
	SIXBIT	/NECDNA/
	SIXBIT	/NSDILU/
	SIXBIT	/NRMWLK/
	SIXBIT	/NETPAO/
	SIXBIT	/BNFNSD/
	SIXBIT	/DNESNF/
	SIXBIT	/SLELVL/
	SIXBIT	/NCESNS/

	ERRLTH==:<.-ERRTBL>*2
SUBTTL	START UP CODE

FRS:	TDZA	S,S			;STANDARD START
	MOVSI	S,CCLST			;CCL START
	RESET				;RESET THE WORLD
	SETZB	CH,STOBEG		;CLEAR STORAGE
	MOVE	T1,[STOBEG,,STOBEG+1]	;BLT POINTER
	BLT	T1,STOEND		; ..
	MOVE	P,[IOWD PDLSIZ,PDL]	;LOAD PDP

IFN FTARCH,<
	PUSHJ	P,ARINIC##		;INITIALIZE ARCHIVE SYSTEM
>;END IFN FTARCH

IFN FTIND,<
	MOVE	T1,[IOWD MAXHOM+1,HMBBLK];FOR READING HOME BLOCKS
	MOVEM	T1,CMDHMB		;STORE
	MOVE	T1,[IOWD 200,BLKRIB]	;FOR READING RIB BLOCKS
	MOVEM	T1,CMDRIB		;STORE
>;END IFN FTIND

	MOVE	T1,[IOWD FRSLIM,EXLFIL]	;FOR READING UFD RIBS
	MOVEM	T1,CMDLST		;STORE

;HERE TO COPY SYSTEM NAME INTO MY CORE AREA

	MOVSI	T1,-5			;FIVE WORDS
	MOVE	T2,[SYSNAM,,CNFTBL]	;GETTAB WORD
LOOP1:	MOVE	T3,T2			;GET GETTAB
	GETTAB	T3,			;ACCESS
	  SETZ	T3,			;LOSE
	MOVEM	T3,USYSNM(T1)		;STORE
	ADD	T2,[1,,0]		;NEXT WORD
	AOBJN	T1,LOOP1		;LOOP

;HERE TO COPY VARIOUS OTHER MONITOR WORDS

	MOVE	T1,[MONVER,,CNFTBL]	;MONITOR VERSION
	GETTAB	T1,			;ACCESS
	  SETZ	T1,			;LOSE
	MOVEM	T1,UMONVR		;STORE

	MOVE	T1,[MFDPPN,,LVDTBL]	;MFD PPN
	GETTAB	T1,			;ACCESS
	  MOVE	T1,[1,,1]		;DEFAULT
	MOVEM	T1,UMFD			;STORE
;HERE TO COPY NAMES OF ALL STRS

	MOVSI	T1,-MAXSTR		;MAX NUMBER OF FS
	SETZ	T2,			;ZERO FS NAME
LOOP10:	SYSSTR	T2,			;GET A FS NAME
	  HALT	.			;***TEMP***
	JUMPE	T2,CNTUNI		;INITIALIZE PROTOTYPE
	MOVEM	T2,STRTBL(T1)		;STORE IN TABLE
	MOVE	T3,[POINT 6,T2]		;POINT AT FS NAME
	MOVSI	T4,-6			;MAX OF SIX CHARS
FNDEFS:	ILDB	P1,T3			;GET BYTE
	JUMPE	P1,EFSNAM		;NULL?
	AOBJN	T4,FNDEFS		;NO--LOOP
	HALT	.			;***TEMP***
EFSNAM:	HRRZS	T4			;RETAIN RH
	CAILE	T4,4			;MAX OF 4 CH
	HALT	.			;***TEMP***
	ADD	T3,[060000,,0]		;DECREMENT BYTE POINTER
	MOVEM	T3,STRPTR(T1)		;STORE
	AOBJN	T1,LOOP10		;KEEP GOING

CNTUNI:	SETZ	T1,			;START WITH FIRST UNIT
ASMUNI:	SYSPHY	T1,			;GET UNIT NAME
	  HALT	.			;***TEMP***
	JUMPE	T1,TBLSET		;JUMP IF DONE
	SETZM	DCHBLK			;ZILCH
	MOVE	T2,[DCHBLK,,DCHBLK+1]	; ..
	BLT	T2,DCHBLK+MAXDCH	; ..
	MOVEM	T1,DCHBLK		;STORE
	MOVE	T2,[MAXDCH,,DCHBLK]	;DSKCHR WORD
	DSKCHR	T2,			;ACCESS INFO
	  HALT	.			;***TEMP***
	SKIPN	T2,DCHBLK+.DCSNM	;GET STRUCTURE NAME
	JRST	ASMUNI			;NO STR
	MOVSI	T3,-MAXSTR		;CHECK ALL STR'S
	CAME	T2,STRTBL(T3)		;MATCH?
	AOBJN	T3,.-1			;NO--CONTINUE
	JUMPGE	T3,ASMUNI		;QUIT IF NOT THERE
	AOS	STRUNI(T3)		;INC COUNT
	JRST	ASMUNI			;LOOP
;HERE TO SET UP DATA BASE FOR COMMAND SCANNER

TBLSET:	MOVE	T1,[MFDDEF,,UFDDEF]	;LOAD DEFAULT SORT CODES
	MOVEM	T1,SRTWRD		;STORE

	MOVE	T1,[RQPROT,,PERM]	;COPY PROTOTYPE INTO PERM
	BLT	T1,PERM+RQLTH-1		; ..
	GETPPN	T1,			;GET PROJ-PROG
	  JFCL				;DON'T CARE
	MOVEM	T1,PERM+RQPPN		;STORE
	MOVEM	T1,PERM+RQPPNA		; ..
	MOVE	T1,[PERM,,TEMP]		;COPY PERMANENT INTO TEMP
	BLT	T1,TEMP+RQLTH-1		; ..

;HERE FOR MISC VARIABLES INITIALIZATION

	MOVEI	T1,14			;INIT MODE
	MOVEM	T1,OPNMTA		; ..
IFN FTARCH,<
	MOVEM	T1,OPNTDR##		; ..
>;END IFN FTARCH

	MOVEI	T1,1			;START WITH TAPE 1
	MOVEM	T1,SNTAPE		;STORE

;HERE TO ACCEPT HIS COMMAND INPUT

	OUTCHR	STAR			;SET FLAG

	MOVE	P4,[-COMLTH,,COMNAM]	;SET UP POINTER
	PUSHJ	P,IFIND			;TRY TO FIND COMMAND
	  JRST	NOCOM			;NO SUCH COMMAND
	PUSH	P,COMDSP(T1)		;SAVE DISPATCH WORD
	PUSHJ	P,FRMSPC		;CALL SUBROUTINE
	  JRST	[POP	P,T1		;RESTORE C(T1)
		PUSHJ	P,FLUSH		;FLUSH REST OF LINE
		JRST	FRS]		;RESTART
	POP	P,T1			;RESTORE C(T1)
	PUSHJ	P,0(T1)			;CALL ROUTINE
	JRST	FRS			;RESTART
SUBTTL	COMMAND SUBROUTINES

COMMENT	$
SAVE COMMAND

TRANSFERS DATA FROM DSK TO MTA

TYPICAL COMMAND STRING:  *SAVE MTAN:SETNAM=FILE1,FILE2,...,FILEN
$
OFFLIN:
IFN FTRECO,<
	MOVEI	T1,IONRC		;TURN IONRC ON
	IORM	T1,OPNMTA		; ..
>;END IFN FTRECO
	SOSE	NOSPEC			;JUST ONE OUTPUT SPEC
	JRST	JUST1O			;ASK FOR ONLY ONE OUTPUT SPEC
	SOSG	NTSPEC			;MUST HAVE SOME INPUTS
	JRST	JUST1I			;BEG FOR INPUTS

	MOVEI	T1,RQLTH		; ..
	ADDB	T1,AOSPEC		; ..
	SKIPN	T2,-RQLTH+RQDEV(T1)	;GET DEVICE NAME
	MOVSI	T2,'FRS'		;DEFAULT DEVICE NAME
	MOVEM	T2,OPNMTA+1		;STORE
	DEVNAM	T2,			;GET PHYSICAL NAME
	  SETZ	T2,			;STRANGE
	MOVEM	T2,UPHYN		;STORE
	MOVE	T1,-RQLTH+RQNAM(T1)	;GET SAVE NAME
	MOVEM	T1,UNAME		;STORE
	MOVSI	T1,MTAHDR		;BUFFER HEADER FOR WRITING
	MOVEM	T1,OPNMTA+2		; ..
	MOVEI	P2,NMTAOB		;NUMBER OF BUFFERS
	PUSHJ	P,INIMTA		;INITIALIZE MTA
	  POPJ	P,0			;RETURN
	PUSHJ	P,INIPOS		;POSITION
	PUSHJ	P,DUMOUT		;DO DUMMY OUTPUT
	PUSHJ	P,SAVALL		;CALL DSK TO MTA ROUTINE
	PUSHJ	P,CHECK			;CHECK OUT SPECS
FIN1::	CLOSE	MTA,0			;FINISH OFF I/O
FIN2:	PUSHJ	P,ENDPOS		;POSITION
	RELEAS	MTA,0			;TERMINATE CHANNEL
	POPJ	P,0			;RETURN
COMMENT	$
RESTORE COMMAND

TRANSFERS DATA FROM MTA TO DSK

TYPICAL COMMAND STRING:  *RESTORE FILE1-ALIAS1,FILE2-ALIAS2,...,FILEN-ALIASN=MTAN:SETNAM
$
ONLINE:	SOS	T1,NTSPEC		;GET TOTAL NUMBER OF SPECS
	MOVE	T2,T1			;COPY
	SUB	T2,NOSPEC		;GET NUMBER OF INPUT SPECS
	JUMPN	T2,JUST1I		;COMPLAIN IF NOT JUST 1

	IMULI	T1,RQLTH		;COMPUTE OFFSET FOR MTA SPEC
	ADD	T1,AOSPEC		;ADD ADDRESS OF SPECS
	SKIPN	T2,RQDEV(T1)		;GET DEVICE NAME
	MOVSI	T2,'FRS'		;DEFAULT
	MOVEM	T2,OPNMTA+1		;STORE
	MOVE	T1,RQNAM(T1)		;GET SAVE SET NAME (IF ANY)
	MOVEM	T1,UNAME		;STORE
	MOVEI	T1,MTAHDR		;INPUT ONLY
	MOVEM	T1,OPNMTA+2		;STORE
	MOVEI	P2,NMTAIB		;NUMBER OF INPUT BUFFERS
	PUSHJ	P,INIMTA		;INI
	  POPJ	P,0			;NO CORE
	PUSHJ	P,INIPOS		;POSITION
	PUSHJ	P,RSTALL		;RESTORE
	  POPJ	P,0			; ..
	PUSHJ	P,CHECK			;CHECK OUT SPECS
	JRST	FIN1			;FINISH
;TLIST COMMAND
;
;LISTS CONTENTS OF MTA ON DIRECTED DEVICE
;
;TYPICAL COMMAND STRING:  *TLIST DEV:FILE.EXT[PROJ,PROG]=MTAN:

TLIST:	SOSE	NOSPEC			;CHECK FOR 1 SPEC
	JRST	JUST1O			;ONLY 1 OUTPUT
	SOS	T1,NTSPEC		;GET TOTAL NUMBER OF SPECS
	SOJN	T1,JUST1I		;ONLY 1 INPUT

	MOVE	P1,AOSPEC		;GET ADDRESS OF SPECS
	SETZ	T1,			;ASCII MODE
	SKIPN	T2,RQDEV(P1)		;GET FS NAME
	MOVSI	T2,'DSK'		;ASSUME DEVICE DSK
	MOVEM	T2,CSTR			;STORE
	MOVSI	T3,LSTOB		;OUTPUT ONLY
	OPEN	LST,T1			;INITIALIZE
	  JRST	DVFAIL			;LOSE
	SETZM	EXLFIL			;ZERO BLOCK
	MOVE	T1,[EXLFIL,,EXLFIL+1]	; ..
	BLT	T1,EXLFIL+FRSLIM	; ..
	MOVEI	T1,FRSLIM		;LOAD BLOCK
	MOVEM	T1,EXLFIL+RIBCNT	; ..
	MOVE	T1,RQPPN(P1)		; ..
	MOVEM	T1,EXLFIL+RIBPPN	; ..
	SKIPN	T1,RQNAM(P1)		; ..
	MOVSI	T1,'FRS'		; ..
	MOVEM	T1,EXLFIL+RIBNAM	; ..
	SKIPN	T1,RQEXT(P1)		; ..
	MOVSI	T1,'TXT'		; ..
	MOVEM	T1,EXLFIL+RIBEXT	; ..
	ENTER	LST,EXLFIL		;ENTER FILE
	  JRST	EEFIL			;LOSE
	OUTBUF	LST,NLSTOB		;MAKE OUTPUT BUFFERS
	SKIPN	T1,RQLTH+RQDEV(P1)	;GET MTA NAME
	MOVSI	T1,'FRS'		;DEFAULT
	MOVEM	T1,OPNMTA+1		; ..
	MOVEI	T1,MTAHDR		;INPUT ONLY
	MOVEM	T1,OPNMTA+2		; ..
	MOVEI	P2,NMTAIB		;NUMBER
	PUSHJ	P,INIMTA		;MAKE BUFFERS
	  POPJ	P,0			;RETURN
	PUSHJ	P,INIPOS		;POSITION
	PUSHJ	P,MLIST			;LIST TAPE
	  POPJ	P,0			;RETURN
	RELEAS	LST,0			;TERMINATE CHANNEL
	CLOSE	MTA,0			;CLOSE CHANNEL
	MTBSF.	MTA,			;BACK UP ONE FILE
	MTWAT.	MTA,			;WAIT FOR COMPLETION
	JRST	FIN2			;FINISH
COMMENT	$
LABEL COMMAND

WRITES LABEL ON DIRECTED MTA

TYPICAL COMMAND STRING:  *LABEL MTAN:
$
LABEL:
IFN FTRECO,<
	MOVEI	T1,IONRC		;TURN IONRC ON
	IORM	T1,OPNMTA		; ..
>;END IFN FTRECO
	SOSE	NOSPEC			;JUST 1 OUTPUT
	JRST	JUST1O			;LOSE

	MOVE	T1,AOSPEC		;GET ADDRESS OF SPECS
	SKIPN	T1,RQDEV(T1)		;GET NAME OF MTA
	MOVSI	T1,'FRS'		;DEFAULT
	MOVEM	T1,OPNMTA+1		;STORE
	MOVSI	T1,MTAHDR		;GET HEADER ADDRESS
	MOVEM	T1,OPNMTA+2		;STORE

	MOVEI	P2,1			;JUST 1 RECORD
	PUSHJ	P,INIMTA		;INIT
	  POPJ	P,0			;LOSE
	PUSHJ	P,INIPOS		;POSITION
	STATO	MTA,IOBOT		;MUST BE AT LOAD POINT
	JRST	NEEDBT			;TELL DUMMY
	PUSHJ	P,DUMOUT		;DO DUMMY OUTPUT

	MOVSI	T1,TLBL			;LABEL RECORD
	MOVEM	T1,0(MBUF)		;STORE
	MOVE	T1,REELNM		;NAME GIVEN
	MOVEM	T1,LBLNAM(MBUF)		;STORE
	MSTIME	T1,			;READ CLOCK
	MOVEM	T1,LBLTC(MBUF)		;STORE
	DATE	T1,			;READ CALENDAR
	MOVEM	T1,LBLDC(MBUF)		;STORE
	MOVE	T1,DSTDAY		;GET DESTRUCT DATE
	MOVEM	T1,LBLDD(MBUF)		;STORE
	MOVE	T1,[TEXT,,LBLCOM]	;COMMENT WORD(S)
	ADD	T1,MBUF			;FORM ADDRESS
	BLT	T1,LBLCOM+<MAXCHR/5>(MBUF);TRANSFER
	PUSHJ	P,MTAOUT		;OUTPUT
	JRST	FIN1			;FINISH
;TAPE POSITIONING COMMANDS
;
;INITIALIZES LOCATION OF TAPE
;
;TYPICAL COMMAND STRING:  *POSITION MTAN:

TAPE:	SOSE	NOSPEC			;JUST 1 OUTPUT
	JRST	JUST1O			;INSURE
	MOVE	T1,AOSPEC		;GET ADDRESS OF SPECS
	SKIPN	T1,RQDEV(T1)		;GET MTA NAME
	MOVSI	T1,'FRS'		; ..
	MOVEM	T1,OPNMTA+1		;STORE
	DEVCHR	T1,			;GET CH
	TLNN	T1,DV.MTA		;INSURE MTA
	JRST	NOTMTA			;BALK
	SETZM	OPNMTA+2		;NO BUFFERS
	OPEN	MTA,OPNMTA		;INIT DEVICE
	  JRST	MTFAIL			;LOSE
	JRST	CPOPJ1			;SKIP BACK

REWIND:	PUSHJ	P,TAPE			;SET UP TAPE
	  POPJ	P,0			;LOSE
	MTREW.	MTA,			;REWIND
	MTWAT.	MTA,			;WAIT
	RELEAS	MTA,0			;FINISH OFF CHANNEL
	POPJ	P,0			;RETURN

SKIP:	PUSHJ	P,TAPE			;SET UP TAPE
	  POPJ	P,0			;LOSE
	MTSKF.	MTA,			;SKIP A FILE
	MTWAT.	MTA,			;WAIT
	RELEAS	MTA,0			;RELEASE CHANNEL
	POPJ	P,0			;RETURN
;HELP COMMAND

HELP:	OUTSTR	HLPMSG
	MOVSI	P1,-COMLTH
HELP1:	MOVE	T1,COMNAM(P1)
	PUSHJ	P,SIXOUT
	OUTSTR	CRLF
	AOBJN	P1,HELP1
	POPJ	P,0

HLPMSG:	ASCIZ	/COMMANDS:
/
SUBTTL	COMMAND SCANNER PURE DATA

	DEFINE	COMMANDS<
	X	<>,FLUSH,	;;NO COMMAND
	X	RESTORE,ONLINE,	;;MTA TO DSK
	X	SAVE,OFFLIN,	;;DSK TO MTA
	X	LIST,TLIST,	;;LIST MTA
IFN FTARCH,<
	X	ASAVE,ASAVE##,	;;ARCHIVAL SAVE
	X	ARESTORE,ARESTO##,;;ARCHIVAL RESTORE
>;END IFN FTARCH
	X	LABEL,LABEL,	;;LABEL MTA
	X	HELP,HELP,	;;HELP TEXT
	X	REWIND,REWIND,	;;REWIND MTA
	X	SKIP,SKIP,	;;SKIP TO NEXT EOF ON MTA
>
	DEFINE	X(A,B)<
	EXP	SIXBIT	/A/
>
COMNAM:	COMMANDS

	COMLTH==.-COMNAM

	DEFINE	X(A,B)<
	EXP	B
>
COMDSP:	COMMANDS
	DEFINE	SWITCHES<
	X	CUD,STOD,RQCUD,		;;CREATION UPPER DATE
	X	CUT,SCUT,RQCUT,		;;CREATION UPPER TIME
	X	CLD,STOD,RQCLD,		;;CREATION LOWER DATE
	X	CLT,SCLT,RQCLT,		;;CREATION LOWER TIME
	X	AUD,STOD,RQAUD,		;;ACCESS UPPER DATE
	X	ALD,STOD,RQALD,		;;ACCESS LOWER DATE
	X	MAXBLK,SDEC,RQMAXB,	;;MAXIMUM BLOCK SIZE
	X	MINBLK,SDEC,RQMINB,	;;MINIMUM BLOCK SIZE
	X	SCATTER,CFLAG1,NSCATR,	;;SCATTER FILES
	X	NOSCATTER,SFLAG1,NSCATR,;;DO NOT SCATTER FILES
	X	SCAN,CBIT1,RQNSN.,	;;BACKSCAN SFD'S
	X	NOSCAN,SBIT1,RQNSN.,	;;DO NOT BACKSCAN SFD'S
	X	NEWER,SBIT1,RQNEW.,	;;LOOKUP FILES
	X	NEVER,SBIT1,RQNEV.,	;;DO NOT SUPERCEDE FILES
	X	ALWAYS,CBIT1,RQNEW.!RQNEV.,;;ALWAYS SUPERCEDE FILE
	X	SHORT,SFLAG1,SHORT,	;;DO ABBREVIATED TLIST
	X	NUSETI,SFLAG1,NUSETI,	;;DO NOT USE SUPER USETI'S
	X	1REWIND,SFLAG1,RWD1,	;;REWIND TAPE BEFORE USING
	X	1EOT,SFLAG1,EOT1,	;;SKIP TO EOT BEFORE USING
	X	1SKIP,SFLAG1,SKP1,	;;SKIP ONE FILE BEFORE USING
	X	2REWIND,SFLAG1,RWD2,	;;REWIND TAPE AFTER USING
	X	2UNLOAD,SFLAG1,UNL2,	;;UNLOAD TAPE AFTER USING
	X	DENSITY,SDENS,0,	;;TAPE DENSITY
	X	PARITY,PARITY,0,	;;EVEN OR ODD
	X	MFDSRT,MFDSRT,0,	;;MFD SORT
	X	UFDSRT,UFDSRT,0,	;;UFD SORT
	X	REEL,SIXSTO,REELNM,	;;SIXBIT REEL NAME
	X	DSTDAY,SDATE,DSTDAY,	;;REEL DESTRUCT DATE
	X	NTAPE,SWDEC,SNTAPE,	;;RELATIVE REEL NUMBER
	X	COMMENT,UCOM,TEXT,	;;STORE TEXT
	X	PASSWORD,UCOM,PSWD,	;;STORE ENCRIPTION CODE
IFN FTIND,<
	X	IND,SFLAG1,IND,		;;INDEPENDENT DSK IO
	X	NOIND,CFLAG1,IND,	;;NO INDEPENDENT DSK IO
>;END IFN FTIND
>
	DEFINE	X(A,B,C)<
	EXP	SIXBIT	/A/
>
SWTNAM:	SWITCHES

	SWTLTH==.-SWTNAM
	DEFINE	X(A,B,C)<
	XWD	C,B
>
SWTDSP:	SWITCHES
SUBTTL	COMMAND SCANNER SUBROUTINE

FRMSPC:	TLZ	S,SPECH!ALIAS!EQH	;ZILCH BITS
	MOVE	T1,.JBFF##		;GET PROGRAM BREAK
	MOVEM	T1,AOSPEC		;STORE AS ADDRESS OF SPECS
	SETZM	NTSPEC			;ZILCH
	SETZM	NOSPEC			; ..
	MOVSI	LVL,-<MAXLVL+1>		;HOW DEEP TO GO PLUS 1
	JUMPE	CH,GOTEND		;JUMP IF NOTHING TO COME
	JUMPG	CH,TSTINI		;JUMP IF ANYTHING BUT SPACE OR TAB

FRM1:	PUSHJ	P,SIXIN			;GET SIXBIT WORD
	JUMPE	P2,NAMDON		;BRANCH IF NULL
	CAIE	CH,":"			;DEVICE?
	JRST	TST1			;NO--CONTINUE
	TLO	S,SPECH			;FLAG AS BEING INSIDE SPEC
	MOVSI	T1,-1			;THREE SIGNIFICANT CH
	CAME	T1,P2			;MATCH?
	JRST	NOTDSK			;NO
	MOVSI	T1,'DSK'		;GENERIC DSK?
	CAME	T1,P1			;CHECK
	JRST	NOTDSK			;NO
	SETZ	P1,			;CHANGE TO STAR
	SETOB	P2,P3			; ..
NOTDSK:	JUMPL	S,DEVALI		;ALIAS FILE?
	MOVEM	P1,TEMP+RQDEV		;STORE
	MOVEM	P1,TEMP+RQDEVA		; ..
	MOVEM	P3,TEMP+RQDEVW		; ..
	JRST	DEVDON			;FINISH
DEVALI:	CAME	P3,TEMP+RQDEVW		;WILD CARDS MUST MATCH
	JRST	WLDERR			;COMPLAIN
	MOVEM	P1,TEMP+RQDEV		;STORE

DEVDON:	PUSHJ	P,SIXIN			;GET NEXT
	JUMPE	P2,NAMDON		;NULL?
TST1:	TLO	S,SPECH			;FLAG
	JUMPL	S,NAMALI		;ALIAS FILE?
	MOVEM	P1,TEMP+RQNAM		;STORE
	MOVEM	P1,TEMP+RQNAMA		; ..
	MOVEM	P3,TEMP+RQNAMW		; ..
	JRST	NAMDON			;FINISH
NAMALI:	CAME	P3,TEMP+RQNAMW		;WILDS MUST MATCH
	JRST	WLDERR			;LOSE
	MOVEM	P1,TEMP+RQNAM		;STORE
NAMDON:	CAIE	CH,"."			;EXTENSION FORTHCOMING?
	JRST	EXTDON			;NO--MAYBE PPN
	TLO	S,SPECH			;FLAG
	PUSHJ	P,SIXIN			;GET EXTENSION
	JUMPL	S,EXTALI		;ALIAS FILE?
	HLLZM	P1,TEMP+RQEXT		;STORE
	HLLZM	P1,TEMP+RQEXTA		; ..
	HLLZM	P3,TEMP+RQEXTW		; ..
	JRST	EXTDON			;DONE
EXTALI:	HLLZS	P3			;JUST KEEP LH
	CAME	P3,TEMP+RQEXTW		;WILDS MUST MATCH
	JRST	WLDERR			;COMPLAIN
	HLLZM	P1,TEMP+RQEXT		;STORE

EXTDON:	CAIE	CH,"["			;PPN?
	JRST	TST3			;NO
	TLO	S,SPECH			;FLAG
	PUSHJ	P,OCTZ			;GET PROJECT
	JUMPL	S,PRJALI		;ALIAS FILE?
	HRLZM	P1,TEMP+RQPPN		;STORE
	HRLZM	P1,TEMP+RQPPNA		; ..
	HRLZM	P3,TEMP+RQPPNW		; ..
	JRST	PRJDON			;DONE
PRJALI:	HLLZ	T1,TEMP+RQPPNW		;GET PRJ WILD
	HRLZS	P3			;GET PRJ WILD FOR ALIAS TYPEIN
	CAME	P3,T1			;MUST MATCH
	JRST	WLDERR			;LOSE
	HRLZM	P1,TEMP+RQPPN		;STORE
PRJDON:	CAIE	CH,","			;MUST BE COMMA
	JRST	NCLOSE			;NEED PROG
	PUSHJ	P,OCTZ			;GET PROGRAMMER
	JUMPL	S,PRGALI		;ALIAS FILE?
	HRRM	P1,TEMP+RQPPN		;STORE
	HRRM	P1,TEMP+RQPPNA		; ..
	HRRM	P3,TEMP+RQPPNW		; ..
	JRST	PRGDON			;DONE
PRGALI:	HRRZ	T1,TEMP+RQPPNW		;GET RH
	HRRZS	P3			;RETAIN JUST RH
	CAME	P3,T1			;MUST MATCH
	JRST	WLDERR			;COMPLAIN
	HRRM	P1,TEMP+RQPPN		;STORE
PRGDON:	CAIE	CH,","			;SFD'S COMING?
	JRST	CHKBRK			;NO--CHECK FOR BRACKET
	AOBJP	LVL,DEEP		;TOO DEEP?
	PUSHJ	P,SIXIN			;GET NAME
	JUMPL	S,SFDALI		;BRANCH IF ALIAS
	AOS	TEMP+RQLVL		;INCREMENT MAIN LEVEL COUNT
	AOS	TEMP+RQLVLA		; ..
	MOVEM	P1,TEMP+RQSFD-1(LVL)	;STORE
	MOVEM	P1,TEMP+RQSFDA-1(LVL)	; ..
	MOVEM	P3,TEMP+RQSFDW-1(LVL)	; ..
	JRST	PRGDON			;CONTINUE
SFDALI:	AOS	TEMP+RQLVL		;INCREMENT ACTUAL LEVEL COUNT
	CAME	P3,TEMP+RQSFDW-1(LVL)	;CHECK IF WILD MATCHES
	JRST	WLDERR			;NO--COMPLAIN
	MOVEM	P1,TEMP+RQSFD-1(LVL)	;STORE
	JRST	PRGDON			;CONTINUE

CHKBRK:	MOVE	T1,TEMP+RQLVLA		;GET ALIAS SFD LEVEL
	CAME	T1,TEMP+RQLVL		;MUST BE SAME AS ACTUAL LEVEL
	JRST	ALIERR			;ALIAS LEVEL ERROR

	CAIE	CH,"]"			;MUST END WITH BRACKET
	JRST	NCLOSE			;NEED CLOSE BRACKET
	PUSHJ	P,STYI			;GET NEXT

TST3:	CAIE	CH,"-"			;ALIAS COMING?
	JRST	TSTINI			;NO
	TLO	S,SPECH!ALIAS		;YES--FLAG
	MOVSI	LVL,-<MAXLVL+1>		;RESET
	SETZM	TEMP+RQLVL		; ..
	JRST	FRM1			;GET MORE

TSTINI:	CAIE	CH,"("			;INITIAL SPEC?
	JRST	TST4			;NO
	PUSHJ	P,SIXIN			;GET DEVICE
	CAIE	CH,":"			;CHECK
	JRST	BADINI			;BAD SPEC
	MOVEM	P1,INISTR		;STORE
	PUSHJ	P,STYI			;GET NEXT CH
	CAIE	CH,"["			;MUST BE PPN
	JRST	BADINI			;BARF
	PUSHJ	P,OCTIN			;GET PROJ
	CAIE	CH,","			;MUST END WITH COMMA
	JRST	BADINI			;BARF
	HRLZM	T1,INIPPN		;STORE
	PUSHJ	P,OCTIN			;GET PROG
	CAIE	CH,"]"			;MUST END WITH BRACKET
	JRST	BADINI			;BARF
	HRRM	T1,INIPPN		;STORE
	PUSHJ	P,STYI			;GET NEXT CH
	CAIE	CH,")"			;GOOD?
	JRST	BADINI			;NO--BARF
	JRST	FRM1			;YES--START AGAIN
TST4:	CAIE	CH,"/"			;MAYBE A SWITCH
	JRST	TST5			;NO
	MOVE	P4,[-SWTLTH,,SWTNAM]	;CALLING WORD
	PUSHJ	P,IFIND			;TRY TO FIND SWITCH
	  JRST	USWT			;UNKNOWN SWITCH
	HRRZ	T2,SWTDSP(T1)		;GET DISPATCH ADDRESS
	PUSHJ	P,0(T2)			;CALL SUBROUTINE
	  POPJ	P,0			;RETURN
	JUMPL	CH,FRM1			;IFF IT ENDED WITH SP
	JRST	TSTINI			;CHECK FOR ANOTHER SWITCH

TST5:	JUMPN	CH,TST6			;END OF LINE?
	MOVEI	T1,","			;LOAD ASCII COMMA
	CAMN	T1,LASTCH		;SIGNAL CONTINUED ON NEXT LINE?
	JRST	FRM1			;YES--KEEP ON READING
	JRST	GOTEND			;NO--FINISH OFF

TST6:	CAIE	CH,","			;END OF SPEC?
	CAIN	CH,"="			;END OF OUTPUT DEVICES?
	JRST	GOTEND			;YES
	OUTSTR	[ASCIZ/% INC SPEC
/]
	POPJ	P,0			;RETURN

GOTEND:	TLZ	S,SPECH!ALIAS		;ZILCH
	MOVEI	T1,RQLTH		;ONE MORE
	PUSHJ	P,UCORE			;GET CORE
	  POPJ	P,0			;LOSE
	HRLI	P1,TEMP			;BLT SPEC
	MOVE	T1,P1			;COPY
	BLT	P1,RQLTH-1(T1)		; ..
	AOS	NTSPEC			;ONE MORE SPEC
	TLNN	S,EQH			;OUTPUT?
	AOS	NOSPEC			;YES--INCREMENT
	JUMPE	CH,CPOPJ1		;RETURN IF DONE
	MOVE	T1,[PERM,,TEMP]		;REFRESH TEMP
	BLT	T1,TEMP+RQLTH-1		; ..
	CAIN	CH,"="			;EQUALS?
	TLO	S,EQH			;FLAG
	MOVSI	LVL,-<MAXLVL+1>		;HOW DEEP TO GO PLUS 1
	JRST	FRM1			;START AGAIN
SUBTTL	SWITCH DISPATCH ROUTINES

STOD:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE TABLE INDEX
	PUSHJ	P,DECIN			;GET DATE NNMMOO
	IDIVI	T1,^D10000		;GET MONTH IN T1
	IDIVI	T2,^D100		;GET DAY IN T2/YEAR IN T3
	SUBI	T3,^D64			;DATE ALGORITHM
	IMULI	T3,^D12			; ..
	ADDI	T1,-1(T3)		;FORM (YEAR-64)*12+(MONTH-1)
	IMULI	T1,^D31			; ..
	ADDI	T1,-1(T2)		;FORM ((YEAR-64)*12+(MONTH-1))*31+(DAY-1)
GENSTO:	POP	P,T2			;RESTORE INDEX
	HLRZ	T2,SWTDSP(T2)		;GET INDEX
	MOVEM	T1,TEMP(T2)		;STORE DATE
	TLNN	S,SPECH			;SKIP IF TEMP SWITCH
	MOVEM	T1,PERM(T2)		;STORE DATE
	JRST	CPOPJ1			;RETURN

SCUT:	DATE	T2,			;GET TODAY'S DATE
	HRLOI	T3,377777		;GET LARGEST POSITIVE NUMBER
	TLNE	S,SPECH			;CHECK IF PERM
	JRST	SCUT1			;NO--SKIP THIS
	CAME	T3,PERM+RQCUD		;STILL UPPER BOUND?
	JRST	STOT			;NO--SKIP THIS
	MOVEM	T2,PERM+RQCUD		;YES--STORE TODAY'S DATE
	MOVEM	T2,TEMP+RQCUD		; ..
	JRST	STOT			;CONTINUE
SCUT1:	CAMN	T3,TEMP+RQCUD		;STILL UPPER BOUND?
	MOVEM	T2,TEMP+RQCUD		;YES--FIX
	JRST	STOT			;RESUME

SCLT:	DATE	T2,			;GET TODAY'S DATE
	TLNE	S,SPECH			;STILL PERMANENT?
	JRST	SCLT1			;NO--CHECK TEMP
	SKIPE	PERM+RQCLD		;CHECK IF STILL LOWER BOUND
	JRST	STOT			;NO--NO SPECIAL ACTION
	MOVEM	T2,PERM+RQCLD		;STORE TODAY'S DATE
	MOVEM	T2,TEMP+RQCLD		; ..
	JRST	STOT			;RESUME
SCLT1:	SKIPN	TEMP+RQCLD		;CHECK IF STILL LOWER BOUND
	MOVEM	T2,TEMP+RQCLD		;NO--MAKE SO

STOT:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE TABLE INDEX
	PUSHJ	P,DECIN			;GET TIME NNMM
	IDIVI	T1,^D100		;GET HOUR IN T1/MINUTE IN T2
	IMULI	T1,^D60			;FORM MINUTES
	ADD	T1,T2			; ..
	JRST	GENSTO			;STORE TIME
SDEC:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE TABLE INDEX
	PUSHJ	P,DECIN			;GET NUMBER
	JRST	GENSTO			;STORE

CBIT1:	HLLZ	T1,SWTDSP(T1)		;GET SWITCH
	ANDCAM	T1,TEMP+RQBIT1		;CLEAR
	TLNN	S,SPECH			;PERMANENT?
	ANDCAM	T1,PERM+RQBIT1		;CLEAR
	JRST	CPOPJ1			;RETURN

SBIT1:	HLLZ	T1,SWTDSP(T1)		;GET SWITCH
	IORM	T1,TEMP+RQBIT1		;STORE
	TLNN	S,SPECH			;SKIP IF AFTER SPEC
	IORM	T1,PERM+RQBIT1		;STORE
	JRST	CPOPJ1			;RETURN

SFLAG1:	HLRZ	T1,SWTDSP(T1)		;GET SWITCH
	TLO	S,0(T1)			;STORE
	JRST	CPOPJ1			;RETURN

CFLAG1:	HLRZ	T1,SWTDSP(T1)		;GET SWITCH
	TLZ	S,0(T1)			;ZERO
	JRST	CPOPJ1			;RETURN

SWDEC:	CAIE	CH,":"			;INSURE ARGUMENTS FOLLOWING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE TABLE INDEX
	PUSHJ	P,DECIN			;GET DECIMAL NUMBER
	POP	P,T2			;RESTORE INDEX
	HLRZ	T2,SWTDSP(T2)		;GET ADDRESS OF WORD
	MOVEM	T1,0(T2)		;STORE
	JRST	CPOPJ1			;SKIP BACK
SIXSTO:	CAIE	CH,":"			;INSURE MORE COMING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE INDEX
	PUSHJ	P,SIXIN			;GET ARGUMENT
	POP	P,T1			;RESTORE INDEX
	HLRZ	T1,SWTDSP(T1)		;GET ADDRESS
	MOVEM	P1,0(T1)		;STORE
	JRST	CPOPJ1			;SKIP BACK

SDATE:	CAIE	CH,":"			;INSURE MORE COMING
	JRST	NOTENF			; ..
	PUSH	P,T1			;SAVE INDEX
	PUSHJ	P,DECIN			;GET ARGUMENT
	IDIVI	T1,^D10000		;CONVERT TO DATE
	IDIVI	T2,^D100		; ..
	SUBI	T3,^D64			; ..
	IMULI	T3,^D12			; ..
	ADDI	T1,-1(T3)		; ..
	IMULI	T1,^D31			; ..
	ADDI	T1,-1(T2)		; ..
	POP	P,T2			;RESTORE INDEX
	HLRZ	T2,SWTDSP(T2)		;GET ADDRESS
	MOVEM	T1,0(T2)		;STORE
	JRST	CPOPJ1			;SKIP BACK
;HERE ON /COMMENT:'...TEXT...' SWITCH
;HERE ON /PASSWORD:'...TEXT...' SWITCH

UCOM:	CAIE	CH,":"			;INSURE ARG FOLLOWING
	JRST	NOTENF			;BALK
	PUSHJ	P,STYI			;GET NEXT NON-BLANK
	MOVEM	CH,DELCHR		;STORE CH
	AOS	0(P)			;SKIP RETURN
	HLRZ	T2,SWTDSP(T1)		;GET ADDRESS OF BLOCK
	MOVSI	T1,-MAXCHR		;MAX NUMBER OF CH
	HRLI	T2,440700		;FORM BYTE POINTER
UCOM1:	PUSHJ	P,TYI			;GET CH
	CAMN	CH,DELCHR		;END OF STRING?
	JRST	TYI			;GET NEXT
	SKIPGE	CH			;BLANK OR TAB?
	MOVEI	CH,SP			;YES--FIX
	IDPB	CH,T2			;STORE
	AOBJN	T1,UCOM1		;LOOP
UCOM2:	PUSHJ	P,TYI			;GET CH
	CAMN	CH,DELCHR		;END OF STRING?
	JRST	TYI			;EOS
	JRST	UCOM2			;LOOP
;HERE ON /PARITY:TYPE SWITCH

PARNAM:	SIXBIT	/EVEN/
	SIXBIT	/ODD/

	PARLTH==.-PARNAM

PARXCT:	IORM	T2,OPNMTA
	ANDCAM	T2,OPNMTA

PARITY:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	MOVE	P4,[-PARLTH,,PARNAM]	;POINTER
	PUSHJ	P,IFIND			;FIND IT
	  JRST	UPAR			;UNKNOWN PARITY
	MOVEI	T2,IOPAR		;DECISIVE BIT
	XCT	PARXCT(T1)		;DISPATCH
	JRST	CPOPJ1			; ..
;HERE ON /DENSITY:TYPE SWITCH

DENNAM:	SIXBIT	/200/
	SIXBIT	/556/
	SIXBIT	/800/

	DENLTH==.-DENNAM

DENTYP:	EXP	IOD200
	EXP	IOD556
	EXP	IOD800

SDENS:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	MOVE	P4,[-DENLTH,,DENNAM]	;TABLE TO SEARCH
	PUSHJ	P,IFIND			;LOOK FOR IT
	  JRST	UDENS			;UNKNOWN DENSITY
	MOVEI	T2,IODCLR		;LOAD CLEAR BITS
	ANDCAM	T2,OPNMTA		;CLEAR THOSE
	MOVE	T1,DENTYP(T1)		;GET DENSITY TYPE
	IORM	T1,OPNMTA		;SET BIT
	JRST	CPOPJ1			;SKIP BACK
;HERE ON /MFDSRT:TYPE OR /UFDSRT:TYPE SWITCH

SRTNAM:	SIXBIT	/NONE/
	UFDDEF==.-SRTNAM-1
	SIXBIT	/ALPHAB/
	MFDDEF==.-SRTNAM-1
	SIXBIT	/LOCATI/

	SRTLTH==.-SRTNAM

SRTDSP:	EXP	CPOPJ
	EXP	ALPSRT
	EXP	LOCSRT

MFDSRT:	PUSHJ	P,SORTN			;GET SORT CODE
	  POPJ	P,0			;RETURN
	HRLM	T1,SRTWRD		;STORE
	JRST	CPOPJ1			;RETURN

UFDSRT:	PUSHJ	P,SORTN			;GET SORT CODE
	  POPJ	P,0			;RETURN
	HRRM	T1,SRTWRD		;STORE
	JRST	CPOPJ1			;RETURN

SORTN:	CAIE	CH,":"			;INSURE ARGUMENT FOLLOWING
	JRST	NOTENF			; ..
	MOVE	P4,[-SRTLTH,,SRTNAM]	;LOAD POINTER
	PUSHJ	P,IFIND			;FIND IT
	  JRST	USRT			;UNKNOWN SORT
	JRST	CPOPJ1			;GOOD RETURN
SUBTTL	DSK TO MTA SUBROUTINE

SAVALL::JSP	T1,SAVE1		;SAVE 1 PERMANENT

;HERE TO WRITE BEGINNING-OF-SAVE RECORD ON TAPE

	MOVSI	T1,TBEG			;INDICATE START OF SAVE
	PUSHJ	P,GENSAV		;FILL IN REST OF CHARS

	MOVSI	P1,-MAXSTR		;AOBJN WORD FOR STR LIST

;HERE TO SELECT A STR

GETSTR:	SKIPN	T1,STRTBL(P1)		;GET STR NAME
	JRST	FINSTR			;NULL--LIST FINISHED
	SKIPN	INISTR			;ANY INITIAL FS?
	JRST	GETST1			;NO
	CAME	T1,INISTR		;MATCH?
	JRST	NXTSTR			;NO--DROP FS
	SETZM	INISTR			;ZILCH
GETST1:	MOVEM	T1,CSTR			;STORE
	MOVEM	T1,DCHBLK		; ..

;HERE TO CHECK IF ANY FILE SPEC ASKS FOR STR

	MOVE	T1,NTSPEC		;LOAD NUMBER OF SPECS
	MOVE	T2,AOSPEC		;LOAD ADDRESS OF SPECS

CHKSTR:	MOVE	T3,CSTR			;COPY FS NAME
	XOR	T3,RQDEV(T2)		;GET DIFFERENCES
	TDZ	T3,RQDEVW(T2)		;ZERO DON'T CARES
	JUMPE	T3,GOTSTR		;BRANCH IF GOOD STR

	ADDI	T2,RQLTH		;ADD LENGTH
	SOJG	T1,CHKSTR		;LOOP
	JRST	NXTSTR			;CHECK NEXT FS

;HERE IF AT LEAST ONE FILE SPEC NEEDS THIS STR

GOTSTR:	PUSHJ	P,SAVSTR		;SAVE FS

NXTSTR:	AOBJN	P1,GETSTR		;LOOP FOR ALL FS

;HERE TO WRITE END-OF-SAVE RECORD ON TAPE

FINSTR:	MOVSI	T1,TEND			;INDICATE END OF SAVE
;SUBROUTINE TO FILL IN TBEG & TEND MTA RECORD HEADERS

GENSAV:	MOVEM	T1,GEN0(MBUF)		;STORE
	MOVEI	T1,SVSNAM(MBUF)		;LOC FOR SYSTEM NAME
	HRLI	T1,USYSNM		;WHERE I HAVE IT
	BLT	T1,SVSNAM+4(MBUF)	;XFR
	MOVE	T1,UMONVR		;GET MONITOR VERSION
	MOVEM	T1,SVSVER(MBUF)		;STORE
	MOVEI	T1,FORMAT		;CURRENT FRS FORMAT
	MOVEM	T1,SVFMT(MBUF)		;STORE
	MOVE	T1,.JBVER		;FRS VERSION
	MOVEM	T1,SVPRG(MBUF)		;STORE
	MSTIME	T1,			;CURRENT TIME
	MOVEM	T1,SVTIME(MBUF)		;STORE
	DATE	T1,			;CURRENT DATE
	MOVEM	T1,SVDATE(MBUF)		;STORE
	MOVE	T1,OPNMTA		;GET INIT MODE
	MOVEM	T1,SVMODE(MBUF)		;STORE
	MOVE	T1,UTRKS		;GET NUMBER OF TRACKS
	MOVEM	T1,SVTRKS(MBUF)		;STORE
	MOVE	T1,UNAME		;GET SUPPLIED NAME
	MOVEM	T1,SVNAME(MBUF)		;STORE
	MOVE	T1,UPHYN		;GET PHYSICAL DEVICE NAME
	MOVEM	T1,SVPHYN(MBUF)		;STORE
	MOVE	T1,[TEXT,,SVCOM]	;XFER COMMENT
	ADD	T1,MBUF			;FORM ADDRESS
	BLT	T1,SVCOM+<MAXCHR/5>(MBUF);XFER
	JRST	MTAOUT			;SEND BUFFER
SAVSTR:	JSP	T1,SAVE2		;SAVE 2 PERMANENTS

	TLZ	S,STR1			;STARTING STR

;HERE TO GET CHARACTERISTICS OF STR

	MOVE	T1,[MAXDCH+1,,DCHBLK]	;CALL TO DSKCHR UUO
	DSKCHR	T1,			;GET STATS OF FS
	  HALT	.			;***TEMP***
	LDB	T1,[POINT 9,DCHBLK+.DCUCH,8];GET BLOCKS PER CLUSTER
	MOVEM	T1,BKSCLS		;STORE

;HERE TO INITIALIZE ALL STR CHANNELS

	MOVEI	T1,17			;DUMP MODE
	MOVE	T2,CSTR			;CURRENT FS
	SETZ	T3,			;NO BUFFERS

	OPEN	MFD,T1			;OPEN CHANNEL FOR MFD
	  JRST	DVFAIL			;LOSE
	OPEN	STR,T1			;OPEN CHANNEL FOR SCREWING AROUND
	  JRST	DVFAIL			;LOSE

	MOVSI	P1,-<MAXLVL+1>		;HOW MANY SFD LEVELS PLUS 1
OPNCHN:	HRLZ	T4,P1			;GET LEVEL
	LSH	T4,5			;SHIFT TO AC FIELD
	IOR	T4,[OPEN T1]		;FORM OPEN UUO
	XCT	T4			;OPEN LEVEL
	  JRST	DVFAIL			;LOSE
	AOBJN	P1,OPNCHN		;LOOP FOR ALL LEVELS

	MOVEI	T1,14			;BUFFERED BINARY MODE
	MOVEI	T3,DSKHDR		;BUFFER HEADER

	OPEN	FILE,T1			;OPEN CHANNEL FOR DISK FILE
	  JRST	DVFAIL			;LOSE
IFN FTIND,<
	TLNN	S,IND			;INDEPENDENT IO?
	JRST	CONT1			;NO--CONTINUE

	USETI	STR,[EXP HMBNBR]	;GET HOME BLOCK
	INPUT	STR,CMDHMB		;READ INTO CORE

	MOVSI	T1,'HOM'		;INSURE HOME BLOCK
	CAME	T1,HMBBLK+HOMNAM	; ..
	JRST	NOHOME			;TELL HIM IT IS INACCESSABLE

	USETI	STR,HMBBLK+HOMMFD	;GET MFD'S RIB
	INPUT	STR,CMDRIB		;READ IN RIB
>;END IFN FTIND
;HERE TO READ MFD INTO CORE

CONT1:	SETZM	EXLUFD			;ZERO EXTENDED BLOCK
	MOVE	T1,[EXLUFD,,EXLUFD+1]	; ..
	BLT	T1,EXLUFD+FRSLIM	; ..

	MOVEI	T1,FRSLIM		;SET BLOCK FOR LOOKUP
	MOVEM	T1,EXLUFD+RIBCNT	; ..
	MOVE	T1,UMFD			; ..
	MOVEM	T1,EXLUFD+RIBPPN	; ..
	MOVEM	T1,EXLUFD+RIBNAM	; ..
	MOVSI	T1,'UFD'		; ..
	MOVEM	T1,EXLUFD+RIBEXT	; ..

	LOOKUP	MFD,EXLUFD		;EXTENDED LOOKUP
	  JRST	ELUFD			;LOSE

	SKIPLE	T1,EXLUFD+RIBSIZ	;HOW BIG IS IT?
	PUSHJ	P,UCORE			;GET CORE TO READ FILE
	  POPJ	P,0			;LOSE
	PUSH	P,P1			;SAVE FOR RESTORATION
	MOVNS	T1			;NEGATE
	HRL	P1,T1			;PUT RH OF T1 INTO LH OF P1
	SUBI	P1,1			;COMPUTE IOWD
	SETZ	P2,			;ZERO NEXT CMD WORD
	INPUT	MFD,P1			;TRY TO READ MFD INTO CORE
	PUSHJ	P,SRTMFD		;SORT IT

;HERE TO SELECT A UFD

GETUFD:	SKIPE	T1,1(P1)		;GET FIRST UFD
	CAMN	T1,UMFD			;DO NOT REPEAT MFD
	JRST	NXTUFD			;LOSE
	HLRZ	T2,2(P1)		;GET EXTENSION
	CAIE	T2,'UFD'		;IT HAD BETTER BE UFD
	JRST	NXTUFD			;NOT--FORGET THIS ONE
	SKIPN	INIPPN			;ANY INITIAL PPN?
	JRST	GETUF1			;NO
	CAME	T1,INIPPN		;MATCH?
	JRST	NXTUFD			;NO--DROP PPN
	SETZM	INIPPN			;ZILCH
GETUF1:	MOVEM	T1,CPPN			;STORE
	MOVEM	T1,PH1BLK+2		;STORE IN PATH BLOCK
;HERE TO CHECK IF ANY FILE SPEC ASKS FOR THIS UFD ON THIS STR

	MOVE	T1,NTSPEC		;GET NUMBER OF SPECS
	MOVE	T2,AOSPEC		;GET ADDRESS

CHKUFD:	MOVE	T3,CSTR			;GET CURRENT STRT
	XOR	T3,RQDEV(T2)		;GET DIFF
	TDZ	T3,RQDEVW(T2)		;ZERO DON'T CARES
	JUMPN	T3,NEXT1		;NO GOOD

	MOVE	T3,CPPN			;GET CURRENT PPN
	XOR	T3,RQPPN(T2)		;GET DIFF
	TDZ	T3,RQPPNW(T2)		;ZERO DON'T CARES
	JUMPE	T3,GOTUFD		;BRANCH IF GOOD PPN

NEXT1:	ADDI	T2,RQLTH		;NEXT SPEC
	SOJG	T1,CHKUFD		;CHECK NEXT PPN
	JRST	NXTUFD			;GO TO NEXT PPN

;HERE IF AT LEAST ONE FILE SPEC NEEDS THIS UFD ON THIS STR

GOTUFD:	SETZB	LVL,ADRLST		;ZERO TO START
	MOVE	T1,[ADRLST,,ADRLST+1]	;BLT XWD
	BLT	T1,ADRLST+MAXLVL	;ZERO
	TLZ	S,UFD1			;UFD USE FLAG
	PUSHJ	P,SAVUFD		;SAVE FILES

NXTUFD:	AOBJN	P1,.+1			;SKIP ONE WORD
	AOBJN	P1,GETUFD		;CHECK NEXT UFD

;HERE TO RELEASE ALL STR CHANNELS

	RELEAS	FILE,0			;DONE
	RELEAS	STR,0			; ..
	RELEAS	MFD,0			; ..
	JRST	FPOPJ			;RETURN
SAVUFD:	JSP	T1,SAVE4		;SAVE C(P1) & C(P2)

;HERE TO READ UFD INTO CORE

	SETZM	EXLUFD			;ZERO BLOCK
	MOVE	T1,[EXLUFD,,EXLUFD+1]	; ..
	BLT	T1,EXLUFD+FRSLIM	; ..

	MOVEI	T1,FRSLIM		;SET BLOCK
	MOVEM	T1,EXLUFD+RIBCNT	; ..
	JUMPG	LVL,SETSFD		;SET SFD BLOCK?
	MOVE	T1,UMFD			; ..
	MOVEM	T1,EXLUFD+RIBPPN	; ..
	MOVE	T1,CPPN			; ..
	MOVEM	T1,EXLUFD+RIBNAM	; ..
	MOVSI	T1,'UFD'		; ..
	JRST	SETFIN			;FINISH UP
SETSFD:	MOVE	T1,[PH1BLK,,PH2BLK]	;BLT POINTER
	BLT	T1,PH2BLK+1(LVL)	;TRANSFER
	SETZM	PH2BLK+2(LVL)		;ZILCH LAST ONE
	MOVEI	T1,PH2BLK		;PATH BLOCK
	MOVEM	T1,EXLUFD+RIBPPN	;STORE
	MOVE	T1,PH1BLK+2(LVL)	;GET SFD NAME
	MOVEM	T1,EXLUFD+RIBNAM	;STORE
	MOVSI	T1,'SFD'		;EXTENSION
SETFIN:	MOVEM	T1,EXLUFD+RIBEXT	; ..

	HRLZ	T1,LVL			;GET LEVEL
	LSH	T1,5			;PUT IN AC FIELD
	IOR	T1,[LOOKUP EXLUFD]	;FORM UUO
	XCT	T1			;EXEC IT
	  JRST	ELUFD			;LOSE

;HERE TO PERFORM SPECIAL READ OF UFD'S RIB

;THE RIB IS WRITTEN ONTO TAPE IN A TUFD RECORD AND IS USED WHEN
;IN ORDER TO ENTER A SUBSEQUENT FILE ON TAPE THIS UFD IS NEEDED

	HRLZ	T1,LVL			;GET LEVEL
	LSH	T1,5			;PUT IN AC FIELD
	TLO	T1,(<USETI>)		;FORM UUO
	XCT	T1			;EXEC IT
	MOVEI	T1,200			;NEED 200 WORDS
	PUSHJ	P,UCORE			;GET THEM
	  POPJ	P,0			;LOSE
	PUSH	P,P1			;STORE JOBFF ON STACK
	MOVEM	P1,ADRLST(LVL)		;STORE FOR LATER REF
	MOVSI	T1,-200			;NEG NBR OF WORDS
	HRRI	T1,-1(P1)		;IOWD FOR DATA
	SETZ	T2,			;END OF CMD LIST
	HRLZ	T3,LVL			;GET LEVEL
	LSH	T3,5			;PUT IN AC FIELD
	IOR	T3,[INPUT T1]		;FORM UUO
	XCT	T3			;EXEC IT

	JUMPLE	LVL,LVL0		;SKIP THIS CODE IF UFD
	MOVEI	T1,200(T1)		;ADDR OF END OF RIB BLOCK
	MOVN	T2,LVL			;NEGATIVE NUMBER OF LEVELS
	HRLZS	T2			;FORM AOBJN XWD
UFDPTH:	MOVE	T3,PH2BLK+2(T2)		;GET SFD NAME
	MOVEM	T3,0(T1)		;STORE
	SUBI	T1,1			;DECREMENT
	AOBJN	T2,UFDPTH		;LOOP

LVL0:	SKIPLE	T1,EXLUFD+RIBSIZ	;SEE IF SIZABLE
	PUSHJ	P,UCORE			;EXPAND CORE
	  JRST	CLSUF1			;LOSE
	MOVNS	T1			;NEGATE
	HRL	P1,T1			;PUT RH OF T1 INTO LH OF P1
	SUBI	P1,1			;COMPUTE IOWD
	SETZ	P2,			;ZERO NEXT CMD WORD
	HRLZ	T1,LVL			;GET LEVEL
	LSH	T1,5			;PUT IN AC FIELD
	IOR	T1,[INPUT P1]		;FORM UUO
	XCT	T1			;EXEC IT
	PUSHJ	P,SRTUFD		;SORT IT

;HERE TO SELECT A FILE

GETFIL:	SKIPN	T1,1(P1)		;GET A FILE NAME
	JRST	NXTFIL			;NOT INTERESTED IN NULLS
	MOVEM	T1,CNAM			;STORE
	HLRZ	T1,2(P1)		;GET EXTENSION
	CAIE	T1,'SFD'		;SFD?
	JRST	NOTSFD			;NO--DO NORMAL HANDLING

	CAIGE	LVL,MAXLVL		;LEVEL EXCEEDED?
	AOJA	LVL,SAFE1		;NO--CONTINUE

	OUTSTR	[ASCIZ/% SFD LEVEL EXCEEDED
/]
	JRST	NXTFIL			;GET NEXT FILE
SAFE1:	MOVE	T2,CNAM			;GET SFD NAME
	MOVEM	T2,PH1BLK+2(LVL)	;STORE IN PATH BLOCK

	MOVE	P3,NTSPEC		;NUMBER OF SPECS
	MOVE	P4,AOSPEC		;ADDRESS OF SPECS

WANT1:	PUSHJ	P,VER1			;VERIFY STR,UFD,SFD'S
	  JRST	BADSFD			;NO GOOD--SKIP THIS SPEC

	PUSHJ	P,SAVUFD		;MATCH--CALL UFD(SFD) HANDLER

	SETZM	PH1BLK+2(LVL)		;ZERO
	SOJA	LVL,NXTFIL		;CONTINUE

BADSFD:	ADDI	P4,RQLTH		;UP ADDRESS
	SOJG	P3,WANT1		;LOOP

	SETZM	PH1BLK+2(LVL)		;ZERO
	SOJA	LVL,NXTFIL		;CONTINUE

NOTSFD:	HRLZM	T1,CEXT			;STORE
	HRRZ	T1,2(P1)		;GET COMPRESSED-FILE-POINTER
	IMUL	T1,BKSCLS		;COMPUTE LOGICAL BLOCK ON STR
	MOVEM	T1,CBLOCK		;STORE

;HERE TO CHECK IF ANY FILE SPEC ASKS FOR THIS FILE

	MOVE	P3,NTSPEC		;NBR OF SPECS
	MOVE	P4,AOSPEC		;ADDRESS OF SPECS

CHKFIL:	MOVSI	T1,RQNSN.		;SCAN OR NO SCAN
	TDNE	T1,RQBIT1(P4)		;ON OR OFF?
	CAMN	LVL,RQLVL(P4)		;SAME LEVEL?
	PUSHJ	P,VER1			;CHECK FILE ID
	  JRST	NEXT2			;NO GOOD
	PUSHJ	P,VER2			; ..
	  JRST	NEXT2			; ..

	TLNE	S,NUSETI		;USE SUPER USETI'S?
	JRST	STNCHK			;NO--USE LOOKUP UUO

	USETI	STR,CBLOCK		;TARGET TO RIB BLOCK
	INPUT	STR,CMDLST		;READ INTO CORE
	MOVE	T1,EXLFIL+RIBPPN	;VERIFY RIB BLOCK
	CAME	T1,CPPN			; ..
	JRST	STNCHK			; ..
	MOVE	T1,EXLFIL+RIBNAM	; ..
	CAME	T1,CNAM			; ..
	JRST	STNCHK			; ..
	HLLZ	T1,EXLFIL+RIBEXT	; ..
	CAMN	T1,CEXT			; ..
	JRST	DECODE			;GO DECODE RIB

STNCHK:	SETZM	EXLFIL			;ZERO LOOKUP BLOCK
	MOVE	T1,[EXLFIL,,EXLFIL+1]	; ..
	BLT	T1,EXLFIL+FRSLIM	; ..

	MOVEI	T1,FRSLIM		;LIMIT OF ARGS
	MOVEM	T1,EXLFIL+RIBCNT	; ..
	MOVEI	T1,PH1BLK		;PPN AND SFD PATH
	MOVEM	T1,EXLFIL+RIBPPN	; ..
	MOVE	T1,CNAM			;NAME
	MOVEM	T1,EXLFIL+RIBNAM	; ..
	MOVE	T1,CEXT			;EXT
	MOVEM	T1,EXLFIL+RIBEXT	; ..

	LOOKUP	STR,EXLFIL		; ..
	  JRST	GOTFIL			;ASSUME FILE IS GOOD
	CLOSE	STR,CLSACS		; ..

DECODE:	MOVEI	T1,RP.NFS		;CHECK NO SAVE BIT
	TDNE	T1,EXLFIL+RIBSTS	;ON?
	JRST	NXTFIL			;YES--SKIP THIS ONE

	MOVE	T1,EXLFIL+RIBSIZ	;GET FILE SIZE
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;FORM BLOCK SIZE
	MOVEM	T1,CBSIZE		;STORE

	LDB	T1,[POINT 12,EXLFIL+RIBEXT,35];GET ACCESS DATE
	MOVEM	T1,CADATE		; ..

	LDB	T1,[POINT 11,EXLFIL+RIBPRV,23];GET CREATION TIME
	MOVEM	T1,CCTIME		; ..

	LDB	T1,[POINT 12,EXLFIL+RIBPRV,35];GET CREATION DATE
	MOVEM	T1,CCDATE		; ..

	TRNE	S,ARCMOD		;ARCHIVE MODE?
	JRST	VEROK			;YES--THIS FILE WINS

	PUSHJ	P,CHKLIM		;CHECK LIMITS
	  JRST	NEXT2			;NO GOOD
VEROK:	TRON	S,SFLMAT		;FLAG FIND
	MOVE	P2,P4			;SAVE C(P4)
	MOVSI	T1,RQMAT.		;LOAD BIT
	IORM	T1,RQBIT1(P4)		;SET

NEXT2:	ADDI	P4,RQLTH		;ADVANCE TO NEXT SPEC
	SOJG	P3,CHKFIL		;CHECK NEXT ONE
	TRZN	S,SFLMAT		;ANY FILE MATCH?
	JRST	NXTFIL			;GET NEXT
	MOVE	P4,P2			;YES--RESTORE C(P4)

;HERE IF AT LEAST ONE FILE SPEC NEEDS THIS FILE

GOTFIL:	TLOE	S,UFD1			;FIRST FILE--ANY PREVIOUS?
	JRST	GOTFL1			;YES--GO SAVE IT

	HLRZ	T1,CPPN			;GET PROJECT
	PUSHJ	P,OCTOUT		;TYPE
	OUTCHR	COMMA			; ..
	HRRZ	T1,CPPN			;GET PROGRAMMER
	PUSHJ	P,OCTOUT		;TYPE

	TLOE	S,STR1			;SEE IF FIRST TIME FOR STR
	JRST	RECUFD			;NOPE--FORGET THIS

	OUTCHR	TAB			;TAB OVER
	MOVE	T1,CSTR			;GET STR NAME
	PUSHJ	P,SIXOUT		;TYPE IT

RECUFD:	OUTSTR	CRLF			;CR-LF

GOTFL1:	MOVSI	P2,-<MAXLVL+1>		;HOW MANY LEVELS PLUS ONE

WRIB:	SKIPN	T1,ADRLST(P2)		;ANYTHING TO WRITE?
	JRST	NORIB			;NO--CONTINUE
	SETZM	ADRLST(P2)		;YES--ZILCH
	MOVSI	T2,TUFD			;LOAD UFD TYPE
	MOVEM	T2,GEN0(MBUF)		;STORE
	MOVE	T2,CSTR			;GET STR NAME
	MOVEM	T2,UFDSTR(MBUF)		;STORE
	HRRZM	P2,UFDLVL(MBUF)		;STORE LEVEL
	HRLZS	T1			;PUT ADDRESS IN LH
	HRRI	T1,M(MBUF)		;GET ADDRESS OF BUFFER
	MOVE	T2,T1			;COPY
	BLT	T1,177(T2)		;TRANSFER RIB
	PUSHJ	P,MTAOUT		;EXEC I/O

NORIB:	AOBJN	P2,WRIB			;CIRCLE
	PUSHJ	P,SAVFIL		;SAVE THE FILE

NXTFIL:	AOBJN	P1,.+1			;ONE WORD
	AOBJN	P1,GETFIL		;TWO

;HERE TO TERMINATE I/O TO THIS UFD

CLSUF1:	HRLZ	T1,LVL			;GET LEVEL
	LSH	T1,5			;PUT IN AC FIELD
	IOR	T1,[CLOSE CLSACS]	;FORM UUO
	XCT	T1			;EXEC IT

	SETZM	ADRLST(LVL)		;ZILCH IN CASE NO FILE FOUND

	JRST	FPOPJ			;SKIP BACK
SAVFIL:	JSP	T1,SAVE2		;SAVE SOME ACS

	MOVEI	T1,3			;LOAD BLOCK
	MOVEM	T1,EXLFIL+RIBCNT	; ..
	MOVEI	T1,PH1BLK		; ..
	MOVEM	T1,EXLFIL+RIBPPN	; ..
	MOVE	T1,CNAM			; ..
	MOVEM	T1,EXLFIL+RIBNAM	; ..
	MOVE	T1,CEXT			; ..
	MOVEM	T1,EXLFIL+RIBEXT	; ..

	LOOKUP	FILE,EXLFIL		;LOOKUP FILE
	  JRST	ELFIL			;LOSE
	USETI	FILE,0			;START WITH RIB BLOCK

	TRO	S,FIPROG		;FLAG IN PROGRESS
IFN FTARCH,<
	SETZM	REELPR##		;ZERO PRIOR REEL
>;END IFN FTARCH
	SETZM	RELBLK			;ZILCH
	PUSH	P,.JBFF##		;SAVE JOBFF BEFORE BUFFERS
	INBUF	FILE,NDSKIB		;MAKE INPUT BUFFERS

STREC:	MOVSI	T1,TFIL			;FILE DATA RECORD
	MOVEM	T1,GEN0(MBUF)		;STORE
	MOVE	T1,CSTR			;GET FS NAME
	MOVEM	T1,FILSTR(MBUF)		;STORE
	MOVE	T1,CNAM			; ..
	MOVEM	T1,FILNAM(MBUF)		; ..
	MOVE	T1,CEXT			; ..
	MOVEM	T1,FILEXT(MBUF)		; ..
	MOVE	T1,CPPN			;GET PPN
	MOVEM	T1,FILPPN(MBUF)		;STORE
	MOVE	T1,RELBLK		;LOAD RELATIVE DATA BLOCK
	MOVEM	T1,FILRDB(MBUF)		;STORE
	SETZM	FILCHK(MBUF)		;***TEMP***
	SETZM	FILSDB(MBUF)		;START WITH ZERO
	MOVEM	LVL,FILLVL(MBUF)	;STORE SFD LEVEL

	MOVEI	P1,N			;HOW MANY DISK BLOCKS
	MOVEI	P2,M(MBUF)		;FIRST WORD TO USE

STBLK:	PUSHJ	P,DSKIN			;READ A BLOCK
	  JRST	FINFIL			;DONE
	  JRST	FINFIL			; ..
	MOVE	T1,DSKHDR+2		;GET NUMBER OF WORDS
	MOVEM	T1,FILSIZ(MBUF)		;STORE
	AOS	T1,FILSDB(MBUF)		;ONE MORE GOOD BLOCK
	MOVSI	T2,0(DBUF)		;ADDRESS OF DATA
	HRRI	T2,0(P2)		;WHERE TO GO IN MTA BUFFER
	BLT	T2,177(P2)		;XFR DISK BLOCK
	SKIPN	RELBLK			;SKIP IF NOT FIRST
	CAIE	T1,1			;BLOCK 1?
	JRST	NOTONE			;LOSE

	MOVNI	T1,1(LVL)		;HOW MANY SFD'S PLUS 1
	HRLZS	T1			; ..
	MOVEI	T2,M+177(MBUF)		;END OF RIB BLOCK
XFRPTH:	MOVE	T3,PH1BLK+2(T1)		;GET WORD
	MOVEM	T3,0(T2)		;STORE
	SUBI	T2,1			;DECREMENT
	AOBJN	T1,XFRPTH		;LOOP

NOTONE:	ADDI	P2,200			;NEXT BLOCK SLOT
	SOJG	P1,STBLK		;GO GET NEXT ONE
	PUSHJ	P,MTAOUT		;FINISH OFF

	MOVEI	T1,N			;INCREMENT BLOCK COUNTER
	ADDM	T1,RELBLK		; ..
	JRST	STREC			;GO START AGAIN

FINFIL:	MOVEI	T1,FRSEOF		;MARK AS LAST BLOCK
	IORM	T1,GEN0(MBUF)		;SET FLAG
	PUSHJ	P,MTAOUT		;SEND BUFFER

	CLOSE	FILE,CLSACS		;FINISH FILE
	TRZ	S,FIPROG		;ZILCH IN PROGRESS BIT
	POP	P,.JBFF##		;RESTORE JOBFF BEFORE BUFFERS
IFN FTARCH,<
	JRST	ARENDF##		;HANDLE END OF FILE
>;END IFN FTARCH
	POPJ	P,0			;RETURN
SUBTTL	MTA TO DSK SUBROUTINE

RSTALL:	JSP	T1,SAVE4		;SAVE C(P1) & C(P2)

	SETZM	LSTSTR			;ZERO LAST STR WORD
	SETZM	LSTPPN			;ZERO LAST PPN WORD

	MOVEI	T1,<FRSLIM+1>*<MAXLVL+1>;WORDS FOR UFD & SFD RIBS
	PUSHJ	P,UCORE			;GET IT
	  POPJ	P,0			;LOSE

	TLZ	S,UFDHAV		;HAVE NOT SEEN UFD YET

	SKIPN	P2,UNAME		;SAVE SET SPECIFIED?
	JRST	RSTREC			;NO--PUNT

SPCSET:	PUSHJ	P,XMTAIN		;GET RECORD
	  JSP	T1,WAIT1		;WAIT FOR CONTINUE
	  JRST	[TRNN	S,RDEOF2
		JRST	SPCSET
		JRST	CPOPJ1]

	HLRZ	T1,GEN0(MBUF)		;GET RECORD TYPE
	CAIN	T1,TBEG			;START OF SAVE?
	CAME	P2,SVNAME(MBUF)		;RIGHT ONE?
	JRST	SPCSET			;NO--KEEP GOING

RSTREC:	PUSHJ	P,MTAIN			;GET A BUFFER
	  JSP	T1,WAIT1		;WAIT FOR CONTINUE
	  JRST	[TRNN	S,RDEOF2
		JRST	RSTREC
		JRST	CPOPJ1]

	HLRZ	T1,GEN0(MBUF)		;GET RECORD TYPE
	CAIN	T1,TEND			;END OF SAVE?
	JRST	HAVEND			;YES
	CAIN	T1,TUFD			;IS IT UFD DATA?
	JRST	HAVUFD			;YES--COPY RIB
	CAIN	T1,TFIL			;IS IT FILE DATA?
	JRST	HAVFIL			;YES--CHECK IT OUT

	JUMPLE	T1,NOSUCH		;UNRECOGNIZABLE RECORD TYPE
	CAIG	T1,NT			;KNOW OF IT?
	JRST	RSTREC			;YES--CONTINUE READING

NOSUCH:	OUTSTR	[ASCIZ/% RECORD TYPE /]	;MESSAGE TO CONSOLE
	PUSHJ	P,OCTOUT		; ..
	OUTSTR	CRLF			;CR-LF
	JRST	RSTREC			;GET NEXT
;HERE IF HAVE TEND TYPE RECORD IN BUFFER

HAVEND:	SKIPN	UNAME			;SAVE SET SPECIFIED?
	JRST	RSTREC			;NO--KEEP GOING
	JRST	CPOPJ1			;YES--THIS MUST BE END

;HERE IF HAVE TUFD TYPE RECORD IN BUFFER

HAVUFD:	SKIPN	T1,UFDLVL(MBUF)		;GET UFD LEVEL
	TLO	S,UFDHAV		;NOW HAVE SEEN UFD
	IMULI	T1,FRSLIM+1		;WORDS PER RIB
	ADD	T1,P1			;ADD IN BASE ADDRESS
	HRLI	T1,M(MBUF)		;START ADDR
	MOVE	T2,T1			;COPY
	BLT	T1,FRSLIM(T2)		;XFR ACROSS

	JRST	RSTREC			;GO GET NEXT RECORD

;HERE IF HAVE TFIL TYPE RECORD IN BUFFER

HAVFIL:	SKIPE	FILRDB(MBUF)		;SKIP IF FIRST RECORD
	JRST	RSTREC			; ..

	MOVE	P3,NTSPEC		;NUMBER OF SPECS
	MOVE	P4,AOSPEC		;ADDRESS OF SPECS

RSTVER:	MOVE	T1,FILLVL(MBUF)		;GET FILE SFD LEVEL
	MOVSI	T2,RQNSN.		;NO BACKSCAN BIT
	TDNN	T2,RQBIT1(P4)		;IS BIT ON IN SPEC?
	JRST	LVLOK			;NO LEVEL CHECK
	CAME	T1,RQLVL(P4)		;MATCH?
	JRST	RSTNOT			;NO--SKIP THIS ONE

LVLOK:	MOVE	T1,FILSTR(MBUF)		;XFER DATA
	MOVEM	T1,CSTR			; ..
	MOVE	T1,FILPPN(MBUF)		; ..
	MOVEM	T1,CPPN			; ..
	MOVE	T1,FILNAM(MBUF)		; ..
	MOVEM	T1,CNAM			; ..
	MOVE	T1,FILEXT(MBUF)		; ..
	MOVEM	T1,CEXT			; ..

	MOVE	T1,FILLVL(MBUF)		;GET SFD LEVEL
	MOVNI	T1,1(T1)		;GET NEGATIVE MINUS 1
	HRLZS	T1			;FORM AOBJN XWD
	MOVEI	T2,M+177(MBUF)		;WHERE PATH STARTS
GETPTH:	MOVE	T3,0(T2)		;GET SFD NAME
	MOVEM	T3,PH1BLK+2(T1)		;STORE
	SUBI	T2,1			;DECREMENT
	AOBJN	T1,GETPTH		;LOOP
	SETZM	PH1BLK+2(T1)		;ZERO NEXT LOC
	PUSHJ	P,VER1			;COMPARE
	  JRST	RSTNOT			;NO GOOD
	PUSHJ	P,VER2			;COMPARE
	  JRST	RSTNOT			;NO GOOD

	MOVE	T1,M+RIBSIZ(MBUF)	;GET SIZE
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;DIVIDE BY 200
	MOVEM	T1,CBSIZE		;STORE

	LDB	T1,[POINT 12,M+RIBEXT(MBUF),35];GET ACCESS DATE
	MOVEM	T1,CADATE		;STORE

	LDB	T1,[POINT 11,M+RIBPRV(MBUF),23];GET CREATION TIME
	MOVEM	T1,CCTIME		;STORE

	LDB	T1,[POINT 12,M+RIBPRV(MBUF),35];GET CREATION DATE
	MOVEM	T1,CCDATE		;STORE

	PUSHJ	P,CHKLIM		;CHECK LIMITS
	  JRST	RSTNOT			;NO GOOD

	TRON	S,SFLMAT		;MATCH?
	MOVE	P2,P4			;SAVE C(P4)
	MOVSI	T1,RQMAT.		;LOAD BIT
	IORM	T1,RQBIT1(P4)		;SET FLAG

RSTNOT:	ADDI	P4,RQLTH		;NEXT SPEC
	SOJG	P3,RSTVER		;LOOP
	TRZN	S,SFLMAT		;MATCH?
	JRST	RSTREC			;NO--GO BACK
	MOVE	P4,P2			;YES--GET COPY OF ADDR

	MOVE	T1,CSTR			;GET CURRENT STR
	MOVE	T2,CPPN			;GET CURRENT PPN
	CAMN	T1,LSTSTR		;SAME AS LAST?
	JRST	STRSAM			;STRUCTURE IS THE SAME
	MOVEM	T1,LSTSTR		;STORE NEW LAST STR
	MOVEM	T2,LSTPPN		;STORE
	PUSHJ	P,TYLPPN		;TYPE LAST PPN
	OUTCHR	TAB			;TAB OVER
	MOVE	T1,LSTSTR		;GET STR NAME
	PUSHJ	P,SIXOUT		;TYPE STR NAME
	JRST	XRST0			;TYPE <CR><LF> AND RESTORE
STRSAM:	CAMN	T2,LSTPPN		;SAME AS LAST?
	JRST	XRST1			;YES--RESTORE
	MOVEM	T2,LSTPPN		;NO--REPLACE
	PUSHJ	P,TYLPPN		;TYPE LAST PPN
XRST0:	OUTSTR	CRLF			;<CR><LF>

XRST1:	PUSHJ	P,RSTFIL		;RESTORE FILE

	JRST	RSTREC			;CONTINUE

TYLPPN:	HLRZ	T1,LSTPPN		;GET PROJ
	PUSHJ	P,OCTOUT		;TYPE
	OUTCHR	COMMA			;COMMA
	HRRZ	T1,LSTPPN		;GET PROG
	JRST	OCTOUT			;TYPE
;HERE TO RESTORE SINGLE FILE FROM MTA TO DSK

RSTFIL::JSP	T1,SAVE2		;SAVE C(P1) & C(P2)

	TRZ	S,PAOFLG		;ZERO FLAG
	SETZM	THSRDB			;START WITH RDB 0

;HERE TO COMPUTE ALIAS STR NAME AND INITIALIZE CHANNELS

	MOVE	T2,CSTR			;GET STR NAME
	SETCM	T1,RQDEVW(P4)		;COMPLEMENT OF WILD
	TDZ	T2,T1			;ZILCH
	IOR	T2,RQDEVA(P4)		;ALIAS STR NAME

	TLNE	S,NSCATR		;SCATTER FILES?
	JRST	NOSCAT			;NOPE

	MOVSI	T1,-MAXSTR		;HOW MANY STRS
	CAME	T2,STRTBL(T1)		;MATCH?
	AOBJN	T1,.-1			;NO--CONTINUE
	JUMPGE	T1,FAIL0		;NOT THERE--FAKE OPEN FAILURE

	AOS	T3,STRCNT(T1)		;SELECT NEXT UNIT
	IDIV	T3,STRUNI(T1)		;HOW MANY LOGICAL UNITS
	MOVE	T3,T4			;GET REMAINDER
	IDIVI	T3,8			;SPLIT LOGICAL UNIT NUMBER
	MOVE	T1,STRPTR(T1)		;GET POINTER TO T2
	JUMPE	T3,FSTNUL		;NULL FIRST DIGIT?
	ADDI	T3,'0'			;FORM SIXBIT
	IDPB	T3,T1			;STORE
FSTNUL:	ADDI	T4,'0'			;FORM SIXBIT
	IDPB	T4,T1			;STORE

NOSCAT:	MOVEI	T1,17			;DUMP MODE
	SETZ	T3,			;NO BUFFERS

	OPEN	UFD,T1			;OPEN CHANNEL FOR CREATING UFD
	  JRST	FAIL0			;LOSE

	MOVEI	T1,14			;BUFFERED BINARY
	MOVSI	T3,DSKHDR		;OUTPUT BUFFER HEADER ADDDRESS

	OPEN	FILE,T1			;OPEN CHANNEL FOR WRITING FILE
	  JRST	FAIL0			;LOSE

;HERE TO COPY RIB OUT OF MTA BUFFER AND INTO ENTER BLOCK

	MOVSI	T1,M(MBUF)		;ADDRESS OF RIB
	HRRI	T1,EXLFIL		;EXTENDED ENTER BLOCK
	MOVE	T2,T1			;COPY
	BLT	T1,FRSLIM(T2)		;XFR RETRIEVAL INFO
;HERE TO COMPUTE VARIOUS ALIAS SLOTS

	MOVE	T1,EXLFIL+RIBPPN	;GET PPN FOR FILE
	SETCM	T2,RQPPNW(P4)		;GET COMPLEMENT
	TDZ	T1,T2			;ZILCH
	IOR	T1,RQPPNA(P4)		;FORM ALIAS
	MOVEM	T1,PH1BLK+2		;STORE

	MOVEI	T1,PH1BLK		;WHERE TO FIND PATH
	MOVEM	T1,EXLFIL+RIBPPN	;STORE

	MOVE	T1,EXLFIL+RIBNAM	;GET NAME FOR FILE
	SETCM	T2,RQNAMW(P4)		;GET COMPLEMENT
	TDZ	T1,T2			;ZILCH
	IOR	T1,RQNAMA(P4)		;FORM ALIAS
	MOVEM	T1,EXLFIL+RIBNAM	;RESTORE

	MOVE	T1,EXLFIL+RIBEXT	;GET EXT FOR FILE
	SETCM	T2,RQEXTW(P4)		;GET COMPLEMENT
	TDZ	T1,T2			;ZILCH
	IOR	T1,RQEXTA(P4)		;FORM ALIAS
	HLLM	T1,EXLFIL+RIBEXT	;RESTORE

	MOVN	T1,FILLVL(MBUF)		;GET SFD LEVEL
	HRLZS	T1			;FORM AOBJN XWD
	JUMPGE	T1,ONOSFD		;BRANCH IF NONE
OSFDWD:	MOVE	T2,PH1BLK+3(T1)		;GET SFD
	MOVE	T3,T1			;ADDR
	ADD	T3,P4			;BASE FOR SPEC
	SETCM	T4,RQSFDW(T3)		;FORM ALIAS
	TDZ	T2,T4			; ..
	IOR	T2,RQSFDA(T3)		; ..
	MOVEM	T2,PH1BLK+3(T1)		;STORE
	AOBJN	T1,OSFDWD		;LOOP

ONOSFD:	SETZM	PH1BLK+3(T1)		;ZERO LAST WORD

;HERE TO CHECK WHETHER COPY ON DSK (IF ANY) SHOULD BE SUPERCEDED

	MOVSI	T1,RQNEW.!RQNEV.	;CHECK IF LOOKUP NEEDED
	TDNN	T1,RQBIT1(P4)		;SKIP IF SO
	JRST	NOLOOK			;NO--MUCH FASTER
	MOVEI	T1,RIBPRV		;WORD NEEDED
	MOVEM	T1,EXLPRV+RIBCNT	;STORE
	MOVE	T1,[EXLFIL+1,,EXLPRV+1]	;TRANSFER OVER
	BLT	T1,EXLPRV+RIBPRV	; ..

	LOOKUP	FILE,EXLPRV		;FILE THERE?
	JRST	NOLOOK			;NOPE--GOODIE

	MOVSI	T1,RQNEV.		;CHECK IF SHOULD NOT SUPERCEDE
	TDNE	T1,RQBIT1(P4)		;SKIP IF OFF
	JRST	CLSFL1			;CLOSE FILE CORRECTLY

	LDB	T1,[POINT 12,EXLPRV+RIBPRV,35];GET CREATION DATE
	CAMGE	T1,CCDATE		;NEWER OR EQUAL?
	JRST	FINCHN			;NO--RESTORE FROM TAPE
	CAME	T1,CCDATE		;EQUAL?
	JRST	CLSFL1			;NO--NEWER--DO NOT SUPERCEDE
	LDB	T1,[POINT 11,EXLPRV+RIBPRV,23];GET CREATION TIME
	CAMLE	T1,CCTIME		;OLDER OR EQUAL?
	JRST	CLSFL1			;NO--NEWER--DO NOT SUPERCEDE

FINCHN:	CLOSE	FILE,0			;DONE WITH FILE

;HERE TO ENTER FILE ON DSK

NOLOOK:	LDB	T1,[POINT 4,M+RIBPRV(MBUF),12];GET CREATION MODE
	SETSTS	FILE,0(T1)		;FAKE OUT TONY

	PUSHJ	P,SETFIL		;SET UP FILE ENTER BLOCK

	ENTER	FILE,EXLFIL		;TRY TO ENTER FILE
	  JRST	CHKWHY			;HOPEFULLY JUST IPPERR

;FILE IS ENTERED. HERE TO TRANSFER ACTUAL DATA.

NORMAL:	SETSTS	FILE,14			;BACK TO BUFFERED BINARY
	PUSH	P,.JBFF##		;SAVE C(JOBFF)
	OUTBUF	FILE,NDSKOB		;GEN BUFFERS
	PUSHJ	P,DSKOUT		;GET FIRST BUFFER
	  HALT	.			; ..
	  HALT	.			; ..

	MOVE	P1,FILSDB(MBUF)		;GET NBR OF SDB
	SOJLE	P1,CHKEND		;MAYBE 0 BLOCKS
	MOVEI	P2,M+200(MBUF)		;ADDRESS OF DATA BLOCK
XFR1:	MOVSI	T1,0(P2)		;MTA WORDS
	HRRI	T1,0(DBUF)		;DISK BUFFER
	MOVE	T2,T1			;COPY BLT POINTER
	BLT	T1,177(T2)		;XFR DATA BLOCK

	MOVEI	T1,FRSEOF		;FRS EOF BIT
	TDNE	T1,GEN0(MBUF)		;IS IT ON?
	CAIE	P1,1			;YES--AND IS THIS THE LAST BLOCK?
	JRST	NOTLST			;NO--CONTINUE

;HERE IF LAST DSK BLOCK TO BE WRITTEN

	MOVSI	T1,(<OUT FILE,0>)	;WILL DO OUTPUT
	MOVN	T2,FILSIZ(MBUF)		;GET SIZE OF RECORD
	ADDM	T2,DSKHDR+2		;DECREMENT BYTE COUNT
	MOVNS	T2			;NEGATE
	PUSHJ	P,ALTDSK		;PERFORM SPECIAL OUTPUT
	  HALT	.			;***TEMP***
	  HALT	.			;***TEMP***
	JRST	XFRDON			;DONE

;HERE TO CONTINUE TRANSFERING FILE

NOTLST:	PUSHJ	P,DSKOUT		;ADVANCE DSK BUFFER
	  HALT	.			;***TEMP***
	  HALT	.			;***TEMP***
	ADDI	P2,200			;ADVANCE TO NEXT BLOCK IN RECORD
	SOJG	P1,XFR1			;SEE IF ANY MORE TO GO

CHKEND:	MOVEI	T1,FRSEOF		;EOF BIT
	TDNE	T1,GEN0(MBUF)		;SKIP IF NOT ON
	JRST	XFRDON			;FINISHED

NOTNEW:	PUSHJ	P,XMTAIN		;GET NEXT RECORD
	  JSP	T1,WAIT1		;WAIT FOR CONTINUE
	  JRST	XFRERR			; ..

	MOVE	T1,CSTR			;GET SUPPOSED STR
	MOVE	T2,CPPN			;AND PPN
	CAMN	T1,FILSTR(MBUF)		;MATCH?
	CAME	T2,FILPPN(MBUF)		; ..
	JRST	MISMAT			;NO--LOSE
	MOVE	T1,CNAM			;GET SUPPOSED NAME
	MOVE	T2,CEXT			;AND EXT
	CAMN	T1,FILNAM(MBUF)		;MATCH?
	CAME	T2,FILEXT(MBUF)		; ..
	JRST	MISMAT			;NO--LOSE
	SKIPN	P1,FILSDB(MBUF)		;ANY SIGNIFICANT DATA BLOCKS?
	JRST	CHKEND			;NO--SHOULD BE END

	MOVE	T1,THSRDB		;LOAD CURRENT RDB
	ADDI	T1,N			;HOW MANY MORE
	CAMLE	T1,FILRDB(MBUF)		;CURRENT OR LATER?
	JRST	NOTNEW			;NO--DROP IT
	MOVEM	T1,THSRDB		;STORE AS NEW RDB

	CAME	T1,FILRDB(MBUF)		;MUST BE NEEDED ONE
	JRST	BADNBR			;NO--ATTEMPT TO READ WENT TO FAR

	MOVEI	P2,M(MBUF)		;ADDRESS OF FIRST BLOCK
	JRST	XFR1			;GO XFR OVER

XFRDON:	MOVE	T1,[CLOSE FILE,CLSACS!CLSDLL];LOAD CLOSE UUO
	TRNE	S,PAOFLG		;PAO FLAG ON?
	TRZ	T1,CLSDLL		;YES--CLEAR CLOSE BIT
	XCT	T1			;EXEC FUNCTION
IFN FTDEBUG,<
	PUSHJ	P,SETFIL		;RESET LOOKUP/ENTER BLOCK
	LOOKUP	FILE,EXLFIL		;GET IT AGAIN
	  HALT	.			;***TEMP***
	MOVE	T1,EXLFIL+RIBSIZ	;GET FILE SIZE IN WORDS
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;COMPUTE BLOCKS
	CAMN	T1,CBSIZE		;SAME AS MTA'S?
	JRST	SAMSIZ			;YES--CARRY ON
	OUTSTR	[ASCIZ/% SIZE ERROR/]	;NO--SQUEAL
	MOVEI	P1,EXLFIL		;LOAD ADDRESS OF BLOCK
	PUSHJ	P,GUUO			;TYPE NAME
>;END IFN FTDEBUG
SAMSIZ:	RELEAS	FILE,0			;RELEASE CHANNEL
	RELEAS	UFD,0			; ..
	JRST	FPOPJ			;RESTORE JOBFF

BADNBR:	OUTSTR	[ASCIZ/% HEADER RBN INCONSISTENCY
/]
	JRST	XFRERR

MISMAT:	OUTSTR	[ASCIZ/% HEADER FILE SPEC INCONSISTENCY
/]
XFRERR:	CLOSE	FILE,CLSRST		;ABORT FILE
	RELEAS	FILE,0			; ..
	RELEAS	UFD,0			; ..
	PUSHJ	P,EAFIL			;TYPE OUT BAD NEWS
	JRST	FPOPJ			;RETURN

;HERE TO CLOSE FILE CHANNEL AND NOT DISTURB FILE

CLSFL1:	CLOSE	FILE,CLSACS		;CLOSE
	POPJ	P,0			;RETURN
;INVESTIGATE WHY ENTER FOR FILE FAILED

CHKWHY:	HRRZ	T1,EXLFIL+RIBEXT	;GET ERROR CODE

	CAIN	T1,PAOERR		;PARTIAL ALLOCATION?
	JRST	PAOCOD			;YES--FIX

	CAIE	T1,IPPERR		;SKIP IF NO UFD
	CAIN	T1,SNFERR		;SFD NOT FOUND?
	TLNN	S,UFDHAV		;HAVE WE READ UFD RIB YET?
	JRST	EEFIL			;FATAL ERROR

	SETZ	LVL,			;START AT UFD LEVEL

MAKSFD:	MOVE	T1,LVL			;WHAT LEVEL WE'RE AT
	IMULI	T1,FRSLIM+1		;HOW MANY WORDS PER RIB
	ADD	T1,P1			;ADD IN BASE ADDRESS
	HRLZS	T1			;LH
	HRRI	T1,EXLUFD		;BLOCK
	BLT	T1,EXLUFD+FRSLIM	;TRANSFER

	MOVE	T1,PH1BLK+2(LVL)	;GET ALIAS NAME
	MOVEM	T1,EXLUFD+RIBNAM	;STORE

	JUMPLE	LVL,LEVEL0		;SKIP FOLLOWING IF UFD

	MOVE	T1,PH1BLK+1(LVL)	;GET ONE HIGHER SFD
	MOVEM	T1,PH2BLK+1(LVL)	;STORE
	SETZM	PH2BLK+2(LVL)		; ..

	MOVEI	T1,PH2BLK		;WHERE TO FIND PATH
	MOVEM	T1,EXLUFD+RIBPPN	;STORE

LEVEL0:	MOVEI	T1,3			;JUST RIBPPN,NAM,EXT
	MOVEM	T1,EXLUFD+RIBCNT	;STORE

	LOOKUP	UFD,EXLUFD		;IS IT THERE?
	  JRST	ENTSFD			;MUST DO ENTER
	JRST	NXTSFD			;THAT GUY'S THERE
ENTSFD:	MOVEI	T1,FRSLIM		;WHOLE RIB
	MOVEM	T1,EXLUFD+RIBCNT	;STORE
	SETZM	EXLUFD+RIBPOS		; ..
	SETZM	EXLUFD+RIBDEV		; ..
	MOVEI	T1,RP.DIR		; ..
	MOVEM	T1,EXLUFD+RIBSTS	; ..
	SETZM	EXLUFD+RIBELB		; ..
	SETZM	EXLUFD+RIBEUN		; ..
	SETZM	EXLUFD+RIBUSD		; ..
	SETZM	EXLUFD+RIBNXT		; ..
	SETZM	EXLUFD+RIBPRD		; ..
	SETZM	EXLUFD+RIBUFD		; ..
	SETZM	EXLUFD+RIBFLR		; ..
	SETZM	EXLUFD+RIBXRA		; ..

	ENTER	UFD,EXLUFD		;ATTEMPT TO CREATE UFD
	  JRST	EEUFD			;ERROR RETURN
	USETO	UFD,2			;INSURE 1 BLOCK

NXTSFD:	CLOSE	UFD,CLSACS		;CLOSE UFD
	CAMGE	LVL,FILLVL(MBUF)	;RIGHT LEVEL?
	AOJA	LVL,MAKSFD		;LOOP

	PUSHJ	P,SETFIL		;RESET EXLFIL BLOCK

	HRRZ	T1,M+RIBEXT(MBUF)	;GET EXTENSION & ACCESS DATE BACK
	HRRM	T1,EXLFIL+RIBEXT	;RESTORE

	ENTER	FILE,EXLFIL		;TRY TO ENTER FILE
	  SKIPA				;CHECK FOR PAOERR
	JRST	NORMAL			;OK

	HRRZ	T1,EXLFIL+RIBEXT	;GET ERROR CODE
	CAIE	T1,PAOERR		;PAO?
	JRST	EEFIL			;NO--QUIT

PAOCOD:	PUSHJ	P,SETFIL		;RESET BLOCK
	SETZM	EXLFIL+RIBALC		;ZILCH

	HRRZ	T1,M+RIBEXT(MBUF)	;GET ACCESS DATE BACK
	HRRM	T1,EXLFIL+RIBEXT	;RESTORE

	ENTER	FILE,EXLFIL		;ATTEMPT TO ENTER FILE
	  JRST	EEFIL			;BALK

	TRO	S,PAOFLG		;FLAG AS SUCH

	JRST	NORMAL			;GOOD--PROCEED
SETFIL:	MOVEI	T1,FRSLIM		;ARG COUNT
	MOVEM	T1,EXLFIL+RIBCNT	;STORE
	SETZM	EXLFIL+RIBPOS		; ..
	SETZM	EXLFIL+RIBDEV		; ..
	SETZM	EXLFIL+RIBSTS		; ..
	SETZM	EXLFIL+RIBELB		; ..
	SETZM	EXLFIL+RIBEUN		; ..
	SETZM	EXLFIL+RIBUSD		; ..
	SETZM	EXLFIL+RIBNXT		; ..
	SETZM	EXLFIL+RIBPRD		; ..
	SETZM	EXLFIL+RIBUFD		; ..
	SETZM	EXLFIL+RIBFLR		; ..
	SETZM	EXLFIL+RIBXRA		; ..

	POPJ	P,0			;RETURN
SUBTTL	MTA LISTING

MLIST:	JSP	T1,SAVE2		;SAVE PERMANENT(S)

	SETZB	LVL,SFDBEG		;ZERO SECTION OF CORE
	MOVE	T1,[SFDBEG,,SFDBEG+1]	; ..
	BLT	T1,SFDEND		; ..

MLIST1:	PUSHJ	P,MTAIN			;GET A RECORD
	  JSP	T1,WAIT1		;WAIT FOR CONTINUE
	  JRST	[TRNN	S,RDEOF2
		JRST	MLIST1
		JRST	CPOPJ1]

	HLRZ	T1,GEN0(MBUF)		;RE-COPY CODE IN CASE CLOBBERED

	CAIN	T1,TFIL			;NOT MORE FILE DATA?
	JRST	CHKL1			;MORE DATA--CONTINUE
	CAIE	T1,TUFD			;UFD(SFD)?
	JRST	PRTBLK			;PRINT TOTALS
	SKIPE	UFDLVL(MBUF)		;SKIP IF LEVEL 0
	JRST	CHKL1			;MORE DATA--CONTINUE

PRTBLK:	TLNN	S,FSTBLK		;DATA THERE?
	JRST	CHKL0			;NO--KEEP GOING

	MOVEI	CH,LF			;EXTRA LF
	PUSHJ	P,MO			;OUTPUT A CHARACTER

	MOVEI	P1,[ASCIZ/	TOTAL OF /];MESSAGE
	PUSHJ	P,MSG			; ..

	SETZ	T1,			;ZERO
	EXCH	T1,TOTBLK		;EXCH
	PUSHJ	P,MDECO			;TYPE NUMBER OF BLOCKS

	MOVEI	P1,[ASCIZ/ BLOCKS IN /]	;MESSAGE
	PUSHJ	P,MSG			; ..

	SETZ	T1,			;ZERO
	EXCH	T1,TOTFIL		;EXCH
	PUSHJ	P,MDECO			;TYPE NUMBER OF FILES

	MOVEI	P1,[ASCIZ/ FILES

/]
	PUSHJ	P,MSG			;MESSAGE
CHKL0:	TLZA	S,FSTBLK		;ZILCH
CHKL1:	TLO	S,FSTBLK		;SET HAVE DATA FLAG

	HLRZ	T1,GEN0(MBUF)		;RE-COPY CODE IN CASE CLOBBERED

	CAIN	T1,TLBL			;LABEL?
	JRST	XXTLBL			;EXECUTE CODE

	MOVE	T1,NTAPE(MBUF)		;GET RELATIVE TAPE NUMBER
	CAMN	T1,LSTNBR		;SAME AS LAST RECORD?
	JRST	FINAL			;YES--CONTINUE
	MOVEM	T1,LSTNBR		;NO--STORE NEW NUMBER
	MOVEI	CH,FF			;FORM FEED
	PUSHJ	P,MO			; ..
	MOVEI	P1,[ASCIZ/---------------------------------------------------------
START OF RELATIVE TAPE /]
	PUSHJ	P,MSG			;SEND TO FILE
	PUSHJ	P,MDECO			;TYPE TAPE NUMBER
	MOVEI	P1,CRLFLF		;<CR><LF><LF>
	PUSHJ	P,MSG			;SEND TO FILE

FINAL:	HLRZ	T1,GEN0(MBUF)		;GET RECORD NUMBER

	JUMPLE	T1,UNREC		;TEST FOR FUNNY NUMBER
	CAIG	T1,NT			;SKIP IF KNOWN RECORD TYPE
	JRST	@EXEC-2(T1)		;GO HANDLE RECORD

UNREC:	MOVEI	P1,[ASCIZ/% RECORD TYPE /]; ..
	PUSHJ	P,MSG			; ..
	PUSHJ	P,MOCTO			; ..
XEND:	MOVEI	P1,CRLFLF		; ..
	PUSHJ	P,MSG			; ..
	JRST	MLIST1			; ..

EXEC:	EXP	XXTBEG,XXTEND,XXTFIL,XXTUFD

	NT==.-EXEC+1
XXTLBL:	MOVEI	P1,[ASCIZ/LABEL RECORD FOR TAPE /]
	PUSHJ	P,MSG			; ..
	MOVE	T1,LBLNAM(MBUF)		;GET TAPE LABEL
	PUSHJ	P,MSIXO			; ..
	MOVEI	P1,[ASCIZ/
LABELED ON /]
	PUSHJ	P,MSG			; ..
	MOVE	T1,LBLDC(MBUF)		;GET DATE OF LABELING
	PUSHJ	P,MDATE			; ..
	MOVEI	P1,[ASCIZ/ AT /]	; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,LBLTC(MBUF)		;GET TIME OF LABELING
	PUSHJ	P,MTIME			; ..
	SKIPN	T1,LBLDD(MBUF)		;GET DATE OF DESTRUCTION
	JRST	NODATE			;NONE
	MOVEI	P1,[ASCIZ/
DESTRUCTION DATE ON /]
	PUSHJ	P,MSG			; ..
	PUSHJ	P,MDATE			; ..
	PUSHJ	P,MCRLF			;CR-LF
	JRST	FINLBL			;CONNECT

NODATE:	MOVEI	P1,[ASCIZ/
NO DESTRUCTION DATE
/]
	PUSHJ	P,MSG			; ..
FINLBL:	MOVEI	P1,LBLCOM(MBUF)		;ADDRESS OF COMMENT
	PUSHJ	P,MSG			;SEND
	JRST	XEND			; ..
XXTBEG:	SKIPA	P1,[EXP[ASCIZ/*START* OF /]]
XXTEND:	MOVEI	P1,[ASCIZ/**END** OF /]
	PUSHJ	P,MSG			; ..
	MOVEI	T1,377			;LOW ORDER 8 BITS
	ANDCAM	T1,SVSNAM+4(MBUF)	;INSURE ASCIZ
	MOVEI	P1,SVSNAM(MBUF)		;SYSTEM NAME
	PUSHJ	P,MSG			; ..
	MOVEI	P1,[ASCIZ/ (/]		; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,SVSVER(MBUF)		;GET MONITOR VERSION
	PUSHJ	P,MOCTO			; ..
	MOVEI	P1,[ASCIZ/) SAVE /]	; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,SVNAME(MBUF)		;GET SAVE NAME
	PUSHJ	P,MSIXO			; ..
	MOVEI	P1,[ASCIZ/ ON /]	; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,SVPHYN(MBUF)		;GET PHYSICAL DEVICE NAME
	PUSHJ	P,MSIXO			; ..
	MOVEI	P1,[ASCIZ/:

FRS VERSION /]
	PUSHJ	P,MSG			; ..
	LDB	T1,[POINT 9,SVPRG(MBUF),11];GET MAJOR VERSION
	PUSHJ	P,MOCTO			; ..
	LDB	T1,[POINT 6,SVPRG(MBUF),17];GET MINOR VERSION
	JUMPE	T1,NMINOR		;JUMP IF NONE
	ADDI	T1,"A"			;FORM LETTER
	PUSHJ	P,MO			;OUTPUT
NMINOR:	HRRZ	T1,SVPRG(MBUF)		;GET EDIT
	JUMPE	T1,NEDIT		;JUMP IF NONE
	MOVEI	CH,"("			;OPEN PARENS
	PUSHJ	P,MO			; ..
	PUSHJ	P,MOCTO			; ..
	MOVEI	CH,")"			;CLOSE PARENS
	PUSHJ	P,MO			; ..
NEDIT:	LDB	T1,[POINT 3,SVPRG(MBUF),2];GET CUSTOMER VERSION
	JUMPE	T1,NCUST		;JUMP IF NONE
	MOVEI	CH,"-"			;DASH
	PUSHJ	P,MO			; ..
	PUSHJ	P,MOCTO			; ..
NCUST:	MOVEI	P1,[ASCIZ/ ON /]	; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,SVDATE(MBUF)		; ..
	PUSHJ	P,MDATE			; ..
	MOVEI	P1,[ASCIZ/ AT /]	; ..
	PUSHJ	P,MSG			; ..
	MOVE	T1,SVTIME(MBUF)		; ..
	PUSHJ	P,MTIME			; ..
	PUSHJ	P,MCRLF			;CR-LF
	MOVEI	P1,SVCOM(MBUF)		;COMMENT
	PUSHJ	P,MSG			;SEND
	JRST	XEND			;FINISH
XXTUFD:	SETZM	CHRCNT			;ZERO CHARACTER COUNT
	SKIPG	LVL,UFDLVL(MBUF)	;SKIP IF SFD
	JRST	SKIP50			;NO--SKIP CODE
	AOS	TOTFIL			;ONE MORE FILE
	MOVE	T1,M+RIBSIZ(MBUF)	;GET WORD SIZE
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;COMPUTE BLOCKS
	ADDM	T1,TOTBLK		;ADD
	MOVE	T1,M+RIBNAM(MBUF)	;GET SFD NAME
	PUSHJ	P,MSIXO			;PRINT
	JRST	JOIN50			;REJOIN
SKIP50:	HLRZ	T1,M+RIBNAM(MBUF)	;GET PROJ
	PUSHJ	P,MOCTO			;TYPE ALL DIGITS
	MOVEI	CH,","			;COMMA
	PUSHJ	P,MO			; ..
	HRRZ	T1,M+RIBNAM(MBUF)	;GET PROG
	PUSHJ	P,MOCTO			; ..
JOIN50:	MOVEI	CH,HT			;TAB
	MOVE	T1,CHRCNT		;LOAD CHARACTER COUNT
	CAILE	T1,7			;SMALL ENOUGH?
	MOVEI	CH,SP			;NO--USE SPACE
	PUSHJ	P,COM1			;TYPE REST OF SPEC
	MOVE	T1,UFDSTR(MBUF)		;GET STR NAME
	MOVEM	T1,PH2BLK+1		;STORE
	JUMPG	LVL,SFDLVL		;BRANCH IF AT SFD LEVEL
	MOVE	T1,M+RIBNAM(MBUF)	;GET UFD NAME
	MOVEM	T1,PH2BLK+2		;STORE
	PUSHJ	P,COMP0			;COMPARE
	JRST	XEND			;CR-LF-LF
SFDLVL:	MOVN	T1,LVL			;NEGATIVE NUMBER OF LEVELS
	PUSHJ	P,COMP1			;COMPARE
	PUSHJ	P,MCRLF			;CR-LF
	JRST	MLIST1			; ..

XXTFIL:	SKIPE	FILRDB(MBUF)		;SKIP IF FIRST FILE RECORD
	JRST	MLIST1			;NOPE--FORGET IT

	MOVE	LVL,FILLVL(MBUF)	;GET PATH LEVEL
	AOS	TOTFIL			;ONE MORE FILE
	MOVE	T1,M+RIBSIZ(MBUF)	;GET WORD SIZE
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;COMPUTE BLOCKS
	ADDM	T1,TOTBLK		;ADD

	MOVE	T1,M+RIBNAM(MBUF)	;GET FILE NAME
	PUSHJ	P,MSIXO			; ..
	MOVEI	CH,HT			;TAB
	PUSHJ	P,COM1			;TYPE REST OF SPEC
	MOVE	T1,FILSTR(MBUF)		;GET STR NAME
	MOVEM	T1,PH2BLK+1		;STORE
	MOVNI	T1,1(LVL)		;HOW MANY PATH ARGS
	PUSHJ	P,COMP1			;TRANSFER PATH AND COMPARE
	PUSHJ	P,MCRLF			;CR-LF
	JRST	MLIST1			; ..
COMP1:	HRLZS	T1			;FORM AOBJN XWD
	MOVEI	T2,M+177(MBUF)		;ADDRESS OF PATH (REVERSED)

STOPH2:	MOVE	T3,0(T2)		;GET PATH WORD
	MOVEM	T3,PH2BLK+2(T1)		;STORE
	SUBI	T2,1			;DECREMENT INDEX
	AOBJN	T1,STOPH2		;LOOP

COMP0:	MOVSI	T1,-<MAXLVL+2>		;HOW MANY WORDS

XOR1:	MOVE	T2,PH1BLK+1(T1)		;GET LAST PATH
	CAMN	T2,PH2BLK+1(T1)		;COMPARE
	AOBJN	T1,XOR1			;LOOP
	JUMPGE	T1,CLEAR		;ALL MATCHES--CLEAR AND TRANSFER

	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..

	MOVE	T1,PH2BLK+1		;GET STR NAME
	PUSHJ	P,MSIXO			;PRINT
	MOVEI	CH,":"			;COLON
	PUSHJ	P,MO			;PRINT
	MOVEI	CH,HT			;HT
	PUSHJ	P,MO			;PRINT

	MOVEI	CH,"["			;OPEN BRACKET
	PUSHJ	P,MO			;SEND
	HLRZ	T1,PH2BLK+2		;GET PROJECT
	PUSHJ	P,MOCTO			;SEND
	MOVEI	CH,","			;COMMA
	PUSHJ	P,MO			; ..
	HRRZ	T1,PH2BLK+2		;GET PROGRAMMER
	PUSHJ	P,MOCTO			;SEND
	MOVSI	P1,-MAXLVL		;NOW DO ALL SFD'S
PTH0:	SKIPN	T1,PH2BLK+3(P1)		;GET SFD
	JRST	PTH1			;FINISHED
	MOVEI	CH,","			;COMMA
	PUSHJ	P,MO			;SEND
	PUSHJ	P,MSIXO			;PRINT
	AOBJN	P1,PTH0			;LOOP
PTH1:	MOVEI	CH,"]"			;CLOSE
	PUSHJ	P,MO			; ..

CLEAR:	MOVE	T1,[PH2BLK,,PH1BLK]	;BLT POINTER
	BLT	T1,PH1BLK+MAXLVL+3	;TRANSFER OLD PATH
	SETZM	PH2BLK			;ZERO OLD PATH
	MOVE	T1,[PH2BLK,,PH2BLK+1]	;BLT POINTER
	BLT	T1,PH2BLK+MAXLVL+3	;ZERO
	POPJ	P,0			;RETURN
COM1:	PUSHJ	P,MO			; ..
	HLLZ	T1,M+RIBEXT(MBUF)	;GET EXTENSION
	PUSHJ	P,MSIXO			; ..
	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
	MOVE	T1,M+RIBSIZ(MBUF)	;GET WORD SIZE
	ADDI	T1,177			;FORCE CARRY
	ASH	T1,-7			;DIVIDE BY 200
	PUSHJ	P,MDECO			; ..
	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
	MOVEI	CH,"<"			;OPEN PROT
	PUSHJ	P,MO			; ..
	MOVEI	P1,3			;3 DIGITS
	MOVE	P2,[POINT 3,M+RIBPRV(MBUF)]; ..
COM2:	ILDB	CH,P2			;GET DIGIT
	ADDI	CH,"0"			;FORM ASCII
	PUSHJ	P,MO			; ..
	SOJG	P1,COM2			; ..
	MOVEI	CH,">"			;CLOSE PROT
	PUSHJ	P,MO			; ..
	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
	TLNE	S,SHORT			;DO NOT DO THIS IF TTY
	JRST	NOTYPE			;SKIP CODE
	HRRZ	T1,M+RIBEXT(MBUF)	;GET ACCESS DATE
	PUSHJ	P,MDATE			; ..
	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
	LDB	T1,[POINT 11,M+RIBPRV(MBUF),23];GET TIME OF CREATION
	JUMPE	T1,COM3			;FORGET IF NULL
	IMULI	T1,^D60*^D1000		;FORM MS
	PUSHJ	P,MTIME			; ..
COM3:	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
NOTYPE:	LDB	T1,[POINT 12,M+RIBPRV(MBUF),35];GET DATE OF CREATION
	PUSHJ	P,MDATE			; ..
	TLNE	S,SHORT			;DO NOT DO THIS IF SHORT
	POPJ	P,0			;RETURN NOW
	MOVEI	CH,HT			;TAB
	PUSHJ	P,MO			; ..
	LDB	T1,[POINT 4,M+RIBPRV(MBUF),12];GET MODE OF CREATION
	MOVEI	CH,SP			;ASSUME SPACE
	TRZE	T1,10			;0?
	MOVEI	CH,"1"			;NO
	PUSHJ	P,MO			;TYPE DIGIT
	MOVEI	CH,"0"(T1)		;GET SECOND DIGIT
	JRST	MO			; ..
SUBTTL	MTA INPUT/OUTPUT SUBROUTINES

COMMENT	$
SUBROUTINE MTAOUT

CALLING SEQUENCE:

	MOVEI	MBUF,<ADDRESS OF OUTPUT BLOCK>
	PUSHJ	P,MTAOUT
	NORMAL RETURN -- BLOCK INTO OUTPUT BUFFER RING

	ALL WRITE PROBLEMS (INCLUDING WRITE LOCK) ARE CORRECTED WITHIN
THIS SUBROUTINE.
$
;HERE FOR ENTRY POINT AND ENCRIPTION CODE

MTAOUT:	JSP	T1,SAVE2		;SAVE C(P1) & C(P2)

	HLRZ	T1,GEN0(MBUF)		;GET RECORD CODE
	CAIN	T1,TFIL			;FILE DATA?
	SKIPN	PSWD			;PASSWORD TYPED?
	JRST	NOSCRM			;LOSE--NO SCRAMBLING

	MOVEM	7,SAVACS+7		;SAVE AC0 THRU AC7
	MOVEI	7,SAVACS		; ..
	BLT	7,SAVACS+6		; ..
	MOVE	7,SAVACS+7		;RESTORE IF NEEDED

	TROE	S,ENCINI		;INITIALIZED?
	JRST	CLSCRM			;YES--SKIP THIS
IFLE S-7,<
	MOVEM	S,SAVACS+S		;STORE NEWLY SET BIT
>;END IFLE S-7
	MOVEI	7,PSWD			;LOC OF PASSWORD
	PUSHJ	P,CRASZ.##		;CALL CODER
	MOVEM	5,SVCODE		;SAVE SEED

CLSCRM:	MOVSI	7,-200*N		;HOW MANY WORDS
	HRRI	7,M(MBUF)		;WHERE IT'S AT
	MOVE	6,FILRDB(MBUF)		;GET RELATIVE BLOCK
	MOVE	5,SVCODE		;GET SEED BACK
	PUSHJ	P,CRYPT.##		;CALL ENCRIPTER

	MOVSI	7,SAVACS		;RESTORE REGISTERS
	BLT	7,7			; ..

NOSCRM:	MOVE	T1,SNTAPE		;GET TAPE NUMBER
	MOVEM	T1,NTAPE(MBUF)		;STORE
DUMOUT::SETZM	MTAHDR+2		;ZERO HEADER
	MOVEI	T1,MTBFSZ		;LOAD BUFFER SIZE
	ADDM	T1,MTAHDR+1		;INCREMENT BYTE POINTER
	OUT	MTA,0			;EXECUTE OUTPUT UUO
	  JRST	MTASET			;SUCCESSFUL OUTPUT

	GETSTS	MTA,P1			;GET ERROR STATUS
	SETSTS	MTA,@OPNMTA		;RESET ERROR BITS

	TRNN	P1,IOIMPM		;CHECK WRITE LOCK BIT
	JRST	NOTLOK			;NO--CHECK OTHERS

	OUTSTR	[ASCIZ/% MTA WRITE LOCKED--NEED WRITE RING
#/]
	PUSHJ	P,WAIT0			;WAIT FOR CONTINUE
	JRST	MTASET			;ALL OK

NOTLOK:	TRNN	P1,IOEOT		;CHECK END OF TAPE BIT
	JRST	NOTEOT			;NO--CHECK OTHERS

	CLOSE	MTA,0			;WRITE THE REST OF THE BLOCKS
	AOS	SNTAPE			;INCREMENT TAPE NUMBER
LOSMTA:	MTUNL.	MTA,			;START UNLOADING THE TAPE
	OUTSTR	EOTMSG			;TYPE MESSAGE
	PUSHJ	P,WAIT0			;WAIT FOR CONTINUE
IFN FTARCH,<
	PUSHJ	P,NXTOTP##		;NEXT OUTPUT TAPE
	  JRST	LOSMTA			;BAD MTA
>;END IFN FTARCH
	JRST	DUMOUT			;GO AHEAD

EOTMSG:	ASCIZ	/% EOT REACHED--NEED NEW TAPE
#/
NOTEOT:	TRNN	P1,IODERR!IODTER!IOBKTL	;CHECK DATA ERROR BITS
	JRST	QOUT			;GIVE UP

	SETZ	T1,			;ZERO IMPLIES SLEEP ONE TICK
ACTON:	STATO	MTA,IOACT		;I/O ACTIVE?
	JRST	ACTOFF			;NO--CONTINUE
	SLEEP	T1,			;WAIT ONE TICK
	JRST	ACTON			;CHECK AGAIN

ACTOFF:	MOVEI	T1,IODERR!IODTER!IOBKTL	;LOAD ERROR BITS
	MOVE	P2,MTAHDR		;GET ADDRESS OF SECOND WORD IN NEW BUFFER

FNDBUF:	HRRZ	P2,0(P2)		;GET TO NEXT BUFFER
	CAMN	P2,MTAHDR		;FOUL UP?
	JRST	NOFIND			;PROGRAM & DSK TOO FAST
	TDNN	T1,-1(P2)		;CHECK IF THIS IS ERROR BUFFER
	JRST	FNDBUF			;NO--KEEP CHECKING

;HERE WHEN BAD BUFFER FOUND

	PUSHJ	P,MASTER		;PRINT ERROR
IFE FTRECO,<
	JRST	MTASET			;QUIT PEACEFULLY
>;END IFE FTRECO
IFN FTRECO,<
	MOVEI	T1,RPTREC		;FLAG AS REPEATER
	IORM	T1,2+GEN0(P2)		; ..

	MOVEI	T1,1			;ONE ITEM
	PUSH	P,P2			;STORE ADDR OF BAD BUFFER

FNDFST:	HRRZ	P2,0(P2)		;GET NEXT BUFFER
	PUSH	P,P2			;STORE ADDR
	CAME	P2,MTAHDR		;IS IT THE FIRST ONE?
	AOJA	T1,FNDFST		;KEEP COUNT

;HERE TO MOVE ALL BUFFERS AHEAD ONE IN RING

XFRBUF:	POP	P,P2			;GET ADDRESS
	HRL	P2,0(P)			;GET ADDRESS OF ONE BEFORE
	AOBJN	P2,.+1			;INC BOTH SIDES
	AOBJN	P2,.+1			; ..
	MOVE	T2,P2			;COPY AC
	BLT	T2,MTBFSZ-1(P2)		;BLT BUFFER
	SOJG	T1,XFRBUF		;COUNTDOWN
	POP	P,0(P)			;REMOVE LAST ITEM

	JRST	DUMOUT			;TRY AGAIN
>;END IFN FTRECO
NOFIND:	OUTSTR	[ASCIZ/% DURING UNTRACEABLE DATA
/]
	PUSHJ	P,ERRBIT		;TYPE ERROR BITS
	JRST	MTASET			;GIVE GOOD RETURN

QOUT:	OUTSTR	[ASCIZ/% UNIDENTIFIABLE OUTPUT ERROR
/]
MTASET:	HRRZ	MBUF,MTAHDR+1		;FIRST WORD MINUS ONE
	AOJA	MBUF,CPOPJ		;RETURN
COMMENT	$
SUBROUTINES MTAIN & XMTAIN

CALLING SEQUENCES:

	PUSHJ	P,MTAIN/XMTAIN
	  ERROR1 RETURN -- END OF TAPE
	  ERROR2 RETURN -- END OF FILE
	NORMAL RETURN -- BLOCK AVAILABLE IN INPUT BUFFER RING

	MTAIN IS CALLED WHEN REPEATER BLOCKS SHOULD BE IGNORED.
	ALL BAD INPUT BLOCKS ARE PASSED IN THEIR ENTIRETY TO THE
CALLING PROGRAM.
$
MTAIN:	PUSHJ	P,XMTAIN		;GET A RECORD
	  POPJ	P,0			;LOSE
	  JRST	CPOPJ1			; ..
	MOVEI	T1,RPTREC		;CHECK REPEATER BIT
	TDNE	T1,GEN0(MBUF)		;IS IT ON?
	JRST	MTAIN			;YES--DROP THIS ONE
	JRST	CPOPJ2			; ..

XMTAIN::PUSH	P,P1			;SAVE C(P1)
	PUSH	P,P2			;AND C(P2)

	SETZM	MTAHDR+2		;ZERO HEADER
	MOVEI	T1,MTBFSZ		;LOAD BUFFER SIZE
	ADDM	T1,MTAHDR+1		;INCREMENT BYTE POINTER

	IN	MTA,0			;EXECUTE INPUT UUO
	  JRST	INOK			;SUCCESS

	GETSTS	MTA,P1			;READ STATUS
	SETSTS	MTA,@OPNMTA		; ..

	TRNN	P1,IOEOT		;END OF TAPE?
	JRST	NIEOT			;NO--SKIP

	CLOSE	MTA,0			;YES--CLEAR STATUS ENTIRELY
	TRZ	S,RDEOF1!RDEOF2		;ZERO EOF BITS
	MTUNL.	MTA,			;START UNLOADING TAPE
	OUTSTR	EOTMSG			;PRINT MESSAGE
	JRST	POP2			;RETURN TO CALLER
NIEOT:	TRNN	P1,IOEOF		;END OF FILE?
	JRST	NIEOF			;NO--SKIP

	CLOSE	MTA,0			;YES--CLEAR STATUS
	TROE	S,RDEOF1		;ADJUST FLAGS
	TRO	S,RDEOF2		; ..
	AOS	-2(P)			;SKIP RETURN
	JRST	POP2			; ..

NIEOF:	TRNN	P1,IODERR!IODTER!IOBKTL	;WORD ERRORS?
	JRST	QIN			;DON'T KNOW

	MOVE	P2,MTAHDR		;GET ADDR OF 2ND WORD IN BUFFER

	PUSHJ	P,MASTER		;TYPE MESSAGE(S)

	JRST	INOK			;GO FINISH

QIN:	OUTSTR	[ASCIZ/% UNIDENTIFIABLE INPUT ERROR
/]
INOK:	TRZ	S,RDEOF1!RDEOF2		;ZERO EOF BITS
	HRRZ	MBUF,MTAHDR+1		;GET WORD ADDR
	ADDI	MBUF,1			;INCREMENT

	PUSHJ	P,DECOD0		;UN-ENCRIPT

	AOS	-2(P)			;DOUBLE SKIP
	AOS	-2(P)			; ..
	JRST	POP2			; ..
MASTER:	OUTSTR	[ASCIZ/% DURING /]	;MESSAGE
	HLRZ	T1,2+GEN0(P2)		;GET RECORD TYPE
	CAIE	T1,TFIL			;FILE DATA?
	JRST	NONFIL			;NO--NOTE

	MOVE	T1,2+FILSTR(P2)		;GET STR
	PUSHJ	P,SIXOUT		; ..
	OUTCHR	COLON			; ..
	MOVE	T1,2+FILNAM(P2)		;GET FILE NAME
	PUSHJ	P,SIXOUT		; ..
	SKIPN	T1,2+FILEXT(P2)		;GET EXT
	JRST	MAS1			;SKIP
	OUTCHR	DOT			; ..
	PUSHJ	P,SIXOUT		; ..
MAS1:	OUTCHR	LBR			; ..
	HLRZ	T1,2+FILPPN(P2)		;GET PROJ
	PUSHJ	P,OCTOUT		;TYPE
	OUTCHR	COMMA			; ..
	HRRZ	T1,2+FILPPN(P2)		;GET PROG
	PUSHJ	P,OCTOUT		;TYPE
	OUTSTR	[ASCIZ/](BLOCK=/]	;TYPE BLOCK NUMBER
	MOVE	T1,2+FILRDB(P2)		;ACCESS
	PUSHJ	P,DECOUT		;TYPE
	OUTSTR	[ASCIZ/)
/]
	JRST	ERRBIT			;MOVE OVER TO BITS
NONFIL:	OUTSTR	[ASCIZ/ NON-FILE DATA
/]
ERRBIT:	TRNE	P1,IODERR		; ..
	OUTSTR	[ASCIZ!% DATA MISSED/TAPE BAD/TRANSPORT HUNG
!]
	TRNE	P1,IODTER		; ..
	OUTSTR	[ASCIZ!% PARITY ERROR
!]
	TRNE	P1,IOBKTL		; ..
	OUTSTR	[ASCIZ!% BLOCK TOO LARGE
!]
	POPJ	P,0			;RETURN
DECOD0:	HLRZ	T1,GEN0(MBUF)		;GET RECORD TYPE
	CAIN	T1,TFIL			;FILE DATA?
	SKIPN	PSWD			;PASSWORD TYPED?
	POPJ	P,0			;RETURN NOW

	MOVEM	7,SAVACS+7		;SAVE REGISTERS
	MOVEI	7,SAVACS		; ..
	BLT	7,SAVACS+6		; ..
	MOVE	7,SAVACS+7		;RESTORE IF NEEDED

	TROE	S,ENCINI		;INITIALIZED?
	JRST	DECOD1			;CALL UNSCRAMBLER
IFLE S-7,<
	MOVEM	S,SAVACS+S		;STORE NEWLY SET FLAG
>;END IFLE S-7
	MOVEI	7,PSWD			;ARGS
	PUSHJ	P,CRASZ.##		; ..
	MOVEM	5,SVCODE		;STORE

DECOD1:	MOVSI	7,-200*N		;NUMBER OF WORDS
	HRRI	7,M(MBUF)		;WHERE TO FIND THEM
	MOVE	6,FILRDB(MBUF)		;LOAD BLOCK NUMBER
	MOVE	5,SVCODE		;GET SEED BACK
	PUSHJ	P,CRYPT.##		;GO TRANSLATE

	MOVSI	7,SAVACS		;RESTORE REGISTERS
	BLT	7,7			; ..
	POPJ	P,0			;RETURN
SUBTTL	DSK INPUT/OUTPUT SUBROUTINES

DSKOUT:	SKIPA	T1,[OUT FILE,0]		;OUTPUT CALL
DSKIN:	MOVSI	T1,(<IN FILE,0>)	;INPUT CALL
	SETZ	T2,			;ZERO C(T1)
	EXCH	T2,DSKHDR+2		;ZERO BYTE COUNT
ALTDSK:	ADDM	T2,DSKHDR+1		;INCREMENT BYTE POINTER
	XCT	T1			;XCT I/O UUO
	  JRST	DSKSET			;OK
	WAIT	FILE,			;WAIT FOR I/O TO CEASE
	GETSTS	FILE,T1			;GET ERROR STS
	TRNE	T1,IOEOF		;SKIP IF NOT EOF
	JRST	CPOPJ1			;RETURN
	OUTSTR	[ASCIZ/% DURING/]	;INTRODUCTION
	PUSH	P,T1			;SAVE STATUS
	PUSH	P,P1			;SAVE C(P1)
	MOVEI	P1,EXLFIL		;ADDRESS OF LOOKUP/ENTER BLOCK
	PUSHJ	P,GUUO			;TYPE OUT
	POP	P,P1			;RESTORE C(P1)
	POP	P,T1			;RESTORE STATUS
	OUTSTR	[ASCIZ!% DSK I/O ERROR !];ERROR MESSAGE
	PUSHJ	P,OCTOUT		;TYPE NUMBER
	OUTSTR	CRLF			;CR-LF
	POPJ	P,0			;RETURN
DSKSET:	HRRZ	DBUF,DSKHDR+1		;FIRST DATA WORD MINUS ONE
	AOJA	DBUF,CPOPJ2		;RETURN

;MTA POSITIONING

INIPOS:	TLZE	S,RWD1			;REWIND?
	MTREW.	MTA,			;YES--DO SO
	TLZE	S,SKP1			;SKIP FILE?
	MTSKF.	MTA,			;YES--DO SO
	TLZE	S,EOT1			;SKIP TO EOT?
	MTEOT.	MTA,			;YES--DO SO
	MTWAT.	MTA,			;WAIT FOR TERMINATION
	POPJ	P,0			;RETURN

ENDPOS:	TLZE	S,RWD2			;REWIND?
	MTREW.	MTA,			;YES--DO SO
	TLZE	S,UNL2			;UNLOAD?
	MTUNL.	MTA,			;YES--DO SO
	POPJ	P,0			;RETURN
SUBTTL	LST OUTPUT ROUTINES

MSIXO:	MOVE	T2,[POINT 6,T1]		;POINT TO WORD
MSIXO1:	ILDB	CH,T2			;GET CHARACTER
	JUMPE	CH,CPOPJ		;RETURN
	ADDI	CH,40			;MAKE ASCII
	PUSHJ	P,MO			;TYPE
	TLNE	T2,770000		;DONE?
	JRST	MSIXO1			;NO--GET MORE
	POPJ	P,0			;RETURN

MOCTO:	TDZA	T3,T3			;0 INDICATES BASE 8
MDECO:	MOVEI	T3,2			;2 INDICATES BASE 10
MNBRO:	IDIVI	T1,8(T3)		;SPLIT DIGITS
	HRLM	T2,0(P)			; ..
	SKIPE	T1			; ..
	PUSHJ	P,MNBRO			; ..
	HLRZ	CH,0(P)			; ..
	ADDI	CH,"0"			; ..

MO:	SOSG	LSTOB+2			;SEE IF ROOM IN BUFFER
	OUTPUT	LST,0			;ADVANCE
	IDPB	CH,LSTOB+1		;STORE
	AOS	CHRCNT			; ..
	POPJ	P,0			; ..

MCRLF:	MOVEI	P1,CRLF			;CR-LF
MSG:	HRLI	P1,440700		;MAKE ASCII POINTER
MSG1:	ILDB	CH,P1			;GET CHARACTER
	JUMPE	CH,CPOPJ		; ..
	PUSHJ	P,MO			; ..
	JRST	MSG1			; ..
MDATE:	IDIVI	T1,^D31			;GET DAY-1
	PUSH	P,T1			;SAVE
	MOVEI	T1,1(T2)		;GET DAY
	PUSHJ	P,SPTWO			; ..
	POP	P,T1			;RETORE
	IDIVI	T1,^D12			;GET MONTH-1
	PUSH	P,T1			;SAVE REMAINDER
	MOVE	T1,MONTBL(T2)		;GET MONTH
	PUSHJ	P,MSIXO			; ..
	POP	P,T1			;RESTORE YEAR-1964
	ADDI	T1,^D64			; ..
	JRST	TWOOUT			; ..

MONTBL:	SIXBIT	/-JAN-/
	SIXBIT	/-FEB-/
	SIXBIT	/-MAR-/
	SIXBIT	/-APR-/
	SIXBIT	/-MAY-/
	SIXBIT	/-JUN-/
	SIXBIT	/-JUL-/
	SIXBIT	/-AUG-/
	SIXBIT	/-SEP-/
	SIXBIT	/-OCT-/
	SIXBIT	/-NOV-/
	SIXBIT	/-DEC-/

MTIME:	IDIV	T1,[DEC 60*60*1000]	;GET HOUR
	PUSH	P,T2			;SAVE REMAINDER
	PUSHJ	P,SPTWO			; ..
	MOVE	CH,COLON		;GET COLON
	PUSHJ	P,MO			;TYPE
	POP	P,T1			;RESTORE
	IDIVI	T1,^D60*^D1000		;GET MINUTE

TWOOUT:	IDIVI	T1,^D10			;SPLIT DIGITS
	MOVEI	CH,"0"(T1)		;GET FIRST
SPTWO1:	PUSHJ	P,MO			; ..
	MOVEI	CH,"0"(T2)		;GET SECOND
	JRST	MO			; ..

SPTWO:	IDIVI	T1,^D10			;SPLIT DIGITS
	MOVEI	CH,SP			;ASSUME SPACE
	SKIPE	T1			;TRUE?
	MOVEI	CH,"0"(T1)		;NO--GET DIGIT
	JRST	SPTWO1			; ..
SUBTTL	SUBROUTINES

;SUBROUTINE INIMTA

INIMTA::MOVE	T1,OPNMTA+1		;GET DEVICE NAME
	DEVCHR	T1,			;GET CHARACTERISTICS
	TLNN	T1,DV.MTA		;MTA?
	JRST	NOTMTA			;NO--PUNT
	OPEN	MTA,OPNMTA		;TRY TO INITIALIZE
	  JRST	MTFAIL			;LOSE

;SUBROUTINE BUFGEN
;
;CALLING SEQUENCE:
;
;	MOVEI	P2,<NUMBER OF BUFFERS TO BE MADE>
;	PUSHJ	P,BUFGEN
;	  ERROR RETURN
;	NORMAL RETURN
;
;THE ERROR RETURN WILL BE TAKEN ON FAILURE TO EXPAND CORE AS NEEDED.

BUFGEN:	MOVE	T1,P2			;GET NUMBER OF BUFFERS NEEDED
	IMULI	T1,MTBFSZ+3		;HOW MANY WORDS NEEDED
	PUSHJ	P,UCORE			;GET WORDS
	  POPJ	P,0			;RETURN
	SETZM	0(P1)			;ZERO CORE AREA
	MOVSI	T1,0(P1)		;MAKE BLT POINTER
	HRRI	T1,1(P1)		; ..
	MOVE	T2,.JBFF##		;GET BACK NEW JOBFF
	BLT	T1,-1(T2)		;ZILCH CORE

	MOVEI	T1,1(P1)		;ADDRESS OF 1ST BUF PLUS 1

BUFGN1:	MOVSI	T2,MTBFSZ+1		;DATA WORDS
	SOJLE	P2,LAST			;SEE IF THIS IS LAST BUFFER
	HRRI	T2,MTBFSZ+3(T1)		;LOC OF NEXT BUF PLUS 1
	MOVEM	T2,0(T1)		;STORE
	ADDI	T1,MTBFSZ+3		;NEXT BUFFER
	JRST	BUFGN1			;LOOP

LAST:	HRRI	T2,1(P1)		;LOC OF 1ST BUF PLUS 1
	MOVEM	T2,0(T1)		;STORE

	MOVEI	T1,1(P1)		;LOC OF 1ST BUF PLUS 1
	HRLI	T1,400000		;VIRGIN RING
	MOVEM	T1,MTAHDR		; ..
	MOVSI	T1,4400			;INDICATE 36 BIT BYTES
	MOVEM	T1,MTAHDR+1		;STORE
	SETZM	MTAHDR+2		;ZERO BYTE COUNT
	JRST	CPOPJ1			;SKIP BACK
;SUBROUTINE TO CHECK USE OF ALL FILE SPECS

CHECK:	JSP	T1,SAVE3		;SAVE 3 REGISTERS
	MOVE	P1,AOSPEC		;ADDRESS OF SPECS
	MOVE	P2,NTSPEC		;NUMBER OF SPECS
	MOVSI	P3,RQMAT.		;IF FILE SPEC USED

CHECK1:	TDNE	P3,RQBIT1(P1)		;SPEC NOT USED?
	JRST	ENDCHK			;IT WAS--SKIP THIS CODE
	OUTSTR	[ASCIZ/% NO FILES FOUND /];MESSAGE
	MOVE	T1,RQDEV(P1)		;GET DEVICE NAME
	MOVE	T2,RQDEVW(P1)		;AND WILD SPEC
	PUSHJ	P,SPCSIX		;TYPE
	OUTCHR	COLON			;TYPE COLON
	MOVE	T1,RQNAM(P1)		;GET FILE NAME
	MOVE	T2,RQNAMW(P1)		;AND WILD SPEC
	PUSHJ	P,SPCSIX		;TYPE
	OUTCHR	DOT			;END OF NAME
	MOVE	T1,RQEXT(P1)		;GET EXTENSION
	HLLO	T2,RQEXTW(P1)		;AND WILD SPEC
	PUSHJ	P,SPCSIX		;TYPE
	OUTCHR	LBR			;OPEN BRACKET
	HLRZ	T1,RQPPN(P1)		;GET PPN
	HLRZ	T2,RQPPNW(P1)		;AND WILD SPEC
	PUSHJ	P,SPCOCT		;TYPE
	OUTCHR	COMMA			;END OF PROJ
	HRRZ	T1,RQPPN(P1)		;GET PPN
	HRRZ	T2,RQPPNW(P1)		;AND WILD SPEC
	PUSHJ	P,SPCOCT		;TYPE
	OUTCHR	RBR			;END OF THAT
	OUTSTR	CRLF			;END OF LINE

ENDCHK:	ADDI	P1,RQLTH		;INCREMENT ADDR
	SOJG	P2,CHECK1		;LOOP
	POPJ	P,0			;RETURN
COMMENT	$
SUBROUTINE SPCSIX

OUTPUTS TO CONSOLE ONE SIXBIT WORD (WHICH MAY INCLUDE WILD BYTES)

CALLING SEQUENCE:

	MOVE	T1,[<SIXBIT WORD>]
	MOVE	T2,[<WILD BYTE WORD>]
	PUSHJ	P,SPCSIX
	ALWAYS RETURN
$
SPCSIX:	SETCM	T3,T2			;GET COMPLEMENT
	JUMPN	T3,SIX0			;BRANCH IF SOME NOT WILD
	OUTCHR	STAR			;COMPLETELY WILD
	POPJ	P,0			;RETURN

SIX0:	MOVE	T3,[POINT 6,T1]		;LOAD POINTER
	MOVE	T4,[POINT 6,T2]		; ..

SIX1:	ILDB	CH,T3			;GET CHARACTER
	IBP	T4			;INC
	JUMPN	CH,SIX2			;BRANCH IF PRINTABLE
	LDB	CH,T4			;GET WILD BYTE
	JUMPE	CH,CPOPJ		;RETURN IF ALSO NULL
	MOVEI	CH,'?'			;LOAD SIXBIT FOR Q MARK
SIX2:	ADDI	CH,40			;CONVERT SIXBIT TO ASCII
	OUTCHR	CH			;OUTPUT
	TLNE	T3,770000		;DONE?
	JRST	SIX1			;NO--CONTINUE
	POPJ	P,0			;RETURN
COMMENT	$
SUBROUTINE SPCOCT

OUTPUTS TO CONSOLE ONE OCTAL NUMBER (WHICH MAY CONTAIN WILD BYTES)

CALLING SEQUENCE:

	MOVE	T1,[<OCTAL NUMBER>]
	MOVE	T2,[<WILD BYTE WORD>]
	PUSHJ	P,SPCOCT
	ALWAYS RETURN
$
SPCOCT:	SETCM	T3,T2			;GET COMPLEMENT
	TRNE	T3,-1			;SKIP IF ALL WILD
	JRST	OCT0			;NOT ALL WILD--DO INDIVIDUALLY
	OUTCHR	STAR			;COMPLETELY WILD
	POPJ	P,0			;RETURN

OCT0:	IOR	T1,T2			;MAKE ALL WILD DIGITS 7
	MOVE	T3,T2			;MOVE INTO T3
OCT1:	IDIVI	T1,8			;SPLIT DIGITS
	PUSH	P,T2			;STORE REMAINDER
	IDIVI	T3,8			;SPLIT WILD DIGITS
	HRLM	T4,0(P)			;STORE ON STACK
	SKIPE	T1			;DONE?
	PUSHJ	P,OCT1			;LOOP
	POP	P,T1			;RESTORE LAST WORD
	HRRZ	CH,T1			;GET DIGIT
	ADDI	CH,"0"			;MAKE ASCII FROM BINARY
	TLNE	T1,-1			;WILD?
	MOVEI	CH,"?"			;YES--USE Q MARK
	OUTCHR	CH			;OUTPUT
	POPJ	P,0			;RETURN
;SUBROUTINE IFIND
;
;CALLING SEQUENCE:
;
;	MOVE	P4,[-<NUMBER OF WORDS IN TABLE>,,<ADDRESS OF TABLE>]
;	PUSHJ	P,FIND
;	  ERROR RETURN -- WORD NOT FOUND
;	NORMAL RETURN -- C/RH(T1) = INDEX OF WORD IN TABLE

IFIND:	PUSHJ	P,SIXIN			;GET SIXBIT WORD

	TRZ	S,U1!U2			;ZERO UNIQUE MASKS
	HLLZ	T1,P4			;COPY LENGTH
	HRRZ	T2,P4			;GET BASE ADDRESS
	HRLI	T2,T1			;WITH INDEX REGISTER T1

FIND1:	CAMN	P1,@T2			;MATCH?
	JRST	CPOPJ1			;YES--RETURN
	MOVE	T3,P1			;COPY WORD
	XOR	T3,@T2			;COMPARE WITH TABLE WORD
	AND	T3,P2			;JUST RETAIN SIGNIFICANT BYTES
	JUMPN	T3,NOMAT		;BRANCH IF NO
	MOVEM	T1,T4			;SAVE FOR LATER
	TROE	S,U1			;SET AND SKIP IF FIRST TIME
	TRO	S,U2			;FLAG DUPLICATE FIND
NOMAT:	AOBJN	T1,FIND1		;LOOP
	TRNN	S,U2			;JUST 1 IF ANY
	TRNN	S,U1			;1?
	POPJ	P,0			;LOSE
	MOVE	T1,T4			;RE-COPY INDEX
	MOVE	P1,@T2			;COPY FULL WORD
	JRST	CPOPJ1			;GOOD RETURN
;SUBROUTINE VER1
;
;CALLING SEQUENCE:
;
;	MOVEI	P4,<ADDRESS OF FILE SPEC BLOCK>
;	PUSHJ	P,VER1
;	  ERROR RETURN -- FILE DOES NOT MEET NAME SPECIFICATIONS
;	NORMAL RETURN -- FILE MEETS NAME SPECIFICATIONS

VER1::	MOVE	T1,CSTR			;GET CURRENT STR
	XOR	T1,RQDEV(P4)		;GET DIFF
	TDZ	T1,RQDEVW(P4)		; ..
	JUMPN	T1,CPOPJ		;RETURN NOW IF BAD

	MOVE	T1,CPPN			;GET CURRENT PPN
	XOR	T1,RQPPN(P4)		; ..
	TDZ	T1,RQPPNW(P4)		; ..
	JUMPN	T1,CPOPJ		; ..

	JUMPLE	LVL,CPOPJ1		;RETURN NOW IF NO SFD'S
	MOVN	T1,LVL			;GET LEVEL
	HRLZS	T1			;FORM AOBJN XWD
	MOVE	T2,P4			;ANOTHER INDEX

SFDCHK:	MOVE	T3,PH1BLK+3(T1)		;GET SFD NAME
	XOR	T3,RQSFD(T2)		;GET DIFFERENCES
	TDZ	T3,RQSFDW(T2)		;BLOT OUT DIFFERENCES
	JUMPN	T3,CPOPJ		;RETURN IF NO GOOD
	ADDI	T2,1			;INCREMENT
	AOBJN	T1,SFDCHK		;LOOP
	JRST	CPOPJ1			;SKIP BACK

VER2::	MOVE	T1,CNAM			;GET CURRENT NAME
	XOR	T1,RQNAM(P4)		; ..
	TDZ	T1,RQNAMW(P4)		; ..
	JUMPN	T1,CPOPJ		; ..

	MOVE	T1,CEXT			;GET CURRENT EXT
	XOR	T1,RQEXT(P4)		; ..
	TDZ	T1,RQEXTW(P4)		; ..
	JUMPE	T1,CPOPJ1		;GOOD RETURN
	POPJ	P,0			;BAD RETURN
;SUBROUTINE CHKLIM
;
;CALLING SEQUENCE:
;
;	MOVEI	P4,<ADDRESS OF FILE SPEC BLOCK>
;	PUSHJ	P,CHKLIM
;	  ERROR RETURN -- FILE DOES NOT MEET TIME AND SIZE SPECIFICATIONS
;	NORMAL RETURN -- FILE MEETS TIME AND SIZE SPECIFICATIONS

CHKLIM::MOVE	T1,RQCUD(P4)		;GET UPPER CREATION DATE
	CAMGE	T1,CCDATE		;SKIP IF GE FILE'S
	POPJ	P,0			;LOSE

	CAME	T1,CCDATE		;BOUNDARY DATE?
	JRST	LIM1			;NO--DO NOT CHECK TIME

	MOVE	T1,RQCUT(P4)		;UPPER CREATION TIME
	CAMGE	T1,CCTIME		;SKIP IF GE FILE'S
	POPJ	P,0			;LOSE

LIM1:	MOVE	T1,RQCLD(P4)		;LOWER CREATION DATE
	CAMLE	T1,CCDATE		;SKIP IF LE FILE'S
	POPJ	P,0			;LOSE

	CAME	T1,CCDATE		;BOUNDARY DATE?
	JRST	LIM2			;NO--DO NOT CHECK TIME

	MOVE	T1,RQCLT(P4)		;LOWER CREATION TIME
	CAMLE	T1,CCTIME		;SKIP IF LE FILE'S
	POPJ	P,0			;LOSE

LIM2:	TRNE	S,ARCMOD		;ARCHIVE MODE?
	JRST	CPOPJ1			;YES--SKIP BACK NOW

	MOVE	T1,RQAUD(P4)		;UPPER ACCESS DATE
	CAMGE	T1,CADATE		;SEE IF GE FILE'S
	POPJ	P,0			;LOSE

	MOVE	T1,RQALD(P4)		;LOWER ACCESS DATE
	CAMLE	T1,CADATE		;SEE IF LE FILE'S
	POPJ	P,0			;LOSE

	MOVE	T1,RQMAXB(P4)		;UPPER BLOCK LIMIT
	CAMGE	T1,CBSIZE		;SEE IF GE FILE'S
	POPJ	P,0			;LOSE

	MOVE	T1,RQMINB(P4)		;LOWER BLOCK LIMIT
	CAMG	T1,CBSIZE		;SEE IF GT FILE'S
	AOS	0(P)			;GOOD RETURN
	POPJ	P,0			; ..
;SUBROUTINE SRTUFD/SRTMFD
;
;CALLING SEQUENCE
;
;	MOVE	P1,[-<NUMBER OF WORDS>,,<ADDRESS OF DATA>-1]
;	PUSHJ	P,SRTUFD/SRTMFD
;	ALWAYS RETURN

SRTUFD:	HRRZ	T1,SRTWRD		;GET SORTING CODE
	JRST	@SRTDSP(T1)		;DISPATCH

SRTMFD:	HLRZ	T1,SRTWRD		;GET SORTING CODE
	JRST	@SRTDSP(T1)		;DISPATCH

LOCSRT:	MOVE	T1,P1			;COPY POINTER
	ADD	T1,[2,,0]		;SKIP FIRST
	JUMPGE	T1,CPOPJ		;RETURN

LOC1:	HRRZ	T2,2(T1)		;GET CFP OF FIRST
	HRRZ	T3,4(T1)		;GET CFP OF SECOND
	CAMLE	T2,T3			;SKIP IF LE
	JRST	LOCINV			;INVERSION
LOC2:	AOBJN	T1,.+1			;ADVANCE 1
	AOBJN	T1,LOC1			;CONTINUE IF MORE

	TLZE	S,FLOP			;ZILCH & SKIP IF NO INVERSIONS
	JRST	LOCSRT			;SCAN AGAIN
	POPJ	P,0			;RETURN

LOCINV:	MOVE	T2,1(T1)		;GET FIRST FILE NAME
	EXCH	T2,3(T1)		;EXCHANGE
	MOVEM	T2,1(T1)		; ..
	MOVE	T2,2(T1)		;GET FIRST EXT
	EXCH	T2,4(T1)		;EXCHANGE
	MOVEM	T2,2(T1)		; ..
	TLO	S,FLOP			; ..
	JRST	LOC2			; ..
ALPSRT:	MOVE	T1,P1			;COPY POINTER
	ADD	T1,[2,,0]		;SKIP FIRST
	JUMPGE	T1,CPOPJ		;RETURN

ALP1:	MOVE	T2,1(T1)		;GET FIRST FILE NAME
	TLC	T2,(1B0)		;COMPLEMENT SIGN BIT
	MOVE	T3,3(T1)		;GET SECOND FILE NAME
	TLC	T3,(1B0)		;COMPLEMENT SIGN BIT
	CAMLE	T2,T3			;TEST
	JRST	INVERT			;INVERSION
	CAME	T2,T3			;SKIP IF EQUAL
	JRST	ALP2			;FINISHED
	HLRZ	T2,2(T1)		;GET FIRST EXT
	HLRZ	T3,4(T1)		;GET SECOND EXT
	CAMLE	T2,T3			;TEST FOR INVERSION
	JRST	INVERT			;INVERSION
ALP2:	AOBJN	T1,.+1			;ADVANCE 1
	AOBJN	T1,ALP1			;ADVANCE 2

	TLZE	S,FLOP			;ZERO & TEST IF ANY INVERSIONS
	JRST	ALPSRT			;THERE WERE SOME--CONTINUE
	POPJ	P,0			;NONE--SKIP BACK

INVERT:	MOVE	T2,1(T1)		;GET FIRST
	EXCH	T2,3(T1)		;EXCHANGE FIRST WITH SECOND
	MOVEM	T2,1(T1)		;PUT SECOND IN FIRST
	MOVE	T2,2(T1)		;GET FIRST
	EXCH	T2,4(T1)		;EXCHANGE FIRST WITH SECOND
	MOVEM	T2,2(T1)		;PUT SECOND IN FIRST
	TLO	S,FLOP			;SET BIT
	JRST	ALP2			;CONTINUE
;SUBROUTINE UCORE
;
;CALLING SEQUENCE:
;
;	MOVEI	T1,<NUMBER OF WORDS TO ALLOCATE>
;	PUSHJ	P,UCORE
;	  ERROR RETURN -- NO CORE AVAILABLE
;	NORMAL RETURN -- C(P1) = ADDRESS OF BLOCK

UCORE::	MOVE	P1,T1			;COPY NUMBER OF WORDS
	ADD	P1,.JBFF##		;INCREMENT TO FORM NEW JOBFF
	MOVE	T2,P1			;COPY AGAIN
	TRO	T2,1777			;ROUND TO NEAREST 1K
	CAMG	T2,.JBREL##		;SKIP IF TOO BIG
	JRST	UCORE1			;IT FITS--GOOD
	CORE	T2,			;EXPAND IF NECESSARY
	  JRST	NOCORE			;LOSE
UCORE1:	MOVE	T2,.JBFF##		;GET OLD JOBFF
	SETZM	0(T2)			;ZILCH FIRST WORD
	HRLS	T2			;PUT IN LH
	ADDI	T2,1			;FORM BLT POINTER
	BLT	T2,-1(P1)		;ZERO NEW CORE
	EXCH	P1,.JBFF##		;GET BASE ADDR
	JRST	CPOPJ1			;SKIP BACK
SUBTTL	TELETYPE I/O SUBROUTINES

TYI:	MOVEM	CH,LASTCH		;SAVE LAST CH
TYI1:	INCHWL	CH			;GET A CHARACTER
	JUMPE	CH,TYI1			;IGNORE IF NULL
	CAIN	CH,CR			;IGNORE RETURNS
	JRST	TYI1			; ..
	PUSH	P,T1			;SAVE C(T1)
	MOVSI	T1,-BRKLTH		;LENGTH OF TABLE
	CAMN	CH,BRKTBL(T1)		;SKIP IF NO MATCH
	SETZ	CH,			;MATCH--INDICATE BY 0
	AOBJN	T1,.-2			;LOOP
	POP	P,T1			;RESTORE
	CAIL	CH,140			;SKIP IF UPPER CASE
	SUBI	CH,40			;CONVERT
	CAIE	CH,SP			;SPACE?
	CAIN	CH,HT			;HORIZONTAL TAB?
	MOVNI	CH,1			;YES--FLAG WITH -1
	POPJ	P,0			;RETURN

BRKTBL:	EXP	CTRLC,BELL,LF,VT,FF,CTRLZ,ALT33,ALT175,ALT176

	BRKLTH==.-BRKTBL

STYI:	PUSHJ	P,TYI			;GET A CHARACTER
	JUMPL	CH,STYI			;SPACE?
	POPJ	P,0			;NO--RETURN

FLUSH:	JUMPE	CH,CPOPJ		;RETURN IF BREAK
FLUSH1:	PUSHJ	P,TYI			;GET A CH
	JUMPN	CH,FLUSH1		;LOOP IF NOT BREAK
	POPJ	P,0			;RETURN
SIXIN:	SETZB	T1,T3			;FOR MASKS
	SETOB	T2,T4			; ..
	SETZ	P1,			;RETURN WORD

	PUSHJ	P,STYI			;GET NON-BLANK
	SKIPA	P2,[POINT 6,P1]		;SET UP BYTE POINTER
SIXIN1:	PUSHJ	P,TYI			;READ A CHARACTER

	CAIE	CH,"?"			;WILD?
	JRST	NOTQ			;NO--CHECK FOR STAR
	TLNN	P2,770000		;INCREMENT
	JRST	SIXIN1			;LOOP
	IBP	P2			; ..
	LSHC	T1,6			;ONE MORE SIGNIFICANT
	LSHC	T3,6			;ONE MORE WILD
	JRST	SIXIN1			;LOOP

NOTQ:	CAIE	CH,"*"			;WILD?
	JRST	NOTS			;NO--CHECK FOR ALPHANUMERIC
	CAME	P2,[POINT 6,P1]		;HAD BETTER BE FIRST CHARACTER
	POPJ	P,0			;NO--ROTTEN SYNTAX
	SETOB	P2,P3			;ALL SIGNIFICANT AND WILD
	JRST	TYI			;RETURN

NOTS:	CAIL	CH,"0"			;SEE IF ALPHANUMERIC
	CAILE	CH,"Z"			; ..
	JRST	SIXIN3			;DONE
	CAILE	CH,"9"			; ..
	CAIL	CH,"A"			; ..
	JRST	SIXIN2			; ..

SIXIN3:	TLNN	P2,770000		;DONE?
	JRST	SIXIN4			;NO
	IBP	P2			;ONE MORE
	LSH	T1,6			; ..
	LSH	T3,6			; ..
	JRST	SIXIN3			;LOOP

SIXIN4:	MOVEM	T1,P2			;STORE SIGNIFICANCE MASK
	MOVEM	T3,P3			;STORE WILD MASK
	POPJ	P,0			;RETURN

SIXIN2:	TLNN	P2,770000		;SEE IF DONE
	JRST	SIXIN1			;LOOP
	SUBI	CH,40			;CONVERT ASCII TO SIXBIT
	IDPB	CH,P2			;DEPOSIT
	ADDI	CH,40			;RESTORE
	LSHC	T1,6			;ONE MORE SIGNIFICANT
	LSH	T3,6			;NOT WILD
	JRST	SIXIN1			;LOOP
OCTZ:	SETZB	T1,T3			;FOR MASKS
	SETOB	T2,T4			; ..

	PUSHJ	P,STYI			;GET FIRST NON-BLANK CH
	TDZA	P1,P1			;CRANK IT UP
OCTZ1:	PUSHJ	P,TYI			;GET CH

	CAIE	CH,"?"			;WILD?
	JRST	OCTZ1A			;NO--CHECK OTHERS
	LSH	P1,3			;ONE MORE DIGIT
	LSHC	T1,3			;ONE MORE POSITION
	LSHC	T3,3			; ..
	JRST	OCTZ1			;LOOP

OCTZ1A:	CAIE	CH,"*"			;WILD?
	JRST	OCTZ2			;NOPE
	JUMPN	T1,CPOPJ		;LOSE IF NOT FIRST
	SETOB	P2,P3			;ALL SIGNIFICANT/ALL WILD
	JRST	TYI			;AFTER GETTING NEXT CH

OCTZ2:	CAIL	CH,"0"			;OCTAL?
	CAILE	CH,"7"			; ..
	JRST	OCTFIN			;FINISH UP
	ASH	P1,3			;MAKE ROOM
	ADDI	P1,-"0"(CH)		;ADD IN
	LSHC	T1,3			;ONE MORE SIGNIFICANT
	LSH	T3,3			;WHICH IS NOT WILD
	JRST	OCTZ1			;CONTINUE

OCTFIN:	MOVEM	T1,P2			;STORE SIGNIFICANCE MASK
	MOVEM	T3,P3			;STORE WILD MASK
	POPJ	P,0			;RETURN
OCTIN:	TDZA	T2,T2			;ZERO C(T2)
DECIN:	MOVEI	T2,2			;10=8+2
	PUSHJ	P,STYI			;GET FIRST NON-BLANK
	TDZA	T1,T1			;START WITH 0
NBRIN:	PUSHJ	P,TYI			;GET A CHARACTER
	CAIL	CH,"0"			;TOO SMALL?
	CAILE	CH,"7"(T2)		;TOO BIG?
	POPJ	P,0			;YES--RETURN
	IMULI	T1,8(T2)		;SHIFT OVER
	ADDI	T1,-"0"(CH)		;ADD CHARACTER IN
	JRST	NBRIN			;LOOP

SIXOUT::MOVE	T2,[POINT 6,T1]		;POINTER TO OBJECT WORD
SIXOU1:	ILDB	T3,T2			;GET BYTE
	JUMPE	T3,CPOPJ		;RETURN IF NULL
	ADDI	T3,40			;CONVERT
	OUTCHR	T3			;OUTPUT TO TTY
	TLNE	T2,770000		;SKIP IF DONE
	JRST	SIXOU1			;MORE TO GO
	POPJ	P,0			;RETURN

OCTOUT:	TDZA	T3,T3			;INDICATE BASE 8
DECOUT:	MOVEI	T3,2			;INDICATE BASE 10
NBROUT:	IDIVI	T1,8(T3)		;START SPLITTING NUMBER
	HRLM	T2,0(P)			;STORE DIGIT ON STACK
	SKIPE	T1			;SEE IF DONE
	PUSHJ	P,NBROUT		;KEEP GOING
	HLRZ	T1,0(P)			;GET DIGIT OFF STACK
	ADDI	T1,"0"			;CONVERT BINARY TO ASCII
	OUTCHR	T1			;OUTPUT TO TTY
	POPJ	P,0			;RETURN

WAIT1:	PUSHJ	P,TYI			;GET A CH
	JUMPN	CH,WAIT1		;WAIT FOR BREAK CH
	JRSTF	-2(T1)			;ONE INST. BEFORE CALL
WAIT0::	JSP	T1,SAVE4		;SAVE ALL PERMANENTS
WAIT0A:	MOVE	P4,[-TCMLTH,,TCMNAM]	;LIST OF TAPE COMMANDS
	PUSHJ	P,IFIND			;SEE IF CAN FIND
	  JRST	ERROR0			;INFORM HIM OF BAD RESPONSE
	PUSHJ	P,FLUSH			;GOBBLE REST OF INPUT
	MTREW.	MTA,			;START AT LOAD POINT
	TRNN	S,ARCMOD		;DON'T DO ANYTHING IN ARCHIVE MODE
	XCT	TCMINS(T1)		;EXECUTE APPROPRIATE COMMAND
	MTWAT.	MTA,			;WAIT FOR COMPLETION
	POPJ	P,0			;RETURN

ERROR0:	PUSHJ	P,FLUSH			;GOBBLE REST OF INPUT
	OUTSTR	[ASCIZ/% COMMANDS INCLUDE: CONTINUE & SKIP
#/]
	JRST	WAIT0A			;TRY AGAIN

TCMNAM:	SIXBIT	/CONTIN/
	SIXBIT	/SKIP/

	TCMLTH==.-TCMNAM

TCMINS:	MTWAT.	MTA,
	MTSKF.	MTA,
SUBTTL	ERROR MESSAGES

MESG1:	ASCIZ	/% CANNOT OPEN "/

MESG2:	ASCIZ	/"
/

CRLFLF:	BYTE(7)CR,LF,CR,LF,0

CRLF:	BYTE(7)CR,LF,0

NOCORE:	OUTSTR	[ASCIZ/% NOT ENOUGH CORE
/]
	POPJ	P,0

FAIL0:	MOVE	T1,T2
	JRST	FAIL1
MTFAIL:	SKIPA	T1,OPNMTA+1
DVFAIL:	MOVE	T1,CSTR
FAIL1::	OUTSTR	MESG1
	PUSHJ	P,SIXOUT
	OUTSTR	MESG2
	POPJ	P,0

NOCOM:	PUSHJ	P,FLUSH
	OUTSTR	[ASCIZ/% NO SUCH COMMAND "/]
	MOVE	T1,P1
	PUSHJ	P,SIXOUT
	OUTSTR	MESG2
	JRST	FRS

USWT:	OUTSTR	[ASCIZ/% NO SUCH SWITCH "/]
USWTX:	MOVE	T1,P1
	PUSHJ	P,SIXOUT
	OUTSTR	MESG2
	POPJ	P,0

NOTENF:	OUTSTR	[ASCIZ/% TOO FEW ARGS FOR "/]
	JRST	USWTX

UPAR:	OUTSTR	[ASCIZ/% NO SUCH PARITY "/]
	JRST	USWTX

UDENS:	OUTSTR	[ASCIZ/% NO SUCH DENSITY "/]
	JRST	USWTX

USRT:	OUTSTR	[ASCIZ/% NO SUCH SORT "/]
	JRST	USWTX

NCLOSE:	OUTSTR	[ASCIZ/% INC PPN
/]
	POPJ	P,0

JUST1O:	OUTSTR	[ASCIZ/% INC # OUTPUT
/]
	POPJ	P,0

JUST1I:	OUTSTR	[ASCIZ/% INC # INPUT
/]
	POPJ	P,0

WLDERR:	OUTSTR	[ASCIZ/% INC WILD
/]
	POPJ	P,0

BADINI:	OUTSTR	[ASCIZ/% INC INI
/]
	POPJ	P,0

NEEDBT::OUTSTR	[ASCIZ/% NEED BOT
/]
	POPJ	P,0

NOTMTA:	OUTSTR	[ASCIZ/% DEVICE "/]
	MOVE	T1,OPNMTA+1
	PUSHJ	P,SIXOUT
	OUTSTR	[ASCIZ/" IS NOT AN MTA
/]
	POPJ	P,0

ALIERR:	OUTSTR	[ASCIZ/% SFD ALIAS LEVEL INC
/]
	POPJ	P,0

DEEP:	OUTSTR	[ASCIZ/% SFD LEVELING TOO DEEP
/]
	POPJ	P,0
IFN FTIND,<
NOHOME:	OUTSTR	[ASCIZ/% CANNOT READ HOME BLOCK FOR STR /]
	MOVE	T1,CSTR
	PUSHJ	P,SIXOUT
	OUTSTR	MESG2
	POPJ	P,0
>;END IFN FTIND
EAFIL:	JSP	T1,SAVE1
	MOVEI	P1,EXLFIL

AMSG:	OUTSTR	[ASCIZ/% ABORT/]
	JRST	GUUO

ELUFD:	JSP	T1,SAVE1
	MOVEI	P1,EXLUFD
	JRST	LMSG

ELFIL:	JSP	T1,SAVE1
	MOVEI	P1,EXLFIL

LMSG:	OUTSTR	[ASCIZ/% LOOKUP /]
	JRST	EGUUO

EEUFD:	JSP	T1,SAVE1
	MOVEI	P1,EXLUFD
	JRST	EMSG

EEFIL:	JSP	T1,SAVE1
	MOVEI	P1,EXLFIL

EMSG:	OUTSTR	[ASCIZ/% ENTER /]

EGUUO:	HRRZ	T1,RIBEXT(P1)
	PUSHJ	P,OCTOUT

	HRRZ	T2,RIBEXT(P1)
	CAIL	T2,ERRLTH
	JRST	GUUO
	OUTCHR	LPAREN
	ROT	T2,-1
	MOVE	T1,ERRTBL(T2)
	TLNE	T2,(1B0)
	MOVSS	T1
	HLLZS	T1
	PUSHJ	P,SIXOUT
	OUTCHR	RPAREN

GUUO:	OUTCHR	SPACE

	MOVE	T1,CSTR
	PUSHJ	P,SIXOUT
	OUTCHR	COLON
	HLRZ	T1,RIBEXT(P1)
	CAIE	T1,'UFD'
	JRST	NOTUFD
	HLRZ	T1,RIBNAM(P1)
	PUSHJ	P,OCTOUT
	OUTCHR	COMMA
	HRRZ	T1,RIBNAM(P1)
	PUSHJ	P,OCTOUT
	JRST	JOIN1
NOTUFD:	MOVE	T1,RIBNAM(P1)
	PUSHJ	P,SIXOUT
JOIN1:	HLLZ	T1,RIBEXT(P1)
	JUMPE	T1,JOIN2
	OUTCHR	DOT
	PUSHJ	P,SIXOUT
JOIN2:	OUTCHR	LBR
	HLRZ	T1,RIBPPN(P1)
	JUMPE	T1,JOIN3
	PUSHJ	P,OCTOUT
	OUTCHR	COMMA
	HRRZ	T1,RIBPPN(P1)
	PUSHJ	P,OCTOUT
EDONE:	OUTCHR	RBR
	OUTSTR	CRLF
	POPJ	P,0

JOIN3:	HRRZ	P1,RIBPPN(P1)
	HLRZ	T1,2(P1)
	PUSHJ	P,OCTOUT
	OUTCHR	COMMA
	HRRZ	T1,2(P1)
	PUSHJ	P,OCTOUT

JOIN4:	SKIPN	T1,3(P1)
	JRST	EDONE
	OUTCHR	COMMA
	PUSHJ	P,SIXOUT
	AOJA	P1,JOIN4
SUBTTL	MISC

SAVE1::	PUSH	P,P1
	PUSHJ	P,0(T1)
	  SKIPA
	AOS	-1(P)
	JRST	POP1

SAVE2::	PUSH	P,P1
	PUSH	P,P2
	PUSHJ	P,0(T1)
	  SKIPA
	AOS	-2(P)
	JRST	POP2

SAVE3::	PUSH	P,P1
	PUSH	P,P2
	PUSH	P,P3
	PUSHJ	P,0(T1)
	  SKIPA
	AOS	-3(P)
	JRST	POP3

SAVE4::	PUSH	P,P1
	PUSH	P,P2
	PUSH	P,P3
	PUSH	P,P4
	PUSHJ	P,0(T1)
	  SKIPA
	AOS	-4(P)
POP4:	POP	P,P4
POP3:	POP	P,P3
POP2:	POP	P,P2
POP1:	POP	P,P1
	POPJ	P,0
CPOPJ2::AOS	0(P)
CPOPJ1::AOSA	0(P)
FPOPJ::	POP	P,.JBFF##
CPOPJ::	POPJ	P,0

STAR:	"*"
DOT:	"."
COLON:	":"
COMMA:	","
LPAREN:	"("
RPAREN:	")"
LBR:	"["
RBR:	"]"
TAB:	EXP	HT
SPACE:	EXP	SP

LITBEG:	XLIST	;DO NOT LIST LITERALS
	LIT
	LIST
	LITEND==.-1
SUBTTL	STORAGE

	RELOC	0		;START OF LOW SEGMENT

	STOBEG==.		;BEGINNING OF STORAGE

STRTBL::BLOCK	MAXSTR		;FS NAMES
STRUNI::BLOCK	MAXSTR		;UNIT COUNTS
STRCNT::BLOCK	MAXSTR		;TOTAL NUMBER OF FILES RESTORED
STRPTR::BLOCK	MAXSTR		;POINTER TO LOGICAL UNIT BYTES
USYSNM::BLOCK	5		;SYSTEM NAME
UMONVR::BLOCK	5		;MONITOR VERSION
UMFD::	BLOCK	1		;MFD PPN

IFN FTIND,<
CMDHMB::BLOCK	2		;<IOWD MAXHOM+1,HMBBLK>
HMBBLK::BLOCK	MAXHOM+1	;HOME BLOCK
CMDRIB::BLOCK	2		;<IOWD 200,BLKRIB>
BLKRIB::BLOCK	200		;RIB BLOCK
>;END IFN FTIND

OPNMTA::BLOCK	3		;SPACE TO OPEN MTA CHANNEL

PERM::	BLOCK	RQLTH		;PERMANENT FILE SPECS
TEMP::	BLOCK	RQLTH		;TEMPORARY

PSWD::	BLOCK	MAXCHR/5+1	;PASSWORD TEXT
TEXT::	BLOCK	MAXCHR/5+1	;COMMENT TEXT

DSKHDR::BLOCK	3		;DSK BUFFER HEADER
MTAHDR::BLOCK	3		;MTA BUFFER HEADER
LSTOB::	BLOCK	3		;LST BUFFER HEADER

CSTR::	BLOCK	1		;CURRENT STR
CPPN::	BLOCK	1		;PPN
CNAM::	BLOCK	1		;FILE
CEXT::	BLOCK	1		;EXT
CBLOCK::BLOCK	1		;LOGICAL BLOCK ON STR
CCTIME::BLOCK	1		;CREATION TIME
CCDATE::BLOCK	1		;CREATION DATE
CADATE::BLOCK	1		;ACCESS DATE
CBSIZE::BLOCK	1		;BLOCK SIZE

CMDLST::BLOCK	2		;<IOWD FRSLIM,EXLFIL>
LSTSTR::BLOCK	1		;LAST STR
LSTPPN::BLOCK	1		;LAST PPN
DELCHR::BLOCK	1		;DELIMITER CHARACTER
LSTNBR::BLOCK	1		;RELATIVE TAPE
SNTAPE::BLOCK	1		;RELATIVE TAPE WITHIN SAVE SET
SAVACS::BLOCK	10		;PLACE TO SAVE REGISTERS
SVCODE::BLOCK	1		;SEED WORD
REELNM::BLOCK	1		;SIXBIT NAME OF REEL
DSTDAY::BLOCK	1		;DESTRUCTION DATE
THSRDB::BLOCK	1		;CURRENT RELATIVE DATA BLOCK
LASTCH::BLOCK	1		;LAST CH BEFORE CURRENT
AOSPEC::BLOCK	1		;ADDRESS OF SPECS
NTSPEC::BLOCK	1		;NUMBER OF SPECS
NOSPEC::BLOCK	1		;NUMBER OF SPECS TO LEFT OF EQUALS
TOTFIL::BLOCK	1		;FOR MLIST
TOTBLK::BLOCK	1		; ..
UPHYN::	BLOCK	1		;PHYSICAL DEVICE NAME
UNAME::	BLOCK	1		;SAVE SET NAME
UTRKS::	BLOCK	1		;TRACKS ON TAPE
RELBLK::BLOCK	1		;RELATIVE DATA BLOCK OF FILE
BKSCLS::BLOCK	1		;BLOCKS PER CLUSTER
SRTWRD::BLOCK	1		;LH=MFD SORT CODE/RH = UFD SORT CODE
INISTR::BLOCK	1		;INITIAL STR
INIPPN::BLOCK	1		;INITIAL PPN
DCHBLK::BLOCK	MAXDCH+1	;FOR DSKCHR UUO
REQNAM::BLOCK	1		;REQUEST TYPE
REQSAV::BLOCK	1		;REQUEST FILE NAME
CHRCNT::BLOCK	1		;CHARACTER COUNT
PDL::	BLOCK	PDLSIZ		;PUSHDOWN LIST

EXLPRV::BLOCK	RIBPRV+1	;TO GET RIBPRV
EXLFIL::BLOCK	FRSLIM+1	;EXTENDED LOOKUPS/ENTERS/RENAMES
EXLUFD::BLOCK	FRSLIM+1	; ..

	SFDBEG==.

PH1BLK::BLOCK	MAXLVL+4	;ROOM FOR PATHING
PH2BLK::BLOCK	MAXLVL+4	;ROOM FOR PATHING
ADRLST::BLOCK	MAXLVL+1	;ADDRESS OF RIBS

	SFDEND==.-1

	STOEND==.-1		;END OF STORAGE

	END	FRS