Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0048/rdmt11.mac
There are 2 other files named rdmt11.mac in the archive. Click here to see a list.
	TITLE RDMT11- PDP-11 MAGTAPE UTILITY/W. J. MESERVE/WJM 25 AUG 72.
	SUBTTL	MAIN ROUTINE.
	F=	0	;LH=FLAGS AS LISTED BELOW.
		FEOF=	1B18	;EOF SEEN ON MTA.
		FAST=	1B19	;ASTERISK SEEN IN FILE SPEC.
		FDEL=	1B20	;OUTPUT DELIMITER SEEN IN CMD.

			;RH=ERROR NUMBERS WHEN RETURNING TO CALLER.
	P1=	1	
	P2=	2	
	P3=	3
	A1=	4	;AC'S TO PASS ARGUMENTS BETWEEN ROUTINES.
	A2=	5
	A3=	6
	A4=	7
	A5=	10
	T1=	11	;TEMPORARY AC'S.
	T2=	12
	T3=	13
	T4=	14
	T5=	15
	T6=	16
	P=	17	;PUSHDOWN POINTER.

	;ERROR NUMBERS STORED IN RH(F) WHEN ERROR DETECTED.
	SEQR=	1	;CHAR SEQUENCE ERROR IN INPUT CMD STRING.
	ILCR=	2	;ILLEGAL CHAR IN INPUT CMD STRING.
	DELR=	3	;ILLEGAL DELIMITER IN FILE SPEC.
	FLDR=	4	;UNEXPECTED FIELD IN INPUT STRING.
	INPR=	5	;NO INPUT DATA-SET SPECIFICATION.
	CHCR=	6	;TOO MANY CHARACTERS IN COMMAND.
	MTIR=	7	;CAN'T INIT MTA.
	DKIR=	10	;CAN'T INIT DSK.
	BHDN=	11	;NON-FATAL  BAD HDR FOUND, SKIPS TO NEXT FILE.
	BTPR=	12	;FATAL MTA READ ERRORS.
	DKEN=	13	;CAN'T ENTER A FILE ON DSK.
	QUON=	14	;DISK RAN OVER QUOTA.
	DKHR=	15	;HARD DATA ERROR ON DISK.
	DUPR=	16	;TOO MANY OUTPUT SPECS SEEN.

	PDLSIZ=	30	;SIZE FO PUSHDOWN LIST.
	FILMAX=	30	;MAX NUMBER OF FILES ALLOWED IN DATA-SET SPEC.
	TTBFSZ=	17	;NUMBER OF WORDS PER TTY BUFFER.
	TTCHMX=	TTBFSZ*5;MAX NUMBER OF CHARS PER TTY BUFFER.

	;STATUS BITS FOR ALL DEVICES.
	IOIMPM=	1B18	;IMPROPER MODE.
	IODERR=	1B19	;HARD DATA ERROR.
	IODTER=	1B20	;DATA ERROR.
	IOBKTL=	1B21	;BLOCK TOO LARGE OR QUOTA PROBLEM.
	IOEOF=	1B22	;EOF SEEN ON INPUT.

	;STATUS BITS FOR MTA.
	IOBOT=	1B24	;BEGINNING OF TAPE.
	IOTEND=	1B25	;END OF TAPE.

	;MTAPE UUO'S
	MTASLP=	0	;MAKE MTA WAIT FOR END OF OP.
	MTAREW=	1	;REWIND MTA.
	MTABKR=	7	;BACKSPACE MTA ONE RECORD.
	MTABKF=	17	;BACKSPACE MTA ONE FILE.
	MTASFL=	16	;SKIP FORWARD ONE FILE.
	MTAIND=	101	;INIT MTA FOR INDUSTRY COMPATIBLE MODE.

	;DATA MODES
	IMBIN=	13	;BUFFERED IMAGE BINARY FOR DISK.
	IMODE=	10	;IMAGE MODE FOR MTA.

	;I/O CHANNELS
	MTACH=	0
	DSKCH=	1

	;OTHER I/O PARAMETERS.
	MTBYT=	10	;MTA BYTSIZE.
	MTNMBF=	10	;NUMBER OF MTA BUFFERS.
	MTBFSZ=	200	;SIZE OF MTA BUFFERS.

	;MACRO FOR GENERATING MTNMBF MTA BUFFERS.

	DEFINE	XWDBUF(PARAM)
<	XWD	MTBFSZ+1,MTAB'PARAM+1
>
	DEFINE	BLDBUF(X)
	<Y=	X+1
	G=	MTNMBF-X
	IFE	G, <Y=1>
MTAB'X:	0
	XWDBUF	(\Y)
	BLOCK	MTBFSZ+1
>
	ZERO=	0	;LISTED  SO THAT IMPORTANT REFERENCES TO 
	ONE=	1	;NUMBERS WILL BE INDICATED IN CREF.
	TWO=	2
	THREE=	3
	FOUR=	4
	FIVE=	5
	SIX=	6
	SEVEN=	7
	TEN=	10
	TWENTY=	20
	THIRTY=	30
	FORTY=	40
	FIFTY=	50
	SIXTY=	60
	SEVENT=	70
	HUNDRE=	100

	APOST=	"'"
	ASTER=	"*"
	BARRO=	"_"
	COLON=	":"
	CONTZ=	32
	COMMA=	","
	CRRET=	15
	EQUAL=	"="
	LINFD=	12
	PERCT=	"%"
	PRIOD=	"."
	QUEST=	"?"
	QUOTE=	42
	SLASH=	"/"
	SPACE=	" "

	PARB=	200	;PARITY BIT IN MTA BYTE. (ALWAYS IGNORED.)

	OPDEF	PJRST	[JRST	0]
	
INIPRO:	RESET
	MOVE	P,PDINWD	;INIT PD LIST.
INIFLG:	SETZM	F		;RETURN HERE ON FATAL ERROR.
INITAB:	MOVE	T1,DATINI	;INIT DATA TABLE
	SETZM	DATTAB
	BLT	T1,DATEND
	PUSHJ	P,INICCT	;INIT BUFFER CHAR CNTR.
	HRRZI	T1,ASTER
	OUTCHR	T1		;OUTPUT ASTERISK.
	PUSHJ	P,PRESCN	;GET INPUT STRING.
	JRST	INIFLG		;ERROR RETURN.
	PUSHJ	P,CMDCDR	;NOW DECODE CMD.
	JRST	INIFLG		;ERROR RETURN.
	PUSHJ	P,MAKFLG	;SET FLAGS FOR WILD CARD CHARS.

PAGE
	SUBTTL	MAIN ROUTINE FOR FILE TRANSFER.

INIMTA:	MOVEI	T1,IMODE	;IMAGE MODE FOR MTA.
	MOVE	T2,DEVTAB+1	;PICK UP INPUT DEVICE NAME.
	MOVEI	T3,MTAHDR	;BFR HEADER ADR.
	OPEN	MTACH,T1	;INIT MTA.
	JRST	ERMTIR		;(ERROR RETURN, FATAL)CAN'T INIT DEVICE.
INIHDR:	MOVE	T1,MTAIN1	;INIT MTA BUFFER HEADER FOR 8 BIT BYTES
	MOVEM	T1,MTAHDR
	MOVE	T1,MTAIN2
	MOVEM	T1,MTAHDR+1
	MTAPE	MTACH,MTAREW	;REWIND TAPE.
