Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/mars.mac
There are no other files named mars.mac in the archive.
TITLE MARS  A Magtape Archive Retrieval System for the DECsystem-10
SUBTTL Introduction to MARS

;***Copyright(C) 1975, 1976, 1977 Mark R. Crispin
;All Rights Reserved

;  MARS is a DECsystem-10 program to handle file storage and
; retrieval via magnetic tape media.
;
;  MARS is a user-oriented rather than a system-oriented magtape
; program.  It is not intended to replace a system tool such
; as FRS, but to supplement their functions, by providing capabilities
; only poorly(or not at all) provided by the system program.
;
;  MARS operates on the myth that a magtape is a directoried device.
; It then goes to make a very effective and efficient simulation of
; that assumption.  Field tests have shown MARS to be considerably
; faster than other programs of its genre on random I/O transfers.

.TEXT */VERSION:10(320)*

SEARCH JOBDAT,MACTEN,UUOSYM	; DEFINE SYSTEMY VALUES
.DIRECTIVE .XTABM		; TENEXY MACROS
SALL				; NO EXPANSIONS

	LOC 0			; FOR "SHOW."

	SHOW. %%JOBDAT		; VERSION OF JOBDAT USED
	SHOW. %%MACTEN		; VERSION OF MACTEN USED
	SHOW. %%UUOSYM		; VERSION OF UUOSYM USED
SUBTTL Table of Contents

;		Table of Contents for MARS.MAC
;
;
;			   Section			      Page
;    1. Introduction to MARS..................................   1
;    2. Table of Contents.....................................   2
;    3. Revision History......................................   3
;    4. Format of a MARS tape.................................   4
;    5. Assembly Parameters...................................   5
;    6. Definitions...........................................   6
;    7. Start of Program......................................   8
;    8. UUO Handler...........................................  10
;    9. Command Scanner
;         9.1   Verb mode command scanner.....................  11
;         9.2   Subroutines...................................  12
;         9.3   Pure Data.....................................  18
;   10. COPY Switch
;        10.1   Entry Point...................................  20
;        10.2   Index Subroutines.............................  24
;        10.3   Position Tape.................................  26
;        10.4   Wildcard Magtape I/O..........................  27
;        10.5   MTA to MTA COPYing............................  33
;   11. DELETE Switch.........................................  35
;   12. SAVE and LOAD Switches................................  36
;   13. Positioning Switches..................................  38
;   14. ZERO Switch...........................................  40
;   15. IDENTIFY Switch.......................................  41
;   16. LIST Switch...........................................  42
;   17. YANK Switch...........................................  48
;   18. RUN Switch and Friendly Natives.......................  50
;   19. HELP Switches.........................................  51
;   20. WHAT Switch...........................................  52
;   21. I/O Subroutines and Friends...........................  54
;   22. Processor Type Fetcher................................  62
;   23. APR and Error Trap Routines...........................  63
;   24. ! Mode Command Scanner and Friends....................  64
;   25. Literals and Low Segment..............................  65
SUBTTL Revision History

; %10(255)
;
;[255]	16-JUN-75	/MC - INSTITUTE A REVISION HISTORY, MAKE
;				SOURCE SOMEWHAT MORE STRUCTURED
;[256]	16-JUN-75	/MC - RENAME TO MARS FROM BACKUP TO AVOID
;				CONFUSION WITH DEC'S BACKUP
;[257]	16-JUN-75	/MC - ADD /OKNONE
;[260]	16-JUN-75	/MC - MAKE TMPCOR CODE USE /OKNONE
;[261]	17-JUN-75	/MC - ADD /FORGET
;[262]	17-JUN-75	/MC - SPIFF UP SOURCE MORE
;[263]	17-JUN-75	/MC - ADD PROCESSOR IDENTIFICATION
;[264]	25-JUN-75	/MC - SEARCH JOBDAT INSTEAD OF LEAVING EXTERNAL
;[265]	25-JUN-75	/MC - SPIFF UP /DELETE OUTPUT
;[266]	25-JUN-75	/MC - EXTEND TMPCOR CAPACITIES
;[267]	25-JUN-75	/MC - MAKE BROCKETS EQUIVILANT TO BRACKETS FOR 2741
;[270]	25-JUN-75	/MC - PRESERVE CREATION MODE ON RESTORES
;[271]	25-JUN-75	/MC - ADD /PROTECTION:XXX
;[272]	30-JUN-75	/MC - INTERFACE TO JOBDAT BETTER
;[273]	30-JUN-75	/MC - IMPROVE [265]
;[274]	30-JUN-75	/MC - ADD $ ERRORS, CHANGE %MRSEOT & %MRSIMP
;[275]	30-JUN-75	/MC - ADD !ABORT
;[276]	 1-JUL-75	/MC - ADD ER$FUL CODE, FIX [274]
;[277]	 2-JUL-75	/MC - ADD APR AND ERROR TRAPPING
;[300]	 7-AUG-75	/MC - FIX I/O ABORTING TRANSFER
;[301]	12-AUG-75	/MC - PRETTY UP LISTING USING NEW MACTEN
;[302]	13-SEP-75	/MC - FIX UP TYPING OF WILDS
;[303]	13-SEP-75	/MC - FIX UP EOT AND IMP HANDLING
;[304]	20-SEP-75	/MC - MAKE EOT REWIND TAPE
;[305]	20-SEP-75	/MC - PRETTY UP DNR HANDLING
;[306]	27-SEP-75	/MC - DO SOMETHING(!) ABOUT UFD'S!
;[307]	 9-DEC-75	/MC - CLEAN UP CODE SOME
;[310]	 9-DEC-75	/MC - MAKE /LIST MTA0:FOO ILLEGAL (!)
;[311]	 1-FEB-76	/MC - FIX 6.02 LOSSAGE ON ENTER ERROR 20(.RBPOS)
;[312]	 1-FEB-76	/MC - USE MIT ALGORITHM FOR COMMAND SCANNER
;[313]	25-APR-76	/MC - FIX YET MORE 6.02 LOSSAGE(I HOPE!)
;[314]	28-APR-76	/MC - FIX LAST 6.02 LOSSAGE(?)
;[315]	17-JAN-77	/MC - FIX BUG WITH RUNNING OUT OF STRS
;[316]	27-JAN-77	/MC - REMOVE LOSING ^C INTERCEPT
;[317]	27-JAN-77	/MC - USE MTCHR. INSTEAD OF CONI SINCE
;				BAGBITING 6.02 FLUSHED DEVSTS
;[320]	27-JAN-77	/MC - MORE 6.02 CONVERSION
SUBTTL Format of a MARS Tape

COMMENT \

		*** MTA RECORD FORMATS ***

	THE MTA IS ORGANIZED IN THE FOLLOWING MANNER:

----- ----- ----- ----- ----- -----            -----
I   I I   I I   I I   I I   I I   I .......... I   I
----- ----- ----- ----- ----- -----            -----

 (A)   (A)   (A)   (A)   (A)   (A)              (B)

(A)	INDIVIDUAL FILES.

(B)	INDEX RECORD.

	THE INDIVIDUAL FILES ARE EACH DIVIDED INTO 2440(BY DEFAULT)
WORD LONG RECORDS.  THE RECORDS ARE IN THE FORMAT:

WORD		ITEM
----		----

0-34		FILE RIB FROM EXTENDED LOOKUP
35		VERSION OF MARS SAVED UNDER
36		NUMBER OF WORDS IN THIS RECORD
37		DATE SAVED ON TAPE
40-2437		FILE DATA

	THE INDEX RECORD IS SIMILARLY DIVIDED INTO 2440-WORD
RECORDS.  THE INDEX IS IN THE FORMAT:

WORD		ITEM
----		----

0		TAPE ID IN SIXBIT
1		ZERO WORD TO IDENTIFY AS INDEX
2		NUMBER OF FILES SAVED ON THE TAPE
3		NUMBER OF BLOCKS USED ON TAPE
4		DATE LABELLED
5		TIME LABELLED IN MS
6		LABELLING MARS VERSION
7		LABELLING MONITOR VERSION
10-2437		INDEXING DATA:
	A	FILE NAME
	B	LH-EXTENSION, RH-DATE SAVED ON MTA

0-2437		IN SUCCEEDING RECORDS, ENTIRELY INDEXING DATA

\
SUBTTL Assembly Parameters

DEBUG==0		; DO NOT INCLUDE /DDT
PDLLEN==^D50		; PDL LENGTH
MAXSPC==^D50		; MAXIMUM # OF SPECS
MAXSTR==^D50		; MAXIMUM # OF STRS
PURE==1			; TWO-SEGMENT VERSION
N==^D10			; NUMBER OF BLOCKS PER RECORD
M==40			; NUMBER OF WORDS PER RECORD HEADER
MFDBF==3		; NUMBER OF BLOCKS IN MFD BUFFER
UFDBF==2		; NUMBER OF BLOCKS IN UFD BUFFER

IFN	DEBUG,<PURE==0	; DEBUGGING VERSIONS ARE IMPURE
.HWFRMT			; LIST IN USEFUL FORMAT
IF2	<PRINTX	Bug hunt is on>>

; CHECK ASSEMBLY PARAMETERS

IFL	M-40,N==0
IFL	PDLLEN-^D20,N==0
IFL	MAXSPC-2,N==0
IFLE	MAXSTR,N==0
IFLE	MFDBF,N==0
IFLE	UFDBF,N==0
IFLE	N,<PASS2
	PRINTX ?Invalid assembly parameter(s)
	XPUNGE
	END>




; REQUIRED FOR PROPER OPERATION OF MARS:

; HARDWARE:
;
; PDP-10 (KA, KI, OR KL) OR PDP-6 PROCESSOR WITH BYTE INSTRUCTIONS
; AT LEAST ONE MAGTAPE DRIVE
; AT LEAST ONE DISK STRUCTURE
; ONE TELETYPE CONSOLE
;
; SOFTWARE:
;
; TOPS-10, TENEX(WITH TOPS-10 COMPATABILITY PACKAGE), OR ITS(WITH TOPS-10
; COMPATABILITY PACKAGE) MONITOR.  THIS PROGRAM HAS BEEN TESTED ON A
; KI-10 PROCESSOR RUNNING TOPS-10 6.02.
;
; MACRO-10 ASSEMBLER WITH THE FOLLOWING UNIVERSALS ON DSK:, SYS:, OR UNV:
;	JOBDAT		MACTEN		UUOSYM
;
; (NOTE: FOR PDP-6 OR PDP-10 WITHOUT TWO-REGISTER CAPABILITY, THE
;	 "PURE" ASSEMBLY SWITCH SHOULD BE SET TO ZERO.)
SUBTTL Definitions

; AC DEF'S

%==0		; FLAGS
T0==1		; TEMP AC'S
T1==2		; ''
T2==3		; ''
P0==4		; SEMI-PERM. AC
F==5		; PROTOTYPE FILENAME
E==6		; PROTOTYPE EXTENSION
M1==7		; MASK #1
M2==10		; MASK #2
B==11		; BREAK CH
W==12		; WORD
BP==13		; BYTE POINTER
K==14		; KLOBBERABLE AC
I==15		; MISC. INDEX
D==16		; COPY OF DEVICE NAME
P==17		; PDP

; I/O CHANNELS

DSK==1		; DISK CHANNEL
MTA==2		; MTA CHANNEL
UFD==3		; UFD CHANNEL
MTC==4		; MTA COPY CHANNEL
LST==5		; LIST CHANNEL
MFD==6		; MFD CHANNEL

PDLLN2==10*<MAXSPC-1>		; LENGTH OF THE OTHER PDL
BKSZ==M+<N*200>			; SIZE OF RECORDS ON TAPE
DBS==203			; DISK BUFFER SIZE ON TOPS-10 %506B
$RBBKV==.RBTIM+1		; MTA RIB MARS VERSION
$RBWPR==$RBBKV+1		; # OF WORDS IN THIS RECORD
$RBDAT==$RBWPR+1		; DATE SAVED ON TAPE

; OPDEF'S

OPDEF	ERTYPE	[1K,,0]		; ERROR TYPING UUO

	DEFINE	SKP<JRST .+2>	;[262] IT'S MY PROGRAM...

	LOC	.JB41
IFN	PURE<PUSHJ P,UUOSER>	;[262] MUST BE A PDP-10
IFE	PURE<JSR UUOSER>	;[262] MIGHT BE A PDP-6

	LOC	.JBREN
	RENADR

IFN	PURE<TWOSEGMENTS
	RELOC	400K>
IFE	PURE	<RELOC>
; FLAGS

; LH - SW$ -- SWITCH BITS

SW$EXT==1B0		; EXIT WHEN DONE
SW$IDN==1B1		; TO CLEAR TAPE ID
SW$LSF==1B2		; BE VERY GABBY
SW$UNL==1B3		; UNLOAD INSTEAD
SW$FST==1B4		; WANT A FAST LISTING
SW$DDT==1B5		; WANT DDT
SW$KIL==1B6		; DELETE INPUT FILE IF MONITOR SAYS OKAY
SW$NVR==1B7		; NEVER SUPERCEDE
SW$ALL==1B8		; LIST EVEN DELETED FILES
SW$OWN==1B9		; GIVE TO OWNER, NOT ME
SW$SIL==1B10		; SILENCE
SW$BUG==1B11		;[244] TYPE .BUG FILE
SW$OKN==1B12		;[257] DON'T GIVE %MRSLKP
SW$PRO==1B13		;[271] PROTECTION CHANGE DESIRED

; RH - SF$ -- STATUS FLAGS

SF$FAF==1B22		;[241] FOUND A FILE
SF$TAE==1B23		; TYPED A !
SF$DOD==1B24		; INDEX ON DISK, SAVE IT
SF$DGD==1B25		; DON'T GET A DIRECTORY LOVE
SF$DDR==1B26		; DOING A DIRECTORY
SF$DNA==1B27		; DO NOT ABORT
SF$NOK==1B28		; NOT OKAY IN ! MODE
SF$EXP==1B29		; THE ! PROMPT FLAG
SF$CMF==1B30		; THE COMMA FLAG
SF$ALL==1B31		; WILDCARD I/O
SF$IOE==1B32		; SAW AN I/O ERROR
SF$DMO==1B33		; DID SOME MTA OUTPUT
SF$AWI==1B34		; WILD INPUT ALLOWED
SF$DIC==1B35		; DIRECTORY IN CORE

; ERTYPE CODES

ER$WRN==1		; WARNING MESSAGE "%"
ER$INT==2		; INTERVENTION REQUIRED "$"
ER$FUL==4		; TYPE FULL TEXT GEGARDLESS OF .GTWCH
ER$RTN==10		; RETURN TO USER
SUBTTL Start of Program

MARS:	PORTAL	.+2			; FOR KI/KL OPERATION
	PORTAL	.+1			; FOR KI/KL CCL
	MOVEM	.SGPPN,HLPPPN		; REMEMBER WHERE WE CAME FROM
	MOVEI	%,RENADR		;[237] TO RESET .JBSA
	HRRM	%,.JBSA			;[237] SO HLPPPN ISN'T CLOBBERED
KORE:	RESET				; RESET THE WORLD
	MOVEI	P,PDL-1			;[253] TEMPORARY(!) PDP
	MOVE	%,.JBFF			; IN CASE WE GREW
	CORE	%,			; ENSMALLIFY
	 JFCL				; OH WELL
	MOVX	%,.RBTIM		;[253] FOR "NEXT" LOOKUP
	MOVEM	%,SPEC			;[253] SAVE IN SPEC
	MOVX	%,.IODMP		; LOAD MTA OPEN WORD
	MOVEM	%,MTASTA		; SAVE SO IT CAN BE CHANGED
	PUSHJ	P,GETPRC		;[263] GET PROCESSOR TYPE
	PUSHJ	P,NAMKLG		; SET NAME RIGHT

; HERE TO GET THINGS FROM THE MONITOR

	MOVX	%,%LDMFD		;[235] LOAD GETTAB ARG FOR MFD PPN
	GETTAB	%,			;[235] ACCESS
	 MOVX	%,<1,,1>		;[235] DEFAULT
	MOVEM	%,MFDPPN		;[235] SAVE
	SETZ	%,			; FOR SYSSTR
	MOVSI	W,-MAXSTR		; LOAD STR TABLE AOBJN POINTER
GETSTR:	SYSSTR	%,			; GET A STR NAME
	 HALT	MARS			; ***SYSSTR FAILED***
	JUMPE	%,GETLSS		; GOT ALL STRS, NEXT INITIATION
	MOVEM	%,STRTAB(W)		; SAVE IN STR TABLE
	AOBJN	W,GETSTR		; GET NEXT STR
	HALT	MARS			; ***STR TABLE TOO SMALL***
GETLSS:	MOVE	W,[.TCRDF,,TMPSPC]	;[253] LOAD TEMPCORE BLOCK
	TMPCOR	W,			;[253] FETCH "LAST" SPECS
	 JRST	NXTINI			;[253] GUESS THERE WERN'T ANY
	SKIPN	W,TAPEID		;[253] CHECK FOR A TAPEID
	 JRST	NXTINI			;[253] NONE, DON'T GET INDEX
	MOVEM	W,SPEC+.RBNAM		;[253] FOOL /LOAD
	TXO	%,SW$OKN		;[260] NO ERROR IF NONE
	PUSHJ	P,LOAD			;[253] FAKE A /LOAD TO GET INDEX

; HERE WHEN A COMMAND IS DONE, OR ON A REENTRY

RENADR:	PORTAL	.+1			; FOR REENTER
	ANDI	%,SF$DIC!SF$EXP!SF$DOD	; CLEAR FLAGS
	TXZE	%,SF$EXP		; TEST AND CLEAR ! FLAG
	 OUTSTR	CRLF			; CRLF FIRST
	MOVE	P,[.TCRWF,,TMPSPC]	;[253] LOAD TEMCORE BLOCK
	TMPCOR	P,			;[253] SAVE "LAST" SPECS
	 JFCL				;[253] TOO BAD IF COULDN'T WRITE
NXTINI:	MOVEI	P,[ASCIZ@MARS is idle
@]
	MOVEM	P,MRSSTA		; SAVE STATUS MESSAGE
	STORE	P,CORBEG,COREND,0	; ZAK!
	MOVX	P,.RBTIM		; WE WANT THAT MUCH
	MOVEM	P,SPEC			; IN THE SPEC
	MOVE	P,[IOWD PDLLN2,OTHPDL]	; LOAD OTHER PDP
	MOVEM	P,OTHPDP		; SAVE IT
	MOVE	P,[IOWD PDLLEN,PDL]	; LOAD PDP
	SKPINL				; SUPPRESS ^O
	 JFCL				; WHO CARES?
	OUTCHR	["/"]			; BEG FOR INPUT
	PUSHJ	P,SCAN			; SCAN COMMAND STRING
	PUSHJ	P,SETTRP		;[277] SET UP TRAPS
	TXNN	%,SF$EXP		; TEST FOR ! FLAG
	 JRST	.+3			;[241] NO ! LOVE
	OUTCHR	["!"]			; FIRST !
	TXO	%,SF$TAE		;[236] FOR ERROR MESSAGES
IFN DEBUG<TXNN	%,SW$DDT		; DDT?
	 JRST	COMCLL			; NO
	SKIPN	T0,.JBDDT		; ANY DDT?
	 ERTYPE	['DDT',,[ASCIZ/No DDT/]]; NO DDT
	PUSHJ	P,(T0)			; YES, DDT>

; HERE TO CALL COMMAND PROCESSOR

COMCLL:	SKIPE	T0,DSPLOC		; ANYWHERE TO GO?
	 PUSHJ	P,(T0)			; YES, GO THERE
	  JFCL				; IN CASE OF SKIP
	SOSLE	SPCCNT			; ANY MORE SPECS?
	 JRST	MULSPC			; YES: MULTIPLE SPECS
ERREN:	TXZE	%,SF$DMO		; THE DID MTA OUTPUT FLAG?
	 PUSHJ	P,PUTDIR		; WRITE DIRECTORY
	RESET				; RESET THE WORLD
	TXZE	%,SW$EXT		; SHALL I LEAVE?
	 MONRT.				; YES
	JRST	RENADR			; BEG FOR MORE

; HERE TO RESTORE SPECS RIGHT

MULSPC:	EXCH	P,OTHPDP		; GET THE OTHER PDP
	POP	P,DEVMSK		; RESTORE ALL THINGS
	POP	P,M2			; ''
	POP	P,M1			; ''
	POP	P,PPNMSK		; ''
	POP	P,SPEC+.RBPPN		; ''
	POP	P,SPEC+.RBEXT		; ''
	POP	P,SPEC+.RBNAM		; ''
	POP	P,INDEV			; ''
	EXCH	P,OTHPDP		; GET MASTER PDP BACK
	JRST	COMCLL			; GO AND CALL COMMAND AGAIN
SUBTTL UUO Handler

UUOSER:	PORTAL	.+1			;[236] KI-10 ENTRY HAPPY
	TXNN	%,SF$TAE		; SEE IF ! TYPED
	 JRST	.+3			; NO, NEVER CRLF
	TXNN	%,SF$DNA		; YES, SEE IF SCANNER ERROR
	 OUTSTR	CRLF			; NO, THEN CRLF
	MOVX	T2,"?"			; ASSUME FATAL
	MOVE	T0,.JBUUO		; UNLESS TOLD OTHERWISE
	TXNE	T0,<<ER$WRN>B12>	; HERE
	 MOVX	T2,"%"			; NON-FATAL
	TXNE	T0,<<ER$INT>B12>	; INTERVENTION REQ?
	 MOVX	T2,"$"			; YES
	OUTCHR	T2			; TYPE INDICATION
	MOVE	T2,(T0)			; LOAD MESSAGE WORD
	HRROI	T1,.GTWCH		; SET UP FOR GETTAB
	GETTAB	T1,			; ACCESS
	 SETZ	T1,			; LOSE
	TXNN	T0,<<ER$FUL>B12>	;[303] FULL TEXT?
	 TXNN	T1,JW.WPR!JW.WFL	; SEE IF ANY
	  TXO	T1,JW.WPR!JW.WFL	; DEFAULT
	TXNE	T1,JW.WPR		; PREFIX?
	 PUSHJ	P,PREFIX		; YUP
	OUTCHR	[" "]			; INTERMEDIATE
	TXNE	T1,JW.WFL		; FIRST?
	 OUTSTR	(T2)			; YES
	TXNE	T0,<<ER$RTN>B12>	; THE NO CRLF FLAG ON?
