Google
 

Trailing-Edge - PDP-10 Archives - cuspmar86binsrc_2of2_bb-fp63a-sb - 10,7/soup/fedit.mac
There are 3 other files named fedit.mac in the archive. Click here to see a list.
TITLE	FEDIT	VERSION 3	
SUBTTL	SOURCE INPUT PROCESSOR FOR FED		CWRU/CAM

;EDIT==6

;COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
EXTERN	BASCLN,BPAGNO,XSW
	EXTERN TSW,FIRST1
	EXTERN	IMPRSP
	EXTERN	LSTTY,LOGTTY
	EXTERN	CMDCN
 	EXTERNAL	MCBUF
	EXTERN	FIRST,LAST,CMDBUF,CMDCNT,BUF,BUFFCT
	EXTERN	LINEN0,COPYCT,PEOFLG,TAG,PDLIST,M,N,LASNUM
	EXTERN	CHARS,ID,MCSAV,MCSAV2,BOLX,CLINEN,DELCT,FLUSHT,COPYCT
	EXTERN	SAVEAC
	ENTRY	COMPAR
	HISEG


	EXTERNAL	MCIN
	EXTERNAL	UCDDB,MRGDDB,LOGDDB,LSTDDB
	ENTRY	FEDIT
	EXTERNAL	MANCOR,UCIN,CMDLVL,ACTAB,LSTOUT,LOGOUT
	EXTERNAL	LSTOP,FED,MRGOUT


C=1			; REGS C - C+3 FOR INTEGER TO STRING
TEMP=5			; TEMP,TEMP+1 HOLD CHAR FOR STRING TEST
BUPT=7			; POINTS TO BASE CHECK LINE
CMD=10			; POINTS TO COMMAND TEXT
CHX=11			; ONE COMMAND CHAR FOR PROCESSING
PDP=12			; FOR PUSH DOWN LIST
CHAR=13			; ONE CHAR FROM IO
RETURN=14		; GENERAL RETURN FROM IO
TAC=15		; TEMPORARY AC (CLOBBERED FREQUENTLY)



	EXTERNAL	LSTOP


PRBIT==400		;LH TAC BIT MEANING PRINT THINGS IN UPDATE
FLBIT==1000		;LH TAC BIT TELLING UPDATE WE'RE FLUSHING
INSBIT==2000		;LH TAC BIT TELLING UPDATE WE'RE INSERTING NEW
	; FEDIT IS THE FINAL EDITOR FOR SOUP
	; IT ACCEPTS THE FOLLOWING EDITING COMMANDS:

		; -N	INSERT THE TEXT WHICH FOLLOWS AFTER
		; 	THE NTH LINE OF THE ORIGINAL FILE

		; -N,M	DELETE LINES N THROUGH M INCLUSIVE AND INSERT
		; 	FOLLOWING TEXT IN THE RESULTANT HOLE

	; COMMANDS AND 'TEXT THAT FOLLOWS' COMES FROM MANCOR
	; BASE FILE INPUT FROM UCIN, NEW FILE OUTPUTTED VIA MRGOUT





FEDIT:	MOVEM	17,SAVEAC+17	; PREPARE TO RESTORE CALLERS REGS
	MOVEI	17,SAVEAC
	MOVEM	JFFSAV
	SETZM	LINEN0		; SET LINE COUNTER TO 0
	SETOM	FED		; FED HAS BEEN ENTERED
	BLT	17,SAVEAC+16	; DONE
	MOVE	PDP,[IOWD 20,PDLIST]
	MOVE	[XWD FIRST,FIRST+1]
	SETZM	FIRST
	BLT	LAST
	SKIPN	TSW		; TIME MSG?
	JRST	NOTIM		; NOT REQUIRED
	PUSHJ	PDP,TIMEIS
	JSP	14,LOGOUT
	TIMCNT
	TIMBUF
NOTIM:	MOVE	.JBFF
	MOVEM	JFFSAV		; NOW SAVE USER'S .JBFF
	SETZM	TIMCNT		; ZERO TIME COUNT
	SKIPE	LSTOP
	PUSHJ	PDP,THINK
	MOVE	17,MCBUF	; WHAT SHOULD FEDIT DO?
	JRST	.+2(17)
	JRST	COPYVR		; COPY VERBATIM
	JRST	.+2		; FULL BLOWN	EDIT
	JRST	NICHTS		; DELETE FROM COMPLEX
	SETOM	FED		; TELL CSS WE ARE RUNNING FED
	SETZM	LINEN0		; MAKE SURE LISTING IS RIGHT
	SKIPN	LSTTY
	JRST	.+4
	SKIPN	LOGTTY
	JRST	.+2
	SETOM	FIRST		; IF LST&LOG ARE TTY, DUP ER MSGS NO GOOD
	AOS	LASNUM		; LASNUM IS FIRST NUMBER THAT CAN
				; BE EDITED;  INITIALLY SET TO ONE
	PUSHJ	PDP,MCINX	; GET THE FIRST CHAR FROM CORRECTION FILE
	CAIE	CHAR,"-"	; IT MUST BE A '-' TO PLAY BALL
	JRST	ILCOM1		; IT WASN'T COMPLAIN




	; AT THIS POINT, THE FIRST - IS REMOVED FROM THE COMMAND
	; LINE, AND SCANIT WILL SCANIT FROM THERE, SUPPLYING THE
	; TWO INTEGERS N AND M AND FINDING THE ID IF IT EXISTS