WAITMR:	MTAPE	MTACH,MTASLP	;WAIT A WHILE.
	STATO	MTACH,IOBOT	;BEGINNING OF TAPE?
	JRST	WAITMR		;NO, GO WAIT SOME MORE.
	MTAPE	MTACH,MTAIND	;INIT FOR IND COMP MODE.
INIDSK:	MOVEI	T1,IMBIN	;SET FOR IMAGE BINARY MODE.
	MOVE	T2,DEVTAB	;OUTPUT DEVICE NAME.
	HRLZI	T3,DSKHDR	;BUFFER HDR ADR FOR OUTPUT BUFFER.
	OPEN	DSKCH,T1	;INIT THE DEVICE.
	JRST	ERDKIR		;(FATAL ERROR) CAN'T INIT.
RDMTHD:	PUSHJ	P,RDHDRC	;READ MTA HEADER RECORD.
	JRST	HDRERR		;EOF OR ERROR RET (BHDN, BTPR).
	PUSHJ	P,CHKMTH	;SEARCH FOR A MATCH AGAINST FILTAB
	JRST	NOMTCH		;NO MATCH FOUND.
	MOVE	T1,HDRFIL	;FOUND A MTACH.
	HLLZ	T2,HDREXT	;PREPARE FOR AN ENTER ON DSK.
	SETZB	T3,T4		;USER'S PPN ONLY.
	ENTER	DSKCH,T1	;ENTER SAME NAME ON DSK.
	JRST	ERDKIN		;FATAL ERROR ON ENTER FAILURE.
NXTWRD:	SETZM	P3		;GOOD ENTER, INIT CHAR COLLECTOR.
	HRREI	P2,-5		;INIT CHAR COUNTER.
NXTBYT:	PUSHJ	P,GETBYT	;GET MTA BYTE IN A1.
	JRST	RECERR		;EOF OR ERROR RET.
	TRZ	A1,PARB		;IGNORE PARITY.
	JUMPE	A1,NXTBYT	;FORGET NULLS.
	CAIE	A1,177		;AND DELETES.
	CAIN	A1,32		;AND ^Z'S.
	JRST	NXTBYT
	LSH	P3,7		;MAKE ROOM FOR ASCII CHAR.
	OR	P3,A1		;OR CHAR INTO COLLECTOR.
	AOJL	P2,NXTBYT	;GET NEXT BYTE IF MORE ROOM.
	LSH	P3,1		;LEFT JUSTIFY 5 ASCII CHARS.
	PUSHJ	P,OUTWRD	;OUTPUT THE WORD.
	JRST	DSKERR		;NON-RECOVERABLE I/O PROBS (DKHR,QUON).
	JRST	NXTWRD		;GET NEXT FIVE BYTES.
PAGE

	;INPUT ROUTINE FOR MTA.

GETBYT:	SOSLE	MTAHDR+2	;BUFFER EMPTY?
	JRST	LOADBT		;NO.
	IN	MTACH,		;YES, GET A BUFFER.
	JRST	LOADBT		;NORMAL RET.
	STATZ	MTACH,IOEOF	;ERROR OR EOF.
	TLOA	F,FEOF		;EOF SEEN.
	HRRI	F,BTPR		;MUST BE HARD DATA ERROR
	POPJ	P,		;ERROR RET.

LOADBT:	ILDB	A1,MTAHDR+1	;GET BYTE.
	JRST	POP2		;NORMAL RET.


	;ROUTINE TO WRITE DISK.

OUTWRD:	SOSLE	DSKHDR+2	;BUFFER EMPTY?
	JRST	PUTWRD		;NO, IDPB WORD AND RETURN.
	OUT	DSKCH,		;YES, DO AN OUTPUT.
	JRST	PUTWRD		;GOOD RET.
	HRRI	F,DKHR		;ERROR RET, ASSUME DATA ERROR.
	STATZ	DSKCH,IOBKTL	;IS IT QUOTA?
	HRRI	F,QUON		;YES, SET ERROR NUMBER.
	POPJ	P,		;ERROR RET.

PUTWRD:	IDPB	P3,DSKHDR+1	;DEPOSIT WORD.
	JRST	POP2		;AND GIVE NORMAL RET.
PAGE
	;ROUTINE TO GET FILENAME FROM MTA HEADER.
	;EXIT WITH NAME STORED IN HDRFIL AND HDREXT.
	;NON-SKIP RETURN MEANS EOF OR MTA ERROR OR HEADER ERROR.

RDHDRC:	JSP	P3,GETBT2	;GET FIRST 3 CHAR OF FILENAME.
	HLLZM	A1,HDRFIL	;STORE THEM.
	MOVE	A1,MTAHDR+2
	CAIE	A1,^D15		;SHOULD BE 14 CHARS LEFT IN HDR.
	JRST	BDHDR1		;NOT A GOOD HEADER BLOCK.
	JSP	P3,GETBT2	;GET LAST 3 CHARS FO FILENAME.
	HLRM	A1,HDRFIL
	JSP	P3,GETBT2	;GET EXTENSION.
	HLLZM	A1,HDREXT
	SETZM	MTAHDR+2	;DONE WITH THIS RECORD.
	JRST	POP2		;GOOD RETURN.

BDHDR1:	HRRI	F,BHDN		;NOT A HEADER RECORD.
	POPJ	P,		;SKIPS TO NEXT FILE.

	;ROUTINE TO PIC UP TWO RADIX50 BYTES AND
	;CONVERT THEM TO SIXBIT.
	;ROUTINE NORMALLY EXITS TO CALLER.
	;IF MTA ERROR CONDITION ROUTINE POP'S UP ONE LEVEL.
	;CALLED WITH JSP P3,GETBT2.
	;RETURNS TWO BYTES LEFT ADJUSTED IN A1.

GETBT2:	MOVEI	A3,2		;CNTR TO GET BYTE TWICE.
	SETZM	A2		;COLLECTOR.
GETBT3:	PUSHJ	P,GETBYT	;GET A BYTE IN A1.
	POPJ	P,		;MTA ERROR OUT.
	PUSH	P,A1		;SAVE BYTE.
	SOJG	A3,GETBT3	;GET SECOND BYTE.
	POP	P,A1		;RETRIEVE EVEN BYTE.
	LSH	A1,10		;SHIFT EVEN BYTE.
	POP	P,A2		;RETRIEVE ODD BYTE.
	OR	A1,A2		;COMBINE TWO BYTES.
	PUSHJ	P,RAD50X	;CONVERT AND
	JRST	(P3)		;RETURN WITH SIXBIT BYTES LEFT ADJUSTED.


PAGE
	;ROUTINE TO SEARCH FILTAB AND EXTTAB TO SET MASKING FLAGS
	;	FOR WILD CHARS.
	;A4 IS USED AS INDEX INTO FILTAB.
	;A NULL FILENAME SIGNALS END OF FILENAMES.