IFN PURE,<POPJ	P,			;[262] RETURN THE PDP-10 WAY>
IFE PURE,<JRSTF	@UUOSER			;[262] RETURN THE PDP-6 WAY>
;	JRST	ERRTN			;[255] RETURN FROM ERROR

; HERE TO RETURN FROM ERRORS

ERRTN:	OUTSTR	CRLF			; CR/LF
	CLRBFI				; CANCEL TYPEAHEAD
	TXNE	%,SF$DNA		; DO NOT ABORT?
	 JRST	NABORT			; ABORTION ILLEGAL HERE MARYBETH
	TXZ	%,SF$EXP!SW$EXT		; SINCE WE DIED, NO CRLF
	JRST	ERREN			;[236] ERROR REENTRY

; HERE TO COMPUTE AND TYPE PREFIX

PREFIX:	PUSH	P,I			; SAVE I
	PUSH	P,W			; SAVE W FOR LATER
	PUSH	P,B			; AND THE BREAK
	PUSH	P,BP			; AND THE BYTE POINTER
	MOVSI	W,'MRS'			; OUR PRECIOUS NAME
	HLR	W,T2			; LOAD CODE
	PUSHJ	P,SIXLST		; TYPE IT
	POP	P,BP			; REGET BP
	POP	P,B			; REGET B
	POP	P,W			; REGET W
	POP	P,I			; REGAIN I
	POPJ	P,			; RETURN
SUBTTL Command Scanner -- Verb Mode Command Scanner

SCAN:	PUSHJ	P,GET1WD		; GET A WORD
	JUMPG	W,BADCOM		; BAD IF NOT ALPHA
	JUMPE	W,NOARGG		; FLUSH IF NO COMMAND
	MOVE	T0,W			;[312] COPY VERB INTO ANOTHER AC
	OR	T0,MSKTAB(K)		;[312] PADDED WITH _'S
	MOVSI	I,-NUMCOM		; LOAD COMMAND

; HERE TO FIND VERB IN TABLE USING MIT ALGORITHM

	CAMLE	W,COMTAB(I)		;[312] POSSIBLE MATCH?
	 AOBJN	I,.-1			;[312] NOPE, TRY NEXT
	CAMN	W,COMTAB(I)		;[312] EXACT MATCH?
	 JRST	FNDACM			;[312] YES, ALLOW DESPITE UNIQUENESS
	CAMGE	T0,COMTAB(I)		;[312] IN RANGE?
	 JRST	BADCOM			;[312] ** BAD COMMAND **
	CAML	T0,COMTAB+1(I)		;[312] UNIQUE?
	 JRST	NOTUNI			;[312] ** NOT UNIQUE **

; HERE TO SET UP BLOCK FOR EXECUTION AFTER FINDING COMMAND

FNDACM:	SKIPN	T0,COMDSP(I)		; LOAD COMMAND DISPOSITION
	 JRST	SETFLG			; NO DISPOSITION, SET FLAGS
	CAMN	T0,DSPLOC		; SAME?
	 JRST	SETFLG			; YES: DON'T BOTHER
	SKIPE	DSPLOC			; CHECK DISPATCHING LOCATION
	 JRST	VRBCON			; VERB CONFLICT
	MOVEM	T0,DSPLOC		; SAVE IT
SETFLG:	OR	%,FLGTAB(I)		; TURN ME ON
	MOVE	T0,FLGTAB(I)		; FOR TO CHECK
	TXNE	T0,SW$IDN		; CHECK
	 SETZM	TAPEID			; IT GETS CHANGED, CLEAR IT
	CAIE	B,":"			; SEE IF AN ARG GIVEN
	 CAIN	B," "			; ''
	  SKP				; YES: CHECK ARG
	   JRST	NOARGG			; NO: NO ARG GIVEN
	SKIPN	T0,ARGTAB(I)		; SEE IF AN ARG ALLOWED
	 JRST	NOARG			; NO ARG ALLOWED
	PUSHJ	P,(T0)			; CALL THE RIGHT ARG GETTER

; HERE TO PROCESS ANOTHER VERB OR RETURN

NOARGG:	CAIN	B,"/"			; SEE IF ANOTHER SWITCH
	 JRST	SCAN			; YES: SCAN IT
	PUSHJ	P,TSTBRK		; CHECK IF AT END OF LINE
	 POPJ	P,			; RETURN
	JRST	SYNERR			;[236] EXTRA JUNK IN COMMAND
SUBTTL Command Scanner -- Subroutines

FILSPC:	PUSHJ	P,GET1WD		; GET WORD
	CAIE	B,":"			; SEE IF A SPEC
	 JRST	GOTFIL			; NO, GOT A FILE
	MOVEM	W,INDEV			; SAVE AS DEVICE
	MOVEM	M2,DEVMSK		; SAVE DEVICE MASK
	PUSHJ	P,GET1WD		; GET A WORD
GOTFIL:	MOVEM	W,SPEC+.RBNAM		; SAVE FILE NAME
	MOVE	M1,M2			; COPY MASK
	SETZ	M2,			;[307] IN CASE NO EXT SPEC
	CAIE	B,"."			; EXT SPEC?
	 JRST	SEEPPN			; NO: CHECK IF PPN
	PUSHJ	P,GET1WD		; GOBBLE EXTENSION
	HLLM	W,SPEC+.RBEXT		; SAVE EXTENSION
	TRZ	M2,-1			; ZILCH MASK
SEEPPN:	CAIE	B,"["			; PPN SPEC?
	 CAIN	B,"<"			;[266] BROCKET?
	  SKP				;[266] A PPN SPEC
	   JRST	FLSRTN			; NO: RETURN
	INCHWL	B			; GET VERY FIRST
	CAIN	B,"-"			;[247] MAYBE HE WANTS DEFAULT?
	 JRST	DEFPPN			;[247] GO TO IT GIRL!!
	CAIN	B,"@"			; INSURE NOT SIXBIT
	 JRST	SIXPPN			;[223] SIXBIT PPN
PROJC:	PUSHJ	P,GETANM+1		; GET PROJ
	CAILE	W,377777		; SEE IF ONLY 1 HALF
BADPPN:	 ERTYPE	['PPN',,[ASCIZ/Bad PPN/]]
	MOVSM	W,SPEC+.RBPPN		; SAVE PROJ
	MOVSM	K,PPNMSK		; SAVE PROJ MASK
	CAIE	B,","			; MUST BE A ,
	 JRST	SYNERR			; OH DEAR
	PUSHJ	P,GETANM		; GET PROG
	CAILE	W,377777		; OK?
	 JRST	BADPPN			; NO
	HRRM	W,SPEC+.RBPPN		; SAVE PROG
	HRRM	K,PPNMSK		; SAVE PROG MASK
PPNDON:	TXZN	%,SF$AWI		; WILDS?
	 SKIPN	PPNMSK			; NO: SEE IF WILD
	  SKP				; NO
	   JRST	BADPPN			; BALK
	CAIE	B,">"			;[266] CLOSE BROCKET
	 CAIN	B,"]"			; CLOSE BRACKET
	  PUSHJ	P,GRNGCH		; GOBBLE A CH
	   JFCL				; IN CASE OF SKIP
FLSRTN:	TXZ	%,SF$AWI		;[237] IN CASE OF NO PPN
	POPJ	P,			; NORMAL RETURN: GOT SPEC
SIXPPN:	PUSH	P,M2			;[237] SAVE MASK
	PUSHJ	P,GET1WD		;[223] GET SIXBIT PPN
	MOVEM	M2,PPNMSK		;[237] SAVE PPN MASK
	POP	P,M2			;[237] REGAIN EXT MASK
	MOVEM	W,SPEC+.RBPPN		; SAVE
	JRST	PPNDON			; CONTINUE AS IF OCTAL
; HERE TO GET 1 SIXBIT WORD

GET1WD:	SETZ	W,			; SUBROUTINE TO GET 1 WORD
	MOVX	BP,<POINT 6,W>		; IN SIXBIT
	TXNN	%,SF$AWI		; CHECK ABOUT WILDS
	 JRST	.+3			; NOT ALLOWED MARYBETH
	SETZ	M2,			; CLOBBER MASK
	MOVX	T0,<POINT 6,M2>		; LOAD MASK POINTER MARYBETH
	MOVX	K,6			; SET COUNTER
SIXEAT:	PUSHJ	P,GRNGCH		; GET A CHARACTER(NON-BREAK)
	 POPJ	P,			; DONE WITH THIS WORD
	SUBI	B," "			; CONVERT TO SIXBIT
	IDPB	B,BP			; SAVE IT IN THE WORD
	TXNE	%,SF$AWI		; ARE WILDS ALLOWED?
	 IBP	T0			; INCREMENT MASK THING
	CAIN	B,77			; SEE IF WILD
	 DPB	B,T0			; YEAH, SAVE IT
	SOJG	K,SIXEAT		; GET SOME MORE
	PUSHJ	P,GRNGCH		; GRUNGE A CHARACTER
	 POPJ	P,			; TRUST SCANNER TO PICK IT UP
	JRST	.-2			; TRY AGAIN LITTLE GIRL

; HERE TO GRUNGH AN INPUT CHARACTER

GRNGCH:	INCHWL	B			; GOBBLE A CHARACTER
	CAIN	B,.CHCNZ		; SEE IF ^Z
	 MONRT.				; HELLO TOPS-10
GRNGC1:	JUMPE	B,GRNGCH		; IN CASE OF NUL
	CAIN	B,.CHCRT		; TEST FOR THINGS
	 JRST	GRNGCH			; TO BE IGNORED
	CAIG	B," "			; SEE IF ^ CHAR OR SPACE
	 POPJ	P,			; YES, DON'T BOTHER CHECKING
	CAIL	B,173			; TEST FOR VERY HIGH
	 POPJ	P,			; YES, DON'T BOTHER ANY MORE
	CAIL	B,"A"+" "		; TEST FOR
	 CAILE	B,"Z"+" "		; LOWER CASE
	  SKP				; NOT
	   TRZ	B," "			;[262] IS, UPPERCASEIFY
	TXNN	%,SF$AWI		; CHECK ALLOW WILD INPUT
	 PJRST	SIXBRK			; NOT WILD
	CAIN	B,"*"			; SEE IF *
	 JRST	STARWD			; STAR WILD
	CAIE	B,"?"			; CHECK WILD
	 PJRST	SIXBRK			; NOT QUESTION MARK WILD
	MOVX	B,137			; FOR UNSIXBIT CONVERSION
	PJRST	CPOPJ1			; RETURN DECENTLY
STARWD:	OR	M2,MSKTAB(K)		; TURN ON REMAINING MASK BITS
	OR	W,MSKTAB(K)		; TURN ON REMAINING WORD BITS
	PUSHJ	P,GRNGCH		; GOBBLE A CH
	 POPJ	P,			; RETURN(AND RETURN)
	JRST	SYNERR			; SYNTAX ERROR
; HERE TO TEST FOR BREAK CHARACTERS

TSTBRK:	PUSHJ	P,GRNGC1		; GRUNGH INPUT
	 SKP				; COULD BE A BREAK...
	  PJRST	CPOPJ1			; COULDN'T
	MOVEI	K,NUMBRK		; LOAD NUMBER OF BREAKS
NBTEST:	CAMN	B,BRKTAB(K)		; SEE IF FOUND A MATCH
	 POPJ	P,			; NON-SKIP RETURN
	SOJGE	K,NBTEST		; TRY AGAIN
	PJRST	CPOPJ1			; NOT A BREAK CHARACTER

; HERE TO TEST FOR A SIXBIT BREAK CHARACTER

SIXBRK:	MOVEI	D,NUM6BK		; LOAD COUNTER
	CAMN	B,SIXBRT(D)		; SEE IF MATCH
	 POPJ	P,			; YES: A BREAK
	SOJGE	D,SIXBRK+1		; NO: TRY NEXT
	PJRST	CPOPJ1			; NOT A BREAK

; HERE TO TYPE A SIXBIT WORD

SIXLST:	MOVX	BP,<POINT 6,W>		; GET BYTE POINTER
	MOVX	I,6			; SET INDEX
	ILDB	B,BP			; GET CHARACTER
	JUMPE	B,CPOPJ			; RETURN IF ZERO
	ADDI	B," "			; CONVERT TO ASCII
	CAIN	B,"_"			;[302] WILD ?
	 MOVX	B,"?"			;[302] GET RIGHT THING
	OUTCHR	B			; PRINT IT
	SOJG	I,.-6			; LOOP FOR ANOTHER
	POPJ	P,			; RETURN

; HERE TO REPORT SCANNER ERRORS

SYNERR:	ERTYPE	ER$RTN,['SYN',,[ASCIZ/Syntax error: /]]
	OUTCHR	B			; TYPE FIRST BAD
	INCHRS	B			; GOBBLE A CH
	 JRST	ERRTN			; RETURN
	PUSHJ	P,TSTBRK		; TEST FOR BREAK
	 JRST	ERRTN			; RETURN
	JRST	SYNERR+1		; NEXT
NOARG:	ERTYPE	ER$RTN,['ARG',,[ASCIZ/Argument error: /]]
	MOVE	W,COMTAB(I)		; LOAD THE BEAST
	JRST	WHTBLK			; SKIP NEXT
VRBCON:	ERTYPE	ER$RTN,['SWC',,[ASCIZ/Switch conflict: /]]
	JRST	WHTBLK
NOTUNI:	ERTYPE	ER$RTN,['UNI',,[ASCIZ/Not unique: /]]
	JRST	WHTBLK
BADCOM:	ERTYPE	ER$RTN,['BSW',,[ASCIZ/Bad switch: /]]
WHTBLK:	PUSHJ	P,SIXLST		; TYPE THE OFFENDING SWITCH
	JRST	ERRTN			; RETURN AS BEFORE
; HERE TO GET TAPE ID SPEC

GTTPID:	PUSHJ	P,GET1WD		; GET A DEVICE SPEC
	MOVEM	W,OUTDEV		; SAVE AS OUTPUT DEVICE
	CAIE	B,":"			; IS IT WHAT I WANT MARYBETH
	 CAIN	B," "			; YOU CAN DO THE OTHER THING LOVE
	  PUSHJ	P,GET1WD		; GET A WORD
	MOVEM	W,TAPEID		; SAVE ARGUMENT
	POPJ	P,			; RETURN

; HERE TO GET NUMBER SPECS

GTRSFN:	PUSHJ	P,DEVSPC		; GET A DEVICE SPEC
	SETZ	W,			; CLEAR NUMBER
	CAIN	B,"/"			; SEE IF /
	 JRST	.+4			; YES
	PUSHJ	P,TSTBRK		; BREAK?
	 SKP				; IT'S BROKEN MARYBETH LOVE
	  PUSHJ	P,DECKLG		; KLUDGE INTO DECIMAL INPUT
	MOVEM	W,POSFNO		; SAVE IT
	POPJ	P,			; RETURN

; HERE TO GET DENSITY SPEC

GTDENS:	SETZ	T2,			; CLEAR NUMBER
	PUSHJ	P,GETADN		; GET DENSITY NUMBER
	CAXN	W,^D1600		;[235] 1600 BPI?
	 MOVX	T2,.TFD16		;[262] YES
	CAXN	W,^D800			; 800 BPI?
	 MOVX	T2,.TFD80		;[262] YES
	CAXN	W,^D556			; 556 BPI?
	 MOVX	T2,.TFD55		;[262] YES
	CAXN	W,^D200			; 200 BPI?
	 MOVX	T2,.TFD20		;[262] YES
	JUMPE	T2,NOARG		; BAD ARGUMENT
	MOVE	K,[3,,T0]		; LOAD TAPOP. POINTER
	MOVX	T0,.TFSET+.TFDEN	; HACK DENSITY
	MOVE	T1,PHMTAN		; TAPE DRIVE NAME
	TAPOP.	K,			; NOW DO IT!
	 JFCL				; OH WELL.
	POPJ	P,			; RETURN

; HERE TO GET PARITY SPEC