PROC:	PUSHJ	PDP,SCANIT	; SCAN THE COMMAND



	; THE VARIABLE TAG IS SET TO 0 WHEN A TAG
	; (<ID>*NEW*-NNN> IS NOT DESIRED AT THE END
	; OF THE LISTING LINE  SEE UPDATE FOR MORE DETAILS



	SETOM	FIRST1		; FIRST COMMAND RECEIVED
	SETZM	TAG		; NO TAG DESIRED
	MOVE	TEMP,M
	JUMPE	TEMP,TESTN	; IF M IS 0 IT IS AN INSERTION ONLY
	CAMGE	TEMP,N		; IF NOT 0 IT MUST BE GTR N
	JRST	ILCOM1		; IF IT ISN'T, COMPLAIN
TESTN:	MOVE	TEMP,N
	JUMPE	TEMP,SKIPIT	; IF N IS 0 TOO, THIS IS A -0 COMMAND
	CAMGE	TEMP,LASNUM	; N MUST BE GE FIRST LINE LEGALLY EDITABLE
	JRST	ILCOM1		; OR ELSE FEDIT IS ANNOYED
SKIPIT:	SKIPE	M		; IF M IS 0 DO AN INSERTION ONLY
	JRST	FIXNUM		; NOT 0, DO INSERTION DELETION
	SUB	TEMP,LASNUM
	AOJ	TEMP,
	MOVEM	TEMP,COPYCT	; COPY N-LASNUM+1 LINES
	MOVE	TEMP,N		; MAKE LASNUM
	AOJ	TEMP,
	MOVEM	TEMP,LASNUM	; BE N+1
	PUSHJ	PDP,COPY	; DO THE COPY
	PUSHJ	PDP,WHERE	; IF EXCEPTIONS MODE, TYPE LOCATING MESSAGE
	SETOM	TAG		; NEW LINES NEED THE TAG
	PUSHJ	PDP,INSERT	; NOW DO THE INSERT
	SETZM	TAG		; NOW MAKE THE TAG DISAPPEAR
	JRST	PROC		; GO TRY FOR ANOTHER COMMAND
FIXNUM:	MOVE	TEMP,N
	SUB	TEMP,LASNUM
	MOVEM	TEMP,COPYCT	; INSERTION DELETION REQUIRES
				; THAT N-LASNUM LINES SHOULD BE COPIED
	MOVE	TEMP,M
	SUB	TEMP,N
	AOJ	TEMP,
	MOVEM	TEMP,FLUSHT	; AND M-N+1 LINES DELETED
	MOVEM	TEMP,CMDCN	; CMDCNT HOLDS IT FOR LIST ROUTINE
	AOS	TEMP,M
	MOVEM	TEMP,LASNUM	; LASNUM SET TO M+1
	SETZM	TAG		; NO TAG YET
	PUSHJ	PDP,COPY	;  COPY THE INDICATED LINES
	PUSHJ	PDP,WHERE
	PUSHJ	PDP,FLUSH	; FLUSH THE OLD LINES
	MOVE	TEMP,CMDCN	; GET THE NUMBER OF LINES DELETED
	ADDM	TEMP,DELCT	; TO TELL LIST ROUTINE
	SETOM	TAG		; NEW LINES NEED TAG
	PUSHJ	PDP,INSERT	; INSERT THE NEW ONES
	SETZM	TAG		; RESET THE FLAG
	JRST	PROC		; READ NEXT COMMAND
ILCOM1:	JSP	14,LOGOUT	; COMPLAINTS ARE REGISTERED HERE
				; REMEMBER THAT THE OFFENSIVE COMMAND
				; IS IN THE CMDBUF
	[^D25]
	[ASCII/*** IMPROPER SEQUENCING
/]
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[^D25]
	[ASCII/*** IMPROPER SEQUENCING
/]
	PUSHJ	PDP,CLINEO	; CALL COMMAND LINE OUT ROUTINE
	PUSHJ	PDP,FLUSH2	; FLUSH CORR. FILE TO NEXT COMMAND
	JRST	PROC		; THEN SEE IF USER DOES ANY BETTER


	; WHERE PRINTS AN IDENTIFYING MESSAGE IN EXCEPTIONS (/X) MODE
	; TELLING WHERE THE DIFFERENCES OCCURRED IN THE BASE FILE.

WHERE:
	SKIPN	XSW		;LISTING ONLY EXCEPTIONS?
	 POPJ	 PDP,		; NO, DONE
XINS:	PUSH	PDP,CHAR	; SAFETY -- DCS
	MOVNI	14,3
	ADDB	14,LINCTR	;CHECK OVERFLOW
	JUMPG	14,NOHD
	SKIPN	HEADSW
	JRST	NOHD		;NO HEADING DESIRED
	PUSHJ	PDP,THINK	;PRINT HEADING IF NECC.
	SOS	LINCTR		;ACCOUNT FOR 1 LINE ONLY
	JRST	NOSPP
NOHD:	JSP	14,LSTOUT
	[2]
	[BYTE (7)12,12]		;TWO EXTRA SPACES
NOSPP:
	JSP	14,LSTOUT	; GET PAGE NUMBER IN
	[13]
	[ASCII .AFTER PAGE .]
	MOVE	C+1,BPAGNO	; ASCII
	AOJ	C+1,		;ALWAYS ONE BEHIND
	PUSHJ	PDP,NCON
	JSP	14,LSTOUT
	C+3
	C+2
	JSP	14,LSTOUT	;NOW LINE NUMBER
	[7]
	[ASCII	/, LINE /]
	SKIPN	BASCLN		;USE "EDIT10" SEQUENCE # IF PRESENT
	 JRST	 NONASC		; NONE, USE OTHER
	JSP	14,LSTOUT
	[5]
	BASCLN
	JRST	FINL
NONASC:	MOVE	C+1,LINEN0
	PUSHJ	PDP,NCON
	JSP	14,LSTOUT
	C+3
	C+2
FINL:	JSP	14,LSTOUT
	[2]
	[BYTE (7) 15,12]
	POP	PDP,CHAR	;UNSAFETY -- DCS
	POPJ	PDP,		;DONE
	; COPY IS A ROUTINE THAT COPIES LINES FROM THE BASE FILE 

	; INTO THE NEW FILE VERBATIM.  THE NUMBER OF LINES TO BE

	; COPIED IS STORED IN COPYCT




COPY:	SKIPN	COPYCT		; ANY LINES TO BE COPIED
	POPJ	PDP,		; NO SO RETURN
	PUSHJ	PDP,UCINX	; GET A CHAR FROM OLD FILE
	JUMPE	CHAR,RELES0	; ZERO MEANS EOF
	MOVE	TEMP,CHAR	; SAVE IT IN TEMP
	MOVSI	TAC,0		; PRINT (WILL BE INVERTED), NO
				;  FLUSH, NOT INSERTING FROM NEW
	PUSHJ	PDP,UPDATE	; MAKE IT APPEAR IN LISTING
	CAIL	TEMP,15		; FEED CHAR?
	JRST	COPY		; NO
	HLRZ	TEMP,ACTAB(TEMP)
	JUMPE	TEMP,COPY
	SOSLE	COPYCT		; YES, ONE LINE COPIED
	JRST	COPY
	POPJ	PDP,		; NOTHING LEFT FOR ME TO DO




	; INSERT IS A ROUTINE THAT INSERTS TEXT FOUND IN THE

	; CORRECTION FILE INTO THE NEW FILE. IT QUITS WHEN

	; IT FINDS THE NEXT COMMAND


INSERT:	PUSHJ	PDP,MCINX	; GET A CHAR FROM CORR. FILE
	CAIN	CHAR,55		; - MEANS DONE ALREADY
	POPJ	PDP,
	MOVE	TEMP,CHAR
	HLRZ	CHAR,ACTAB(TEMP)
	JUMPE	CHAR,INSRT0
INSRT9:	
	MOVSI	TAC,INSBIT	;INSERT, NO FLUSH, PRINT
	SETZM	BOLX		; BREAK CHAR RESETS END OF LINE
	PUSHJ	PDP,UPDATE	; AS FAR AS UPDATE IS CONCERNED
	PUSHJ	PDP,MCINX	; GET ONE MORE
	CAIN	CHAR,55		; - AFTER FEED MEANS COMMAND
	POPJ	PDP,		; AND THAT MEANS TO STOP
	MOVE	TEMP,CHAR	; NOT A - THEREFORE OUTPUT IT
	HLRZ	CHAR,ACTAB(CHAR); A FEED??
	JUMPN	CHAR,INSRT9	; OUTPUT TILL - SHOWS UP!!
INSRT0:	
	MOVSI	TAC,INSBIT	;INSERT, NO FLUSH, PRINT
	PUSHJ	PDP,UPDATE
INSRT1:	PUSHJ	PDP,MCINX	; SPECIAL CASES ALL DONE
	MOVE	TEMP,CHAR
INSRT2:	
	MOVSI	TAC,INSBIT
	PUSHJ	PDP,UPDATE	; COPY EVERYTHING UNTIL A FEED SHOWS UP
	CAIL	TEMP,15
	JRST	INSRT1
	HLRZ	TEMP,ACTAB(CHAR)
	JUMPE	TEMP,INSRT1
	PUSHJ	PDP,MCINX	; FEED CHAR APPEARS
	MOVE	TEMP,CHAR
	CAIE	TEMP,55		; IS IT FOLLOWED BY A -?
	JRST	INSRT2
	SETZM	TAG		; YES
	POPJ	PDP,		; GWAN BACK




	; FLUSH DELETES LINES BY NOT OUTPUTTING ANYTHING

	; THE NUMBER OF LINES TO BE FLUSHED IS STORED

	; IN FLUSHT


FLUSH:	SKIPG	FLUSHT		; ANY LINES TO BE FLUSHED?
	POPJ	PDP,		; NOPE
	PUSHJ	PDP,UCINX	; GET OLD FILE CHAR
	PUSH	PDP,CHAR	;SAFETY -- DCS
	MOVE	TEMP,CHAR	;WOW
	MOVSI	TAC,FLBIT!PRBIT ;FLUSH, NO PRINT, NO INSERT
	 PUSHJ	 PDP,UPDATE	; IN EXCEPTIONS MODE
	POP	PDP,CHAR
	CAIL	CHAR,15
	JRST	FLUSH
	HLRZ	CHAR,ACTAB(CHAR)
	JUMPE	CHAR,FLUSH
	SOSLE	FLUSHT		; FEED CHAR, DECR COUNT
	JRST	FLUSH
	POPJ	PDP,		; ALL DONE




	; CMDLIN BUFFERS UP THE EDITING COMMAND SO IT CAN

	; BE DUMPED SOMEWHERE IF IT IS ILLEGAL.  IT IS

	; STORED IN ASCIZ FORM IN CMDBUF, AND IT IS C(CMDCNT)

	; CHARACTERS LONG.




CMDLIN:	MOVE	[XWD	CMDBUF,CMDBUF+1]		; PREPARE TO ZERO BUFFER AREA
	SETZM	CMDBUF
	BLT	CMDBUF+30
	MOVE	CMD,[POINT 7,CMDBUF-1,35]	; INIT BYTE POINTER
	SETZM	CMDCNT
CMDCH:	PUSHJ	PDP,MCINX	; GET A CHAR
	IDPB	CHAR,CMD	; MAKE A DEPOSIT
	SKIPE	CMDBUF+30	; OVERFLOW?
	JRST	BUFUL		; OUCH
	AOS	CMDCNT		; BOOKKEEP
	HLRZ	TEMP,ACTAB(CHAR)
	JUMPE	TEMP,CMDCH
SETIT:	MOVE	CMD,[POINT 7,CMDBUF-1,35]	; FEED ENCOUNTERED, RESET POINTER
	POPJ	PDP,		; COMMAND CAN NOW BE CRAWLED OVER BY SCANNER
BUFUL:	TTCALL	3,[ASCIZ/?GAG? LINE TOO LONG TRUNCATED TO /]
	TTCALL	3,CMDBUF
	TTCALL	3,[ASCIZ/
/]
	MOVEI	CHAR,15
	DPB	CHAR,CMD
	MOVEI	CHAR,12
	IDPB	CHAR,CMD
	JRST	SETIT



	; GETNUM CONVERTS STRING TO INTEGER. IT IS ENTERED WITH
	; THE FIRST CHARACTER TO BE CONVERTED IN CHX.
	; IT HALTS WHEN IT FINDS A NON-NUMERIC CHARACTER, WHICH
	; IT LEAVES IN REG CHX, WITH 60 SUBTRACTED FROM IT


GETNUM:	SUBI	CHX,60		; MAKE THE ASCII AN INTEGER
	JUMPL	CHX,CPOPJ	; NOT NUMERIC, RETURN
	CAIL	CHX,12
	POPJ	PDP,
	MOVE	TEMP+1,CHX	;  MOVE INTEGER TO TEMP+1
NUMCH:	ILDB	CHX,CMD		; GET NEXT ONE FROM BUFFER
	SUBI	CHX,60		; MAKE IT INTEGER
	JUMPL	CHX,CPOPJ	; NOT NUMERIC, RETURN
	CAIL	CHX,12
	POPJ	PDP,
	IMULI	TEMP+1,12	; MULTIPLY DIGIT BY 10
	ADD	TEMP+1,CHX	; ADD NEW DIGIT
	JRST	NUMCH		; NOW LOOK FOR MORE




	; SCANIT IS ENTERED WITH THE BYTE POINTER IN CMD

	; POINTING JUST PAST THE FIRST '-' IN THE COMMAND.

	; IT WILL NOT RETURN UNTIL IT HAS SCANNED A SYNTACTICALLY 

	; KOSHER COMMAND




SCANIT:	PUSHJ	PDP,CMDLIN	; GET A COMMAND INTO THE BUFFER
	SETZM	ID		; SET ID TO 0
	ILDB	CHX,CMD		; LOAD THE FIRST CHARACTER
	CAIE	CHX,40		; BLANKS
	CAIN	CHX,11		; OR TABS
	JRST	IGNOR		; ARE IGNORED
	CAIN	CHX,55		; A - MEANS
	JRST	INSRT3		; INSERT THE COMMAND VERBATIM
	CAIGE	CHX,"0"
	JSP	14,ILLCOM
	CAILE	CHX,"9"
	JSP	14,ILLCOM		; ANYTHING NOT NUMERIC IS DISCARDED
FIRSTN:	PUSHJ	PDP,GETNUM	; NUMERICS FALL THROUGH HERE
	ADDI	CHX,60		; FIND OUT WHY GETNUM STOPPED
	MOVEM	TEMP+1,N	; PUT THE NUMBER FOUND IN N
	SETZM	M		; ZERO M TO DISTINGUISH INSERTION ONLY 
	CAIN	CHX,15		; CR TERMINATING MEANS END OF LINE
	POPJ	PDP,
	CAIN	CHX,","		; COMMA TERMINATING MEANS ID OR 2ND #
	JRST	SECOND
	CAIN	CHX,":"		; : MEANS REDUNDANCY CHECK IMMENENT
	JRST	REDUN
	CAIE	CHX,40		; BLANKS
	CAIN	CHX,11		; OR TABS
	POPJ	PDP,		; ALSO MEAN END OF LINE
	JSP	14,ILLCOM		; ANYTHING ELSE IS AN ERROR





SECOND:	MOVEI	TEMP+1,0	; ZERO INTEGER RETURN REG
	ILDB	CHX,CMD		; GET NEXT CHAR
	PUSHJ	PDP,GETNUM	; SEE IF THERE IS ANOTHER NUMBER
	MOVEM	TEMP+1,M	; STORE IT IN M
	JUMPE	TEMP+1,GETID	; IF IT WAS ZERO, THE ID FIELD EXISTS
	ADDI	CHX,60		; A NUMBER WAS ON THE LINE 
	CAIN	CHX,15		; CR MEANS DONE
	POPJ	PDP, 
	CAIN	CHX,54		; COMMA MEANS SCAN THE ID TOO
	JRST	GETID
	CAIE	CHX,40		; SPACES
	CAIN	CHX,11		; AND TABS
	POPJ	PDP,		; SIGNIFY FIN




	; ILLEGAL (SYNTACTICALLY) COMMANDS ARE DUMPED AND 

	; EDITED HERE

ILLCML:	JSP	14,ILLCOM
	JFCL
ILLCME:	JSP	14,ILLCOM
	JFCL

ILLCOM:	JSP	14,LOGOUT
	[^D22]
	[ASCII/*** IMPROPER COMMAND
/]
	SETZM	TAG
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[^D22]
	[ASCII/*** IMPROPER COMMAND
/]
	PUSHJ	PDP,CLINEO	; NUMBER THE CORRECTION LINE
	PUSHJ	PDP,FLUSH2	; FLUSH UP TO NEXT COMMAND
	JRST	SCANIT		; TRY THIS NEW ONE






	; A REDUNDANCY CHECK IMPLIES FURTHER THAT SOME LINES MUST BE

	; COPIED


REDUN:	SUB	TEMP+1,LASNUM
	JUMPL	TEMP+1,ILLCOM	; N-LASNUM LINES MUST BE COPIED
	MOVEM	TEMP+1,COPYCT
	MOVE	TEMP+1,N
	MOVEM	TEMP+1,LASNUM
	AOS	LASNUM		; AND LASNUM MUST BE N+1 
	PUSHJ	PDP,COPY	; COPY THE LINES
	PUSHJ	PDP,BUFFER	; GET THE BASE LINE INTO THE BUFFER
	PUSHJ	PDP,COMPAR	; DO THE STRING COMPAR
	SKIPA			; RETURN HERE IF THEY MATCH
	JRST	NOMATC		; OTHERWISE TROUBLE
	PUSHJ	PDP,MCINX	; SEE IF NEXT LINE IS A COMMAND
	CAIE	CHAR,55
	JSP	14,ILLCOM		; IT WASN'T
	JRST	SCANIT		; GET A REAL COMMAND

 


	; AT THIS POINT, THE CHECK LINES DO NOT MATCH

	; AND A DIALOG WITH THE USER IS NECESSARY


NOMATC:	MOVE	TEMP,[POINT 7,CMDBUF-1,35]
	TTCALL	3,[ASCIZ/		*** UNMATCHING SYNC LINES:
BASE FILE WAS:
	/]
	ILDB	CHX,TEMP
	CAIE	CHX,":"		; FLUSH THE LINE UNTIL THE : SHOWS UP
	JRST	.-2
	MOVE	C+1,CLINEN
	PUSHJ	PDP,NCON	; GET NUMBER OF UNMATCHING LINE
	TTCALL	3,C+2		; TYPE IT OUT
	TTCALL	3,[ASCIZ/.	/]
	ILDB	CHX,TEMP
	TTCALL	1,CHX
	JUMPN	CHX,.-2		; TYPE EACH CHAR OUT ONE BY ONE
	TTCALL	3,[ASCIZ/
USER'S FILE IS: 
	/]
	MOVE	C+1,LASNUM
	SOJ	C+1,
	PUSHJ	PDP,NCON	; GET AND CONVERT BASE LINE NUMBER
	TTCALL	3,C+2		; TYPE IT OUT
	TTCALL	3,[ASCIZ/.	/]
	TTCALL	3,BUF		; AND FEED HIM THE BUFFER
	TTCALL	1,[12]		; AND A LINE FEED TO BE NEAT
	TTCALL	3,[ASCIZ/*/]	; THEN A * TO FORCE A REPLY
RETRY:	TTCALL	4,TEMP		; LISTEN FOR A LINE TO BE TYPED
	TTCALL	11,0		; CLEAR INPUT BUFFER
	CAIN	TEMP,"K"	; A  K
	JRST	GNEXT		; MEANS KEEP THIS FILE
	CAIN	TEMP,15		; A CR MEANS
	JRST	COPY1		; COPY IT WITH NO MORE ALTERATIONS 
	TTCALL	3,IMPRSP	; IMPROPER RESPONSE
	JRST	RETRY		; ANYTHING ELSE IS NOT 'MEANINGFUL DIALOG'
GNEXT:	PUSHJ	PDP,MCINX	; USER WANTS TO LIVE DANGEROUSLY
	CAIE	CHAR,55		; NEXT COMMAND MUST BE FOR REAL
	JSP	14,ILLCOM		; LEST WE COMPLAIN
	JRST	SCANIT		; SCAN THE NEW COMMAND




	; BUFFER PUTS THE LINE FROM THE BASE FILE TO BE CHECKED

	; IN ASCIZ FORM WITH THE FEED CHAR ERASED INTO BUF.

	; IT ALSO COPIES THE LINE IT BUFFERS UP INTO THE NEW FILE


BUFFER:	MOVE	BUPT,[POINT 7,BUF-1,35]	; SET UP THE POINTER TO THE BUFFER
	SETZM	BUFFCT		; ZERO THE CHAR COUNT
BCH:	PUSHJ	PDP,UCINX	; GET SOMETHING
	IDPB	CHAR,BUPT	; AND PUT IT AWAY
	MOVE	TEMP,CHAR	;  AND THEN COPY THE CHAR
	MOVSI	TAC,0		;PRINT, NO FLUSH, NO INSERT
	PUSHJ	PDP,UPDATE	; VIA UPDATE
	AOS	BUFFCT		; BOOK KEEP
	CAIL	CHAR,15
	JRST	BCH
	HLRZ	TEMP,ACTAB(CHAR)
	JUMPE	TEMP,BCH
	MOVEI	TEMP,0		; FEED?
	DPB	TEMP,BUPT	; YES,REPLACE WITH NULL
	MOVE	BUPT,[POINT 7,BUF-1,35]	; RESET POINTER
	POPJ	PDP,		; GO BACK




	; COMPAR TESTS IF THE STRINGS IN CMDBUF AND BUF ARE

	; THE SAME. IT GIVES A SKIP RETURN IF THEY ARE DIFFERENT.

	 ; CHECK LINES  CAN CONTAIN A CR-CR-LF MEANING THAT THE 

	; ORIGINAL LINE WAS ONLY A CR-LF. IF A CHECK LINE HAS ONLY

	; A CR-LF AT THE END, THE ORIGINAL LINE WAS A FEED CHAR

	; THIS ROUTINE MUST TRY TO MAKE SENSE OUT OF THESE OCCURENCES


COMPAR:	SETZM	MCSAV		; ZERO A FLAG
	ILDB	TEMP,CMD	; LOAD CMD CAR 
	ILDB	TEMP+1,BUPT	; LOAD OLD FILE CHAR
	CAIN	TEMP,15		; A CR IN CMD LINE REQUIRES SPEC. CONSIDERATION
	JRST	BUFMT
	JUMPE	TEMP+1,CPOPJ1	; A NULL MEANS ALL DONE
	CAME	TEMP,TEMP+1	; TEST THEM
	JRST	CPOPJ1		; NO MATCH, SKIP RETURN
	JUMPE	TEMP,CPOPJ	; COMPARING NULLS MEANS SUCCESS
	JRST	COMPAR		; TEST THE REST
BUFMT:	JUMPE	TEMP+1,NOFEED	; NULL LINE MEANS LINE WAS FEED ONLY
	SKIPE	MCSAV		; BEEN HERE BEFORE?
	JRST	CPOPJ1		; YES, AND NO MATCH
	AOS	MCSAV		; NO, LEAVE FOOTPRINTS
	CAMN	TEMP+1,TEMP	; TEST CHARS
	JRST	CPOPJ		; SAME, RETURN
CPOPJ1:	AOS	(PDP)		; DIFFERENT,POP RETURN
CPOPJ:	POPJ	PDP,		; GENERAL RETURN, FROM OTHER PLACES TOO
NOFEED:	ILDB	TEMP,CMD	; THE NEXT CHAR SHOULD BE A LINE FEED
	CAIN	TEMP,12
	JRST	CPOPJ		; IT WAS
	JRST	CPOPJ1		; IT WASN'T




	; INTEGER TO STRING -- ENTER WITH NUMBER IN C+1

	; RETURNS WITH ASCII IN C+2 AND CHARACTER COUNT 

	; IN C+3


NCON:	SETZB	C,C+2		; ZERO SOME REGISTERS
	MOVEI	C+3,0
	DIVI	C,12		; DIVIDE NUMBER BY 10
	ADDI	C+1,60		; MAKE REMAINDER ASCII
	ROTC	C+1,-7		; SHIFT INTO C+2
	MOVE	C+1,C		; SWAP QUOTIENT AND REMAINDER
	MOVEI	C,0	 	; ZERO C TO MAKE DIVI WORK
	AOJ	C+3,		; BOOKKEEP CHAR COUNT				
	JUMPN	C+1,.-6		; LOOP UNTIL REMAINDER IS ZERO
	POPJ	PDP,		; AND WHEN THAT HAPPENS, RETURN




	; MCINX GETS CHARACTERS ONE BY ONE FROM THE CORRECTION

	; FILE USING MANCOR. THE LAST CHAR READ MAY

	; BE SAVED IN MCSAV2 TO BE USED TWICE UNDER CERTAIN

	; CONDITIONS, SUCH AS LOOKING FOR THE

	; SEQUENCE <FEED>-'-' - '-' WHEN THE CORRECTION FILE

	; IS BEING FLUSHED




MCINX:	SKIPE	MCSAV2		; HAS A CHAR BEEN SAVED?
	JRST	MCPOP		; YES
	PUSHJ	16,MANCOR	; CALL MANCOR
	CHAR			; PUT  CHARACTER INTO CHAR
	JRST	COPY1		; EOF RETURN
	JUMPE	CHAR,COPY1	; NULL MEANS  EOF
CKCHAR:	CAIL	CHAR,15
	POPJ	PDP,
	HLRZ	TEMP,ACTAB(CHAR)
	JUMPE	TEMP,CPOPJ
	AOS	CLINEN		; A FEED CHAR FORCES LINE COUNT
	POPJ	PDP,		; TO BE INCREMENTED
MCPOP:	MOVE	CHAR,MCSAV2	; LOAD SAVED CHAR
	SETZM	MCSAV2		; UNSTORE IT
	JRST	CKCHAR		; SEE IF IT WAS A FEED






	; UPDATE MAKES THE NEW FILE AS WELL AS A LISTING

	; IF ORIGINALLY REQUESTED. ENTER WITH

	 ; THE CHARACTER TO BE OUTPUT IN REGISTER TEMP




UPDATE:	
	TLNN	TAC,INSBIT	; IF INSERTING OR IF
	SKIPN	XSW		;  NOT IN EXCEPTIONS MODE,
	 TLC	TAC,PRBIT	;  CORRECT THE PRINT BIT
	TLNE	TAC,FLBIT	; IF FLUSHING, DO NOT
	 JRST	 UPDATF		;  PUT CHARACTER IN OUTPUT FILE
	JSP	14,MRGOUT	; OUTPUT THE GIVEN CHARACTER
	[0]
	TEMP
UPDATF:	SKIPN	LSTOP		; SKIP IF LIST DESIRED
	POPJ	PDP,
	CAIL	TEMP,15		; FEED CHAR?
	JRST	CPY1
	CAIG	TEMP,11
	JRST	CPY1
	CAIN	TEMP,14
	MLON
	JRST	[ SKIPN	XSW
		  JRST	.+1	;IF INSERTING AND A FF AND EXCEPTIONS,
		  JRST	CPY1	; GO HANDLE ELSEWHERE
		]
	SKIPN	BOLX		; YES - SKIP IF BEGINNING OF LINE
	PUSHJ	PDP,LINUM	; HAS ALREADY BEEN EDITED WITH NUMBERS
FIXEND:
	TLNN	TAC,PRBIT	;PRINTING?
	JRST	NOTG1		; NOT THIS LINE, RETURN
	TLNE	TAC,INSBIT	;(IF NOT INSRTNG, DON'T PRINT #DELETED YET)
	SKIPN	DELCT
	JRST	NUTHIN
	SKIPN	ID
	JRST	NOID
	PUSHJ	PDP,SPACES
	TLO	TAC,100
	JSP	14,LSTOUT
	[3]
	ID
	TLO	TAC,200
NOID:	TLON	TAC,100
	PUSHJ	PDP,SPACES
	MOVE	C+1,DELCT
	PUSHJ	PDP,NCON
	JSP	14,LSTOUT
	[2]
	[ASCII/*-/]
	JSP	14,LSTOUT
	C+3
	C+2
	SETZM	DELCT
NUTHIN:	
	TLNN	TAC,FLBIT!INSBIT
	JRST	NOTAG		;TAG IF INSERTING, OR FLUSHING & PRINTING
TAGIT:	TLON	TAC,100
	PUSHJ	PDP,SPACES
	SKIPN	ID
	JRST	NOID1
	TLOE	TAC,200
	JRST	NOID1
	JSP	14,LSTOUT
	[3]
	ID
NOID1:	
	MOVEI	C+1,[ASCII /*NEW*/] ;ASSUME NEW
	TLNN	TAC,INSBIT	    ;*OLD* IF FLUSHING
	MOVEI	C+1,[ASCII /*OLD*/] ;WRONG ASSUMPTION
	JSP	14,LSTOUT
	[5]
	XWD	20,C+1		;WOW, INDIRECT BIT
NOTAG:	JSP	14,LSTOUT
	[0]
	[15]			; OUTPUT A CR
	JSP	14,LSTOUT
	[0]
	TEMP			; OUTPUT ORIGINAL FEED CHAR
NOTG1:	SETZM	BOLX		; SET BOL TO 0
	SETZM	CHARS		; SET CHARS TO 0
	TLNN	TAC,PRBIT	; PRINTING THIS TIME?
	 POPJ	 PDP,		;  NO
	CAIN	TEMP,14		; FORM FEED?
	JRST	THINK2		; SEE IF HEADING NEEDED
	SOSN	LINCTR		; TIME FOR HEADING
	JRST	THINK		; MAYBE
	SETZM	BOLX		; TELL LINUM IT'S OK TO NUMBER NXT LINE
	POPJ	PDP,		; ALL DONE
THINK:	SKIPN	HEADSW		; HEADING?
	POPJ	PDP,
	JSP	14,LSTOUT
	[0]
	[14]			;FORM FEED
	JRST	HEADNG		; DO HEADING
THINK2:	SKIPE	HEADSW
	SKIPE	XSW		; NO HEADING ON FF IF IN EXCEPTION MODE
	POPJ	PDP,
	JRST	HEADNG		; DO HEADING (LIKE PUSHJ-POPJ)
 
SIXOUT:	JSP	14,LSTOUT
	SIXCNT
	SIXBUF
	POPJ	PDP,
	EXTERN	HEADSW,LINCTR,PAGCNT,SIXTO7,SIXBUF,SIXCNT
DUMP6:	HRRZM	TAC,P6WORD
	PUSHJ	16,SIXTO7
	PUSHJ	PDP,SIXOUT
	MOVE	TAC,P6WORD
	AOJ	TAC,
	HRROM	TAC,P6WORD
	PUSHJ	16,SIXTO7
	PUSHJ	PDP,SIXOUT
	POPJ	PDP,
	EXTERN	P6WORD
	EXTERN	MCDDB
HEADNG:	MOVEI	^D49
	PUSH	PDP,TAC		;SAVE IT
	MOVEM	LINCTR
	MOVEI	TAC,MRGDDB+2
	PUSHJ	PDP,DUMP6
	JSP	14,LSTOUT
	[20]
	[ASCII/ PREPARED FROM  /]
	MOVEI	TAC,UCDDB+2
	PUSHJ	PDP,DUMP6
	JSP	14,LSTOUT
	[6]
	[ASCII/ AND  /]
	MOVEI	TAC,MCDDB+2
	PUSHJ	PDP,DUMP6
	EXTERN	ID.
	SKIPN	ID.
	JRST	OVER1
	JSP	14,LSTOUT
	[4]
	[ASCII/ BY /]
	JSP	14,LSTOUT
	[4]
	ID.
	JSP	14,LSTOUT
	[0]
	[11]
OVER1:	PUSHJ	PDP,TODAY
	AOS	C+1,PAGCNT
	JSP	14,LSTOUT
	[11]
	[ASCII/		PAGE:  /]
	PUSHJ	PDP,NCON
	JSP	14,LSTOUT
	C+3
	C+2
	JSP	14,LSTOUT
	[14]
	[BYTE (7) 15,12,"F","R","O","M"," ","P","A","G","E"," "]
	MOVE	C+1,BPAGNO
	AOJ	C+1,		;ALWAYS ONE BEHIND
	PUSHJ	PDP,NCON	;MAKE ASCII
	JSP	14,LSTOUT
	C+3
	C+2
NOSOS:	JSP	14,LSTOUT
	[4]
	[BYTE	(7) 15,12,12,12]
	POP	PDP,TAC		;GET IT BACK
DIDID:	POPJ	PDP,
	EXTERNAL DATCNT,DATBUF,TIMCNT,TIMBUF
TODAY:	SKIPE	DATCNT		; DATE EDITED?
	JRST	OUT1		; YES
	CALLI	C+1,14		; GET DATE
	MOVEI	C,0
	DIVI	C,37		; DIV BY 31
	AOJ	C+1,
	PUSH	16,C+1		; SAVE FOR LATER
	MOVE	C+1,C		; GET QUOTIENT
	MOVEI	C,0
	DIVI	C,14		; DIV BY 12
	AOJ	C+1,
	PUSH	PDP,C		; SAVE QUOTIENT FOR LATER
	MOVE	TAC,[POINT 7,DATBUF-1,35]
	MOVEI	C+3,"-"		; FOR DATE
	PUSHJ	PDP,NPUT	; EDIT
	ADDM	C+2,DATCNT	; SAVE CHAR CNT
	POP	16,C+1		; GET OLD QUOTIENT
	PUSHJ	PDP,NPUT	; NOW EDIT DAY
	ADDM	C+2,DATCNT	; COUNT
	MOVEI	C+3,"	"		; EDIT TAB
	POP	PDP,C+1		; GET YEAR
	ADDI	C+1,^D64	; RELOCATE (!)
	PUSHJ	PDP,NPUT	; EDIT
	ADDM	C+2,DATCNT	; COUNT
	PUSHJ	PDP,TIMEIS
OUT1:	JSP	14,LSTOUT
	DATCNT
	DATBUF
	JSP	14,LSTOUT	; GIVE THE TIME
	TIMCNT
	TIMBUF
	POPJ	PDP,		; RETURN






TIMEIS:	MOVE	TAC,[POINT 7,TIMBUF-1,35]
	MOVEI	C+3,":"
	CALLI	C+1,22		; TIME OF DAY
	MOVEI	C+2,3		; SETUP FOR BABYLONIAN ARITHMETIC
	MOVEI	C,0
	DIVI	C,^D60		; MOD 60
	PUSH	16,C+1		; SAVE REMAINDERS
	MOVE	C+1,C		; EXCHANGE
	SOJG	C+2,.-4		; INSCRIBE IN CLAY LUMP 4 TIMES
	PUSHJ	PDP,NPUT	; EDIT HOURS
	ADDM	C+2,TIMCNT
	POP	16,C+1		; MINUTES
	PUSHJ	PDP,NPUT
	ADDM	C+2,TIMCNT
	POP	16,C+1
	MOVEI	C+3,40		; SPACE
	PUSHJ	PDP,NPUT	; EDIT SECONDS
	ADDM	3,TIMCNT	; COUNT CORRECTLY
	POP	16,14		; THROW AWAY TICKS
	POPJ	PDP,		; RETURN

;N.B. -- THE FAMOUS DEC RECURSIVE NUMBER PRINTER!
NPUT:	MOVEI	C,0		;WILL BE CHARACTER COUNT
	PUSHJ	PDP,FRNP	;CALL THE RECURSIVE NUMBER PRINTER
	IDPB	C+3,TAC		;TACKON SPECIAL CHAR N C+3
	MOVEI	C+2,1(C)	;FINAL CHAR COUNT
	POPJ	PDP,		;DONE
FRNP:	IDIVI	C+1,12		;DIVIDE BY 10
	IORI	C+2,"0"		;REMAINDER IS LOW ORDER DIGIT
	HRLM	C+2,(PDP)	;SAVE IN LH OF RETURN ADDR
	JUMPE	C+1,.+2		;ALL DONE? (LEADING ZERO FOR FREE)
	PUSHJ	PDP,FRNP	;NO, RECUR UNTIL DONE
	HLRZ	C+1,(PDP)	;GET NEXT HIGH DIGIT BACK
	IDPB	C+1,TAC		;DEPOSIT
	ADDI	C,1		;COUNT
	POPJ	PDP,		;DONE THIS LEVEL

LINUM:	
	MOVEI	C+3,0		;IN CASE NO LINE NUMBER (FLUSHING)
	TLNE	TAC,FLBIT	;FLUSHING?
	 JRST	 NOS1		;RIGHT, NO NUMBER
	AOS	C+1,LINEN0	; GET NUMBER OF THIS LINE
	PUSHJ	PDP,NCON	; AND MAKE IT ASCII
NOS1:	
	TLNN	TAC,PRBIT	;PRINTING THIS TIME?
	 JRST	 LNDON		; NO, JUST QUIT
	TLNN	TAC,INSBIT	; IF NOT INSERTING AND THERE IS  AN "EDIT10"
	SKIPN	BASCLN		; SEQUENCE NUMBER, USE IT STATT LINE #
	 JRST	 LINENN		; USE BLANK, OR LINEN0
	JSP	14,LSTOUT
	[5]
	BASCLN			;THE LINE NUMBER IN ASCII
	JSP	14,LSTOUT
	[0]
	[11]			;JUST A TAB
	JRST	LNDON		; NOW QUIT
LINENN:
	MOVEI	5
	SUB	C+3
	JUMPLE	NOSPAC		; PUT OUT 5-C(C+3) SPACES TO RT JUSTIFY
	JSP	14,LSTOUT
	0
	[ASCII/     /]
	JUMPE	C+3,NONUM	;IF NONE WAS PROFERRED
NOSPAC:	JSP	14,LSTOUT
	C+3
	C+2			; NOW THE ASCII
NONUM:	JSP	14,LSTOUT
	[2]
	[ASCII/.	/]	; AND SOMETHING TO MAKE IT LOOK NICE
LNDON:
	MOVE	CHAR,TEMP
	SETOM	BOLX		; MAKE NOTE OF THE FACT WE ARE DONE
	POPJ	PDP,		; AND RETURN


CPY1:	CAIN	TEMP,15
	POPJ	PDP,		; PREVENT CR'S FROM COMING IN MIDDLE OF LINE
	SKIPN	BOLX		; NUMBER IF YOU MUST
	PUSHJ	PDP,LINUM
	TLNN	TAC,PRBIT	; PRINTING THIS TIME?
	 POPJ	 PDP,		; NO, QUIT
	AOS	C,CHARS		; INCREMENT COUNT OF CHARS ON TIS LINE
	CAIN	TEMP,14		;IF FF,
	 JRST	 [JSP 14,LSTOUT ;PUT OUT INDICATION
		  [12]
		  [ASCII .<NEW PAGE>.]
		  ADDI C,11
		  MOVEM C,CHARS
		  MOVEI TEMP,12  ;NOW SIMULATE LF
		  JRST UPDATF	;IN LISTING FILE
		]
	CAIN	TEMP,11
	PUSHJ	PDP,ADD7	; TABS NEED SPECIAL TREATMENT
	JSP	14,LSTOUT
	[0]
	TEMP			; MAKE THE ORIGINAL CHAR APPEAR ON LISTING
	MOVE	CHAR,TEMP	; RESTORE THINGS 
	POPJ	PDP,		; AND RETURN






	; WHEN CONTROL GETS TO HERE, THE CORRECTION SUBFILE HAS

	; HIT EOF.  THE FILE IS THEN TO BE COPIED VERBATIM, WITH

	; NO TAGS AT THE END OF THE LINE




COPY1:	SETZM	TAG
	JUMPL	CHAR,.+2
	SETOM	PEOFLG		; SET A FLAG TO RETURN PROPER VALUE
COPY1A:	JSP	RETURN,UCIN
	MOVE	TEMP,CHAR
	JUMPE	CHAR,RELESE
	MOVSI	TAC,0
	PUSHJ	PDP,UPDATE	; COPY CHARS AS IS
	JRST	COPY1A
RELESE:	RELEAS	2,		; AT THIS POINT GAME IS OVER
	RELEAS	4,		; CLEAN UP IO
	RELEAS	3,
	SKIPN	TSW
	JRST	NOTIM1
	SETZM	TIMCNT
	PUSHJ	PDP,TIMEIS
	JSP	14,LOGOUT
	TIMCNT
	TIMBUF
NOTIM1:	MOVE	[XWD	SAVEAC,0]
	BLT	16		; RESTORE USER'S REGS
	MOVE	17,SAVEAC+17
	SETZM	@(17)
	SKIPE	PEOFLG		; ADJUST PARAMETERS TO FEDCTL
	SOS	@(17)
	SETZM	MRGDDB+6
	SETZM	UCDDB+6		; CLEAN UP DDB'S
	SETZM	LSTDDB+6
	MOVE	JFFSAV		;  RESTORE .JBFF
	MOVEM	.JBFF
	EXTERNAL	.JBFF,JFFSAV
	JRST	1(17)		; RETURN




	; HERE THE BASE FILE RAN OUT BEFORE THE CORRECTION FILE DID.

	; THIS MEANS THAT COMMANDS TRIED TO ALTER LINES OF GREATER NUMBERS

	; THAN THE NUMBER OF LINES IN THE FILE.  THE RIDICULOUS CORRECTIONS,

	; AS WELL AS AN ERROR MESSAGE, ARE GIVEN TO THE USER IN THE LOG AND ON

	; THE LISTING.




TUMUCH:	JSP	14,LOGOUT
	[^D25]
	[ASCII/*** FILE TOO SHORT FOR
-/]
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[^D25]
	[ASCII/*** FILE TOO SHORT FOR
-/]
	JSP	14,LOGOUT
	CMDCNT
	CMDBUF
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	CMDCNT
	CMDBUF
	JSP	14,LOGOUT
	[0]
	TEMP
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[0]
	TEMP
COPY2A:	PUSHJ	PDP,MCINX
	MOVE	TEMP,CHAR
	JUMPE	CHAR,RELES0
	JSP	14,LOGOUT
	[0]
	TEMP
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[0]
	TEMP
	JRST	COPY2A






	; ADD7 ADJUSTS THE CHARACTER COUNT FOR THE LISTING LINE

	; SO THAT THINGS WORK OUT PROPERLY WHEN TABS ARE ENCOUNTERED,

	; SO THAT THE ID IS SPACED OVER PROPERLY.


ADD7:	MOVE	C,CHARS		; GET CURRENT CHARACTER COUNT
	ROTC	C,-3		; DIVIDE BY 8
	TLNE	C+1,700000	; NO REMAINDER MEANS ALREADY AT TAB STOP
	AOJ	C,		;  ADD 1 TO QUOTIENT
	LSH	C,3		; MULTIPLY BY 8
	MOVEM	C,CHARS		; PUT RESULT BACK AS CHARACTER COUNT
	POPJ	PDP,		; THEN RETURN
	; SPACES SPACES OUT TO THE PROPER TAB STOP TO LINE UP ALL THE

	; ID'S AND TAGS AT THE END OF THE LINE.  IF THERE ALREADY ARE

	; TOO MANY CHARACTERS ON THE LINE, NOTHING IS DONE




SPACES:	MOVE	C,CHARS		; GET CURRENT CHAR COUNT
	LSH	C,-3		; DIVIDE BY 8
	AOJ	C,		; MOVE TO NEXT STOP
	MOVEI			; ZERO 0
	SKIPN	LSTTY		; LST DEV TTY?
	MOVEI	3		; GIVE 3 MORE TABS
	ADDI	7		; BUT AT LEAST 7
	SUB	C		; GIVE 7-C TABS TO LINE
	JUMPLE	CPOPJ		; IF TOO MANY ALREADY, JUST RETURN
	JSP	14,LSTOUT
	0
	[ASCII/										/]				; HERE ARE THE TABS
	POPJ	PDP,		; RETURN
INSRT3:	SKIPN	FIRST1		; NOT FIRST COMMAND?
	JSP	14,ILLCOM		; IT WAS AND IS WRONG
	SETOM	TAG		; JUMP HERE TO INSERT -- LINE
	MOVEI	TEMP,55		; SCANNER HAS RIPPED OFF BOTH '-'S
	MOVSI	TAC,INSBIT	;INSERT
	PUSHJ	PDP,UPDATE	; BUT ONLY ONE IS NEEDED
PUTIN:	ILDB	CHX,CMD
	MOVE	TEMP,CHX
	MOVSI	TAC,INSBIT
	PUSHJ	PDP,UPDATE	; OUTPUT CHARACTERS ONE AT A TIME
	CAIG	CHX,11
	JRST	PUTIN
	CAIL	CHX,15
	JRST	PUTIN 
	SETOM	TAG
	PUSHJ	PDP,INSERT	; WHEN A FEED HAS BEEN INSERTED, INSERT
	SETZM	TAG		; LINES THAT FOLLOW
	JRST	SCANIT		; MUST HAVE A COMMAND HERE NOW!
IGNOR:	SKIPE	FIRST1		; FIRST COMMAND?
	JRST	.+3		; NO
	PUSHJ	PDP,MCINX	; GET NEXT CHARACTER
	JRST	SCANIT		; IT BETTER BE A COMMAND
	PUSHJ	PDP,INSERT	; COME HERE TO IGNORE COMMENT LINES
	JRST	SCANIT		; FLUSH AND GET THE NEXT COMMAND






	; FLUSH2 FLUSHES CORRECTION FILE UNTIL IT ENCOUNTERS

	; A COMMAND WHICH IS NOT A -- COMMAND, WHENEVER AN

	; ERROR IN SYNTAX SHOWS UP




FLUSH2:	PUSHJ	PDP,MCINX
	CAIN	CHAR,55		; IF ITS A '-'
	JRST	CK1		; CHECK FURTHER
FLUSH3:	PUSHJ	PDP,MCINX	; GET SOME MORE
	CAIL	CHAR,15
	JRST	FLUSH3
	HLRZ	TEMP,ACTAB(CHAR)
	JUMPE	TEMP,FLUSH3
	PUSHJ	PDP,MCINX
	CAIE	CHAR,55		; CHECK FOR '-' AFTER FEEDS
	JRST	FLUSH3
CK1:	PUSHJ	PDP,MCINX
	MOVEM	CHAR,MCSAV2	; SAVE THIS ONE IN CASE IT ISN'T A -
	CAIN	CHAR,55
	JRST	FLUSH3
	CAIN	CHAR,40		; SPACE?
	JRST	FLUSH3		; NOPE
	CAIN	CHAR,11		; TAB?
	JRST	FLUSH3		; GUESS AGAIN
	POPJ	PDP,		; IT WASN'T, SO RETURN






	; GETID SCANS THE ID FIELD STORING ID IN 'ID'




GETID:	MOVE	TEMP,[POINT 7,ID-1,35]
	SETZB	C,ID		; ZERO ID
	ILDB	CHX,CMD		; GET NEXT CHAR
	CAIE	CHX,40	
	CAIN	CHX,11
	JRST	.-3		; FLUSH SPACES,TABS
	CAIN	CHX,15
	JRST	.-5		; AND STRAY CR'S
	CAIG	CHX,40
	JSP	14,ILLCOM		; NON PRINTING CHARS ILLEGAL
	IDPB	CHX,TEMP	; FIRST CHAR IS STORED IN ID
NXCH1:	ILDB	CHX,CMD
	JUMPE	CHX,ILLCME	; IF FEED CHAR NOT ENCOUNTERED,ERROR
	CAIE	CHX,40		; SPACES MEAN ALL DONE HERE TOO
	CAIN	CHX,11
	POPJ	PDP,
	CAIN	CHX,15
	POPJ	PDP,
	AOJ	C,
	CAIG	C,3		; ONLY STORE 3 CHARS
	IDPB	CHX,TEMP
	JRST	NXCH1






	; UCINX READS BASE FILE TAKING ACTION ON EOF


UCINX:	JSP	RETURN,UCIN
	JUMPE	CHAR,RELES0
	POPJ	PDP,






	; CLINEO DUMPS CORRECTION LINE AND NUMBER INTO

	; LOG AND LIST WHEN ERRORS ARE MADE



CLINEO:	PUSH	PDP,TAC		;SAVE IT
	MOVEI	TAC,LOGOUT	; ALWAYS TO LOG DEV
	PUSHJ	PDP,CLINEB	; SEND A COPY
	MOVEI	TAC,LSTOUT	; IS LST DEV DIFFERENT?
	SKIPN	FIRST		; LETS SEE
	PUSHJ	PDP,CLINEB	; IT IS
	POP	PDP,TAC		; GET IT BACK
	POPJ	PDP,		; RETURN HOME


CLINEB:	MOVE	C+1,CLINEN	; NUMBER OF BAD LINE
	PUSHJ	PDP,NCON
	MOVEI	5
	SUB	C+3
	JUMPLE	NOSPC1		; SEND PROPER NUMBER OF SPACES
	JSP	14,0(15)	; JUMP TO OUTPUT ROUTINE
	0
	[ASCII/     /]
NOSPC1:	JSP	14,0(15)
	C+3
	C+2
	JSP	14,0(15)
	[3]
	[ASCII/.	-/]	; EDITING CHARS
	JSP	14,0(15)
	CMDCNT
	CMDBUF			; COMMAND BUFFER
	JSP	14,0(15)
	[12]
	[ASCII/********
/]
	POPJ	PDP,		; ALL OVER




RELES0:	SKIPG	FLUSHT		; LAST DELETE A SUCCESS?
	JRST	SUCESS		; YES
	JSP	14,LOGOUT	; NO -- FILE TOO SHORT
	[^D31]
	[ASCII/*** FILE TOO SHORT FOR DELETE
/]
	SKIPE	FIRST
	JRST	.+4
	JSP	14,LSTOUT
	[^D31]
	[ASCII/*** FILE TOO SHORT FOR DELETE
/]
	PUSHJ	PDP,CLINEO	; GIVE BAD LINE
SUCESS:	PUSHJ	16,MANCOR	; COME HERE TO CHECK IF MANCOR AT EOF
	TEMP
	JRST	COPY1
	JRST	TUMUCH
COPYVR:	PUSHJ	16,MANCOR
	TEMP
	JRST RELES2
	MOVSI	TAC,INSBIT	; INSERT
	PUSHJ	PDP,UPDATE
	JRST	COPYVR
RELES2:	JUMPL	TEMP,.+2
	SETOM	PEOFLG
	JRST	RELESE
NICHTS:	MOVE	17,SAVEAC+17
	PUSHJ	16,MANCOR
		TEMP
	SKIPA
	JFCL
	JUMPL	TEMP,.+2
	SETOM	PEOFLG
	SETZM	@(17)
	SKIPE	PEOFLG
	SOS	@(17)
	JRST	1(17)
	END;