MAKFLG:	SETOM	A4
NXTFGS:	AOS	A4		;INCREMENT INDEX.
	SKIPN	A2,FILTAB(A4)	;GET NEXT FILE.
	POPJ	P,		;DONE IF NULL.
	SETZM	A3
	HRRM	A3,EXTTAB(A4)	;INIT RH(EXTTAB)
	TRO	A3,1B23		;INIT SLIDING BIT
	MOVEI	A5,6		;INIT COUNTER FOR UP TO SIX CHARS.
	PUSHJ	P,MAKBIT	;SET FLAGS FOR WILD CHARS SEEN.
	HLLZ	A2,EXTTAB(A4)	;GET EXT AS ARG FOR MAKBIT.
	MOVEI	A5,3		;INIT COUNTER FOR UP TO 3 CHARS.
	PUSHJ	P,MAKBIT	;SET FLAGS FOR WILD CHARS SEEN IN EXT.
	MOVEI	A2,7
	ORM	A2,EXTTAB(A4)	;TURN ON RIGHT MOST BITS.
	SKIPGE	A3,CMDFLS	;ANY WILD CHARS YES?
	JRST	NXTFGS		;YES, WILL SEARCH WHOLE TAPE.
	MOVEI	A2,7770		;NO, TEST FOR WILD CHARS ON THIS FLNM.
	TDNN	A2,EXTTAB(A4)	;WILD CHAR SEEN?
	AOSA	A3		;NO, INCREMENT FILE COUNT.
	SETOM	A3		;YES, MAKE INFINITE FILE CNT, MUST SEARCH ENTIRE TAPE.
	MOVEM	A3,CMDFLS	;RESTORE FILE COUNT.
	JRST	NXTFGS

MAKBIT:	TLZ	F,FAST		;INIT ASTERISK SEEN FLAG.
NXTTST:	SETZM	A1		;INIT CHARACTER REGISTER.
	LSH	A3,-1		;SLIDE OVER FLAG MASK.
	TLNE	F,FAST		;ASTERISK SEEN?
	JRST	SETBIT		;YES, SO ALL CHARS ARE WILD.
	LSHC	A1,6		;NO, PICK UP NEXT CHAR.
	JUMPE	A1,SETBT1	;DONE IF NULL, BUT CONT TO SHIFT BIT.
	CAIN	A1,'?'		;IF QUESTION MARK, SET FLAG FOR MASK.
	JRST	SETBIT
	CAIE	A1,'*'		;IF ASTERISK, SET FLAG AND NOTE IT.
	JRST	SETBT1
	TLO	F,FAST
SETBIT:	ORM	A3,EXTTAB(A4)	;SET "WILD CHAR BIT".
SETBT1:	SOJG	A5,NXTTST	;CHECK ALL CHARS BEFORE FIRST NULL.
	POPJ	P,
PAGE
	;ROUTINE TO CHECK FOR A MATCH BETWEEN FILE NAMES.
	;FILTAB AND EXTTAB CONTAIN FILES SPECIFIED BY USER COMMAND.
	;RH(EXTTAB)=A 12 BIT BYTE WHICH SPECIFIES WILD CARDS.

CHKMTH:	SETOM	A1		;SET INDEX FOR FILTAB.
NXTFNM:	AOS	A1		;INCREMENT INDEX.
	SKIPN	A4,FILTAB(A1)	;MORE COMPARISONS TO MAKE?
	POPJ	P,		;NO, FAILURE TO FIND A MATCH.
	MOVE	A3,HDRFIL	;PICK UP FILENAME READ FROM MTA.
	XOR	A3,A4		;TRY FOR A MATCH.
	JUMPE	A3,TSTEXT	;GOOD IF ZERO, GO TEST EXT.
	MOVEI	A2,7700		;OTHERWISE BUILD MASK OF WILD CHARS.
	AND	A2,EXTTAB(A1)	;GET BITS THAT SPECIFY BYTE MASK.
	LSH	A2,-6		;RIGHT JUSTIFY THEM.
	PUSHJ	P,MKBYTM	;GO MAKE BYTE MASK.
	ANDCM	A3,A2		;BYTE MASK RETURNED IN A2.
	JUMPN	A3,NXTFNM	;NO LUCK, TRY NEXT FILENAME.
TSTEXT:	HLLZ	A3,HDREXT	;HERE TO TEST EXT FOR MATCH.
	HLLZ	T5,EXTTAB(A1)	;GET THE CORRESPONDING EXT.
	XOR	A3,T5
	JUMPE	A3,FNDMTC	;MATCH IF ZERO.
	MOVEI	A2,77
	AND	A2,EXTTAB(A1)	;GET BITS THAT SPECIFY WILD CHAR BYTE MASK.
	PUSHJ	P,MKBYTM	;MAKE BYTE MASK.
	ANDCM	A3,A2		;MASK OUT WILD CHAR POSN'S.
	JUMPN	A3,NXTFNM	;NO MATCH IF NON-ZERO.
FNDMTC:	MOVEI	A4,400000	;HERE IF MATCH.
	ORM	A4,EXTTAB(A1)	;MARK IT AS A "FOUND FILE".
	JRST	POP2		;SKIP-RETURN TO INDICATE MATCH.

	;HERE TO MAKE BYTE MASK.
	;A2 CONTAINS 6 BITS RIGHT ADJUSTED TO SPEC CHAR MASK.
MKBYTM:	SETZM	T1		;T1 COLLECTS MASK.
	MOVEI	T2,6		;SET COUNTER.
MKBYT1:	LSH	T1,6		;SHIFT CHAR MASK.
	TRZE	A2,40		;IF BIT=1 CHAR POSN IS WILD.
	ADDI	T1,77
	LSH	A2,1
	SOJG	T2,MKBYT1	;REPEAT SEQUENCE 6 TIMES.
MKBYDN:	MOVE	A2,T1		;RETURN WITH MASK IN A2.
	POPJ	P,
PAGE
	SUBTTL	PRESCAN ROUTINE.
	;ROUTINE TO PRESCAN THE COMMAND STRING, CHECK FOR 
	;ILLEGAL CHARACTER SEQUENCES, ILLEGAL CHARACTERS AND ISOLATE
	;INPUT AND OUTPUT FILE SPECIFICATIONS.
	;(A1)= XWD(FIRST WRD OF CURRENT FILE SPEC, CHAR CNT)
	;(A2)= PTR TO CURRENT CHAR.
	;(A3)= PREVIOUS CHARACTER PROCESSED.
	;(A4)= CURRENT CHARACTER BEING PROCESSED.

PRESCN:	HRLZI	A1,TTIBUF	;INIT BUFFER PTR.
	TLZ	F,FDEL		;INIT DELIMITER SEEN FLAG.
PRESC1:	HLRZ	A2,A1		;MAKE ILDB PTR.
	HRLI	A2,440700
	SETZM	A3		;MAKE LAST CHAR NULL.
NXTCHS:	PUSHJ	P,GETCHR	;GET CHAR IN A4.
	JRST	FLDDEL		;RETURN HERE IF FIELD DELIMITER.
	JRST	ALPCHR		;HERE IF ALPHA-NUMERIC OF SPECIAL
	JRST	ILLCHR		;HERE IF ILLEGAL CHAR.
	JRST	CHCTER		;HERE IF NO MORE ROOM IN BUFFER.

ALPCHR:	PUSHJ	P,CHKSEQ	;CHECK CHR SEQUENCE.
	JRST	SEQERR		;ERROR IN SEQUENCE OF CHARS.
	JUMPE	A3,XFRCHR	;NORMAL RETURN
	IDPB	A3,A2		;DEPOSIT LAST CHR IF NOT NULL.
	AOS	A1		;COUNT IT.