GTPRTY:	PUSHJ	P,GET1WD		; GET 1 WORD
	SETZ	K,			; CAI(CRIPTIC, AIN'T IT?)
	CAXN	W,'EVEN  '		; EVEN PARITY?
	 MOVX	K,IO.PAR		; YES
	CAXE	W,('ODD')		; ODD PARITY?
	 JUMPE	K,NOARG			; BAD ARGUMENT
	MOVX	W,IO.PAR		;[246] TO CLEAR
	ANDCAM	W,MTASTA		;[246] CLEAR IN STATS
	ORM	K,MTASTA		;[246] TURN ON/OFF PARITY BIT
	POPJ	P,			; RETURN
; HERE TO GET A TAPE POSITION

GTMTPS:	PUSHJ	P,GETADN		; GET A DECIMAL NUMBER
	MOVEM	W,MTAPOS		; SAVE IT
	POPJ	P,			; RETURN

; HERE TO GET TAPE NAME

NAMKLG:	SKIPA	W,['MARS  ']		;[262] LOAD KLUDGE NAME
GTMTNM:	PUSHJ	P,GET1WD		; GET ONE WORD
	CAIN	B,":"			; MUST IGNORE :'S
	 PUSHJ	P,GRNGCH		; GOBBLE NEXT
	  JFCL				; IN CASE OF SKIP
	MOVE	D,W			; COPY IN CASE UNREAL
	DEVNAM	W,			; INSURE PHYSICAL
	 MOVE	W,D			; SORRY MARYBETH
	MOVEM	W,PHMTAN		; SAVE IT
	POPJ	P,			; RETURN

; HERE TO GET A DEVICE SPEC

DEVSPC:	PUSHJ	P,GET1WD		; GET 1 WORD
	CAIE	B," "			; GOBBLE SPACE
	 CAIN	B,":"			; GOBBLE :
	  PUSHJ	P,GRNGCH		; FINE
	   JFCL				; IN CASE OF SKIP
	MOVEM	W,OUTDEV		; SAVE
	POPJ	P,			; RETURN

; HERE TO GET A LISTING SPEC

LSTSPC:	PUSHJ	P,FILSPC		; GET A FILE SPEC
	CAIE	B,"="			; CHECK FOR SPEC
	 CAIN	B,"_"			; SEPARATOR
	  SKP				; WAS ONE
	   JRST	NOESPC			; NO EQUALS SPEC...USE DEFAULT
	PUSHJ	P,DEVSPC		; GET A DEVICE SPEC
	MOVE	W,INDEV			; SWAP THINGS
	EXCH	W,OUTDEV		; AROUND
	MOVEM	W,INDEV			; CAUSE THINGS ARE FUNNY
	POPJ	P,			; LOVE YOU MARYBETH
NOESPC:	SKIPN	SPEC+.RBNAM		; SEE IF FILE SPECIFIED
	 POPJ	P,			; NO: SWAP NOTHING
	SETZ	W,			; CLEAR THING
	EXCH	W,INDEV			; COPY AND CLEAR INPUT
	MOVEM	W,OUTDEV		; SAVE
	POPJ	P,			; BYE

; HERE TO GET RUN OFFSET

SETOFF:	PUSHJ	P,GETADN		; GET A NUMBER
	MOVEM	W,RUNOFF		; SAVE OFFSET
	POPJ	P,			; RETURN
; HERE TO GET A COPY SPEC

COPSPC:	TXNE	%,SF$DNA		; CHECK IF ILLEGAL
	 PJRST	TPOPJ			; YES
	PUSHJ	P,GET1WD		; GET 1 WORD
	MOVEM	W,OUTDEV		; SAVE AS OUTPUT
	CAIN	B,":"			; SEE IF TO GOBBLE
	 PUSHJ	P,GRNGCH		; GOBBLE
	  JFCL				; IN CASE OF SKIP
	CAIE	B,"="			; CHECK FOR THING
	 CAIN	B,"_"			; ALLOW OLD STYLE
	  SKP				; WAS ONE
	   POPJ	P,			; ALL WILD
NXTSPC:	TXO	%,SF$AWI		; ALLOW WILD INPUT
	PUSHJ	P,FILSPC		; GET A FILESPEC
	AOS	SPCCNT			; BUMP SPEC COUNTER
	CAIE	B,","			; MULTIPLE SPECS?
	 POPJ	P,			; RETURN
	TXO	%,SF$CMF		; TURN THE COMMA FLAG ON
	EXCH	P,OTHPDP		; GET THE OTHER PDP
	PUSH	P,INDEV			; SAVE ALL THINGS
	PUSH	P,SPEC+.RBNAM		; ''
	PUSH	P,SPEC+.RBEXT		; ''
	PUSH	P,SPEC+.RBPPN		; ''
	PUSH	P,PPNMSK		; ''
	PUSH	P,M1			; ''
	PUSH	P,M2			; ''
	PUSH	P,DEVMSK		; ''
	SETZM	SPEC+.RBNAM		; FILENAMES NOT STICKY
	SETZM	SPEC+.RBEXT		; NEITHER EXTENSIONS
	EXCH	P,OTHPDP		; GET BACK THE OTHER PDP
	JRST	NXTSPC			; NEXT

; HERE TO SET DEFAULT PPN

DEFPPN:	MOVX	K,<3,,T0>		;[247] LOAD POINTER FOR PATH.
	MOVX	T0,.PTFRD		;[247] READ MY DEFAULT PATH
	PATH.	K,			;[247] ZAK!
	 GETPPN	T2,			;[247] SICK MONITOR, USE GETPPN
	  JFCL				;[247] (JACCT SKIP)
	MOVEM	T2,SPEC+.RBPPN		;[247] USE THIS AS PPN
	SETZM	PPNMSK			;[247] NON-WILD HERE
	INCHWL	B			;[250] FETCH NEXT
	JRST	PPNDON			;[247] "PPN DONE"

; HERE TO GET A DELETE SPEC

DELSPC:	TXNE	%,SF$DNA		;[253] IN CASE HE'S STUPID
	 PJRST	TPOPJ			;[253] FORCE ERROR NOW!
	PJRST	NXTSPC			;[253] GET NEXT SPEC
SUBTTL Command Scanner -- Pure Data

	DEFINE	COMMANDS<
XLIST
X	ABORT,ABORT,0,0				;; ABORT COMMAND
X	ALL,0,SW$ALL,0				;; LIST ALL
X	BACKSPACE,BACKSP,SF$EXP!SF$NOK,GTRSFN	;; BACKSPACE N FILES
X	BACKUP,XBKP,SF$EXP!SF$NOK,0		;; SAVE SYSTEM
X	BUG,INFO,SF$NOK!SW$BUG,0		;; TYPE BUG FILE
X	COPY,COPY,SF$EXP!SF$NOK,COPSPC		;; GENERAL COPY COMMAND
X	CORE,CDROP,SF$NOK,0			;; SHRINK CORE
IFN DEBUG,<X DDT,0,SW$DDT,0>			;; CALL DDT
X	DELETE,DELETE,SF$EXP!SF$NOK!SF$AWI,DELSPC;; DELETE A FILE
X	DENSITY,0,0,GTDENS			;; SET MY DENSITY
X	DIRECTORY,LIST,SF$EXP!SF$NOK,LSTSPC	;; SAME AS /LIST
X	EXIT,0,SW$EXT,0				;; EXIT WHEN DONE
X	FAST,LIST,SW$FST!SF$EXP!SF$NOK,0	;; FAST LISTING INSTEAD
X	FORGET,CDROP,SF$NOK,0			;; SAME AS /CORE
X	FORMAT,ZERO,SW$IDN!SF$NOK,GTTPID	;; SAME AS /ZERO
X	HELP,HELP,0,0				;; GIVE HELP
X	IDENTIFY,LABEL,SW$IDN!SF$EXP!SF$NOK,GTTPID;; CHANGE TAPE ID
X	INFORMATION,INFO,SF$NOK,0		;; GIVE DETAILS
X	INITIALIZE,ZERO,SW$IDN!SF$NOK,GTTPID	;; SAME AS /ZERO
X	KILL,0,SW$KIL,0				;; KILL INPUT FILE
X	LABEL,LABEL,SW$IDN!SF$EXP!SF$NOK,GTTPID	;; SAME AS /IDENTIFY
X	LIST,LIST,SF$EXP!SF$NOK,LSTSPC		;; LIST DIRECTORY
X	LOAD,LOAD,SF$NOK,FILSPC			;; LOAD SPECIFIED FILE
X	MAGTAPE,0,0,GTMTNM			;; SAME AS /NAME
X	NAME,0,0,GTMTNM				;; SET TAPE NAME
X	NEVER,0,SW$NVR,0			;; NEVER SUPERCEDE
X	OKNONE,0,SW$OKN,0			;; NO %MRSLKP
X	OWNER,0,SW$OWN,0			;; YANK TO OWNER
X	PARITY,0,0,GTPRTY			;; SET MY PARITY
X	POSITION,0,0,GTMTPS			;; SET POSITION COUNTER
X	PROTECTION,0,SW$PRO,GTPROT		;; GET PROTECTION
X	RESTORE,XRES,SF$EXP!SF$NOK!SW$OWN!SW$SIL,0;; RESTORE SYSTEM
X	REWIND,REWIND,SF$NOK,DEVSPC		;; REWIND TAPE
X	RUN,RUNPRG,SF$NOK,FILSPC		;; RUN A PROGRAM
X	RUNOFFSET,0,0,SETOFF			;; SET RUN OFFSET
X	SAVE,SAVE,SF$NOK,FILSPC			;; SAVE INDEX
X	SILENCE,0,SW$SIL,0			;; NO TALKING AT ALL
X	SKIP,SKIP,SF$EXP!SF$NOK,GTRSFN		;; SKIP N FILES
X	STATUS,WHAT,0,0				;; SAME AS /WHAT
X	TALKATIVE,0,SW$LSF,0			;; BE GABBY
X	TAPE,0,0,GTMTNM				;; SAME AS /NAME
X	UNIT,0,0,GTMTNM				;; SAME AS /NAME
X	UNLOAD,REWIND,SW$UNL!SF$NOK,DEVSPC	;; UNLOAD TAPE
X	WHAT,WHAT,0,0				;; PRINT STATUS
X	YANK,YANK,SF$EXP!SF$NOK,GTRSFN		;; YANK N FILES
X	ZERO,ZERO,SW$IDN!SF$NOK,GTTPID		;; ZERO TAPE
LIST>
BRKTAB:	EXP	.CHCNC,.CHBEL,.CHLFD,.CHVTB,.CHFFD,.CHCNU,.CHCNZ
	EXP	.CHESC,.CHALT,.CHAL2,.CHDEL
NUMBRK==.-BRKTAB

MSKTAB:	000000,,000000			;[312] TABLE OF MASKS
	000000,,000077
	000000,,007777
	000000,,777777
	000077,,777777
	007777,,777777
	777777,,777777

SIXBRT:	EXP	"*",",",".","/",":","<","=",">","?","@","[","\","]","^","_",140
NUM6BK==.-SIXBRT

	DEFINE	X(A,B,C,D)<EXP	SIXBIT/A/>
COMTAB:	COMMANDS			; TABLE OF COMMANDS
NUMCOM==.-COMTAB
	-1				;[312] TERMINATE TABLE
	DEFINE	X(A,B,C,D)<EXP	B>
COMDSP:	COMMANDS			; TABLE OF DISPATCHING LOCATIONS
	DEFINE	X(A,B,C,D)<EXP	C>
FLGTAB:	COMMANDS			; TABLE OF FLAGS SET
	DEFINE	X(A,B,C,D)<EXP	D>
ARGTAB:	COMMANDS			; TABLE OF ARGUMENT ROUTINES
SUBTTL COPY Switch -- Entry Point

; HERE ON /RESTORE

XRES:	HLLOM	POSFNO			; EFFECTIVELY INFINITY
	PJRST	YANK			; YANK 'EM OFF

; HERE ON /BACKUP

XBKP:	SETOM	DEVMSK			; *:
	SETOB	M1,SPEC+.RBNAM		; *
	HRROS	M2,SPEC+.RBEXT		; .*
	SETOM	PPNMSK			; [*,*]
;	JRST	COPY			; COPY FILES

; HERE ON /COPY

COPY:	SKIPN	INDEV			; SEE IF AN INPUT DEVICE
	 SETOM	DEVMSK			; TOTALLY WILD MASK
	SKIPN	SPEC+.RBNAM		; SEE IF ANY FILE
	 SETOB	M1,SPEC+.RBNAM		; NO: FULL WILD
	SKIPN	SPEC+.RBEXT		; SEE IF ANY EXT
	 HRROS	M2,SPEC+.RBEXT		; NO: WILD DEAR
	CAIN	M1,			; SEE IF ANY WILD
	 CAIE	M2,			; ''
	  TXO	%,SF$ALL		; YES, ALL WILD
	SKIPN	PPNMSK			; SEE IF A PPN MASK
	 SKIPE	DEVMSK			; SEE IF A DEVICE MASK
	  TXO	%,SF$ALL		; WILD CARDS!
	SKIPE	W,DEVMSK		; LOAD MASK
	 ORM	W,INDEV			; ON BITS!
	SKIPN	W,OUTDEV		; CHECK OUTPUT DEVICE
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	TXNE	%,SF$ALL		; SEE IF MULTIPLE
	 JRST	ALL			; YES, DO SO
SNGCOP:	MOVE	D,OUTDEV		; GET OUTPUT DEVICE
	DEVCHR	D,			; WHAT IS IT?
	TXNE	D,DV.DSK		; IS IT A DISK?
	 JRST	ONLINE			; COPY FROM TAPE
	TXNN	D,DV.MTA		; MUST BE AN MTA
	 JRST	NTAMTA			; NEITHER DSK OR MTA
	MOVE	D,INDEV			; GET INPUT DEVICE
	MOVX	W,.IODMP		; DUMP MODE
	MOVEM	W,INCH			; OUTPUT DEVICE
	MOVE	W,MTASTA		; LOAD MTA STAT'S
	MOVEM	W,OUTCH			; PACK IT AWAY
	MOVE	W,D			; COPY
	DEVCHR	D,			; FIND OUT WHAT IT IS
	TXNN	D,DV.DSK		; GOTTA BE A DISK OR...
	 JRST	MTCOPY			; NOT A DISK
; HERE TO COPY TO MTA

	OPEN	DSK,INCH		; GET INPUT DEVICE
	 JRST	CTGTDV			; CANNOT GET DEVICE
	MOVE	W,OUTDEV		; COPY IN CASE OF UNABLE TO OPEN
	OPEN	MTA,OUTCH		; OPEN MTA
	 JRST	CTGTDV			; CAN'T GET MTA
	LOOKUP	DSK,SPEC		; FIND FILE
	 JRST	CTACFL			; CAN'T ACCESS FILE
	TXNN	%,SF$DGD		; MARYBETH, DON'T DO IT LOVE!
	 PUSHJ	P,YANKDR		; GET DIRECTORY
	TXO	%,SF$DGD		; WARN MARYBETH IN CASE SHE STRAYS
OFFLIN:	AOS	I,NUMFLS		; GET NUMBER OF FILES
	AOS	MTAPOS			;[166] FIX UNBUMPED COUNTER
	LSH	I,1			; MULTIPLY BY 2
	SETO	K,			; INIT K
	MOVE	T0,SPEC+.RBNAM		; FILE NAME
	HLLZ	T1,SPEC+.RBEXT		; EXTENSION
DLLP:	AOJ	K,			; INCREMENT K
	CAIL	K,(I)			; FINISHED?
	 JRST	SAVEIT			; YES
	HLLZ	T2,DIRECT+1(K)		; COPY
	CAMN	T0,DIRECT(K)		; SEE IF MATCH
	 CAME	T1,T2			; SAME THING
	  AOJA	K,DLLP			; FIRST AT TEN, DO IT AGAIN
	SETZM	DIRECT(K)		; DELETE
SAVEIT:	MOVEI	T0,DIRECT-1(I)		; FOR PANICING
	PUSHJ	P,PANIC1		; HELP ME!!
	MOVE	W,SPEC+.RBNAM		; GET FILE
	MOVEM	W,DIRECT-2(I)		; SAVE NAME
	MOVE	W,SPEC+.RBEXT		; GET EXTENSION
	MOVEM	W,DIRECT-1(I)		; SAVE THAT TOO
	DATE	W,			; GET TODAY
	HRRM	W,DIRECT-1(I)		; SAVE THAT TOO
	MOVEM	W,SPEC+$RBDAT		;[241] SAVE IN BLOCK
	MOVE	W,.JBVER		; LOAD VERSION OF MARS
	MOVEM	W,SPEC+$RBBKV		; SAVE IT
	MOVE	T1,SPEC+.RBSIZ		;[235] GET FILE SIZE IN WORDS
	TRNE	T1,177			;[235] SEE IF NOT EVEN
	 ADDI	T1,200			;[252] MAKE RIGHT # OF BLOCKS
					;[252] NOTE!!!!!  DO NOT USE
					;[252] MOVEI T1,200(T1) SINCE
					;[252] COUNT MAY BE A FULLWORD
					;[252] AND CAUSE GRIEF!!!!!!!!
	LSH	T1,-7			;[235] DIVIDE BY 200
	MOVEM	T1,SPEC+.RBEST		;[235] MAKE IT RIGHT LATER
	ADDM	T1,BLKS			;[234] ADD INTO BLOCKS COUNT
	SETZM	SPEC+$RBWPR		;[236] INITIALLY ZERO(INSURE)
	JUMPE	T1,ZERLNF		;[236] IN CASE ZERO LENGTH FILE
DSKGET:	STORE	T0,BUFR+M,BFREND,0	;[236] ZAK!
	MOVEI	BP,BUFR+M-1		;[234] LOAD ADDRESS FOR IOWD
	CAIG	T1,N			;[237] COMPARE WITH SIZE
	 JRST	LASREC			;[234] LAST RECORD
	SUBI	T1,N			;[234] DECREASE NUMBER TO DO
	MOVX	T0,N*200		;[235] LOAD WORD COUNT
	MOVEM	T0,SPEC+$RBWPR		;[235] SAVE IN BLOCK COUNT
	MOVNS	T0			;[234] CONVERT TO IOWD
	HRLI	BP,(T0)			;[234] FINAL IOWD
	PUSHJ	P,DSKIN			;[234] GET INPUT
	 SKP				;[234] BEAUTIFUL
	  HALT	.+1			;[234] SOMEBODY FUCKED UP
	MOVE	BP,MTLIST		;[234] LOAD MTA IOWD
	PUSHJ	P,MTAOUT		;[234] COPY IT OVER
	JRST	DSKGET			;[234] GET NEXT
LASREC:	MOVE	T0,SPEC+.RBSIZ		;[235] GET SIZE
	IDIVI	T0,200*N		;[235] GET SIZE OF LAST
	CAIN	T1,			;[237] SEE IF FULL
	 MOVX	T1,N*200		;[237] FULL: (CANCELS PART OF [236] AS A BAD IDEA)
	MOVEM	T1,SPEC+$RBWPR		;[235] SAVE COUNTER
	MOVNS	T1			;[234] NOW - FOR IOWD
	HRLI	BP,(T1)			;[234] FINAL(FINISHED) IOWD
	PUSHJ	P,DSKIN			;[234] GET INPUT
	 SKP				;[234] GOOD
	  HALT	.+1			;[234] MONITOR GLITCH OR SOMETHING
ZERLNF:	MOVE	BP,MTLIST		;[234] LOAD MTA IOWD
	PUSHJ	P,MTAOUT		;[234] OUTPUT
	HRROI	BP,BUFR+M-1		;[234] CHECKING
	PUSHJ	P,DSKIN			;[234] SHOULD EOF RETURN
	 HALT	.+1			;[234] MESSED UP
	CLOSE	DSK,CL.ACS		; CLOSE OFF
	CLOSE	MTA,			; DITTO
	TXNE	%,SW$KIL		; KILL THAT FILE?
	 RENAME	DSK,BP+1		; KILL IT
	  JFCL				; OH DEAR
	TXNE	%,SF$ALL		; ALL IS LIT??
	 POPJ	P,			; YES!  RETURN IMMEDIATELY
	PJRST	CPOPJ1			; RETURN

; HERE FOR DUMP MODE COMMAND LIST CONSTANTS

MTLIST:	IOWD	BKSZ,BUFR		; MTA CONTROL WORD
DIRPT:	IOWD	BKSZ,MTADIR		; DIRECTORY CONTROL WORD
TMPSPC:	('MRS')				;[253] TEMPCORE BLOCK
	IOWD	4,LASSPC		;[253] POINTER TO "LAST" SPECS
; HERE TO COPY TO DSK

ONLINE:	MOVX	W,.IODMP		; DUMP MODE
	MOVEM	W,OUTCH			; SAVE IT
	MOVE	W,MTASTA		; LOAD MTA STATS
	MOVEM	W,INCH			;  ''
	SKIPN	W,INDEV			; CHECK INPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,INDEV			; SAVE
	MOVE	D,W			; GET INPUT DEVICE
	DEVCHR	D,			; WHAT IS IT MOMMIE?
	TXNN	D,DV.MTA		; MOMMIE IS THAT AN MTA?
	 JRST	NTAMTA			; NO IT ISN'T
	OPEN	MTA,INCH		; OPEN MTA
	 JRST	CTGTDV			; CAN'T GET MTA
	MOVE	W,OUTDEV		; COPY FOR ERROR MESSAGE IF NEEDED
	OPEN	DSK,OUTCH		; OPEN THE DISK
	 JRST	CTGTDV			; CAN'T
	TXNE	%,SW$NVR		; /NEVER?
	 LOOKUP	DSK,SPEC		; FILE THERE?
	  SKP				; NO
	   JRST	CPOPJ1			; DON'T DO ANYTHING
	PUSHJ	P,GETDIR		; GET DIRECTORY
	PUSHJ	P,POSTAP		; POSITION TAPE
	PUSH	P,SPEC+.RBPPN		;[236] SAVE PPN[NOT FROM RIB]
	MOVE	BP,MTLIST		;[236] FOR TO GET RIB
	PUSHJ	P,MTAIN			;[236] GET RIB AND FIRST BUFFER
	 JFCL				;[236] IN CASE OF SKIP
	POP	P,SPEC+.RBPPN		;[236] RESTORE SPECIFIED PPN
	LDB	T0,MODPNT		;[270] GET FILE DATA MODE
	SETSTS	DSK,(T0)		;[270] SET FILE STATUS
					;[270] NOTE: PARITY ERROR MIGHT
					;[270] CAUSE ILLEGAL DATA MODE
	MOVE	T0,PROTCD		;[271] GET PROTECTION
	TXNE	%,SW$PRO		;[271] A PROTECTION?
	 DPB	T0,PROTPT		;[271] SAVE PROTECTION
	SETZM	SPEC+.RBEST		;[313] IS THIS THE LOSSAGE, OR
	SETZM	SPEC+.RBALC		;[313] IS THIS IT???(WHO KNOWS?)
	SETZM	SPEC+.RBPOS		;[311] NO ENTER ERR 20 PLEASE
	ENTER	DSK,SPEC		;[236] CREATE FILE
	 JRST	CTMKFL			;[236] BALK
	SETSTS	DSK,.IODMP		;[270] BACK TO DUMP
SENDSK:	MOVEI	BP,BUFR+M-1		; GET POINTER
	SKIPN	T0,SPEC+$RBWPR		; GET NUMBER WRITTEN
	 JRST	ONLDON			;[234] IN CASE OF NOTHING
	MOVNS	T0			; CONVERT TO IOWD THING
	HRLI	BP,(T0)			; COPY IT
	PUSHJ	P,DSKOUT		; OUTPUT TO DSK
	MOVE	BP,MTLIST		;[236] GET SUCCEEDING RECORD
	PUSHJ	P,MTAIN			;[236] INPUT IT
	 JRST	SENDSK			;[236] GOT IT, RETURN
ONLDON:	CLOSE	DSK,CL.ACS		;[236] CLOSE OFF FILE
	PJRST	CPOPJ1			;[236] RETURN
SUBTTL COPY Switch -- Index Subroutines

; HERE TO FORCE READING AN INDEX

YANKDR:	TXZ	%,SF$DIC		; FUDGE BIT
;	JRST	GETDIR			;[237] GET A DIRECTORY

; HERE TO READ AN INDEX UNLESS ONE IS IN CORE ALREADY

GETDIR:	MOVX	BP,MTA			; LOAD CHANNEL #
	DEVNAM	BP,			; GET IT'S NAME
	 SETZ	BP,			; DEFAULT
	TXOE	%,SF$DIC		; SEE IF IN CORE
	 CAME	BP,PHMTAN		; SEE IF NAMES MATCH
	  SKP				; NO, RELOAD DIRECTORY
	   POPJ	P,			; YES, RETURN NOW
	MOVEM	BP,PHMTAN		; SAVE NAME AWAY
	PUSHJ	P,MTWAIT		;[236] WAIT
	MTEOT.	MTA,			; GO TO THE END OF DATA BASE
	PUSHJ	P,MTWAIT		; WAIT PLEASE!
	PUSHJ	P,RETGET		; POSITION TAPE
	MOVE	BP,DIRPT		; GET THE DIRECTORY POINTER
	PUSHJ	P,PANIC			; GET CORE NEEDED
	TXC	%,SF$DDR!SF$DIC		; TURN ON FLAG
GTDR:	PUSHJ	P,MTAIN			; GET SOME FROM INDEX
	 JRST	MORGT			; MORE TO COME
	MOVEI	BP,(BP)			; FOR OUR PRECIOUS CORE
	CORE	BP,			; SMALLIFY
	 JFCL				; TRIED TO BE NICE
	MOVE	BP,NUMFLS		; LOAD NUMBER OF FILES
	AOJ	BP,			; BUMP COUNTER
	MOVEM	BP,MTAPOS		; SAVE AS POSITION
	SKIPE	MTADIR+1		;[246] A MARS INDEX?
	 ERTYPE	['MIE',,[ASCIZ/Missing index at end of tape/]]
	TXC	%,SF$DDR!SF$DIC		; TURN OFF BIT
RETGET:	MTBSF.	MTA,			; BACK
	PUSHJ	P,MTWAIT		; WAIT
YNKFIN:	MTBSF.	MTA,			; BACK
	PUSHJ	P,MTWAIT		; WAIT
	STATO	MTA,IO.BOT		; DON'T IF BOT!!
	 MTSKF.	MTA,			; SKIP OVER FILE MARKER
	PUSHJ	P,MTWAIT		; WAIT FOR ME!
	POPJ	P,			; RETURN
MORGT:	ADDI	BP,BKSZ			; SET FOR MORE
	PUSHJ	P,PANIC			; PANIC
	JRST	GTDR			; GET MORE
; HERE TO WRITE AN INDEX ONTO THE TAPE

PUTDIR:	MOVE	BP,DIRPT		; GET POINTER(ASSUME TAPE ALREADY THERE)
	PUSHJ	P,PANIC			; JUST IN CASE MARYBETH