XFRCHR:	HRRZ	A3,A4		;MAKE OLD CHAR=NEW CHAR.
	JRST	NXTCHS

	;HERE IF FILE SPEC DELIMITER:  _ = (CR)
FLDDEL:	JUMPE	A3,FLDDL1	;DEPOSIT LAST CHAR IF NOT NULL.
	IDPB	A3,A2		;DEPOSIT LAST CHAR SEEN.
	AOS	A1		;COUNT IT.
FLDDL1:	HRRZM	A1,P3		;SAVE CHAR CNT
	SKIPE	P3		;IF CHAR CNT=0 MAKE PTR=0.
	MOVEM	A1,P3
	HRRZ	A1,A1
	ADDI	A1,FOUR		;CALCULATE ADR FOR NEW PTR.
	IDIVI	A1,FIVE
	ADDI	A1,TTIBUF	;ADD BUFFER ADR.
	HRLZ	A1,A1		;AND SET FOR NEW PTR.
	SETZM	T1		;ASSUME OUTPUT SPEC.
	SUBI	A4,CRRET	;SET TO ZERO IF CR.
	JUMPE	A4,CRRETS	;<CR>?
	TLOE	F,FDEL		;NO, HAVE WE SEEN OUTPUT SPEC ALREADY?
	JRST	DUPERR		;YES, FATAL ERROR.
	SKIPA			;NO, JUST NOTE IT AND CONTINUE.
CRRETS:	AOS 	T1		;YES, MUST BE INPUT SPEC.
	MOVEM	P3,TTFLPT(T1)	;PLACE OLD PTR PROPERLY.
	JUMPN	A4,PRESC1	;GET NXT FLC SPEC IF NOT CR.
	JRST	POP2		;SKIP RET TO CALLER.

DUPERR:	HRRI	F,DUPR		;ERROR TYPE.
	CLRBFI			;CLEAR INPUT BUFFER.
	MOVEI	A5,QUEST	;FATAL ERROR.
	OUTCHR	A5
	OUTSTR	ERDTS		;TOO MANY DATA SETS ERROR MSG.
	PJRST	TTPRCR		;TYPE <CR> AND  DO NON-SKIP RETURN.

	;HERE WHEN ILLEGAL CHAR DETECTED IN INPUT CMD.
ILLCHR:	HRRI	F,ILCR		;SET ERROR NUMBER.
	CLRBFI			;CLEAR INPUT BUFFER.
	MOVEI	A5,QUEST
	OUTCHR	A5		;OUTPUT QUESTION MARK FOR FATAL ERROR.
	OUTSTR	ERCSQ
	MOVEI	A5,SPACE
	OUTCHR	A5
	MOVEI	A5,APOST
	OUTCHR	A5
	OUTCHR	A4		;OUTPUT ILL CHAR.
	OUTCHR	A5
	OUTSTR	ERCS1
	PJRST	TTPRCR		;OUTPUT CRLF, DO NON-SKIP RET.

	;HERE IF TOO MANY CHARS IN CMD.
CHCTER:	HRRI	F,CHCR		;SET ERROR NUMBER.
	CLRBFI			;CLEAR INPUT BUFFER.
	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERCHC
	OUTSTR	ERCS1
	PJRST	TTPRCR

	;HERE WHEN ILLEGAL SEQUENCE OF CHARS DETECTED.
SEQERR:	HRRI	F,SEQR
	CLRBFI			;CLEAR INPUT BUFFER.
	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERCSQ
	OUTSTR	ERCS2
	MOVEI	A5,SPACE
	OUTCHR	A5
	MOVEI	A5,APOST
	OUTCHR	A5
	OUTCHR	A3
	OUTCHR	A4
	OUTCHR	A5
	OUTSTR	ERCS1
	PJRST	TTPRCR		;NON-SKIP RET FOR FATAL ERROR.

PAGE
	SUBTTL	COMMAND DECODER.
	;ROUTINE TO DECODE COMMAND AFTER PRESCN ROUTINE.
	;ENTER WITH NO ARGUMENTS.
	;(A1) IS ILDB PTR TO FILE SPEC.
	;(A2) IS CTR FOR NUMBER OF CHARS LEFT IN FILE SPEC.

CMDCDR:	SKIPN	A2,TTFLPT	;ANY OUTPUT SPEC'S?
	JRST	MAKSPC		;NO, GO MAKE THEM.
	PUSHJ	P,MAKPTR	;YES, MAKE ILDB PTR AND CTR IN A1,A2.
	PUSHJ	P,GETSPC	;GET FIRST FIELD.
	CAIE 	A4,COLON	;MUST BE DEL FOR OUTPUT SPEC.
	JRST	DELERR		;ERROR OUT (DELR).
	MOVEM	A3,DEVTAB	;STORE OUTPUT DEVICE.
	JUMPE	A2,INSPEC	;DONE IF NO MORE CHARS.
MORFLD:	PUSHJ	P,GETSPC	;GET CHARS FOR ERROR TYPE-OUT.
	JRST	FLDERR		;ERROR OUT (FLDR).

MAKSPC:	MOVEI	T1,'DSK'	;MAKE OUTPUT DEVICE.
	HRLZM	T1,DEVTAB	;STORE IT.
INSPEC:	MOVE	P1,ININFL	;INIT FILTAB INDEX.
	SKIPN	A2,TTFLPT+1	;GET INPUT SPEC PTR.
	JRST	IN1ERR		;EMPTY, ERROR OUT (INPR).
	PUSHJ	P,MAKPTR	;MAKE PTR AND CTR.
	PUSHJ	P,GETSPC	;GET FIRST FIELD.
	CAIE	A4,COLON	;IS IT DEV SPEC?
	JRST	IN1ERR		;NO, ERROR OUT (DELR)
	MOVEM	A3,DEVTAB+1	;YES, SAVE INPUT DEVICE.
NXTFIL:	JUMPE	A2,IN1ERR	;ERROR IF NO FILE SPEC.
	PUSHJ	P,GETSPC	;GET A FIELD.
	CAIE	A4,COMMA	;A COMPLETE FILE NAME?
	JRST	CHKPER		;NO.
	SETZM	A4		;YES, MAKE NULL EXTENSION.
	PUSHJ	P,STOFIL	;AND STORE FILENAME AWAY.
	JRST	NXTFIL
CHKPER:	CAIE	A4,PRIOD	;IS IT A PERIOD?
	JRST	CHKNUL		;NO, SEE IF NULL.
	PUSH	P,A3		;YES, SAVE FILENAME.
	PUSHJ	P,GETSPC	;GET NEXT FIELD.
	CAIE	A4,COMMA	;END OF EXTENSION?
	JRST	CHKNL1		;MAYBE.
	POP	P,A4		;RETRIEVE FILENAME.
	EXCH	A3,A4
	PUSHJ	P,STOFIL	;STORE FILENAME.
	JRST	NXTFIL		;GET ANOTHER FILE.

CHKNUL:	PUSH	P,A3		;SAVE FILENAME.
	MOVE	T1,A4		;GET DELIMITER.
	SETZM	A4		;ZERO EXTENSION NAME.
	JRST	CHKNL2
CHKNL1:	MOVE	T1,A4		;GET DELIMITER.
	MOVE	A4,A3		;SET EXTENSION FOR STOFIL.
CHKNL2:	JUMPN	T1,DELER1	;ILLEGAL DELIM IF NOT NULL.
	POP	P,A3		;RETRIEV FILENAME.
	PUSHJ	P,STOFIL	;STORE FILE AND EXIT.
	JRST	POP2		;NORMAL RETURN.

	;ERROR ROUTINE FOR ILLEGAL DELIMITER.
	;ENTER WITH (A3)= SIXBIT CHARS PRECEDING DEL.
	;           (T1)= ASCII DELIMITER.
DELER1:	EXCH	T1,A4
	POP	P,T2		;POP THE STACK.
DELERR:	HRRI	F,DELR		;ERROR NUMBER.
	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERDEL
	MOVEI	A5,SPACE
	OUTCHR	A5
	PUSHJ	P,OUTSIX	;TYPES OUT CONTENTS OF A3.
	OUTCHR	A4		;TYPE OUT DELIMITER.
	OUTSTR	ERCS1
	PJRST	TTPRCR

PAGE
	;ROUTINE TO INPUT TTY COMMAND CHARACTERS AND DETERMINE CLASS.
	;RETURN WITH CHAR IN A4
	;NON-SKIP RET FOR A FIELD DELIMITER: =,_,<CR>
	;SKIP RET FOR A-N CHAR OR SUB-DEL OR ? OR *
	;SKIP 2 RET FOR AN ILLEGAL CHAR
	;SKIP 3 RET FOR BUFFER OVERFLOW.

GETCHR:	AOSLE	INCHCT		;INCREMENT CHAR CNT.
	JRST	POP4		;AVOID BUFFER OVERFLOW.
	INCHWL	A4		;GET CHR.
	MOVEI	T1,BARRO
	CAILE	A4,"Z"		;ALPHA-NUM?
	JRST	ILLCH1		;NO, MUST BE DEL OR ILLEGAL.
	MOVEI	T1,CRRET
	CAIGE	A4,"*"		;LARGER THAN LOWEST BOUND?
	JRST	ILLCH1		;NO, EITHER ILL CHAR OR CR.
	CAIE	A4,"+"		;ELIMINATE A COUPLE MORE POSSIBILITIES.
	CAIN	A4,"-"
	JRST	POP3		;+ AND - ARE ILLEGAL CHARS.
	CAILE	A4,":"		;NUMERIC OR SPECIAL?
	CAIL	A4,"A"		;ALPHA?
	JRST	POP2		;MUST BE A-N OR SPECIAL.
	CAIN	A4,"?"		;IF NOT ?, MUST BE DEL OR ILLEGAL.
	JRST	POP2		;ITS A SPECIAL.
	MOVEI	T1,EQUAL	;SET UP FOR DATA-SET DEL TEST.

	;HERE WHEN EITHER FIELD DEL OR ILLEGAL CHAR.

ILLCH1:	CAME	A4,T1		;IS IT A DELIMITER?
	JRST	POP3		;NO, MUST BE ILLEGAL.
	CAIE	A4,15		;FLD DELIMITER A CR?
	POPJ	P,
	INCHRW	T1		;YES, SWALLOW LF.
INICCT:	HRROI	T1,-TTCHMX	;RE-INIT INPUT CTR.
	MOVEM	T1,INCHCT
	JRST	POP1

PAGE
	;ROUTINE TO CHECK CHAR SEQ FOR COMMAND DECODER.
	;ENTER WITH (A3)= OLD CHAR.
	;           (A4)= NEW CHAR.
	;NON-SKIP RET FOR ILL SEQ OF CHARS.
	;SKIP-RET FOR GOOD SEQ OF CHARS.

CHKSEQ:	MOVE	T3,A4
	PUSHJ	P,GETVAL	;GET ASSOC VALUE OF NEW CHAR.
	SOS	T4		;SINCE ROWS NUMBER FROM 0 TO 7.
	IMULI	T4,^D8		;SETS PTR TO PROPER ROW OF MATRIX.
	PUSH	P,T4		;SAVE IT.
	MOVE	T3,A3		;GET ASSOC VALUE OF OLD CHAR.
	PUSHJ	P,GETVAL
	POP	P,T3		;RESTORE ASSOC VALUE OF NEW CHARS.
	ADD	T3,T4		;SHIFTS TO PROPER ELEMENT IN THE ROW.
	IDIVI	T3,^D32		;GET WORD NUMBER IN T4.
	MOVEI	T2,1
	MOVNS	T4		;TO ROTATE RIGHT.
	ROT	T2,(T4)		;SHIFT INTO PROPER COLUMN.
	AND	T2,SEQTAB(T3)	;USE MASK TO DETERMINE VALUE OF ELEMENT.
	SKIPE	T2		;SEQ OK IF BIT = 1.
	JRST	POP2		;GOOD SEQUENCE OF CHARS.
	POPJ	P,		;BAD SEQUENC RET.

	;THE FOLLOWING 8 BY 8 MATRIX IS USED FOR CHECKING CHAR SEQ.
	;A 1 INDICATES THAT THE SEQ IS GOOD.

	TMP1=	^B11111011B35	;ALPHA-NUMERIC
	TMP2=	^B10100111B35	;SLASH
	TMP3=	^B10000001B35	;COLON
	TMP4=	^B10000111B35	;COMMA
	TMP5=	^B10000111B35	;PERIOD
	TMP6=	^B00111001B35	;ASTERISK
	TMP7=	^B10111011B35	;QUESTION MARK
	TMP8=	^B11111111B35	;NULL

SEQTAB:	BYTE	(8) TMP1,TMP2,TMP3,TMP4
	BYTE	(8) TMP5,TMP6,TMP7,TMP8
PAGE
	;ROUTINE TO GET ASSOCIATIVE VALUE FOR A CLASS OF CHARS.
	;ENTER WITH CHAR IN T3
	;EXIT WITH ASSOC VALUE IN T4.

GETVAL:	MOVEI	T4,1		;ASSUME ALPHA-NUMERIC.
	MOVE	T2,T3		;SAVE CHAR.
	CAIGE	T2,"0"		;NUMERIC?
	JRST	LOWNUM		;NO, GO INDEX INTO TABLE.
	CAIL	T2,"A"		;ALPHA?
	POPJ	P,		;YES.
	CAIG	T2,"9"		;NO, NUMERIC?
	POPJ	P,		;YES.
	SUBI	T2,70		;NO, MUST BE 72 OR 77.
	JRST	HGHVAL

LOWNUM:	SKIPE	T2		;NULL?
	SUBI	T2,51		;NO, MUST BE 60 OR LESS.
HGHVAL:	MOVE	T4,CHRTAB(T2)	;PICK UP ASSOC VALUE.
	POPJ	P,

	;1 IS THE ASSOC VALUE FOR ALPHANUMERIC.
CHRTAB:	EXP	10 		;ASSOC VALUE FOR NULL.
	EXP	6		;ASSOC VALUE FOR "52" ASTERISK.
	EXP	3		;ASSOC VALUE FOR "72" COLON.
	EXP	4		;ASSOC VALUE FOR "54"  COMMA.
	0			;WASTED WORD.
	EXP	5		;ASSOC VALUE FOR "56"  PERIOD.
	EXP	2		;ASSOC VALUE FOR "57" SLASH.
	EXP	7		;ASSOC VALUE FOR "77" QUESTION MARK.