PTDR:	TXO	%,SF$DDR		; TURN ON FLAG
	PUSHJ	P,MTAOUT		; OUTPUT INDEX
	TXZ	%,SF$DDR		; TURN OFF FLAG
	MOVEI	P0,BKSZ(BP)		; GET HOW MANY DONE
	SUBI	P0,DIRECT-1		; GET RELATIVE POSITION
	LSH	P0,-1			; GET NUMBER OF FILES
	CAML	P0,NUMFLS		; DONE?
	 JRST	CLOPTD			; YES, CLOSE OUT
	ADDI	BP,BKSZ			; INCREMENT BP
	PUSHJ	P,PANIC			; PANIC
	JRST	PTDR			; RETURN
CLOPTD:	CLOSE	MTA,			; CLOSE TAPE
	SETZM	SPEC+.RBPRV		;[234] NO DATE75 PROBLEMS
	SETZM	SPEC+.RBPPN		; MYSELF PLEASE
	SETZM	INDEV			; DEFAULT TO DSK
	SETZM	SPEC+.RBEXT		; CLEAR TO GET DEFAULT
	TXNE	%,SF$DOD		; ON DISK TOO?
	 PUSHJ	P,PTDRSV		; SAVE ON DSK TOO
	  JFCL				; BECAUSE OF SKIP
	JRST	RETGET			; RETURN
SUBTTL COPY Switch -- Position Tape

POSTAP:	HLLZS	SPEC+.RBEXT		; GET RID OF DATE
	MOVE	T0,SPEC+.RBNAM		; COPY FILE NAME
	MOVE	I,NUMFLS		; START AT BEGINNING
	MOVEI	K,(I)			; INIT K
	LSH	K,1			; MULTIPLY BY 2
CHFLM:	CAMN	T0,DIRECT-2(K)		; A MATCH?
	 JRST	CHEXT			; CHECK EXTENSION
FAIL:	SUBI	K,2			; INCREMENT K
	SOJG	I,CHFLM			; GO BACK FOR MORE
	 JRST	CTACFL			; CAN'T FIND IT!
CHEXT:	HLLZ	T1,DIRECT-1(K)		; CHECK EXTENSION
	CAME	T1,SPEC+.RBEXT		; IS THERE A MATCH?
	 JRST	FAIL			; NO
	MOVE	P0,MTAPOS		; GET MTA POSITION
	MOVEI	T1,(P0)			;[165] FIX ONLY 1 FILE BACK
	MOVEM	I,MTAPOS		; SAVE NEW POSITION
	AOS	MTAPOS			; PLUS ONE WATSON
	CAIN	I,(P0)			; SEE IF THERE NOW
	 POPJ	P,			; NO NEED TO POSITION
	CAIL	I,(P0)			; SEE IF TO SKIP
	 JRST	GOTSKP			; GOTTA SKIP
	LSH	P0,-1			; DIVIDE BY 2
	CAIGE	I,(P0)			; SEE IF FURTHER OR HALF WAY
	 JRST	REWSKP			; REWIND AND SKIP
	MTBSF.	MTA,			; BACKSPACE
	PUSHJ	P,MTWAIT		; WAIT
	MTBSF.	MTA,			; BACKSPACE AGAIN
	PUSHJ	P,MTWAIT		; WAIT
	SUBI	I,(T1)			;[165] GET NUMBER TO GO BACK
	AOJE	I,SPLP			; WE'RE THERE!
BSLP:	MTBSF.	MTA,			; BACKSPACE
	PUSHJ	P,MTWAIT		; WAIT
	AOJL	I,BSLP			; LOOP FOR MORE
	JRST	SPLP			; SKIP INTO DATA
REWSKP:	MTREW.	MTA,			; REWIND TAPE
	PUSHJ	P,MTWAIT		; WAIT
	SOJE	I,CPOPJ			; DECREMENT I THING
SPLP:	MTSKF.	MTA,			; SKIP A FILE
	PUSHJ	P,MTWAIT		; WAIT
	SOJG	I,SPLP			; LOOP FOR MORE
	POPJ	P,			; RETURN
GOTSKP:	SUBI	I,(P0)			; GET HOW MANY TO SKIP
	JRST	SPLP			; GO TO IT MAN
SUBTTL COPY Switch -- Wildcard Magtape I/O

ALL:	SKIPE	DEVMSK			; SEE IF MULTIPLE STRS
	 JRST	MULDEV			; YES MARYBETH
ALLPPN:	SKIPE	PPNMSK			; SEE IF MULTIPLE PPNS
	 JRST	MULPPN			; YES MARYBETH
ALLUFD:	CAIN	M1,			; CHECK MASKS SINCE IT MIGHT
	 JUMPE	M2,SNGCOP		; BE FOR ANOTHER SPEC
	MOVE	D,OUTDEV		; GET OUTPUT DEVICE
	MOVE	W,D			; COPY IN CASE WE BALK UP AHEAD
	DEVCHR	D,			; WHAT IS IT
	TXNE	D,DV.DSK		; DSK OR MTA?
	 JRST	ALLON			; ALL ON THE DISK
	TXNN	D,DV.MTA		; IS IT AN MTA?
	 JRST	NTAMTA			; NEITHER DSK NOR MTA
	MOVE	D,INDEV			; CHECK INPUT DEVICE
	MOVE	W,D			; COPY
	DEVCHR	D,			; GET CHARS
	TXNN	D,DV.DSK		; GOTTA BE A DISK
	 JRST	MTCOPY			; NO IT ISN'T
	MOVX	W,.IOIBN		; FOR UFD, IMAGE BINARY
	MOVEM	W,UFDCH			; OPEN BLOCK #1
	MOVEI	W,UFDBFH		; BUFFER POINTER
	MOVEM	W,UFDCH+.OPBUF		; SAVE
	MOVE	W,INDEV			; DEVICE
	MOVEM	W,UFDCH+.OPDEV		; OPEN BLOCK #2
	OPEN	UFD,UFDCH		; OPEN THE UFD
	 JRST	CTGTDV			; CAN'T
	MOVEI	T0,UFDBFR		; GET LOCATION
	EXCH	T0,.JBFF		; SLAM IT INTO JOB FF
	INBUF	UFD,UFDBF		; FOOL MONITOR
	MOVEM	T0,.JBFF		; RESTORE JOB FF
	SKIPE	W,SPEC+.RBPPN		; GET PPN SPECIFIED(IF ANY)
	 JRST	SAVPPN			; GOT IT!
	MOVE	W,INDEV			; GET DISK NAME
	DEVPPN	W,			; GET DEVICE'S PPN
	 GETPPN	W,			; CAN'T, ASSUME USER PPN
	  JFCL				; IN CASE OF JACCT OR [1,2]
	MOVEM	W,SPEC+.RBPPN		; SAVE FOR LATER
SAVPPN:	MOVEM	W,UFDDAT		; SAVE AS FILE NAME FOR UFD
	MOVE	W,MFDPPN		; MFDPPN
	MOVEM	W,UFDDAT+3		; SAVE IT
	MOVSI	W,'UFD'			; EXTENSION
	MOVEM	W,UFDDAT+1		; SAVE IT
	LOOKUP	UFD,UFDDAT		; LOOK AT MY UFD
	 JRST	CTGTDR			; NO UFD TO LOOK AT
	TXNE	%,SW$SIL		; SILENCE?
	 JRST	NOTHIN			; NOTHING
	MOVE	W,INDEV			; LOAD STR(?) NAME
	PUSHJ	P,SIXLST		; TYPE IT
	OUTSTR	[ASCIZ/:	/]	; A COLON MARYBETH
	PUSHJ	P,PPNTYP		; TYPE PPN
	OUTCHR	["!"]			; REPROMPT
NOTHIN:	MOVX	T0,.IODMP		; DUMP MODE
	MOVEM	T0,INCH			; SAVE IT
	MOVE	T0,MTASTA		; LOAD MTA STAT WORD
	MOVEM	T0,OUTCH		; SAVE IT
	MOVE	W,OUTDEV		; IN CASE NEXT INST. BALKS
	OPEN	MTA,OUTCH		; GET MTA
	 JRST	CTGTDV			; CAN'T
	MOVE	W,INDEV			; COPY IN CASE OF ERROR
	OPEN	DSK,INCH		; GET DISK
	 JRST	CTGTDV			; CAN'T
	TXNN	%,SF$DGD		; MUST NOT GET DIRECTORY
	 PUSHJ	P,YANKDR		; GET DIRECTORY
	TXO	%,SF$DGD		; NEVER AGAIN
	MOVE	F,SPEC+.RBNAM		; GET FILESPEC
	HLLZ	E,SPEC+.RBEXT		; GET EXTENSION SPEC
UFDLP:	PUSHJ	P,GTUFDW		; GET UFD WORD
	JUMPE	W,REJFL			; NO FILE HERE SIR
	MOVEM	W,SPEC+.RBNAM		; SAVE IT
	OR	W,M1			; TURN ON BITS TO BE IGNORED
	CAME	W,F			; SEE IF SPECS MATCH
	 JRST	REJFL			; BALK
	PUSHJ	P,GTUFDW		; GET UFD WORD
	HLLZS	W			; SAVE IT
	MOVEM	W,SPEC+.RBEXT		; SAVE IT
	OR	W,M2			; TURN ON IGNORE BITS
	CAME	W,E			; SEE IF MATCH
	 JRST	UFDLP			; NO, TRY AGAIN
	LOOKUP	DSK,SPEC		; GET FILE
	 JRST	PROFAL			; ASSUME PROTECTION FAILURE
	TXO	%,SF$FAF		;[241] FOUND A FILE
	TXNE	%,SW$LSF		; LIST FILE?
	 PUSHJ	P,GAB			; YES, DO SO
	PUSHJ	P,OFFLIN		; SAVE IT ON TAPE
	JRST	UFDLP			; GO FOR MORE
REJFL:	PUSHJ	P,GTUFDW		; GOBBLE EXTENSION
	JRST	UFDLP			; TRY AGAIN

; HERE TO GET A WORD FROM UFD

GTUFDW:	SOSGE	UFDBFH+.BFCTR		; SEE IF MUST READ
	 JRST	GTUFDB			; MUST
	ILDB	W,UFDBFH+.BFPTR		; GET WORD
	POPJ	P,			; RETURN
GTUFDB:	IN	UFD,			; GET STUFF FROM UFD
	 JRST	GTUFDW			; RETURN
	CLOSE	UFD,CL.ACS		; CLOSE UFD
	MOVEM	F,SPEC+.RBNAM		; RESTORE FILE WILDCARD
	MOVEM	E,SPEC+.RBEXT		; RESTORE EXT WILDCARD
	TXZN	%,SF$FAF		;[241] FOUND A FILE?
	 PUSHJ	P,CTACFL		;[241] NO
	PJRST	TPOPJ1			; RETURN

PROFAL:	PUSHJ	P,CTACFL		; CAN'T ACCESS
	JRST	UFDLP			; RETRY
; HERE TO PROCESS WILDCARD STRS

MULDEV:	MOVSI	T0,-MAXSTR		; GET STR TABLE AOBJN POINTER
NXTSTR:	MOVE	W,STRTAB(T0)		; GET A STR
	JUMPE	W,CPOPJ1		; RETURN IF ALL DONE
	MOVE	D,DEVMSK		; LOAD THE MASK
	ORM	D,INDEV			; CHOMP BITS
	MOVE	D,W			; COPY NAME
	OR	D,DEVMSK		; CHOMP BITS
	CAME	D,INDEV			; WILDS SHOULD MATCH
	 JRST	REJSTR			; THEY DON'T
	MOVEM	W,INDEV			; THEY DO, SAVE STR NAME
	PUSH	P,T0			; SAVE POINTER
	PUSHJ	P,ALLPPN		; SAVE FILE
	 JFCL				; IN CASE OF SKIP
	POP	P,T0			; REGAIN POINTER
REJSTR:	AOBJN	T0,NXTSTR		; GET NEXT STR IN TABLE
	PJRST	CPOPJ1			; NONE LEFT, QUIT
; HERE TO PROCESS WILDCARD PPN'S