PAGE
	;ROUTINE TO PICK UP AT MOST 6 SIX BIT CHARS AND DELIMITER.
	;ENTER WITH PTR IN A1.
	;            CHAR CNT IN A2.
	;EXIT WITH FROM 0 TO SIX SIXBIT CHARS IN A3 LESFT ADJUSTED.
	;          ASCII DELIMITER IN A4.

GETSPC:	SETZB	A3,A4		;ZERO OUT COLLECTORS.
	MOVEI	T1,6		;SET CTR.
	SKIPG	A2		;EXIT IF CHAR CNT=0.
	POPJ	P,		;CHAR CNT =0.
NXTCHR:	ILDB	T3,A1		;PICK UP CHAR.
	PUSHJ	P,GETVAL	;GET ASSOC VALUE.
	CAIGE	T4,6		;CONSIDER * AND ? TO BE ALPHA.
	CAIN	T4,1
	JRST	ALPHAN		;PROCESS ALPHA-NUMERIC.
FAKDEL:	SOS	A2		;MUST BE DELIMITER, COUNT IT.
	MOVE	A4,T3		;RETURN DELIMITER PROPERLY.
ALLDON:	IMULI	T1,6		;CALCULATE SHIFT.
	LSH	A3,(T1)		;LEFT JUSTIFY.
	POPJ	P,

ALPHAN:	SOJL	T1,FAKDEL	;CONSIDER CHAR DEL IF NO MORE ROOM.
	SUBI	T3,40		;CONVERT TO SIXBIT.
	LSH	A3,6		;MAKE ROOM.
	OR	A3,T3		;COLLECT CHAR.
	SOJG	A2,NXTCHR	;GET NEXT CHAR.
	JRST	ALLDON		;RETURN WITH NULL DEL IF NO MORE CHARS.
PAGE
	SUBTTL	I/O ERROR ROUTINES.

	;HERE ON FAILURE TO ENTER DSK FILE.

ERDKIN:	HRRI	F,DKEN		;FATAL ERROR.
	MOVEI	A5,QUEST	;QUEST TO INDICATE FATAL ERROR.
	OUTCHR	A5
	OUTSTR	EDKEN		;PRINT ENTER FAILURE.
XFRMSG:	MOVEI	A5,SPACE	;OUTPUT SPACE.
	OUTCHR	A5
	HLLZS	T2		;FOR PRINTING EXT.
	PUSHJ	P,PRTFIL	;PRINT FILENAME FROM T1 AND T2.
	JRST	DONXFR		;TYPE # FILES XFRD.

	;HERE TO PRINT FILENAME, SKIP MSG AND SKIP TO NEXT FILE ON MTA.
FILSKP:	MOVEI	A5,SPACE
	OUTCHR	A5		;PRINT SPACE.
	PUSHJ	P,PRTFIL	;PRINT FILENAME FROM T1 AND T2.
	PUSHJ	P,SKPFIL	;SKIP MTA FORWARD TO NXT FILE.
SKPMSG:	OUTSTR	EHDR1		;MSG FOR SKIPPING TO NEXT FILE.
	MOVEI	T1,RDMTHD
	PUSH	P,T1		;SET RET ADR.
	JRST	TTPRCR		;OUTPUT CR.

	;HERE TO PRINT A FILENAME.
	;ENTER WITH NAME IN T1 AND T2.

PRTFIL:	MOVE	A3,T1
	PUSH	P,T2		;SAV EXTENSION.
	PUSHJ	P,OUTSIX	;CONVERT TO ASCII AND PRINT.
	JUMPE	T2,POP1		;RETURN IF NO EXT.
	MOVEI	A5,PRIOD
	OUTCHR	A5
	POP	P,A3		;RETRIEV AND PRINT EXTENSION.
	PJRST	OUTSIX		;AND RETURN.

	;HERE IF ERROR OR EOF ON MTA.

RECERR:	TLNN	F,FEOF		;IS IT AN EOF?
	JRST	HRCERR		;NO, MUST BE NON-RECOV ERROR.
	MOVMS	P2
	IMULI	P2,7		;SHIFTING ASCII CHARS.
	LSH	P3,1(P2)	;LEFT ADJUST REMAINING CHARS.
	PUSHJ	P,OUTWRD	;OUTPUT THE WORD.
	JRST	DSKERR		;OUTPUT PROB, NON-RECOVERABLE.
NOCHAR:	CLOSE	DSKCH,		;GOOD RETURN, CLOSE DISK FILE.
	CLOSE	MTACH,		;RE-INIT THE CHANNEL ON FIRST INPUT.
	AOS	NUMFIL		;COUNT THE FILE.
	MOVEI	A5,QUOTE	;INDICATE OPERATING MSG.
	OUTCHR	A5
	OUTSTR	FILXF		;SEND MSG OF GOOD XFR.
	MOVEI	A5,SPACE
	OUTCHR	A5
	MOVE	T1,HDRFIL	;PRINT FILENAME.
	HLLZ	T2,HDREXT	;AND EXTENSION.
	PUSHJ	P,PRTFIL
	PUSHJ	P,TTCRLF	;PRINT CRLF.
	SOSE	CMDFLS		;ARE WE DONE?
	JRST	RDMTHD		;NO, GO READ NEXT FILE.
	MOVEI	A5,QUOTE	;YES, PREPARE TO TERMINATE PROG.
	OUTCHR	A5	
	JRST	DONXFR		;GO TO CLOSE OUT ROUTINE.

	;HERE FOR NON-RECOV MTA READING ERRORS.

HRCERR:	MOVEI	A5,PERCT
	OUTCHR	PERCT		;WARNING MSG ONLY
	OUTSTR	ERRDM		;HARD DATA ERROR MSG.
	PUSHJ	P,RENFIL	;DELETE THE OUTPUT FILE.
	MOVE	T1,HDRFIL
	HLLZ	T2,HDREXT	
	JRST	FILSKP		;PRT FILE, SKIP TO NEXT FILE

	;HERE ON ERROR WRITING DISK.
DSKERR:	HRRZ	T1,F		;GET ERROR NUMBER.
	CAIE	T1,QUON		;IS IT A QUOTA PROBLEM?
	JRST	WRTERR		;NO, MUST BE DATA ERROR.
	MOVEI	A5,QUEST	;YES, THIS WILL STOP PROGRAM
	OUTCHR	A5
	OUTSTR	EQUON		;OUTPUT MSG ABOUT QUOTA PROB.
	MOVE	T1,HDRFIL
	HLLZ	T2,HDREXT
	JRST	XFRMSG		;GO PRNT NAME, NUM FILES AND RE-INIT PROG.

	;HERE FOR HARD DATA ERROR ON DISK.
WRTERR:	MOVEI	A5,PERCT
	OUTCHR	A5		;NOT FATAL SINCE WE SKIP TO NEXT FILE.
	OUTSTR	ERWRT		;HARD DATA ERROR MSG.
	MOVEI	A5,SPACE
	OUTCHR	A5
	MOVE	T1,HDRFILE
	HLLZ	T2,HDREXT
	PUSHJ	P,PRTFIL	;PRINT FILENAME.
	MOVEI	A5,SPACE
	OUTCHR	A5
	OUTSTR	ERWR1
	PUSHJ	P,RENFIL	;DELETE FILE.
	PUSHJ	P,BCKFIL	;BACK UP ONE FILE.
	MOVEI	T1,RDMTHD
	PUSH	P,T1		;START OVER ON SAME FILE.
	JRST	TTPRCR		;PRINT CRLF AND GO READ HEADER.

	;HERE ON FAILURE TO INIT DEVICES.

ERMTIR:	HRRI	F,MTIR		;ERROR NUMBER.
	MOVE	A3,T2		;DEVICE NAME FOR TYPE-OUT.
	JRST	ERDVIR

ERDKIR:	HRRI	F,DKIR		;ERROR NUMBER.
	MOVE	A3,T2		;DEVICE NAME FOR TYPE OUT.
ERDVIR:	MOVEI	A5,QUEST	;FATAL ERROR.
	OUTCHR	A5
	OUTSTR	ERDVI		;INIT ERROR MSG.
	MOVEI	A5,SPACE
	OUTCHR	A5
	PUSHJ	P,OUTSIX	;TYPE OUT DEVICE.
	MOVEI	T1,INIFLG
	PUSH	P,T1		;SET RETURN ADR.
	JRST	TTPRCR		;TYPE CRLF AND RETURN.

	;SKIP MTA FORWARD TO NEXT FILE.

NOMTCH:	MOVEI	T1,RDMTHD	;
	PUSH	P,T1		;SET RETURN ADR.
SKPFIL:	MTAPE	MTACH,MTASFL	;SKIP FILE.
	MTAPE	MTACH,MTASLP	;WAIT FOR COMPLETION.
	CLOSE	MTACH,		;RE-INIT THE CHANNEL ON FIRST INPUT.
	POPJ	P,

BCKFIL:	MTAPE	MTACH,MTABKF	;BACK UP ONE FILE.
	MTAPE	MTACH,MTASLP	;WAIT TILL DONE.
	STATO	MTACH,IOBOT	;IF BEGINNING OF TAPE NO PROB.
	MTAPE	MTACH,MTASFL	;IF  NOT, SKIP OVER FILE MARK.
	CLOSE	MTACH,		;RE-INIT CHANNEL ON FIRST INPUT.
	POPJ	P,
	
	;HERE WHEN ERROR RETURN READNG MTA FILE HDR.

HDRERR:	TLNE	F,FEOF		;EOF SEEN ON TAPE?
	JRST	EOFRTN		;PRINT MSG AND STOP.
	HRRZ	T1,F		;NO, GET ERROR NUMBER.
	CAIE	T1,BHDN		;BAD HDR?
	JRST	MTDERR		;NO, MUST BE HARD DATA ERROR.
	MOVEI	A5,PERCT
	OUTCHR	A5
	OUTSTR	EHDRM		;TELL USER BAD HEADER.
	OUTSTR	EHDR1

SKPFRD:	PUSHJ	P,SKPFIL	;SKIP TO NEXT FILE.
	MOVEI	T1,RDMTHD
	PUSH	P,T1		;SET RET ADR.
	JRST	TTPRCR		;OUTPUT CRLF.

	;HERE ON MTA HARD DATA ERROR.
MTDERR:	MOVEI	A5,PERCT
	OUTCHR	A5
	OUTSTR	EHDAT
	OUTSTR	EHDA1		;TELL USER HARD DATA ERROR.
	OUTSTR	EHDR1
	JRST	SKPFRD		;SKIP FORWARD TO NEXT FILE.

	;HERE ON LOGICAL END OF MTA.

EOFRTN:	MOVEI	A5,QUOTE
	OUTCHR	A5		;COMMENT TO USER.
	OUTSTR	EOFMG
DONXFR:	RELEASE	DSKCH,		;RELEASE DEVICES.
	RELEASE	MTACH,
	MOVEI	A5,SPACE
	OUTCHR	A5
	MOVE	A3,NUMFIL
	PUSHJ	P,DECPNT	;PRINT NUMBER OF FILES XFRD.
	OUTSTR	EOFM1
	SETZM	A1		;SET INDEX FOR SRCH OF FILTAB.
NXTENT:	PUSHJ	P,TTPRCR
	AOS	A1		;INCREMENT INDEX.
	SKIPN	T1,FILTAB(A1)	;ACTIVE ENTRY.
	JRST	INIFLG		;NO, RETURN FOR NEXT CMD.
	MOVE	T2,EXTTAB(A1)	;YES, GET EXT AND FLAGS.
	TRNE	T2,40000	;WAS THIS FILE FOUND?
	JRST	NXTENT		;YES, TRY NEXT ONE.
	MOVEI	A5,PERCT	;NO, PRINT WARNING MSG.
	OUTCHR	A5
	HLLZS	T2		;ZERO OUT FLAGS FOR PRT OUT.
	OUTSTR	FILNT		;TYPE FILE NOT FOUND MSG.
	PUSHJ	P,PRTFIL	;PRINT FILE NAME FM T1 AND T2
	JRST	NXTENT		;TEST NEXT ENTRY NAME.

	;HERE TO DELETE A FILE.
RENFIL:	SETZB	T1,T2
	SETZB	T3,T4
	RENAME	DSKCH,T1	;DELETE CURRENTLY OPEN FILE.
	HALT	.
	CLOSE	DSKCH,		;CLOSE THE CURRENT CHANNEL.
	POPJ	P,

	SUBTTL	MISCELLANIOUS SUBROUTINES.

	;SUBROUTINE FOR STORING FILE AND EXT IN TABLES.

STOFIL:	AOBJP	P1,NFLERR	;TOO MANY FILE SPECS.
	MOVEM	A3,FILTAB(P1)	;SAVE FILE NAME.
	HLLZM	A4,EXTTAB(P1)	;SAVE EXT NAME.
	POPJ	P,

	;ERROR ROUTINE.

NFLERR:	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERNLF
	MOVE	P,PDINWD	;RE-INIT PDP
	MOVEI	T1,INIFLG
	PUSH	P,T1		;SET RET ADR.
	JRST	TTCRLF		;AND RET.

	;ERROR ROUTINE.

FLDERR:	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERFLD
	MOVEI	A5,SPACE
	OUTCHR	A5
	PUSHJ	P,OUTSIX
	OUTSTR	ERFL1
	PJRST	TTPRCR

	;ERROR ROUTINE.

IN1ERR:	MOVEI	A5,QUEST
	OUTCHR	A5
	OUTSTR	ERFL2
	OUTSTR	ERFL3
	PJRST	TTPRCR

	;ROUTINE TO OUTPUT PERIOD, <CR> AND <LF>.

TTPRCR:	MOVEI	A5,PRIOD
	OUTCHR	A5
TTCRLF:	MOVEI	A5,CRRET
	OUTCHR	A5
	MOVEI	A5,LINFD
	OUTCHR	A5
	POPJ	P,

POP4:	AOS	(P)
POP3:	AOS	(P)
POP2:	AOS	(P)
POP1:	POPJ	P,

	;ROUTINE TO MAKE ILDB PTR FROM XWD PTR.

MAKPTR:	HLRZ	A1,A2
	HRLI	A1,440700
	HRRZS	A2
	POPJ	P,

	;ROUTINE TO TYPE OUT SIXBIT CONTENTS OF A3.