MULPPN:	MOVX	W,.IOIBN		; IMAGE BINARY FOR MFD
	MOVEM	W,MFDCH			; STATUS WORD
	MOVEI	W,MFDBFH		; BUFFER HEADER
	MOVEM	W,MFDCH+.OPBUF		; BUFFER WORD
	MOVE	W,INDEV			; DEVICE NAME
	MOVEM	W,MFDCH+.OPDEV		; OPEN DEVICE
	OPEN	MFD,MFDCH		; OPEN A CHANNEL FOR MFD
	 JRST	CTGTDV			; OH DEAR(NO DDB'S???)
	MOVEI	T0,MFDBFR		; MY BUFFER
	EXCH	T0,.JBFF		; FOOL MONITOR
	INBUF	MFD,MFDBF		; MONITOR THINKS IT MADE IT
	MOVEM	T0,.JBFF		; RESTORE .JBFF
	MOVE	W,MFDPPN		; LOAD MFDPPN
	MOVEM	W,MFDDAT		; FILE NAME
	MOVEM	W,MFDDAT+3		; PPN
	MOVSI	W,'UFD'			; EXT
	MOVEM	W,MFDDAT+1		; SAVE
	LOOKUP	MFD,MFDDAT		; LOOKUP THE MFD
	 ERTYPE	['MFD',,[ASCIZ/Can't access MFD/]]
NXTPPN:	PUSHJ	P,GTMFDW		; GET A PPN
	JUMPE	W,REJPPN		;[232] REJECT IF ZERO
	MOVE	T0,SPEC+.RBPPN		; COPY A GOOD ONE
	OR	T0,PPNMSK		; TURN ON WILD BITS
	OR	W,PPNMSK		; TURN ON WILD BITS
	CAME	T0,W			; SEE IF THE SAME
	 JRST	REJPPN			; REJECT THIS PPN
	LDB	W,MFDBFH+1		; REGAIN PURE PPN
	MOVEM	W,SPEC+.RBPPN		; SAVE IN BLOCK
	PUSHJ	P,ALLUFD		; COPY THE FILE(S)
	 JFCL				; IN CASE OF SKIP
REJPPN:	PUSHJ	P,GTMFDW		; GET AND IGNORE EXTENSION
	JRST	NXTPPN			; GET NEXT ONE

; HERE TO GET A WORD FROM MFD

GTMFDW:	SOSGE	MFDBFH+.BFCTR		; DECREMENT COUNTER
	 JRST	GTMFDB			; NONE LEFT--GET MORE
	ILDB	W,MFDBFH+.BFPTR		; SOME LEFT--GET IT
	POPJ	P,			; RETURN
GTMFDB:	IN	MFD,			; YUM YUM
	 JRST	GTMFDW			; STILL MORE
	CLOSE	MFD,CL.ACS		; NONE LEFT
	PJRST	TPOPJ1			; RETURN
; HERE TO WILDCARD TAPE TO DISK

ALLON:	SKIPN	PPNMSK			; SEE IF WILD
	 SKIPE	DEVMSK			; ''
SPCERR:	  ERTYPE ['SPC',,[ASCIZ/Bad or missing spec/]]
	MOVE	D,INDEV			; GET INPUT DEVICE
	MOVE	W,D			; COPY IN CASE OF ERROR
	DEVCHR	D,			; WHAT IS IT
	TXNN	D,DV.MTA		; AN MTA?
	 JRST	NTAMTA			; GUESS NOT
	MOVE	T0,MTASTA		; LOAD MTA STATS
	MOVEM	T0,INCH			; SAVE
	MOVX	T0,.IODMP		; DUMP MODE
	MOVEM	T0,OUTCH		; SAVE IT FOR OUTPUT
	OPEN	MTA,INCH		; OPEN THE MTA
	 JRST	CTGTDV			; CAN'T
	SETZM	MTAPOS			;[235] CLEAR POSITION
	MOVE	W,OUTDEV		; IN CASE OF ERROR
	OPEN	DSK,OUTCH		; OPEN THE DISK
	 JRST	CTGTDV			; CAN'T
	MTREW.	MTA,			; REWIND THE MTA
	PUSHJ	P,MTWAIT		; WAIT FOR IT TO FINISH
	MOVE	F,SPEC+.RBNAM		; GET PROTOTYPE FILESPEC
	HLLZ	E,SPEC+.RBEXT		; AND EXTENSION(OTHERWISE THEY GET CLOBBERED)
	MOVE	P0,SPEC+.RBPPN		;[236] SAVE PPN
NEXFIL:	AOS	MTAPOS			;[235] BUMP POSITION
	MOVE	BP,MTLIST		; GET COMMAND FOR DUMP THING
	PUSHJ	P,MTAIN			; GET LABEL RECORD
	 JFCL				; IN CASE OF SKIP
	MOVEM	P0,SPEC+.RBPPN		;[236] MUST RESTORE PPN DEAR
	SKIPN	T0,SPEC+.RBNAM		; GET FILENAME
	 PJRST	ALNDON			;[243] ALL DONE
	OR	T0,M1			; MASK ON WILD BITS
	CAME	T0,F			; SEE IF MATCH
	 JRST	TRYAGN			; BALK
	HLLZ	T0,SPEC+.RBEXT		; GET EXTENSION
	OR	T0,M2			; MASK ON WILD BITS
	CAME	T0,E			; SEE IF MATCH
	 JRST	TRYAGN			; IF AT FIRST YOU DON'T SUCCEED...
	TXNE	%,SW$NVR		; /NEVER?
	 LOOKUP	DSK,SPEC		; FILE THERE?
	  SKP				; NO
	   JRST	TRYAGN			; TRY AGAIN
	LDB	T0,MODPNT		;[270] GET FILE DATA MODE
	SETSTS	DSK,(T0)		;[270] SET FILE STATUS
	MOVE	T0,PROTCD		;[271] GET PROTECTION CODE
	TXNE	%,SW$PRO		;[271] A PROTECTION?
	 DPB	T0,PROTPT		;[271] YES, SAVE IT
	SETZM	SPEC+.RBEST		;[314] FIX 6.02 LOSSAGE
	SETZM	SPEC+.RBALC		;[314]  "   "      "
	SETZM	SPEC+.RBPOS		;[311] NO ENTER ERROR 20 PLEASE
	ENTER	DSK,SPEC		; TRY TO CREATE IT
	 JRST	ALNBLK			; BALK
	SETSTS	DSK,.IODMP		;[270] BACK TO DUMP
	TXNE	%,SW$LSF		; SEE IF GABBY HAYS IS ON LINE
	 PUSHJ	P,GAB			; YES, LET HER GAB
	TXO	%,SF$FAF		;[242] FOUND A FILE
RESDSK:	MOVEI	BP,BUFR+M-1		; GET COMMAND
	SKIPN	T0,SPEC+$RBWPR		; GET NUMBER WRITTEN
	 JRST	ANCLS			;[236] ALL DONE IF ZERO
	MOVNS	T0			; NEGATE
	HRLI	BP,(T0)			; LOAD INTO COMMAND THING
	PUSHJ	P,DSKOUT		; WRITE TO THE DISK
	MOVE	BP,MTLIST		; GET DUMP MODE STUFF
	PUSHJ	P,MTAIN			; GET FILE DATA
	 JRST	RESDSK			; OKAY
ANCLS:	CLOSE	DSK,CL.ACS		;[236] CLOSE OFF FILE
	JRST	NEXFIL			; LOOP FOR MORE FILES
TRYAGN:	MTSKF.	MTA,			; LEAVE THIS FILE
	PUSHJ	P,MTWAIT		; WAIT FOR COMPLETION
	JRST	NEXFIL			; GET NEXT ONE UNLESS DONE
ALNBLK:	PUSHJ	P,CTMKFL		; YELL
	JRST	TRYAGN			; TRY NEXT
ALNDON:	MOVEM	F,SPEC+.RBNAM		;[307] GET NAME FOR TYPOUT
	MOVEM	E,SPEC+.RBEXT		;[307] . . .
	TXZN	%,SF$FAF		;[242] FOUND A FILE?
	 PUSHJ	P,CTACFL		;[242] NO, CRY A LITTLE
	PJRST	ATDIR			;[242] FINISH UP
SUBTTL COPY Switch -- MTA to MTA Copying

MTCOPY:	TXZE	%,SF$CMF		; COMMA FLAG SHOULD NOT BE ON
	 JRST	SPCERR			; SPECIFICATION ERROR IF SO
	TXNN	D,DV.MTA		; SEE IF MTA
	 JRST	NTAMTA			; NOT A MTA
	MOVE	T0,MTASTA		; LOAD MTA STATS
	MOVEM	T0,OUTCH		; SAVE IT
	MOVEM	T0,INCH			; SAVE IT
	MOVE	W,OUTDEV		; IN CASE OF BOMB
	OPEN	MTC,OUTCH		; OPEN OUTPUT MTA
	 JRST	CTGTDV			; CAN'T
	MOVE	W,INDEV			; COPY IN CASE OF ERROR
	MOVE	W,INDEV			; IN CASE OF ERROR
	OPEN	MTA,INCH		; GET DEVICE
	 JRST	CTGTDV			; CAN'T
	MOVX	T0,MTA			; SET UP FOR UUO
	DEVNAM	T0,			; WHAT IS IT
	 MOVE	T0,INDEV		; ONLY IF UUO NOT IMPLEMENTED
	MOVX	T1,MTC			; SET UP FOR UUO
	DEVNAM	T1,			; WHAT IS IT
	 MOVE	T1,OUTDEV		; NOT IMPLEMENTED
	CAMN	T0,T1			; SEE IF THE SAME
	 ERTYPE	['SMT',,[ASCIZ!May not /COPY tape to self!]]
	PUSHJ	P,GETDIR		; GET DIRECTORY
	MTREW.	MTA,			; REWIND FIRST
	MTREW.	MTC,			; AND SECOND
	PUSHJ	P,MTWAIT		; WAIT FOR
	MTWAT.	MTC,			; BOTH
	SETZB	P0,BLKS			; SO COUNT IS NEW
	EXCH	P0,NUMFLS		; SO COUNT IS ALSO NEW
	SETZB	I,B			; CLEAR EXTRA JUNK
CHKCOP:	SKIPN	W,DIRECT(I)		; GET FILENAME
	 JRST	SKPTHO			; SKIP THIS ONE
	MOVEM	W,SPEC+.RBNAM		; IN CASE OF ERROR
	MOVEM	W,DIRECT(B)		; SAVE IT
	MOVE	W,DIRECT+1(I)		; GET EXTENSION
	MOVEM	W,SPEC+.RBEXT		; IN CASE OF ERROR
	MOVEM	W,DIRECT+1(B)		; SAVE THAT TOO
	ADDI	I,2			; INCREMENT I
	ADDI	B,2			; INCREMENT B
	AOS	NUMFLS			; INCREMENT FILE COUNTER
READ:	MOVE	BP,MTLIST		; GET COMMAND
	PUSHJ	P,MTAIN			; GET MTA INPUT
	 JRST	WRITE			; WRITE NEXT
	MOVE	W,SPEC+.RBEST		;[235] GET SIZE
	ADDM	W,BLKS			;[235] ADD INTO COUNT
	CLOSE	MTC,			; WRITE THE EOF
	SOJG	P0,CHKCOP		; LOOP FOR MORE
	JRST	CLSALL			; FINISH UP
WRITE:	MOVE	W,.JBVER		; LOAD THIS VERSION
	MOVEM	W,SPEC+$RBBKV		; SAVE IT AWAY
	MOVE	BP,MTLIST		; COMMAND
	SETZ	BP+1,			; PARANOIA
RETR1:	OUT	MTC,BP			; WRITE IT
	 JRST	READ			; MORE TO COME
	GETSTS	MTC,K			; GET STATUS
	TXNE	K,IO.EOT		;[304] EOT?
	 MTREW.	MTC,			;[304] YES, REWIND TAPE
	PUSHJ	P,MTAERR		; TYPE MESSAGE
	 JRST	READ			; READ MORE
	  JRST	RETR1			;[246] RETRY OPERATION
SKPTHO:	MTSKF.	MTA,			; SKIP FILE
	PUSHJ	P,MTWAIT		; WAIT
	ADDI	I,2			; INCREMENT I
	SOJG	P0,CHKCOP		; CHECK IF TO COPY

; HERE WHEN ALL DONE

CLSALL:	MOVE	BP,DIRPT		; ROUTINE TO DO EXACTLY LIKE
	SETZ	BP+1,			; PUTDIR, ONLY TO THE NEW
	PUSHJ	P,PANIC			;[254] FIX ADDRESS CHECK
PTDR2:	OUT	MTC,BP			; MAGTAPE.  SINCE PUTDIR GOES
	 JRST	RETPT2			; TO MTA, NOT MTC, THIS MUST
	GETSTS	MTC,K			; GET MTA STATS
	TXNE	K,IO.EOT		;[304] EOT?
	 MTREW.	MTC,			;[304] YES, REWIND TAPE
	TXO	%,SF$DDR		; TURN ON BIT
	PUSHJ	P,MTAERR		; REPORT ERROR MARYBETH
	 SKP				;[246] NON-RETRYABLE ERROR
	  JRST	PTDR2			;[246] RETRY
RETPT2:	MOVEI	P0,BKSZ(BP)		; GET HOW MANY DONE
	SUBI	P0,DIRECT		; GET RELATIVE POSITION
	LSH	P0,-1			; GET NUMBER OF FILES
	CAML	P0,NUMFLS		; DONE?
	 JRST	CLOPD2			; YES
	ADDI	BP,BKSZ			; TRY FOR MORE
	PUSHJ	P,PANIC			; PRESS RED BUTTON
	JRST	PTDR2			; AND TRY AGAIN
CLOPD2:	CLOSE	MTC,			; WRITE EOT
	TXZ	%,SF$DIC		; CLEAR BIT
	PJRST	CPOPJ1			; RETURN
SUBTTL DELETE Switch

DELETE:	SKIPN	SPEC+.RBNAM		; FILE MUST BE SPECIFIED
	 JRST	SPCERR			; NONE WAS
	SKIPN	W,INDEV			; CHECK INPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,INDEV			; SAVE
	MOVE	D,W			; GET ANOTHER COPY
	DEVCHR	D,			; WHAT IS IT
	TXNN	D,DV.MTA		; MUST BE MTA
	 JRST	NTAMTA			; NOT AN MTA
	MOVE	D,MTASTA		; FOR DUMP MODE THING
	MOVEM	D,INCH			; SAVE IT
	OPEN	MTA,INCH		; GET MTA
	 JRST	CTGTDV			; MTA NOT AVAILABLE
	TXNE	%,SF$DGD		;[253] DO IT?
	 JRST	.+3			;[265] DON'T DO IT
	  OUTSTR [ASCIZ/Files Deleted:
!/]
	  PUSHJ	P,YANKDR		; GET DIRECTORY
	TXO	%,SF$DGD		;[253] MARYBETH DOESN'T WANT TAPE TO ROCK
	MOVE	T2,NUMFLS		; GET NUMBER OF FILES
	LSH	T2,1			; MULTIPLY BY 2
	SETO	P0,			; INIT P0
DELLP:	AOJ	P0,			; INCREMENT P0
	CAIL	P0,(T2)			; ALL DONE?
	 JRST	DELDON			;[237] DELETE DONE
	SKIPN	W,DIRECT(P0)		;[237] GET FILE NAME
	 JRST	NODEL			;[253] ALREADY DELETED
	OR	W,M1			;[237] MASK
	CAME	W,SPEC+.RBNAM		;[237] SEE IF MATCH
	 JRST	NODEL			;[237] NO, DON'T DELETE
	HLLZ	W,DIRECT+1(P0)		;[237] GET EXTENSION
	OR	W,M2			;[237] MASK
	CAME	W,SPEC+.RBEXT		;[253] SEE IF MATCH
	 JRST	NODEL			;[253] NO MATCH
	TXNE	%,SW$SIL		;[253] SILENCE?
	 JRST	KILLIT			;[253] YES, DON'T SAY WHO DIED
	MOVE	W,DIRECT(P0)		;[253] FILE THAT WILL DIE
	PUSHJ	P,SIXLST		;[253] TYPE HIM
	OUTCHR	["."]			;[253] ...OR HER, I GUESS...
	HLLZ	W,DIRECT+1(P0)		;[253] MUST I COMMENT THIS CRUFT?
	PUSHJ	P,SIXLST		;[253] REALLY HARD TO UNDERSTAND
	OUTSTR	CRLF			;[253] GUESS I HAVE TO
	OUTCHR	["!"]			;[265] RETYPE PROMPT
KILLIT:	SETZM	DIRECT(P0)		;[237] YES: DELETE
	TXO	%,SF$FAF		;[253] SO NO ERROR MESSAGE
NODEL:	AOJA	P0,DELLP		;[237] TRY AGAIN
DELDON:	TXZN	%,SF$FAF		;[253] FOUND ONE LOVE?
	 PUSHJ	P,CTACFL		;[253] NO, YELL
	TXO	%,SF$DMO		;[253] SAY TO WRITE DIRECTORY
	PJRST	CPOPJ1			;[253] RETURN
SUBTTL SAVE and LOAD switches

; HERE TO SAVE AN INDEX TO DSK

SAVE:	SKIPN	W,SPEC+.RBNAM		; REQUIRE FILE TOLD
;	 JRST	PTDRSV			; NO, USE TAPE ID
;	JRST	PTDRSV+2		; NO DEFAULT

; HERE TO HANDLE DEFAULT /SAVE WHEN /LOAD WAS USED

PTDRSV:	MOVE	W,TAPEID		; DEFAULT TO TAPE ID
	MOVEM	W,SPEC+.RBNAM		; SAVE AS FILE NAME
	SKIPN	W,SPEC+.RBEXT		; SEE IF AN EXTENSION
	 MOVSI	W,'MTA'			; DEFAULT
	MOVEM	W,SPEC+.RBEXT		; SAVE EXTENSION
	STORE	W,SPEC+.RBSIZ,SPEC+.RBTIM,0;[313] CLEAR REST OF BLOCK
	MOVE	W,.JBVER		;[313] LOAD VERSION OF MARS
	MOVEM	W,SPEC+.RBVER		;[313] SET FILE VERSION WITH IT
	TXNN	%,SF$DIC		; REQUIRE DIRECTORY IN CORE
	 ERTYPE	['NDC',,[ASCIZ/No directory in core/]]
	MOVX	W,.IODMP		; DUMP MODE
	MOVEM	W,OUTCH			; PACK AWAY
	SKIPN	W,INDEV			; CHECK NAME
	 MOVSI	W,'DSK'			; LOAD NAME
	MOVEM	W,OUTDEV		; SAVE IT AWAY
	OPEN	DSK,OUTCH		; GET IT!
	 JRST	CTGTDV			; CAN'T
	MOVE	T0,PROTCD		;[271] GET PROTECTION WORD
	TXNE	%,SW$PRO		;[271] A PROTECTION?
	 DPB	T0,PROTPT		;[271] YES, SAVE IT
	ENTER	DSK,SPEC		; MAKE FILE
	 JRST	CTMKFL			; CAN'T
	TXO	%,SF$DOD		;[246] TURN ON "INDEX ON DISK" BIT
	MOVE	BP,NUMFLS		;[246] FETCH NUMBER OF FILES
	LSH	BP,1			;[246] TWO WORDS PER FILE
	MOVNI	BP,DIRECT-MTADIR(BP)	;[246] COMPUTE WORD COUNT
	HRLI	BP,MTADIR-1		;[246] MAKE INVERTED IOWD
	MOVSS	BP			;[246] MAKE PROPER IOWD
	SETZ	BP+1,			; PARANOIA
	OUTPUT	DSK,BP			; SEND IT
	CLOSE	DSK,			; CLOSE CHANNEL
	PJRST	CPOPJ1			; RETURN

MODPNT:	POINTR	<SPEC+.RBPRV>,RB.MOD	;[270] BYTE POINTER TO MODE
PROTPT:	POINTR	<SPEC+.RBPRV>,RB.PRV	;[271] PROTECTION POINTER
; HERE TO LOAD AN INDEX FROM DSK

LOAD:	SKIPN	SPEC+.RBNAM		; REQUIRE FILE
	 JRST	SPCERR			; BALK
	SKIPN	W,SPEC+.RBEXT		; SEE IF AN EXT
	 MOVSI	W,'MTA'			; DEFAULT
	MOVEM	W,SPEC+.RBEXT		; SAVE
	MOVX	W,.IODMP		; DUMP MODE
	MOVEM	W,INCH			; SAVE AWAY
	SKIPN	W,INDEV			; LOAD DEVICE
	 MOVSI	W,'DSK'			; DEFAULT
	MOVEM	W,INDEV			; SAVE AWAY
	OPEN	DSK,INCH		; OPEN UP
	 JRST	CTGTDV			; CAN'T
	LOOKUP	DSK,SPEC		; GET FILE
	 JRST	CTACFL			; CAN'T
	MOVN	BP,SPEC+.RBSIZ		;[246] GET - WORD COUNT
	HRLI	BP,MTADIR-1		;[246] GET INVERTED IOWD
	MOVSS	BP			;[246] MAKE PROPER IOWD
	SETZ	BP+1,			; PARANOIA
	MOVEI	T0,MTADIR-1		;[247] GET STARTING OFFSET
	ADD	T0,SPEC+.RBSIZ		;[247] NOW HAVE ADDRESS WE NEED
	PUSHJ	P,PANIC1		;[247] INSURE PROPER CORE
	INPUT	DSK,BP			; GET IT
	SKIPE	MTADIR+1		;[246] A PROPER INDEX?
	 ERTYPE	['NAI',,[ASCIZ/Not a MARS index file/]]
	TXO	%,SF$DIC!SF$DOD		; TURN ON BIT
	POPJ	P,			; RETURN
SUBTTL Positioning Switches

; HERE TO REWIND/UNLOAD TAPE

REWIND:	SKIPN	W,OUTDEV		; CHECK OUTPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	MOVE	D,W			; SET DEVICE
	DEVCHR	D,			; GET CHARS
	TXNN	D,DV.MTA		; IS IT OKAY?
	 JRST	NTAMTA			; NO
	OPEN	MTA,OUTCH		; OPEN MTA
	 JRST	CTGTDV			; CAN'T
	SETZM	MTAPOS			; CLEAR WHERE
	AOS	MTAPOS			; AND MAKE IT FIRST
	TXNN	%,SW$UNL		; UNLOAD INSTEAD?
	 JRST	REWMTA			; RETURN
	MTUNL.	MTA,			; UNLOAD TAPE
	TXZA	%,SF$DIC		; TURN OFF IN CORE BIT
REWMTA:	 MTREW.	MTA,			; REWIND TAPE
	PJRST	CPOPJ1			; BRAND NEW WORLD
; HERE TO SKIP TAPE

SKIP:	SKIPN	W,OUTDEV		; CHECK OUTPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	SKIPN	T0,POSFNO		; GET ARG
	 AOJ	T0,			; DEFAULT
	MOVE	D,OUTDEV		; GET WORD
	DEVCHR	D,			; CHECK
	TXNN	D,DV.MTA		; MUST BE MTA
	 JRST	NTAMTA			; BALK
	OPEN	MTA,OUTCH		; OPEN CHANNEL
	 JRST	CTGTDV			; BALK
	ADDM	T0,MTAPOS		; FIX TAPE POSITION
	MTSKF.	MTA,			; SKIP
	PUSHJ	P,MTWAIT		; WAIT
	SOJG	T0,.-2			; REPEAT
	PJRST	CPOPJ1			; RETURN

; HERE TO BACKSPACE TAPE

BACKSP:	SKIPN	W,OUTDEV		; CHECK OUTPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	MOVE	D,OUTDEV		; GET WORD
	DEVCHR	D,			; CHECK
	TXNN	D,DV.MTA		; INSIST ON MTA
	 JRST	NTAMTA			; BALK
	OPEN	MTA,OUTCH		; ACCESS
	 JRST	CTGTDV			; BALK
	SKIPN	T0,POSFNO		; LOAD COUNT
	 AOJ	T0,			; BUMP ARG
	SUBM	T0,MTAPOS		; FIX POSITION
	MOVMS	MTAPOS			; ABSOLUTEVALUEIFY
	MTBSF.	MTA,			; BACKSPACE
	PUSHJ	P,MTWAIT		; WAIT
	SOJGE	T0,.-2			; REPEAT
	STATO	MTA,IO.BOT		; SEE IF BOT
	 MTSKF.	MTA,			; NO, SKIP EOF
	PUSHJ	P,MTWAIT		; WAIT
	PJRST	CPOPJ1			; RETURN
SUBTTL ZERO Switch

ZERO:	MOVE	T0,MTASTA		; DUMP MODE
	MOVEM	T0,OUTCH		; SAVE IT
	SKIPN	W,OUTDEV		; CHECK OUTPUT DEVICE
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	MOVE	D,W			; GET DEVICE
	DEVCHR	D,			; GET CHARACTERISTICS
	TXNN	D,DV.MTA		; IS IT AN MTA?
	 JRST	NTAMTA			; NOT AN MTA
	OPEN	MTA,OUTCH		; GET MTA
	 JRST	CTGTDV			; CAN'T
	SETZM	BLKS			; NO MORE BLOCKS FOR YOU
	SETZM	NUMFLS			; ALL FILES HAVE JUST GONE
	MOVEM	W,PHMTAN		; SET PHYSICAL NAME
	TXO	%,SF$DIC		; NOW A DIRECTORY MARYBETH
	MTREW.	MTA,			; REWIND MTA
	PUSHJ	P,MTWAIT		; WAIT
	JRST	ASKFID			; ASK FOR AN ID
SUBTTL IDENTIFY Switch

LABEL:	SKIPN	W,OUTDEV		; GET DEVICE
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	MOVE	D,W			; GET DEVICE
	DEVCHR	D,			; GET CHARS
	TXNN	D,DV.MTA		; IS IT AN MTA?
	 JRST	NTAMTA			; NOT AN MTA
	MOVE	T0,MTASTA		; DUMP MODE
	MOVEM	T0,OUTCH		; SAVE IT
	OPEN	MTA,OUTCH		; OPEN DEVICE
	 JRST	CTGTDV			; CAN'T
	PUSH	P,TAPEID		; SAVE PROTOTYPE SINCE IT GETS SMASHED
	PUSHJ	P,YANKDR		; GET DIRECTORY
	POP	P,TAPEID		; GET TAPE ID BACK

; HERE TO ASK FOR TAPE ID IF NOT GIVEN

ASKFID:	SKIPE	TAPEID			; DON'T ASK AGAIN
	 JRST	LABTAP			; DO MORE STUFF
	OUTSTR	[ASCIZ/Tape ID: /]	; BEG FOR ID
	PUSHJ	P,GET1WD		; GET ONE WORD
	MOVEM	W,TAPEID		; SAVE IT
	PUSHJ	P,TSTBRK		; SEE IF BREAK
	 JRST	ASKFID			; YESSIR
	JRST	SYNERR			; BAH HUMBUG!

; HERE TO WRITE A NEW INDEX ON TAPE

LABTAP:	MOVE	T0,.JBVER		; LOAD THIS VERSION
	MOVEM	T0,LABVER		; SAVE IT
	MOVX	T0,%CNVER		; LOAD TO GET
	GETTAB	T0,			; ACCESS MONVER
	 SETZ	T0,			; DEFAULT
	MOVEM	T0,MONVER		; PACK AWAY
	MSTIME	T0,			; GET THE TIME
	MOVEM	T0,LABTIM		; SAVE IT
	DATE	T0,			; GET TODAY
	MOVEM	T0,LABDAT		; SAVE IT
	PUSHJ	P,PUTDIR		; SAVE DIRECTORY
	TXZ	%,SF$DMO		;[236] ELIMINATE REDUNDANCY
	PJRST	CPOPJ1			; RETURN
SUBTTL LIST Switch

LIST:	SKIPN	W,INDEV			; CHECK INPUT
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,INDEV			; SAVE
	MOVE	D,W			; GET INPUT DEVICE
	DEVCHR	D,			; ARE WE AN MTA?
	TXNN	D,DV.MTA		; WELL?
	 JRST	NTAMTA			; HMM, VERRY INTERESTING!
	MOVE	T0,MTASTA		; DUMP MODE
	MOVEM	T0,INCH			; SAVE IT
	OPEN	MTA,INCH		; OPEN MTA
	 JRST	CTGTDV			; CAN'T
	MOVX	W,.IOASL		;[236] ASCII LINE
	MOVEM	W,OUTCH			;[236] SAVE AS STATS
	MOVSI	W,OUTCH			; USE AGAIN AS BUFFER HEADER
	MOVEM	W,OUTCH+.OPBUF		; SAVE IT
	MOVSI	T0,'TTY'		; DEFAULT NAME
	SKIPE	SPEC+.RBNAM		; UNLESS A FILE
	 MOVSI	T0,'DSK'		; THEN USE DSK:
	SKIPN	W,OUTDEV		; SEE IF ANY SPECIFIED
	 MOVE	W,T0			; DEFAULT
	MOVEM	W,OUTDEV		; SAVE
	MOVE	T0,W			;[301] (IN CASE T0 DOESN'T HAVE IT)
	DEVCHR	T0,			;[301] GET LIST DEVICE CHARS
	TXNN	T0,DV.LPT!DV.TTY!DV.DIR	;[310] LEGAL LISTING DEVICE?
	 ERTYPE	['ILD',,[ASCIZ/Illegal Listing Device/]]
	OPEN	LST,OUTCH		; OPEN DEVICE
	 JRST	CTGTDV			; ARGH!!
	MOVE	T0,PROTCD		;[271] GET PROTECTION WORD
	TXNE	%,SW$PRO		;[271] A PROTECTION?
	 DPB	T0,PROTPT		;[271] YES, USE IT
	SETZM	SPEC+.RBPOS		;[311] NO ENTER ERROR 20 PLEASE
	ENTER	LST,SPEC		; GET FILE
	 JRST	CTMKFL			; WHAT CAN I SAY?
	MOVEI	T0,MFDBFR		; WHERE IT IS TO GO
	EXCH	T0,.JBFF		; SLAM IT IN JOB FF
	OUTBUF	LST,MFDBF+UFDBF		; FOOL MONITOR
	MOVEM	T0,.JBFF		; RESTORE JOB FF
	PUSHJ	P,GETDIR		; GET DIRECTORY
	TXNN	%,SW$FST		; CHECK FOR /FAST
	 JRST	REGLST			; NO, REGULAR LISTING
	MOVEI	BP,[ASCIZ@Tape ID: @]	; FIRST THING TO TYPE
	PUSHJ	P,ASCTYO		; TYPE IN ASCII
	MOVEI	BP,TAPEID		; GET ID WORD
	PUSHJ	P,SIXTYO		; SAY IT
	MOVEI	BP,[ASCIZ@
In use:	@]
	PUSHJ	P,ASCTYO		; TYPE IT
	MOVE	W,BLKS			; GET # OF BLOCKS
	PUSHJ	P,DECLST		; TYPE IT OUT
	MOVEI	BP,[ASCIZ@ Blks, @]	; CONTINUE MESSAGE
	PUSHJ	P,ASCTYO		; TYPE IT
	MOVE	W,NUMFLS		; GET # OF FILES
	PUSHJ	P,DECLST		; TYPE IT OUT
	MOVEI	BP,[ASCIZ@ Files
@]					; END OF HEADER
	PUSHJ	P,ASCTYO		; TYPE IT OUT
	SKIPN	P0,NUMFLS		; ANY FILES?
	 JRST	LSTCLS			; NO, CLOSEOUT
	SETZ	D,			; START WITH FIRST FILE
FLLOOP:	SKIPN	DIRECT(D)		; FILE THERE?
	 JRST	DRLP			; NO
	MOVEI	BP,DIRECT(D)		; FILE
	HLLZ	T0,DIRECT+1(D)		; EXTENSION
	CAXN	T0,('UFD')		;[306] IS DAT A UFD?
	 JRST	DRLP			;[306] YOU DON'T LIKE IT, YOU WRITE IT
	PUSHJ	P,SIXTY2		; TYPE IT OUT!
	MOVEI	W,"."			; GET A DOT
	PUSHJ	P,TYPE			; TYPE IT
	MOVEI	BP,T0			; POINTER
	MOVEI	I,4			; SET COUNT
	PUSHJ	P,SIXTY2+1		; TYPE IT OUT
	MOVEI	W," "			; SPACE
	PUSHJ	P,TYPE			; TYPE IT
	HRRZ	T0,DIRECT+1(D)		; GET DATE
	PUSHJ	P,DATTYP		; TYPE DATE
	MOVEI	BP,CRLF			; FOR CRLF
	PUSHJ	P,ASCTYO		; TYPE IT OUT
DRLP:	ADDI	D,2			; BUMP I
	SOJG	P0,FLLOOP		; LOOP IF MORE
LSTCLS:	CLOSE	LST,			; CLOSE OUT FILE
	PJRST	CPOPJ1

MNTAB:	SIXBIT/-JAN-/
	SIXBIT/-FEB-/
	SIXBIT/-MAR-/
	SIXBIT/-APR-/
	SIXBIT/-MAY-/
	SIXBIT/-JUN-/
	SIXBIT/-JUL-/
	SIXBIT/-AUG-/
	SIXBIT/-SEP-/
	SIXBIT/-OCT-/
	SIXBIT/-NOV-/
	SIXBIT/-DEC-/
; HERE TO DO A REGULAR LISTING

REGLST:	SKIPE	NUMFLS			; DON'T BOTHER IF NONE
	 MTREW.	MTA,			; START MTA REWINDING
	SETZM	MTAPOS			; CLEAR POSITION COUNT
	MOVEI	BP,[ASCIZ@
*** MTA directory of @]
	PUSHJ	P,ASCTYO		; I CAN'T BRING MYSELF TO COMMENT
	MOVEI	BP,TAPEID		; THIS, IT'S VERY STRAIGHTFORWARD
	PUSHJ	P,SIXTYO		;*******************************
	MOVEI	BP,[ASCIZ@ taken at @]	; ALL THAT IS GOLD DOES NOT GLITTER
	PUSHJ	P,ASCTYO		; NOT ALL THOSE WHO WANDER ARE LOST
	MSTIME	T0,			; THE OLD THAT IS STRONG DOES NOT WITHER
	PUSHJ	P,MSTTYP		; DEEP ROOTS ARE NOT REACHED BY THE FROST.
	MOVEI	BP,[ASCIZ@ on @]	;
	PUSHJ	P,ASCTYO		; FROM THE ASHES A FIRE SHALL BE WOKEN
	DATE	T0,			; A LIGHT FROM THE SHADOWS SHALL SPRING
	PUSHJ	P,DATTYP		; RENEWED SHALL BE BLADE THAT WAS BROKEN
	MOVEI	BP,[ASCIZ@ ***

MARS %@]				; THE CROWNLESS AGAIN SHALL BE KING.
	PUSHJ	P,ASCTYO		;*******************************
	MOVE	T0,.JBVER		;[171] GET THIS VERSION
	PUSHJ	P,VERLST		;[171] SHOW IT
	MOVEI	BP,[ASCIZ@, unit=@]	; MESSAGE
	PUSHJ	P,ASCTYO		;[172] BE SURE TO TYPE IT
	MOVEI	T0,MTA			; GET MTA CHANNEL
	DEVNAM	T0,			; GET PHYSICAL NAME
	 MOVSI	T0,'MTA'		; DEFAULT
	MOVEI	BP,T0			; SET POINTER
	PUSHJ	P,SIXTYO		; TYPE MTA NAME
	MOVEI	BP,[ASCIZ@, Write-@]
	PUSHJ	P,ASCTYO
	MOVEI	T0,MTA			; LOAD CHANNEL
	MTCHR.	T0,			; GET CHARS
	 SETZ	T0,			; DEFAULT
	MOVEI	BP,[ASCIZ@enabled, @]
	TXNE	T0,MT.WLK		; SEE IF WRITE LOCKED
	 MOVEI	BP,[ASCIZ@locked, @]	; ASK THE GODDESS OF KNOWLEDGE
	PUSHJ	P,ASCTYO		; TYPE IT
	PUSH	P,T0			; SAVE BITS
	ANDX	T0,MT.DEN		; JUST THAT
	MOVX	W,^D800			; DEFAULT
	CAXN	T0,.MTDN2		; SEE IF 200 BPI
	 MOVX	W,^D200			; YUP
	CAXN	T0,.MTDN5		; SEE IF 556 BPI
	 MOVX	W,^D556			; YUP
	CAXN	T0,.MTD16		;[235] 1600 BPI?
	 MOVX	W,^D1600		;[235] YES
	POP	P,T0			;[317] GET OTHER BITS BACK
	PUSHJ	P,DECLST		; TYPE
	MOVEI	BP,[ASCIZ@ BPI, @]
	PUSHJ	P,ASCTYO		; TYPE
	MOVEI	W,"9"			; ASSUME 9-TRACK
	TXNE	T0,MT.7TR		; BUT FIND OUT ANYWAY
	 MOVEI	W,"7"			; LEARN THE HARD WAY
	PUSHJ	P,TYPE			; TYPE THE BEASTIE
	MOVEI	BP,[ASCIZ@-Track, @]
	PUSHJ	P,ASCTYO		; TYPE (AGAIN)
	MOVEI	BP,PRCTYP		;[263] FETCH PROCESSOR TYPE
	PUSHJ	P,SIXTYO		;[263] TYPE IT OUT
	MOVEI	BP,[ASCIZ@
Labelled at @]
	PUSHJ	P,ASCTYO
	MOVE	T0,LABTIM		; LOAD LABEL TIME
	PUSHJ	P,MSTTYP		; TYPE IT
	MOVEI	BP,[ASCIZ@ on @]
	PUSHJ	P,ASCTYO
	MOVE	T0,LABDAT		; LOAD LABEL DATE
	PUSHJ	P,DATTYP		; TYPE THE DATE
	MOVEI	BP,[ASCIZ@ by MARS %@]
	PUSHJ	P,ASCTYO		; FOR VERSION
	MOVE	T0,LABVER		; LOAD LABELLING VERSION
	PUSHJ	P,VERLST		; TYPE VERSION
	MOVEI	BP,[ASCIZ@, monitor %@]
	PUSHJ	P,ASCTYO		; TYPE MESSAGE
	MOVE	T0,MONVER		; LOAD MONITOR VERSION
	PUSHJ	P,VERLST		; TYPE IT
	SKIPN	NUMFLS			; ANY FILES TO REPORT, PRIVATE?
	 JRST	EOREP			; NO SIR!
	MOVEI	BP,[ASCIZ@

    #	File Name    Size  Prot	Time	Date	 Device	 Directory

@]
	PUSHJ	P,ASCTYO		; TYPE HEADER
	SETZB	P0,F			; INIT FILE COUNT
FILREP:	PUSHJ	P,MTWAIT		; WAIT FOR COMPLETION
	PUSHJ	P,EXPINP		; SEE IF ANY ! INPUT
	MOVE	BP,MTLIST		; LOAD I/O COMMAND
	SETZ	BP+1,			; GOTTA BE DONE!
RETR2:	IN	MTA,BP			; LOAD RECORD
	 JRST	TYFL			; TYPE IT OUT
	STATZ	MTA,IO.DTE!IO.BKT!IO.DER;[246] IN CASE OF ERROR
	 TXO	%,SF$IOE		; OH DEAR
	MOVEI	K,LST			; GET LST CHANNEL
	DEVCHR	K,			; CHECK IT
	TXNE	K,DV.TTY		; A TTY?
	 CLOSE	LST,			;[246] INSURE AT BOL FOR TTY
	GETSTS	MTA,K			;[246] FETCH TAPE STATS
	TXNE	K,IO.EOT		;[304] EOT?
	 MTREW.	MTA,			;[304] YES, REWIND TAPE
	PUSHJ	P,MTAERR		; TYPE IT
	 JRST	TYFL			;[246] DON'T RETRY
	JRST	RETR2			;[246] RETRY AGAIN
TYFL:	MTSKF.	MTA,			;[235] SKIP FILE
	AOS	P0,MTAPOS		; BUMP FILE COUNT
	MOVEI	W,(P0)			; LOAD FILE NUMBER
	MOVEI	K,(W)			; MAKE YET ANOTHER COPY
	LSH	K,1			; SCALE IT FOR DIRECTORIES
	MOVE	E,K			;[241] SINCE K GETS SMASHED
	TXNN	%,SW$ALL		; ALL?
	 SKIPE	DIRECT-2(K)		; NO, ANYTHING?
	  SKP				; YES, TYPE
	   JRST	SKIPIT			; NO, SKIP IT
	SKIPE	DIRECT-2(K)		; NO NUMBER MARY BETH
	 PUSHJ	P,DECJLS		; PRINT, RIGHT-JUSTIFIED
	MOVEI	W,.CHTAB		; TAB
	PUSHJ	P,TYPE			; TYPE
	MOVEI	BP,SPEC+.RBNAM		; FILE
	HLLZ	T0,SPEC+.RBEXT		; EXTENSION
	CAXN	T0,('UFD')		;[306] A UFD?
	 JRST	[MOVE	W,SPEC+.RBNAM	;[306] A LOSING ROUTINE
		 PUSH	P,SPEC+.RBPPN	;[306] SO SOME SEMI-MEANINGFUL
		 MOVEM	W,SPEC+.RBPPN	;[306] OUTPUT GOES TO THE LUSER
		 PUSHJ	P,LSTPPN	;[306] I HAVE NO INTENTION OF
		 POP	P,SPEC+.RBPPN	;[306] KLUDGING IT FURTHER TO
		 JRST	.+2]		;[306] MAKE UFD'S TYPE PRETTY!
	PUSHJ	P,SIXTY2		; TYPE IN FULL WORD
	MOVEI	W,"."			; LOAD A DOT
	PUSHJ	P,TYPE			; TYPE
	MOVEI	BP,T0			; POINTER
	MOVEI	I,4			; LOAD COUNT
	PUSHJ	P,SIXTY2+1		; TYPE
	MOVE	W,SPEC+.RBEST		; FILE SIZE
	SKIPE	DIRECT-2(E)		;[241] SEE IF DELETED
	 ADD	F,W			;[241] NO, ADD INTO ACTIVE COUNT
	PUSHJ	P,DECJLS		; TYPE
	MOVEI	BP,[ASCIZ@  <@]		;[235] INDENT FOR PROTECTION
	PUSHJ	P,ASCTYO		;[235] TYPE IT OUT
	MOVE	T0,SPEC+.RBPRV		;[235] LOAD PROTECTION WORD
	ANDX	T0,RB.PRV		;[235] ISOLATE PROTECTION
	LSH	T0,^D-27		;[235] RIGHT JUSTIFY
	PUSHJ	P,OCT3TO		;[235] TYPE PROTECTION
	MOVEI	BP,[ASCIZ@>	@]	;[235] END OF PROTECTION
	PUSHJ	P,ASCTYO		;[235] TYPE
	MOVE	T0,SPEC+.RBPRV		; LOAD TIME
	ANDX	T0,RB.CRT		;[234] GET CREATION TIME
	LSH	T0,^D-12		;[234] JUSTIFY IT OVER
	PUSHJ	P,TIMTYP		; TYPE IT
	MOVEI	W," "			; ABOUT HERE I GET REALLY SPACED OUT
	PUSHJ	P,TYPE			; SO SQUEEZE THE WHEEZE
	MOVE	BP,SPEC+.RBEXT		;[234] LOAD PART OF DATE
	ANDX	BP,RB.CRX		;[234] ISOLATE DATE75 BITS
	LSH	BP,-3			;[234] SHIFT IT OVER
	MOVE	T0,SPEC+.RBPRV		;[234] GET WITH REST OF DATE
	ANDX	T0,RB.CRD		;[234] GET CREATION DATE ALONE
	ORI	T0,(BP)			;[234] PUT TWO TOGETHER
	PUSHJ	P,DATTYP		; TYPE IT
	MOVEI	W,.CHTAB		;[223] TAB FOR STR
	PUSHJ	P,TYPE			;[223] TYPE
	MOVEI	BP,SPEC+.RBDEV		;[223] GET STR
	PUSHJ	P,SIXTYO		;[223] TYPE
	MOVEI	BP,[ASCIZ@:	@]	;[223] TAB FOR PPN
	PUSHJ	P,ASCTYO		;[223] TYPE
	PUSHJ	P,LSTPPN		;[306] SEE WHAT YOU MADE ME DO?
	MOVEI	BP,[ASCIZ@	File bad@]
	TXZE	%,SF$IOE		; AN I/O ERROR?(OH HORRORS!)
	 PUSHJ	P,ASCTYO		; INDICATE FILE I/O ERROR
	MOVEI	BP,CRLF			; LOAD A CRLF
	PUSHJ	P,ASCTYO		; TYPE
SKIPIT:	CAME	P0,NUMFLS		; SEE IF DONE
	 JRST	FILREP			; NOT YET
EOREP:	MOVEI	BP,[ASCIZ@
	Total of @]
	PUSHJ	P,ASCTYO
	MOVE	W,BLKS			; LOAD BLOCKS
	PUSHJ	P,DECLST		; TYPE
	MOVEI	W,"("			;[241] LEFT PAREN
	PUSHJ	P,TYPE			;[241] TYPE IT
	MOVE	W,F			;[241] ACTIVE COUNT
	PUSHJ	P,DECLST		;[241] TYPE IT
	MOVEI	BP,[ASCIZ@ active) blocks in @]
	PUSHJ	P,ASCTYO
	MOVE	W,NUMFLS		; LOAD FILES
	AOS	MTAPOS			;[170] BUMP MTA POSITION
	PUSHJ	P,DECLST		; TYPE
	MOVEI	BP,[ASCIZ@ files.
@]
	PUSHJ	P,ASCTYO
	CLOSE	LST,			; TERMINATE LISTING I/O
	PJRST	CPOPJ1			; RETURN

; ROUTINE TO PRINT OUT A PPN TO LST DEVICE

LSTPPN:	MOVEI	W,"["			;[306] LAB
	PUSHJ	P,TYPE			;[306] TYPE IT
	SKIPG	W,SPEC+.RBPPN		;[236] CHECK FOR SIXBIT
	 JRST	LSSXPN			;[236] LIST SIXBIT PPN
	HLRZ	W,SPEC+.RBPPN		;[223] GET PROJ
	PUSHJ	P,OCTLST		;[223] TYPE IT
	MOVEI	W,","			;[223] TYPE A COMMA
	PUSHJ	P,TYPE			;[223] TYPE IT
	HRRZ	W,SPEC+.RBPPN		;[223] GET PROG
	PUSHJ	P,OCTLST		;[223] TYPE IT
LSCSB:	MOVEI	W,"]"			;[223] GET CLOSING
	PJRST	TYPE			;[306] TYPE IT

; HERE IN CASE OF SIXBIT

LSSXPN:	MOVEI	BP,SPEC+.RBPPN		;[251] FIX BUG
	PUSHJ	P,SIXTYO		;[236] TYPE IN SIXBIT THEN
	JRST	LSCSB			;[236] BUSINESS AS USUAL
SUBTTL YANK Switch

YANK:	SKIPN	W,OUTDEV		; GET INPUT(?) DEVICE
	 MOVE	W,PHMTAN		; DEFAULT
	MOVEM	W,INDEV			; SAVE
	MOVE	D,W			; GET INPUT DEVICE
	DEVCHR	D,			; WHAT IT IS
	TXNN	D,DV.MTA		; IS IT AN MTA?
	 JRST	NTAMTA			; NO
	MOVE	T0,MTASTA		; DUMP MODE
	MOVEM	T0,INCH			; SAVE IT
	MOVX	T0,UU.PHS+.IODMP	; FORCE DISK
	MOVEM	T0,OUTCH		; SAVE IT
	OPEN	MTA,INCH		; OPEN TAPE
	 JRST	CTGTDV			; CAN'T
	PUSHJ	P,MTWAIT		; WAIT
	SKIPN	T0,POSFNO		; LOAD COUNTER
	 AOS	T0,POSFNO		; BUMP CAUSE ZERO
	ADDM	T0,MTAPOS		;[165] FIX POSITION
MORTGO:	MOVE	BP,MTLIST		; SET UP BP
	PUSHJ	P,MTAIN			; GET INPUT
	 JFCL				; IN CASE OF SKIP
	MOVSI	W,'DSK'			;[236] ASSUME NO STR
	TXNE	%,SW$OWN		;[236] OWNER?
	 MOVE	W,SPEC+.RBDEV		;[236] GET ORIGINAL STR
	MOVEM	W,OUTDEV		;[236] USE WHATEVER
	OPEN	DSK,OUTCH		;[236] GET A DDB
	 JRST	CTGTDV			;[236] CAN'T
	SKIPN	SPEC+.RBNAM		;[233] SEE IF FILE
	 JRST	ATDIR			;[233] NO, IT IS DIRECTORY
	TXNN	%,SW$OWN		;[233] OWNER?
	 SETZM	SPEC+.RBPPN		;[233] CLEAR PPN
	MOVE	T0,SPEC+.RBPPN		;[233] COPY PPN
	TXNE	%,SW$NVR		;[233] NEVER?
	 LOOKUP	DSK,SPEC		;[233] SEE IF THERE
	  SKP				;[233] NOT THERE OR NO NEVER
	   JRST	YNKBLK+1		;[233] DON'T DO IT
	MOVEM	T0,SPEC+.RBPPN		;[270] RESET PPN
	LDB	T0,MODPNT		;[270] GET FILE MODE
	SETSTS	DSK,(T0)		;[270] STATUS SETTING
	MOVE	T0,PROTCD		;[271] GET PROTECTION WORD
	TXNE	%,SW$PRO		;[271] A PROTECTION?
	 DPB	T0,PROTPT		;[271] YES, USE IT
	SETZM	SPEC+.RBEST		;[314] FIX 6.02 LOSSAGE
	SETZM	SPEC+.RBALC		;[314]  "   "      "
	SETZM	SPEC+.RBPOS		;[311] NO ENTER ERROR 20 PLEASE
	ENTER	DSK,SPEC		; MAKE THE FILE
	 JRST	YNKBLK			; CAN'T
	SETSTS	DSK,.IODMP		;[270] BACK TO DUMP
	TXNN	%,SW$SIL		;[233] SILENCE?
	 PUSHJ	P,GAB			;[233] NO, GAB
	PUSHJ	P,SENDSK		; GO INTO ONLINE ROUTINE
	 JFCL				; SHOULD NEVER HAPPEN
;	JRST	YNKRST			; RESTORE THE FILE
YNKRST:	SOSLE	POSFNO			; SEE IF MORE TO GO
	 JRST	MORTGO			; YES
	PJRST	CPOPJ1			; RETURN
YNKBLK:	PUSHJ	P,CTMKFL		;[233] YELL
	MTSKF.	MTA,			;[233] SKIP
	PUSHJ	P,MTWAIT		;[233] WAIT
	JRST	YNKRST			;[233] RESTART
ATDIR:	MOVE	BP,NUMFLS		;[234] LOAD NUMBER OF FILES
	AOJ	BP,			;[234] BUMP COUNTER
	MOVEM	BP,MTAPOS		;[234] SAVE POSITION
	PJRST	YNKFIN			;[234] RETURN
SUBTTL RUN Switch and Friendly Natives

RUNPRG:	SKIPN	SPEC+.RBNAM		; SEE IF ANY PROGRAM TO RUN
	 ERTYPE	['NPR',,[ASCIZ/No program to run/]]
	SKIPN	W,INDEV			; LOAD INPUT DEVICE
	 MOVSI	W,'SYS'			; ASSUME SYS
	EXCH	W,SPEC+.RBPPN		; SAVE AND GET PPN
	MOVEM	W,SPEC+.RBPPN+4		; PROPER PLACE FOR RUN UUO
	MOVEI	W,SPEC+.RBPPN		; LOAD EFFECTIVE ADDRESS
	HRL	W,RUNOFF		; LOAD OFFSET
	RUN	W,			; RUN THE PROGRAM
	 HALT				; LET MONITOR SAY WHY

; HERE TO FIX UP NEW CORE COMMAND

; /CORE WAS BROKEN BY EDIT 253, SINCE IT WOULD RESTORE ALL THE SPECS
; TO THE WAY THEY WERE(LIKE BARBARA S.'S SONG).  THEREFORE, THE
; TEMPCORE FILE MUST GO AWAY BEFORE WE TRY TO RE-READ IT.

CDROP:	MOVE	%,[.TCRDF,,TMPSPC]	;[254] LOAD A READ&DELETE SPEC
	TMPCOR	%,			;[254] ZAK!
	 JFCL				;[254] SO I DIDN'T HAVE TO DO IT
	SETZM	TAPEID			;[266] CLEAR NECESSARY THINGS
	SETZM	NUMFLS			;[266] . . .
	SETZM	MTAPOS			;[266] . . .
	JRST	KORE			;[254] DO LIKE BEFORE HUN

; OH YEAH, I REALIZE THIS IS A STRANGE(!) PLACE TO PUT THIS CODE, BUT...

; HERE TO PROCESS !ABORT

ABORT:	TXNN	%,SF$DNA		;[275] AT "!" LEVEL?
	 ERTYPE	['NAE',,[ASCIZ/Not at "!" level/]]
	MOVE	T0,ACS			;[275] GET VIRGIN "%"
	TXNN	T0,SF$DMO		;[275] HAVE I DONE ANYTHING?
	 JRST	RENADR			;[275] ABORTED!
	SETZM	SPEC+.RBNAM		;[275] YES, PREVENT MORE...
	SETZM	SPEC+.RBEXT		;[275] . . .
	SETZM	ACS+M1			;[275] . . .
	SETZM	ACS+M2			;[275] . . .
	SETZM	SPCCNT			;[275] NO MORE SPECS!!!!!!
	TXO	%,SW$OKN		;[275] JUST TO BE CUTE
	ORM	%,ACS			;[275] TO REAL "%"
	ERTYPE	ER$WRN,['ARI',,[ASCIZ/Abort Request Initiated/]]
SUBTTL HELP Switches

HELP:	MOVSI	T0,-NUMCOM		; LOAD COMMAND TABLE AOBJN WORD
	OUTSTR	[ASCIZ/Options:/]	; TYPE MESSAGE
	TRNN	T0,7			; 8 TYPED?
	 SKIPA	T1,CRLF			; CRLF
	  MOVSI	T1,(ASCIZ/	/)	; TAB
	OUTSTR	T1			; TYPE
	MOVE	T1,FLGTAB(T0)		;[234] LOAD FLAGS
	TXNN	T1,SF$NOK		;[234] SEE IF LEGAL
	 OUTCHR	["!"]			;[234] LEGAL
	MOVE	W,COMTAB(T0)		; LOAD SWITCH
	PUSHJ	P,SIXLST		; TYPE IT
	AOBJN	T0,HELP+2		; NEXT
	OUTSTR	[ASCIZ/
! Means legal in "!" mode
/]
	JRST	CPOPJ1			; RETURN

; HERE TO TYPE HELP OR BUG FILE

INFO:	MOVX	W,'MARS  '		; LOAD HELP FILE NAME
	MOVEM	W,SPEC+.RBNAM		; SAVE AWAY
	MOVSI	W,'HLP'			; LOAD EXTENSION
	TXNE	%,SW$BUG		;[244] TYPE .BUG FILE?
	 MOVSI	W,'BUG'			;[244] YES
	MOVEM	W,SPEC+.RBEXT		; SAVE AWAY
	MOVE	W,HLPPPN		; LOAD HELP PPN
	MOVEM	W,SPEC+.RBPPN		; GUESS
	MOVE	T0,[-DTBLEN,,DEVTAB]	; LOAD DEVICE TABLE AOBJN WORD
HLPDEV:	MOVX	W,UU.PHS+.IODMP		; LOAD STATUS WORD
	MOVEM	W,INCH			; PACK IT AWAY
	MOVE	W,(T0)			; LOAD DEVICE NAME
	MOVEM	W,INDEV			; SAVE IT AWAY
	TLNN	T0,1			; SEE IF THE ATTRACTION'S PHYSICAL
	 HRRZS	INCH			; NO, WE MUST BE LOGICAL ABOUT THE WHOLE THING
	OPEN	DSK,INCH		; GOBBLE THE DEVICE
	 JRST	BLEWIT			; YOU BLEW IT MARYBETH
	LOOKUP	DSK,SPEC		; GET THE FILE
	 JRST	BLEWIT			; TRY AGAIN MARYBETH
	MOVE	BP,MTLIST		; LOAD COMMAND WORD
	SETZ	BP+1,			; LOAD STOP CODE
	INPUT	DSK,BP			; 10 BLOCKS IS PLENTY
	OUTSTR	BUFR			; TYPE THE THING OUT
	PJRST	CPOPJ1			; I FORGIVE YOU
BLEWIT:	AOBJN	T0,HLPDEV		; DO I HAVE ANOTHER CHANCE WITH HER?
	TXNE	%,SW$BUG		;[244] TRIED .BUG FILE?
	 ERTYPE	ER$WRN,['NBK',,[ASCIZ/No bugs known in this version/]]
	ERTYPE	ER$WRN,['NHF',,[ASCIZ/No help file found; I'm sorry I can't help you/]]
DEVTAB:	('DSK')
	('HLP')
	('HLP')
	('SYS')
	('SYS')
DTBLEN==.-DEVTAB
SUBTTL WHAT Switch

WHAT:	OUTSTR	[ASCIZ/MARS %/]		; TYPE WHAT I AM
	LDB	I,MAJVER		; FOR MAJOR
	PUSHJ	P,OCTTYO		; TYPE IT
	LDB	I,MINVER		; FOR MINOR
	IDIVI	I,^D27			; SEPARATE
	JUMPE	I,.+4			; NO HO(A)RD(ED) WORD
	ADDI	D,(I)			;[171] CORRECT CHARACTER
	MOVEI	I,"@"(I)		; ASCIIIFY
	OUTCHR	I			; TYPE THE BEASTIE
	JUMPE	D,.+3			; NO LORD WORD
	MOVEI	D,"@"(D)		; ASCIIIFY
	OUTCHR	D			; TYPE IT ALL OUT
	HRRZ	I,.JBVER		; LOAD EDIT THING
	JUMPE	I,.+4			; NO EDIT
	OUTCHR	["("]			; GUESS
	PUSHJ	P,OCTTYO		; TYPE
	OUTCHR	[")"]			; GUESSED WRONG
	LDB	I,WHOVER		; LOAD CUSTOMER
	JUMPE	I,.+3			; NONE
	OUTCHR	["-"]			; IS SOME
	PUSHJ	P,OCTTYO		; TYPE
	OUTSTR	CRLF			; CRLF
	TXNN	%,SF$DIC		; SEE IF A DIRECTORY IN CORE
	 JRST	NODIC			; NO DIRECTORY IN CORE
	OUTSTR	[ASCIZ/Tape ID: /]
	MOVE	W,TAPEID		; LOAD TAPE ID
	PUSHJ	P,SIXLST		; TYPE
	OUTSTR	[ASCIZ/, file=/]
	MOVE	I,MTAPOS		; LOAD POSITION
	PUSHJ	P,DECTYO		; TYPE IT
	SKP				; FASTEST SKIP MARYBETH
NODIC:	 ERTYPE	ER$WRN!ER$RTN,['NDC',,[ASCIZ/No directory in core/]]
	OUTSTR	CRLF			; CRLF
	OUTSTR	[ASCIZ/Processor=/]
	MOVE	W,PRCTYP		;[263] FETCH PROCESSOR TYPE
	PUSHJ	P,SIXLST		;[263] TYPE IT
	OUTSTR	[ASCIZ/, Unit=/]
	MOVE	W,PHMTAN		; LOAD PHYSICAL NAME
	PUSHJ	P,SIXLST		; TYPE
	OUTSTR	[ASCIZ/, write-/]
	MOVE	W,PHMTAN		; LOAD NAME
	MTCHR.	W,			; CHARS
	 SETZ	W,			; DEFAULT
	TXNE	W,MT.WLK		; SEE IF WRITE LOCKED
	 SKIPA	BP,[[ASCIZ/locked, /]]
	  MOVEI	BP,[ASCIZ@enabled, @]
	OUTSTR	(BP)			; TYPE RIGHT THING
	PUSH	P,W			; SAVE WORD
	ANDX	W,MT.DEN		; JUST THAT
	MOVX	I,^D800			; DEFAULT
	CAXN	W,.MTDN2		; 200 BPI?
	 MOVX	I,^D200			; YUP
	CAXN	W,.MTDN5		; 556 BPI?
	 MOVX	I,^D556			; YESSIR
	CAXN	W,.MTD16		;[235] 1600 BPI?
	 MOVX	I,^D1600		;[235] YES MARYBETH
	PUSHJ	P,DECTYO		; TYPE
	MOVEI	BP,[ASCIZ@ BPI, @]	; MESSAGE
	OUTSTR	(BP)			; TYPE MESSAGE
	POP	P,W			; GET BACK
	TXNE	W,MT.7TR		; SEE IF 7TRACK
	 SKIPA	BP,["7"]		; 7TRACK
	  MOVEI	BP,"9"			; 9TRACK
	OUTCHR	BP			; TYPE
	OUTSTR	[ASCIZ/-track
/]
	OUTSTR	@MRSSTA			; TYPE MARS STATUS MESSAGE
	PJRST	CPOPJ1			; RETURN

; VERSION BYTE POINTERS (THIS WAY 'CAUSE OF A MACRO BUG)

MAJVER:	POINTR	.JBVER,VR.VER		; MAJOR VERSION
MINVER:	POINTR	.JBVER,VR.MIN		; MINOR VERSION
WHOVER:	POINTR	.JBVER,VR.WHO		; WHO VERSION

MAJT0V:	POINTR	T0,VR.VER
MINT0V:	POINTR	T0,VR.MIN
WHOT0V:	POINTR	T0,VR.WHO
SUBTTL I/O Subroutines and Friends

; HERE TO TYPE OUT A NUMBER

DECLST:	SKIPA	K,[^D10]		; SET NUMBER BASE
OCTLST:	 MOVEI	K,^D8			; SET NUMBER BASE
	IDIVI	W,(K)			; DIVIDE
	PUSH	P,W+1			; SAVE REMAINDER
	CAIE	W,			; FASTER THAN SKIPE
	 PUSHJ	P,OCTLST+1		; NO, KEEP ON GOIN'
	POP	P,W			; GET IT BACK
	MOVEI	W,"0"(W)		; ASCII CONVERSION
	PUSHJ	P,TYPE			; TYPE A CHARACTER
	POPJ	P,			; RETURN

; HERE TO GET AN OCTAL NUMBER

GETANM:	INCHWL	B			; GET A CH
	SETZB	W,K			; CLEAR THING
	CAIN	B,"*"			;[223] SEE IF *
	 JRST	FULWLP			;[223] FULL WILD PPN
	CAIN	B,"?"			;[223] SEE IS ?
	 PUSHJ	P,QMWLP			;[223] ? WILD PPN
	CAIL	B,"0"			; TOO LOW?
	 CAILE	B,"7"			; TOO HIGH?
	  JRST	NOPPNH			; FOURTH DOWN, ARE YOU KICKIN'?
OCTAL:	LSH	K,3			;[223] SHIFT MASK OVER
	LSH	W,3			; MULTIPLY BY 8
	ADDI	W,-"0"(B)		; ADD TOGETHER
	INCHWL	B			; AGAIN
	CAIN	B,"?"			;[223] SEE IF ?
	 PUSHJ	P,QMWLP			;[223] ? WILD PPN
	CAIL	B,"0"			; TOO LOW?
	 CAILE	B,"7"			; TOO HIGH?
	  SKP				; TO RETURN
	   JRST	OCTAL			; LOOP FOR MORE
	LSH	K,-3			; ZAK BACK
	POPJ	P,			; RETURN
FULWLP:	MOVEI	W,377777		; WILD PPN
	MOVEI	K,-1			; WILD MASK
	INCHWL	B			; GOBBLE NEXT
	POPJ	P,			; RETURN TO MAIN
QMWLP:	MOVEI	B,"7"			; WILD PART
	MOVEI	K,7(K)			; PUT IN MASK
	POPJ	P,			; RETURN
NOPPNH:	HRRZ	T0,(P)			;[246] FETCH PC W/O FLAGS
	GETPPN	W,			;[246] GET MY PPN
	 JFCL				;[246] (IN CASE OF JACCT)
	CAIN	T0,PROJC+1		;[246] SEE IF PROJECT
	 MOVSS	W			;[246] YES, SWAP
	HRRZS	W			;[246] ISOLATE RH
	POPJ	P,			;[246] RETURN
; HERE FOR LISTING SUBROUTINES

TYPE:	SOSG	OUTCH+.BFCTR		; BEYOND BUFFER?
	 OUTPUT	LST,			; YEAH
	IDPB	W,OUTCH+.BFPTR		; WRITE IT NOW
	POPJ	P,			; GO BACK

SIXTYO:	MOVEI	I,6			; SET NUMBER OF CHARACTERS
	HRLI	BP,(POINT 6,0)		; TYPE IN SIXBIT
	ILDB	W,BP			; GET A CHARACTER
	JUMPE	W,CPOPJ			; RETURN IF ZERO
	MOVEI	W," "(W)		; CONVERT TO ASCII
	PUSHJ	P,TYPE			; TYPE IT OUT
	SOJG	I,SIXTYO+2		; RETURN FOR MORE
	POPJ	P,			; (IN CASE OF 6)

SIXTY2:	MOVEI	I,6			; LOAD COUNT
	HRLI	BP,(POINT 6,0)		; LOAD BP
	ILDB	W,BP			; LOAD CH
	MOVEI	W," "(W)		; ASCII
	PUSHJ	P,TYPE			; TYPE
	SOJG	I,SIXTY2+2		; LOOP
	POPJ	P,			; RETURN

ASCTYO:	HRLI	BP,(POINT 7,0)		; TYPE IN ASCII
	ILDB	W,BP			; GET A CHARACTER
	JUMPE	W,CPOPJ			; RETURN IF DONE
	PUSHJ	P,TYPE			; TYPE IT
	JRST	ASCTYO+1		; LOOP FOR MORE

; HERE TO GET SOME MORE CORE IF NEEDED

PANIC:	MOVEI	T0,BKSZ(BP)		; GET CORE NEEDED
PANIC1:	CAMG	T0,.JBREL		; ARE WE OKAY?
	 POPJ	P,			; YES, RETURN
	CORE	T0,			; GET SOME CORE
	 ERTYPE	['COR',,[ASCIZ/Insufficient core/]]
	POPJ	P,			; GOT IT!

; HERE TO HANDLE SKIP AND NON-SKIP RETURNS

TPOPJ1:	POP	P,T0			; DROP FIRST
CPOPJ1:	AOSA	(P)			; INCREMENT RETURN ADDRESS
TPOPJ:	 POP	P,T0			; DROP FIRST
CPOPJ:	POPJ	P,			; RETURN
; HERE TO TYPE A DATE IN T0

DATTYP:	IDIVI	T0,^D31			; EXTRACT DAYS
	MOVEI	W," "			; LOAD A SPACE
	CAIGE	T1,^D9			; SEE IF TO TYPE
	 PUSHJ	P,TYPE			; YES
	MOVEI	W,1(T1)			; COMPUTE AND COPY
	PUSHJ	P,DECLST		; TYPE IT
	IDIVI	T0,^D12			; DIVIDE
	MOVEI	BP,MNTAB(T1)		; GET APPROPRIATE MONTH
	PUSHJ	P,SIXTYO		; TYPE IT OUT
	MOVEI	W,^D64(T0)		; GET YEAR
	PUSHJ	P,DECLST		; TYPE IT
	POPJ	P,			; RETURN TO CALLER

; HERE TO TYPE THE TIME

MSTTYP:	IDIVI	T0,^D60000		;[235] TO MINUTES
TIMTYP:	IDIVI	T0,^D60			; HOURS AND MINUTES
	CAIL	T0,^D10			; AN EXTRA ZERO?
	 JRST	TYHOUR			; NO, MAN
	MOVEI	W,"0"			; LOAD 0
	PUSHJ	P,TYPE			; TYPE IT
TYHOUR:	MOVEI	W,(T0)			; LOAD HOURS
	PUSHJ	P,DECLST		; TYPE 'EM
	MOVEI	W,":"			; LOAD :
	PUSHJ	P,TYPE			; SHOW 'EM YOUR STUFF
	CAIL	T1,^D10			; ANOTHER EXTRA ZERO?
	 JRST	TYMINU			; NO WAY
	MOVEI	W,"0"			; LOAD 0
	PUSHJ	P,TYPE			; DISPLAY YOUR WARES
TYMINU:	MOVEI	W,(T1)			; LOAD MINUTES
	PUSHJ	P,DECLST		; DISPLAY
	POPJ	P,			; RETURN

; HERE TO TYPE OUT W<100000 RIGHT JUSTIFIED, DECIMAL

DECJLS:	MOVEI	T1,(W)			; SAVE OUR W!
	MOVEI	W," "			; LOAD A SPACE
	CAIGE	T1,^D10000		;[246] SPACE 0 (?)
	 PUSHJ	P,TYPE			;[246] SPACE
	CAIGE	T1,^D1000		; SPACE 1
	 PUSHJ	P,TYPE			; SPACE
	CAIGE	T1,^D100		; #2
	 PUSHJ	P,TYPE			; TYPE
	CAIGE	T1,^D10			; #3
	 PUSHJ	P,TYPE			; TYPE
	MOVEI	W,(T1)			; RELOAD
	PJRST	DECLST			; TYPE NUMBER
; HERE TO TYPE A VERSION NUMBER IN T0

VERLST:	LDB	W,MAJT0V		; FOR MAJOR
	PUSHJ	P,OCTLST		; TYPE
	LDB	I,MINT0V		; FOR MINOR
	IDIVI	I,^D27			; SEPARATE
	JUMPE	I,.+4			; NO FIRST
	ADDI	D,(I)			;[171] CORRECT SECOND CHARACTER
	MOVEI	W,"@"(I)		; ASCIIIFY
	PUSHJ	P,TYPE			; TYPE
	JUMPE	D,.+3			; NO SECOND(S)
	MOVEI	W,"@"(D)		; ASCII
	PUSHJ	P,TYPE			; TYPE
	MOVEI	I,(T0)			;[172] EDIT
	JUMPE	I,NOEDIT		; NONE
	MOVEI	W,"("			; GUESS
	PUSHJ	P,TYPE			; GUESS
	MOVEI	W,(I)			; LOAD EDIT
	PUSHJ	P,OCTLST		; TYPE
	MOVEI	W,")"			; GUESS
	PUSHJ	P,TYPE			; GUESS
NOEDIT:	LDB	I,WHOT0V		; FOR CUSTOMER
	JUMPE	I,CPOPJ			; NONE
	MOVEI	W,"-"			; GUESS
	PUSHJ	P,TYPE			; TYPE
	MOVEI	W,(I)			; LOAD CUSTOMER
	PUSHJ	P,OCTLST		; TYPE
	POPJ	P,			; RETURN

; HERE TO GET A DECIMAL NUMBER

GETADN:	INCHWL	B			; GET A CH
	CAIL	B,"0"			; NON-NUMERIC?
	 CAILE	B,"9"			; DITTO?
	  JRST	NOARG			; UGH!
	SETZ	W,			; CLEAR W
DECMAL:	IMULI	W,^D10			; MULTIPLY BY 10
	ADDI	W,-"0"(B)		; ADD IT IN
	INCHWL	B			; GET ANOTHER
DECKLG:	CAIL	B,"0"			; NON-NUMERIC?
	 CAILE	B,"9"			; ' '
	  POPJ	P,			; RETURN
	JRST	DECMAL			; LOOP FOR MORE

; HERE TO TYPE OUT T0 IN 3-DIGIT OCTAL

OCT3TO:	MOVEI	W,"0"			;[235] LOAD DEFAULT
	CAIGE	T0,100			;[235] SEE IF ANY PROG
	 PUSHJ	P,TYPE			;[235] TYPE
	CAIGE	T0,10			;[235] SEE IF ANY PROJ
	 PUSHJ	P,TYPE			;[235] TYPE
	MOVEI	W,(T0)			;[235] COPY OVER
	PJRST	OCTLST			;[235] TYPE REST
DSKIN:	MOVEI	K,[ASCIZ@DSK I/O wait
@]
	MOVEM	K,MRSSTA		; SAVE AS STAT
	PUSHJ	P,EXPINP		; CHECK FOR ! STUFF
	SETZ	BP+1,			; PARANOIA CODE
	IN	DSK,BP			; DO INPUT
	 POPJ	P,			; NORMAL: RETURN
	STATO	DSK,IO.DTE!IO.BKT!IO.EOT!IO.DER!IO.IMP
	 JRST	CPOPJ1			; EOF RETURN
	ERTYPE	ER$WRN!ER$RTN,['IOE',,[ASCIZ!DSK I/O error during !]]
	PUSHJ	P,FILTYP		; TYPE IT
	STATZ	DSK,IO.EOF		; EOF?
	 JRST	CPOPJ1			; SKIP
	POPJ	P,			; NORMAL
DSKOUT:	MOVEI	K,[ASCIZ@DSK I/O wait
@]
	MOVEM	K,MRSSTA		; SAVE AS STAT
	PUSHJ	P,EXPINP		; CHECK FOR ! STUFF
	SETZ	BP+1,			; PARANOIA CODE
	OUT	DSK,BP			; DO OUTPUT
	 POPJ	P,			; OKAY
	ERTYPE	ER$WRN!ER$RTN,['IOE',,[ASCIZ!DSK I/O error during !]]
	PJRST	FILTYP			; TYPE IT

MTAIN:	MOVEI	K,[ASCIZ@MTA I/O wait
@]
	MOVEM	K,MRSSTA		; SAVE AS STAT
	PUSHJ	P,EXPINP		; CHECK FOR ! STUFF
RETR3:	SETZ	BP+1,			; PARANOIA CODE
	IN	MTA,BP			; DO INPUT
	 POPJ	P,			; NORMAL
	GETSTS	MTA,K			; GET STATUS
	TXNN	K,IO.DTE!IO.BKT!IO.EOT!IO.DER!IO.IMP
	 JRST	CPOPJ1			;[300] EOF RETURN
	TXNE	K,IO.EOT		;[304] EOT?
	 MTREW.	MTA,			;[304] REWIND TAPE
	PUSHJ	P,MTAERR		; REPORT
	 POPJ	P,			;[300] RETURN
	  JRST	RETR3			;[246] THIRD RETURN
MTAOUT:	PUSHJ	P,EXPINP		; CHECK FOR !
	MOVEI	K,[ASCIZ@MTA I/O wait
@]
	MOVEM	K,MRSSTA		; SAVE AS STAT
	PUSHJ	P,EXPINP		; CHECK FOR ! STUFF
RETR4:	SETZ	BP+1,			; PARANOIA CODE
	TXO	%,SF$DMO		; INFORM WHAT WE HAVE DONE
	OUT	MTA,BP			; DO OUTPUT
	 POPJ	P,			; RETURN
	GETSTS	MTA,K			; GET STATUS
	TXNE	K,IO.EOT		;[304] EOT?
	 MTREW.	MTA,			;[304] REWIND TAPE
	PUSHJ	P,MTAERR		; REPORT ERROR
	 POPJ	P,			; RETURN
	  JRST	RETR4			;[246] FOURTH RETRY
; HERE TO WAIT FOR MTA

MTWAIT:	PUSH	P,K			; IN CASE
	MOVEI	K,[ASCIZ/MTA positioning wait
/]
	movem	k,MRSsta		; save
	pop	p,k			; in case
	PUSHJ	P,EXPINP		; CHECK FOR ! STUFF
	MTWAT.	MTA,			; WAIT A LONG TIME
	PUSHJ	P,EXPINP		; TO BE SURE
	POPJ	P,			; RETURN

; HERE FOR TYPING OUT A NUMBER ALWAYS TO TTY:

DECTYO:	SKIPA	K,[^D10]		; SET NUMBER BASE
OCTTYO:	 MOVEI	K,^D8			; SET NUMBER BASE
	IDIVI	I,(K)			; DIVIDE SO WE CAN GET REMAINDER
	PUSH	P,I+1			; SAVE IT
	CAIE	I,			; SKIP IF =0
	 PUSHJ	P,OCTTYO+1		; KEEP ON TRUCKIN'
	POP	P,I			; GET CHARACTER BACK
	MOVEI	I,"0"(I)		; WE WANT ASCII
	OUTCHR	I			; TYPE IT
	POPJ	P,			; RETURN

; HERE TO TYPE OUT A FILE SPEC

FILTYP:	MOVE	W,SPEC+.RBNAM		; GET FILE
	CAXN	W,'______'		;[302] WILD FILE?
	 JRST	[OUTSTR	[ASCIZ/*./]	;[302] TYPE FILE
		 JRST	.+6]		;[302] CONTINUE
	HLLZ	B,SPEC+.RBEXT		;[306] PEEK AT EXT
	CAXN	B,('UFD')		;[306] A UFD?
	 PJRST	UFDSPC			;[306] U F D ! ! !
	PUSHJ	P,SIXLST		; TYPE
	OUTCHR	["."]			; TYPE A DOT
	HLLZ	W,SPEC+.RBEXT		; GET EXT
	CAXN	W,('___')		;[302] WILD EXT?
	 JRST	[OUTCHR	["*"]		;[302] TYPE WILD EXT
		 JRST	PPNTYP]		;[302] TYPE PPN
	PUSHJ	P,SIXLST		; TYPE
PPNTYP:	HLRZ	I,SPEC+.RBPPN		;[223] GET PROJ
	JUMPE	I,FTYRTN		;[223] DON'T TYPE [0,0]
	OUTCHR	["["]			;[223] TYPE OPEN BRACKET
	SKIPG	W,SPEC+.RBPPN		;[236] SEE IF SIXBIT
	 JRST	SXPPNT			;[236] MAKE SIXBIT
	PUSHJ	P,OCTTYO		;[223] TYPE PROJ
	OUTCHR	[","]			;[223] TYPE COMMA
	HRRZ	I,SPEC+.RBPPN		;[223] GET PROG
	PUSHJ	P,OCTTYO		;[223] TYPE PROG
	OUTCHR	["]"]			;[223] TYPE CLOSING
FTYRTN:	OUTSTR	CRLF			; CRLF
	POPJ	P,			; RETURN
SXPPNT:	PUSHJ	P,SIXLST		;[236] TYPE IN SIXBIT
	JRST	FTYRTN-1		;[236] CONTINUE
; HERE TO TYPE OUT VARIOUS ERROR MESSAGES

CTMKFL:	ERTYPE	ER$WRN!ER$RTN,['ENT',,[ASCIZ/Can't create file /]]
	PUSHJ	P,ERRCOD		;[313] TYPE ERROR CODE
	MOVE	W,OUTDEV
	JRST	GAB+1
CTACFL:	TXNE	%,SW$OKN		;[257] /OKNONE?
	 POPJ	P,			;[257] YES, NOT AN ERROR
	ERTYPE	ER$WRN!ER$RTN,['LKP',,[ASCIZ/Can't access file /]]
	PUSHJ	P,ERRCOD		;[313] TYPE ERROR CODE
GAB:	MOVE	W,INDEV			; LOAD DEVICE
	PUSHJ	P,SIXLST		; TYPE IT
	OUTCHR	[":"]			; TYPE COLON DEAR
	PUSHJ	P,FILTYP		; TYPE OFFENDER
PRMTTN:	TXNE	%,SF$EXP		; ! MODE?
	 OUTCHR	["!"]			; YES
	POPJ	P,			; RETURN
CTGTDR:	ERTYPE	ER$WRN!ER$RTN,['UFD',,[ASCIZ/Can't access UFD /]]
	MOVE	W,INDEV			; GET DEV
	PUSHJ	P,SIXLST		; TYPE
	OUTCHR	[":"]			; COLON MARYBETH
	PUSHJ	P,PPNTYP		; TYPE PPN
	JRST	PRMTTN			; RETURN
CTGTDV:	ERTYPE	ER$RTN,['OPN',,[ASCIZ/Can't access device /]]
	JRST	WHTBLK
NTAMTA:	ERTYPE	ER$RTN,['NMT',,[ASCIZ/Not an mta: /]]
	JRST	WHTBLK

; HERE TO GET A PROTECTION CODE

GTPROT:	SETZ	W,			;[271] CLEAR WORD
	PUSHJ	P,GETPCH		;[271] GET OWNER
	PUSHJ	P,GETPCH		;[271] GET PROJECT
	PUSHJ	P,GETPCH		;[271] GET OTHERS
	MOVEM	W,PROTCD		;[271] SAVE PROTECTION CODE
	PUSHJ	P,GRNGCH		;[271] GOBBLE NEXT CH
	 JFCL				;[271] (IN CASE OF SKIP)
	POPJ	P,			;[271] RETURN

GETPCH:	LSH	W,3			;[271] SHIFT WORD OVER
	INCHWL	B			;[271] GET A CHAR
	CAIL	B,"0"			;[271] CHECK
	 CAILE	B,"7"			;[271] FOR VALIDITY
	  JRST	SYNERR			;[271] SYNTAX ERROR
	ADDI	W,-"0"(B)		;[271] ADD IT IN
	POPJ	P,			;[271] RETURN

; HERE IF FILTYP'D FILE IS A UFD(TO TYPE PRETTY(?))

UFDSPC:	PUSH	P,SPEC+.RBPPN		;[306] SAVE THAT PPN SPEC
	MOVEM	W,SPEC+.RBPPN		;[306] FAKE OUT LUSER
	PUSHJ	P,PPNTYP		;[306] TYPE IT SOMEHOW
	POP	P,SPEC+.RBPPN		;[306] RESTORE PPN
	POPJ	P,			;[306] RETURN TO CALLER
; HERE TO REPORT AN MTA ERROR

MTAERR:	PUSH	P,T1			;[303] PREVENT HALT'S!!!!!!!!!
	PUSH	P,K			;[246] SAVE FLAGS
	PUSH	P,BP			;[246] SAVE IOWD POINTER!!
	PUSHJ	P,$MTERR		;[246] TYPE ERROR MESSAGE
	POP	P,BP			;[246] RESTORE IOWD POINTER
	POP	P,K			;[246] RESTORE FLAGS
	POP	P,T1			;[303] RESTORE T1!!!!!!!!!!!
	TXNN	K,IO.EOT!IO.IMP		;[246] SEE IF RETRYABLE
	 JRST	PRMTTN			;[246] GUESS NOT
	OUTCHR	["!"]			;[303] FAKE PROMPT
	AOBJP	P,.+1			;[303] "RE-PUSH" T1
	TXNE	K,IO.EOT		;[274] EOT?
	 ERTYPE	ER$RTN!ER$INT!ER$FUL,['MNT',,[ASCIZ/Mount new tape/]]
	TXNE	K,IO.IMP		;[274] WRITE LOCK?
	 ERTYPE	ER$RTN!ER$INT!ER$FUL,['MWR',,[ASCIZ/Mount write ring/]]
	OUTSTR	[ASCIZ/ -- Type <CR> when ready
/]
	TXZ	%,SF$DMO		;[276] DESTRUCTION ON /ABORT!
	POP	P,T1			;[303] RESTORE VITAL T1
	OUTCHR	["\"]			;[303] SPECIAL PROMPT
	PJRST	WATKLG			;[274] GO WAIT HUN
$MTERR:	TXNE	K,IO.DTE		; DATA TRANSMISSION ERROR
	 ERTYPE	ER$WRN!ER$RTN,['DTE',,[ASCIZ/MTA parity error/]]
	TXNE	K,IO.BKT		; BLOCK TOO LARGE
	 ERTYPE	ER$WRN!ER$RTN,['BKT',,[ASCIZ/MTA block too large/]]
	TXNE	K,IO.EOT		; END OF TAPE
	 ERTYPE	ER$WRN!ER$RTN,['EOT',,[ASCIZ/MTA at end of tape/]]
	TXNE	K,IO.DER		; DEVICE ERROR
	 ERTYPE	ER$WRN!ER$RTN,['DER',,[ASCIZ/MTA device error/]]
	TXNE	K,IO.IMP		; IMPROPER
	 ERTYPE	ER$WRN!ER$RTN,['IMP',,[ASCIZ/MTA write lock/]]
	TXNE	K,IO.EOF		; EOF?
	 ERTYPE	ER$WRN!ER$RTN,['EOF',,[ASCIZ/Spurious End of File/]]
	TXNE	T1,JW.WFL		; TYPE MORE?
	 OUTSTR	[ASCIZ/ during /]
	TXZN	%,SF$DDR		; A DIRECTORY ERROR?
	 JRST	FILTYP			; NO
	OUTSTR	[ASCIZ/directory
/]
	POPJ	P,			; RETURN

ERRCOD:	OUTCHR	["("]			;[313] LEFT PAREN PLS
	HRRZ	I,SPEC+.RBEXT		;[313] LOAD ERROR CODE
	PUSHJ	P,OCTTYO		;[313] TYPE CODE IN OCTAL
	OUTSTR	[ASCIZ/) /]		;[313] FINISH OFF
	POPJ	P,			;[313] AND RETURN
SUBTTL Processor Type Fetcher

GETPRC:	JUMPPT	W,CP166,KA10,KI10,KL10	;[263] JUMP ON PROCESSOR TYPE

; HERE IF PDP-6

CP166:	MOVX	W,'PDP-6 '		;[263] I'M A PDP-6
	MOVEM	W,PRCTYP		;[263] SAVE IT
	POPJ	P,			;[263] RETURN

; HERE IF KA-10

KA10:	MOVX	W,'PDP10A'		;[263] I'M A PDP-10 KA
	MOVEM	W,PRCTYP		;[263] SAVE IT
	POPJ	P,			;[263] RETURN

; HERE IF KI-10

KI10:	MOVX	W,'PDP10I'		;[263] I'M A PDP-10 KI
	MOVEM	W,PRCTYP		;[263] SAVE IT
	POPJ	P,			;[263] RETURN

; HERE IF KL-10

KL10:	MOVX	W,'PDP10L'		;[263] I'M A PDP-10 KL (WOW!)
	MOVEM	W,PRCTYP		;[263] SAVE IT
	POPJ	P,			;[263] RETURN
SUBTTL APR and Error Trap Routines

; HERE TO SET TRAPS

SETTRP:	MOVEI	T0,APRTRP		;[277] GET ADDR OF ARP TRAP ROUTINE
	MOVEM	T0,.JBAPR		;[277] SET TRAP UP
	MOVX	T0,AP.REN!AP.POV!AP.ILM!AP.NXM!AP.PAR
	APRENB	T0,			;[277] ENABLE THE APR
	MOVEI	T0,INTBLK		;[277] SET UP TRAP
	MOVEM	T0,.JBINT		;[277] . . .
	MOVE	T0,[4,,ERRTRP]		;[277] BLOCK SIZE,,TRAP ROUTINE
	MOVEM	T0,INTBLK+.ERNPC	;[277] SAVE IT
	MOVX	T0,ER.MSG!ER.IDV	;[277] TRAP PROBLEM ON DEVICE
	MOVEM	T0,INTBLK+.ERCLS	;[277] SET WHAT TO TRAP
	SETZM	INTBLK+.EROPC		;[277] IT WON'T DO IT UNLESS CLEAR
	SETZM	INTBLK+.ERCCL		;[277] CLEAR INFO CODES
	POPJ	P,			;[277] ** TRAPS SET **

; HERE TO HANDLE ERROR TRAPS

ERRTRP:	PUSH	P,INTBLK+.EROPC		;[277] SAVE MY PC
	SETZM	INTBLK+.EROPC		;[277] CLEAR SO IT WILL DO IT AGAIN
	MOVEM	P,INTACS+P		;[305] SAVE PDP
	MOVEI	P,INTACS		;[305] LOAD BLT POINTER
	BLT	P,INTACS+16		;[305] ZAK!
	MOVE	P,INTACS+P		;[305] RETRIEVE PDP
	ERTYPE	ER$RTN,['DNR',,[ASCIZ/Device not Ready: /]]
	HRRZ	W,INTBLK+.ERCCL		;[277] GET CHANNEL
	DEVNAM	W,			;[277] GET NAME
	 JFCL				;[277] EEK!!
	PUSHJ	P,SIXLST		;[305] TYPE IT
	MONRT.				;[305] RETURN TO TOPS-10
	OUTSTR	CRLF			;[277] CR/LF COMBINATION
	MOVSI	P,INTACS		;[305] LOAD BLT POINTER
	BLT	P,P			;[305] RESTORE ACS
	POPJ	P,			;[277] RETURN

; HERE TO HANDLE APR TRAPS

APRTRP:	MOVEI	P,.JBDA			;[277] IN CASE OF PDL OV
	OUTSTR	[ASCIZ/?
?MRSAPR APR trap /]
	MOVE	I,.JBCNI		;[277] GET APR CONI WORD
	PUSHJ	P,OCTTYO		;[277] TYPE CONI WORD
	OUTSTR	[ASCIZ/ @ /]		;[277] WHAT I THINK SHOULD BE
	MOVE	I,.JBTPC		;[277] GET PC
	PUSHJ	P,OCTTYO		;[277] TYPE WHAT IT IS
	OUTSTR	CRLF			;[277] CR/LF
	JRST	RENADR			;[277] FAKE A REENTER
SUBTTL ! Mode Command Scanner and Friends

EXPINP:	TXNN	%,SF$EXP		; SEE IF TO LOOK AT ! STUFF
	 POPJ	P,			; GUESS NOT
	SKPINL				; SEE IF INPUT THERE
	 POPJ	P,			; NO INPUT: RETURN
WATKLG:	PUSH	P,OUTDEV		; SAVE ALL VALUABLE THINGS
	PUSH	P,INDEV
	PUSH	P,DEVMSK
	PUSH	P,SPEC+.RBNAM
	PUSH	P,SPEC+.RBEXT
	PUSH	P,SPEC+.RBPPN
	PUSH	P,PPNMSK
	PUSH	P,DSPLOC
	MOVEM	P,ACS+P			; SAVE AC 17
	MOVEI	P,ACS			; LOAD BLT POINTER
	BLT	P,ACS+16		; SAVE ALL MY AC'S
	MOVE	P,ACS+P			; RESTORE PDP
	TXO	%,SF$DNA		; PROHIBIT ABORTION
	SETZM	DSPLOC			; SO NO CCN
	ANDX	%,SF$DIC!SF$DNA		; CLEAR FLAGS
	PUSHJ	P,SCAN			; SCAN COMMAND
	TXZN	%,SF$NOK		; NOT OK?
	 JRST	EXCMCL			; YES IS OKAY
	ERTYPE	['NLG',,[ASCIZ/Illegal in "!" mode/]]
IFN DEBUG<TXNN	%,SW$DDT		; DDT?
	 JRST	EXCMCL			; NO
	SKIPN	T0,.JBDDT		; ANY DDT?
	 ERTYPE	['DDT',,[ASCIZ/No DDT/]]; NO DDT
	PUSHJ	P,(T0)			; YES DDT>
EXCMCL:	SKIPE	T0,DSPLOC		; ANYWHERE TO GO?
	 PUSHJ	P,(T0)			; YES, GO THERE
	  JFCL				; IN CASE OF SKIP
	TXZ	%,SF$DNA		; ALLOW ABORTION
	ORM	%,ACS			; SO FLAGS GET TURNED ON RIGHT
NABORT:	MOVSI	P,ACS			; LOAD BLT POINTER
	BLT	P,P			; RESTORE MY AC'S MARYBETH
	OUTCHR	["!"]			; TYPE PROMPT AGAIN
	POP	P,DSPLOC
	POP	P,PPNMSK
	POP	P,SPEC+.RBPPN
	POP	P,SPEC+.RBEXT
	POP	P,SPEC+.RBNAM
	POP	P,DEVMSK
	POP	P,INDEV
	POP	P,OUTDEV
	POPJ	P,			; RETURN
SUBTTL Literals and Low Segment

CRLF:	ASCIZ/
/				; USEFUL STRING

	XLIST	; CUT OUT LIT CRUFT
	.XCREF				; REMOVE CREF
IF2<	PURGE	BADCOM>
...BDC:	CAXE	W,'COMRC '		; SECRET COMMAND?
	 JRST	BADCOM			; BAD COMMAND
	OUTSTR	COMRC			; OUTPUT COPYRIGHT MESSAGE
	JRST	RENADR			; REENTER PROGRAM
COMRC:	ASCIZ/<***Copyright(C) 1975, 1976, 1977 Mark R. Crispin***>
/
IF1<	PURGE	BADCOM			; UNDEFINE BADCOM
	DEFINE	BADCOM<...BDC>
>
IF2<	PURGE	...BDC,COMRC>
	.CREF
	LIT
	LIST	; RESTORE LISTING

IFN	PURE<RELOC 0>

CORBEG==.
INTBLK:	BLOCK	4			;[277] INTERRUPT BLOCK
OUTCH:	BLOCK	1			; OUTPUT BLOCK
OUTDEV:	BLOCK	2			; OUTPUT DEVICE
INCH:	BLOCK	1			; INPUT BLOCK
INDEV:	BLOCK	2			; INPUT DEVICE
MFDCH:	BLOCK	3			; MFD BLOCK
MFDDAT:	BLOCK	4			; MFD FILE LOOKUP BLOCK
MFDBFH:	BLOCK	3			; MFD BUFFER HEADER
UFDCH:	BLOCK	3			; UFD BLOCK
UFDDAT:	BLOCK	4			; UFD FILE LOOKUP BLOCK
UFDBFH:	BLOCK	3			; UFD BUFFER HEADER
DEVMSK:	BLOCK	1			; DEVICE MASK
SPCCNT:	BLOCK	1			; SPEC COUNT
DSPLOC:	BLOCK	1			; COMMAND SCANNER DISPATCHING LOCATION
POSFNO:	BLOCK	1			; POSITIONING ARG
RUNOFF:	BLOCK	1			; FOR RUN OFFSET STORAGE
PPNMSK:	BLOCK	1			; PPN MASK
PROTCD:	BLOCK	1			;[271] PROTECTION CODE
SPEC:	BLOCK	1			; EXTENDED LOOKUP BLOCK
BUFR:	BLOCK	BKSZ			; GENERAL BUFFER
BFREND==.-1

; THE FOLLOWING TWO STATEMENTS MUST BE IN THIS ORDER

MFDBFR:	BLOCK	MFDBF*DBS		; MFD BUFFER
UFDBFR:	BLOCK	UFDBF*DBS		; UFD BUFFER
COREND==.-1
; HERE FOR LOWSEG NOT TO BE CLOBBERED

PRCTYP:	BLOCK	1			;[263] PROCESSOR TYPE
OTHPDP:	BLOCK	1			; THE OTHER PDP
OTHPDL:	BLOCK	PDLLN2			; THE OTHER PDL
PDL:	BLOCK	PDLLEN			; PUSHDOWN LIST
STRTAB:	BLOCK	MAXSTR+1		; LIST OF ALL STRS
ACS:	BLOCK	20			; FOR TO SAVE MY AC'S
INTACS:	BLOCK	20			;[305] FOR INTERRUPT AC'S
MFDPPN:	BLOCK	1			;[235] MFD PPN
HLPPPN:	BLOCK	1			;[234] HELPING PPN
MRSSTA:	BLOCK	1			; MARS STATUS ADDRESS

; THE FOLLOWING SIX STATEMENTS MUST BE IN THIS ORDER!!!

LASSPC:
MTASTA:	BLOCK	1			; MTA STATUS WORD
MTAPOS:	BLOCK	1			; CURRENT TAPE POSITION
PHMTAN:	BLOCK	1			; PHYSICAL MTA NAME
MTADIR==.				;[234] START OF DIRECTORY
TAPEID:	BLOCK	1			; TAPE IDENTIFICATION WORD
	BLOCK	1			;[234] TO REMAIN BLANK
NUMFLS:	BLOCK	1			; NUMBER OF FILES IN USE
BLKS:	BLOCK	1			; NUMBER OF BLOCKS IN USE
LABDAT:	BLOCK	1			; DATE
LABTIM:	BLOCK	1			; TIME
LABVER:	BLOCK	1			; LABELLING MARS VERSION
MONVER:	BLOCK	1			; LABELLING MONITOR VERSION
DIRECT:	BLOCK	1			; DIRECTORY BLOCK STARTS HERE AND GROWS

END MARS