OUTSIX:	HRLZI	T1,-4		;4 CHARS AT A TIME.
OUTSX1:	SETZM	T2
NXTSIX:	SETZM	A2
	LSHC	A2,6		;SHIFT SIXBIT CHAR INTO A2.
	ADDI	A2,40		;CONVERT TO ASCII.
	LSH	T2,7		;MAKE ROOM.
	OR	T2,A2
	JUMPE	A3,NOMOR1	;NO MORE CHARS TO OUTPUT?
	AOBJN	T1,NXTSIX	;MORE, DO WE HAVE ROOM?
	PUSHJ	P,NOMORE	;NO, OUTPUT UP TO FOUR CHARS.
	HRLZI	T1,-2		;RESET COUNTER FOR AT MOST 2 MORE CHARS.
	JRST	OUTSX1		;GET REMAINING CHARS.

NOMOR1:	AOS	T1
NOMORE:	MOVNS	T1		;RH(T1)= # CHARS IN COLLECTOR.
	IMULI	T1,7		;7 BITS/ASCII-BYTE.
	ROT	T2,(T1)		;ROTATE TO LEFT JUSTIFY.
	OUTSTR	T2
	POPJ	P,

	;ROUTINE TO TYPE OUT DECIMAL NUMBER FROM A3.

DECPNT:	MOVE	T1,A3
DECPN1:	IDIVI	T1,^D10		;DEVIDE BY THE RADIX  10.
	PUSH	P,T2		;SAVE REMAINDER.
	SKIPE	T1		;DONE?
	PUSHJ	P,DECPN1	;NO, GO DIVIDE AGAIN.
DECPN2:	POP	P,T1		;YES, POP DIGITS BACK.
	ADDI	T1,60		;CONVERT OCTAL TO ASCII.
	OUTCHR	T1
	POPJ	P,		;POP BACK FOR ANOTHER NUMBER.

	;ROUTINE TO CONVERT RADIX 50 TO ASCII.
	;ENTER WITH NUMBER IN A1.
	;EXIT WITH CONVERSION IN A1 LEFT ADJUSTED.

RAD50X:	SETZM	T3		;WILL GET RESULT IN T3.
	MOVE	T1,A1
	PUSHJ	P,RAD50Y
	MOVE	A1,T3
	POPJ	P,

RAD50Y:	SKIPN	T1		;ANY MORE NUMBERS?
	POPJ	P,		;NO.
	IDIVI	T1,50	;YES, DEVIDE BY RADIX.
	PUSHJ	P,CONSEV	;CONVERT REM TO 7 BIT.
	SUBI	T2,40		;CONVERT TO SIXBIT.
	LSHC	T2,-6		;SHIFT INTO T3 WHICH IS COLLECTOR.
	JRST	RAD50Y

CONSEV:	CAIGE	T2,33		;ADD 11 OR 22?
	JRST	SMALNM		;NO.
	ADDI	T2,11		;YES.
	CAIGE	T2,34		;ADD 11 MORE?
	POPJ	P,		;NO, ALL DONE.
	ADDI	T2,11		;YES.
	POPJ	P,
SMALNM:	SKIPE	T2		;HERE TO ADD 40 OR 100.
	ADDI	T2,40		;HERE IF ALPHA.
	ADDI	T2,40		;HERE IF SPACE.
	POPJ	P,
PAGE
	SUBTTL	VARIOUS TTY MESSAGES TO USER.

ERCHC:	ASCIZ	/ TOO MANY CHARACTERS/
ERCSQ:	ASCIZ	/ ILLEGAL CHARACTER/
ERCS1:	ASCIZ	/ IN INPUT STRING/
ERCS2:	ASCIZ	/ SEQUENCE/
ERDEL:	ASCIZ	/ ILLEGAL DELIMITER/
ERNLF:	ASCIZ	/ TOO MANY FILE SPECS/
ERFLD:	ASCIZ	/ UNEXPECTED FIELD/
ERFL1:	ASCIZ	/ IN OUTPUT SPEC/
ERFL2:	ASCIZ	/ MISSING FIELD/
ERFL3:	ASCIZ	/ IN INPUT SPEC/
ERDTS:	ASCIZ	/ TOO MANY DATA SET SPECS IN COMMAND/
PAGE
	SUBTTL	I/O ERROR MSGS TO USER.

ERDVI:	ASCIZ	/ CAN'T INIT DEVICE/
EOFMG:	ASCIZ	/ END OF TAPE,/
EOFM1:	ASCIZ	/ FILES TRANSFERRED/
EHDRM:	ASCIZ	/ BAD HEADER DETECTED,/
EHDAT:	ASCIZ	/ HARD DATA ERROR/
EHDA1:	ASCIZ	/ READING HEADER,/
EHDR1:	ASCIZ	/ SKIPPING TO NEXT FILE/
EDKEN:	ASCIZ	/ ENTER FAILURE ON/
FILXF:	ASCIZ	/ FILE TRANSFERRED:/
FILNT:	ASCIZ	/ FILE NOT FOUND:/
ERRDM:	ASCIZ	/ DATA ERROR READING:/
EQUON:	ASCIZ	/ QUOTA ERROR WRITING:/
ERWRT:	ASCIZ	/ HARD ERROR WRITING:/
ERWR1:	ASCIZ	/ TRYING SAME FILE AGAIN/
PAGE
	SUBTTL	TABLE DATA FOR PROGRAM.

MTAIN1:	XWD	400000,MTAB1+1	;INIT WORD FOR BUF HDR.
MTAIN2:	POINT	MTBYT,0		;INIT BUFFER ILDB PTR.
PDLILM:	EXP	-1		;SAFETY VALVE FOR POPPING.
PDLBEG:	BLOCK	PDLSIZ
PDLLEN=	.-PDLBEG
PDINWD:	IOWD	PDLLEN,PDLBEG
ININFL:	IOWD	FILMAX,0
DATINI:	XWD	DATTAB,DATTAB+1
DATTAB=	.
DEVTAB:	BLOCK	2		;I/O DEVICE NAMES SPEC'D BY USER.
FILTAB:	BLOCK	FILMAX		;TABLE OF FILE NAMES.
EXTTAB:	BLOCK	FILMAX
HDRFIL:	BLOCK	1		;STORAGE WORD FOR FILE AS READ FROM MTA.
HDREXT:	BLOCK	1		;XWD EXT,FLAGS FOR MAKING MASKS FOR WILD CHARS.
TTIBUF:	BLOCK	TTBFSZ		;TTY INPUT BUFFER.
TTOBUF:	BLOCK	TTBFSZ		;TTY OUTPUT BUFFER.
TTFLPT:	BLOCK	2		;XWD PTR'S TO FILE SPECS FOR DECODER.
INCHCT:	BLOCK	1		;CHAR CTR FOR TTYIN BUFFER.
CMDFLS:	BLOCK	1		;NUM FILES SPECF'D IN CMD, (MAY BE INFINITE.)
NUMFIL:	BLOCK	1		;NUMBER OF FILES XFRD.
DSKHDR:	BLOCK	3		;DISK BUFFER HEADER.
MTAHDR:	BLOCK	3		;MTA BUFFER HEADER.
DATEND=	.
BUFPAR=	1
	REPEAT	MTNMBF,	<
	BLDBUF	\BUFPAR
	BUFPAR=BUFPAR+1
>
	END	INIPRO