Google
 

Trailing-Edge - PDP-10 Archives - bb-d549g-sb - filcom.mac
There are 45 other files named filcom.mac in the archive. Click here to see a list.
TITLE	FILCOM   %21	7-Apr-78
SUBTTL FILE COMPARE - BOWERING/DMN/TWE/DMN/LCR/LLN/ILG



;COPYRIGHT (C) 1977,1978 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

	VFILCM==21		;VERSION NUMBER
	VUPDATE==1		;DEC UPDATE
	VEDIT==55		;EDIT LEVEL
	VCUSTOM==0

INTERNAL .JBVER
LOC <.JBVER==137>
<VCUSTOM>B2+<VFILCM>B11+<VUPDATE>B17+VEDIT
RELOC	0

EXTERNAL	.JBFF,	.JBREL,	.HELPR

TWOSEG
RELOC 400000

ACDEV==1	;COMMAND SCANNER ACCUMULATORS
ACFILE==2
ACEXT==3
ACDEL==4
ACPNTR==5
ACPPN==6	;COMMAND SCANNER AC FOR PROJ,PROG #

CTL==0		;I/O CHANNEL ASSIGNMENTS
IN1==1
IN2==2
AL==1		;ASCII LINE MODE
BIN==14		;BINARY MODE

W1=1
W2=2
W3=3
FIL=4		;FILE # (0 IS FILE 1; 1 IS FILE 2)
F1=5		;LINE POINTER FILE 1 (CONTAINS INTEGER)
F2=F1+1		;DITTO FILE 2
FR=7		;FLAG REGISTER (LH) AND FILE #(0 OR 1)(RH)
C=10		;CONTAINS 1 CHAR FOR PROCESSING
T=11		;TEMPORARY AC
TT=12		;TEMP AC
LOWER=13	;LOWER BOUND OF COMPARE
UPPER=14	;UPPER BOUND OF COMPARE
CNT=15		;WORD OR LOCATION COUNT (BINARY)
PP=17		;PUSH DOWN POINTER
S1==F1
S2==F2
LPDL==20	;LENGTH OF PUSH DOWN LIST

TAB==11
LF==12
FF==14
CR==15
VT==13		;VERTICAL TAB

NOFORM==1		;DON'T OUTPUT FORM FEED
PAGSW==2
ENDSW==4		;END SWITCH (SUPPRESS FORM-FEED  IF FILES IDENTICAL)
EOF1SW==10		;EOF SEEN ON FILE 1
EOF2SW==20		;EOF SEEN ON FILE 2
IOTTY==40		;OUTPUT TO TTY
SSWBIT==100		;/S SWITCH - IGNORE SPACING
CSWBIT==200		;/C SWITCH - IGNORE COMMENTS
ALLSW==400		;/B SWITCH (ALLOWS COMPARING BLANK LINES)
ASWBIT==1000		;/A SWITCH - LINE BY LINE COMPARE (ASCII)
WSWBIT==2000		;/W SWITCH - WORD BY WORD COMPARE (BINARY)
XSWBIT==4000		;/X SWITCH - EXPAND SAV FILES (BINARY)
CTYPF==10000		;1 IF ANY CHARS TYPED FOR A COMMAND
WDFBIT==20000		;DEFAULT /W (EXTENSION OF REL,XPN,CHN,DMP ETC)
XDFBIT==40000		;DEFAULT /X (EXTENSION OF SAV,LOW,SVE)
HSGBIT==100000		;DEFAULT HIGH SEGMENT FILE (EXT OF SHR OR HGH)
USWBIT==200000		;LIST ENTIRE 2ND FILE, SHOWING CHANGES
EXEBIT==400000	;COMPARING EXE FILES IN PROGRESS

ASCSW==ASWBIT!SSWBIT!CSWBIT!ALLSW!USWBIT	;ASCII SWITCHES
BINSW==WSWBIT!XSWBIT!WDFBIT!XDFBIT!HSGBIT!EXEBIT	;BINARY SWITCHES

MATCH==3		;# LINES TO BE MATCHED
WPL==^D100/5+1		;MEMORY WORDS/LINE
LPP==^D56		;LINES/PAGE

MAXSFD==7		;MAXIMUM NUMBER OF SFD'S ALLOWED
PTHADR==4		;OFFSET TO PATH BLOCK
PTHPPN==6		;OFFSET TO PPN IN BLOCK
PTHSFD==7		;OFFSET TO SFD IN BLOCK
.PTFCN==0		;OFFSET TO PATH. UUO FUNCTION
.PTSWT==1		;  "     "  "     "  SWITCH
.PTPPN==2		;  "     "  "     "  PPN


;VALUES FOR EXE FILE DIRECTORY
SV.DIR==1776		;DIRECTORY CODE
SV.END==1777		;END BLOCK
SUBTTL	REVISION HISTORY

;START OF VERSION 20A
;17		ADD DATE75 HACK

;START OF VERSION 21
;20	(10181)	CHECK FOR DOUBLE = IN BINARY MODE
;21	(14149) FORCE /1L IF /U IS SEEN TO PRINT ONE LINE CHANGES
;		ONLY.  02-OCT-74, JNT.
;22	(12251) CHANGE WORD COUNT FIELD TO 36 BITS TO PROVIDE
;	        FOR FILES LONGER THAN 2048 DISK BLOCKS.
;23		MAKES FILCOM GET THE JOB'S PROJ.NUMBER IF ONLY
;		PROGR.NUMBER IS SPECIFIED, AND THE PROGR.NUMBER IF ONLY
;		PROJ.NUMBER IS SPECIFIED. 03-JAN-75, IB.
;24	(15168)	FIX ERROR MESSAGES FOR FILES NOT FOUND ETC.
;		ILG  29-JAN-75
;
;25	ADD SUPPORT FOR EXE FILE COMPARISONS
;	SEB	12-MAR-75
;26	change "foo: z" to be "foo: block 1" so low seg
;	won't be created
;	ig
;
;27	make "tty:=foo.exe" work correctly.
;	seb	may 6

;30	MAKE SURE THAT THE '/Q' SWITCH TAKES A QUICK EXIT WHEN
;	DIFFERENCES ARE FOUND.
;	SPR # 19411  29-APR-76	LCR.
;
;
;31	CLEAR FILCOM'S BUFFERS DURING INITIALIZATION ROUTINE,
;	TO AVOID GETTING "FILES ARE DIFFERENT" WHEN COMPARING
;	BINARY FILES UNDER ASCII MODE.
;	SPR # 10-19442	30-APR-76	LCR.
;
;32	FIX ADDRESS CALCULATION WHEN EXPANDING .SAV FILES.  WHEN
;	FILCOM FOUND ONE END-OF-FILE, IT COULD GET CONFUSED
;	ABOUT THE ADDRESSES IN THE OTHER FILE.
;	SPR # 10-19991,  27-JUL-76	LLN.
;
;33	CORRECT SOME PROBLEMS ASSOCIATED WITH LINE NUMBERS -- NAMELY,
;	IF SKIPPING BLANK LINES, ALSO SKIP LINES HAVING ONLY A LINE
;	NUMBER.  ALSO, HANDLE PAGE MARKS AND BASIC FILES (WHICH
;	DON'T ALWAYS HAVE TABS AFTER LINE NUMBERS) CORRECTLY
;	BY EATING THE CHARACTER AFTER A LINE NUMBER ONLY IF IT
;	IS A TAB.
;	SPR # 10-20234,  13-AUG-76	LLN.
;34	Try harder to find multiple-line matches in update
;	mode.  This involves varying NUMLIN as the two files are
;	read, if no /L is given by the user.  This gives FILCOM
;	the look-ahead capability lost by edit 21, without
;	reintroducing the same problems edit 21 fixed.
;	SPR # 10-20346,  15-Oct-76	LLN.
;
;35	ADD SUPPORT FOR SFD'S
;	NO SPR	16-DEC-76	ILG
;
;
;36	HAVE HEADER CONTAIN TRUE PATH INFORMATION
;	REGARDLESS OF TYPED IN COMMAND STRING
;	NO SPR  16-DEC-76	ILG
;
;37	COMPARE EXE FILES PROPERLY WHEN ONE FILE HAS DIFFERENT
;	MAP FROM THE OTHER AND THE SECOND IS SHORTER.
;	NO SPR  16-DEC-76	ILG
;
;40	RESERVED FOR DECSYSTEM20.
;
;41	DON'T WRITE A NULL FILE IF NO DIFFERENCES ARE ENCOUNTERED ON
;	A COMPARISON.
;	SPR # 21610	ILG	16-DEC-76
;
;42	ALLOW A NULL SPECIFICATION FOR EXTENSION ON THE OUTPUT SIDE
;	NO SPR	ILG	16-DEC-76
;
;43	Handle .EXE files which have a directory
;	entry which encompasses more than 1000 pages.
;	LLN, SPR # 10-21429, 12-Jan-77
;
;Make this version 21A.
;
;44	Consider carriage-return to be an EOL character
;	if it is not followed by LF, VT, or FF.  This
;	gets underlining right in update mode.
;	LLN, SPR # 10-22466, 22-Apr-77
;
;45	Exit when through processing a command if ^Z was used
;	to terminate it.  LLN, SPR # 10-22854, 2-Jun-77
;
;46	Make buffers for headers big enough to handle the
;	longest possible filespecs.  LLN, SPR # 10-23644,
;	12-Sep-77
;
;47	Make all the month names 3 characters and lowercase.
;	LLN, SPR # 10-23642, 3-Oct-77
;
;50	Accept a line-terminating character in lieu of a
;	closing right-bracket.  LLN, SPR # 10-23642, 4-Oct-77
;
;51	Keep creation dates in the headers lined up.  Note:
;	this edit supercedes edit 46.  LLN, 5-Oct-77,
;	SPR # 10-23642.
;
;52	Always produce a file in update mode, even if
;	there are no differences.  LLN, SPR # 10-23873,
;	9-Dec-77
;
;53	If second input filespec was a magtape, and /W,
;	/E, or /X was specified, no comparison was done and
;	the first file was merely listed.  LLN, 15-Dec-77,
;	SPR # 10-23863.
;
;54	Finish teaching FILCOM about large (more than
;	a halfword) addresses in EXE files.
;	LLN, SPR # 10-25025, 13-Feb-78
;
;55	Prevent sporadic bogus differences with line-numbered
;	files.  LLN, SPR # 10-25063, 7-Apr-78

;	END OF REVISION HISTORY.
SUBTTL	FILE COMPARE

;**;[45] ADD TWO LINES BEFORE COMP:.  LLN, 2-JUN-77
;**;[45] PUT ONCE-ONLY INITIALIZATION HERE.
FILCOM:	SETZM	XITFLG		;[45] ^Z HAS NOT BEEN TYPED
	JRST	COMPGO		;[45]   SO GO PROCESS A COMMAND.
COMP:	CLOSE	CTL,
	RELEAS	CTL,
	RELEAS	IN1,
	RELEAS	IN2,
;**;[45] ADD TWO LINES AT COMPGO:.  LLN, 2-JUN-77
COMPGO:	SKIPE	XITFLG		;[45] EXIT BECAUSE OF ^Z?
	EXIT	1,		;[45] YES, A CONTINUE WILL RESTART
	RESET
	MOVE	PP,[IOWD LPDL,PPSET]	;SET UP PUSH DOWN LIST
	MOVEI	0,ENDP+500	;GUARANTEE ROOM FOR BUFFERS (2 DSK +TTY IN AND OUT)
	CAMG	0,.JBREL	;BUT NEVER REDUCE SIZE
	JRST	.+3		;INCASE LOADED WITH DDT
	CORE	0,
	 JRST	ERRCOR		;NOT AVAILABLE
	SETZB	LOWER,PPSET	;THIS IS THE ZERO WHICH WILL
			;BE "BLT"ED TO CLEAR CORE
	MOVE	[XWD PPSET,PPSET+1]	;ZERO STORAGE AREA
	BLT	ENDP-1		;UPPER LIMIT TO BE ZEROED
;** EDIT	[31]	ADD @COMPGO+12	LCR	30-APR-76
	MOVE	PPSET		;[31] ZERO OUT
	MOVEM	@.JBFF		;[31]		FIRST BUFFER POS.
	HRRZ	.JBFF		;[31] BEGINING OF AREA TO CLEAR
	ADDI	1		;[31] SET THE 'FROM' PART FOR THE 'BLT'
	CAML	.JBREL		;[31] IS THIS NECESARY?
	JRST	CMPGO1		;[31] NO, CONTINUE INITIALICING REST
	HRL	.JBFF		;[31] SET LH FOR 'BLT'
	BLT	@.JBREL		;[31] AND DO IT.
CMPGO1:	HRLOI	UPPER,377777	;LARGE NUMBER BY DEFAULT

	MOVEI	0,MATCH
	MOVEM	0,NUMLIN	;MATCH IS NORMALLY 3 LINES

	AOS	PAGNUM+0	;ZEROED BY BLT ABOVE-1ST PAGE IS 1
	AOS	PAGNUM+1	;DITTO FOR SECOND FILE


	MOVSI	FR,PAGSW+NOFORM	;INIT FR FOR NEW PAGE HEADING
	PUSHJ	PP,INITTY	;INITIALIZE TTY
	PUSHJ	PP,CRLF		;OUTPUT CARRIAGE RETURN - LINE FEED
	MOVEI	C,"*"		;TELL USER WE ARE READY FOR COMMAND
	PUSHJ	PP,TYO		;OUTPUT THE *
	PUSHJ	PP,DMPOUT	;OUT GOES THE *
	SETZM	FILCNT		;CLEAR FILE COUNTER FOR NAME ROUTINE

	SETZM	FILCNT		;DOING FIRST FILE (OUTPUT)
	PUSHJ	PP,NAME1	;ANALYIZE OUTPUT DEVICE AND NAME
	CAIN	C,"_"		;ERROR IF NO ARROW
	JRST	CTLSE1		;ITS THERE--PROCEED
	TLNN	FR,CTYPF	;ANY COMMAND TYPED?
	JRST	COMPGO		;NO
;**;[45] ADD ONE LINE AT CTLSER:.  LLN, 2-JUN-77
CTLSER:	PUSHJ	PP,EAT		;[45] CLEAR OUT THE BAD LINE
	JSP	T,ERROUT
	ASCIZ	/?Command error/

CTLSE1:	SETZM	OUTEXT		;ASSUME NO OUTPUT EXTENSION GIVEN
	CAIN	ACDEL,"."	;DOT THERE?
	SETOM	OUTEXT		;YES,SO THERE IS AN EXTENSION
	JUMPN	ACDEV,CTLSE2	;NO DEFAULT IF DEVICE NOT 0
	SKIPN	ACFILE
	MOVSI	ACDEV,'TTY'	;IF FILENAME 0, ASSUME TTY
	SKIPE	ACFILE
	MOVSI	ACDEV,'DSK'	;IF FILENAME NOT 0, ASSUME DSK
CTLSE2:	MOVEM	ACDEV,OUTDEV	;SAVE OUTPUT DEVICE IN DIRECTORY BLOCK
	MOVEM	ACFILE,OUTDIR	;PUT SIXBIT FILE NAME IN
	HLLZM	ACEXT,OUTDIR+1	;AND SAVE EXTENSION
	MOVEM	ACPPN,OUTDIR+3	;  AND PROJ, PROG NUMBER
;PROCESS INPUT PART OF COMMAND STRING

	AOS	FILCNT		;INCREMENT FILE COUNT
	PUSHJ	PP,NAME1	;GET INPUT COMMAND STRING
	TLNN	FR,CTYPF	;ANY FILE DESCRIPTOR TYPED?
	JRST	CTLSER		;NO, ERROR
	SETZ	T,		;GET A ZERO
	EXCH	T,EXTFL2	;INCASE NO 2ND FILE
	MOVEM	T,EXTFL1	;FLAGS IN RIGHT PLACE
	CAIN	C,","		;COMMA TO TERMINATE 1ST INPUT FILE?
	JRST	CTLSE3		;YES, NORMAL CASE
	TLNE	FR,ASCSW	;ASCII SWITCH?
	JRST	CTLSER		;YES, ERROR
	TLNN	FR,BINSW	;BINARY SWITCH?
	TLNE	T,BINSW		;OR EXT?
	TLOA	FR,EOF2SW	;YES, SET EOF FOR 2'ND INPUT FILE
	JRST	CTLSER		;ASCII, ERROR
	CAIG	C,33		;[20] BUT ONLY ALLOW VALID EOF
	CAIGE	C,LF		;[20] IF GREATER THAN ESC OR LESS THAN FF
	JRST	CTLSER		;[20] GIVE ERROR
	CAILE	C,CR		;[20] ONLY ALLOW LF, VT, FF, CR
	CAIL	C,32		;[20] ^Z AND ESC
	CAIA			;[20] TO END LINE
	JRST	CTLSER		;[20] OTHERWISE GIVE ERROR
CTLSE3:	SKIPN	ACDEV		;ASSUME DSK IF NO SPECIFIED DEVICE
	MOVSI	ACDEV,'DSK'
	MOVEM	ACDEV,INDEV1
	MOVEM	ACFILE,INDIR1	;FIRST INPUT FILE
	MOVEM	ACEXT,INDIR1+1	;AND SAVE EXTENSION
	MOVEM	ACPPN,INDIR1+3	;  AND PROJ,PROG NUMBER
	MOVEM	ACPPN,INDPPN	;SAVE P,P AGAIN

	MOVEI	0,AL		;SET UP INPUT DATA MODE
				;1 (WHICH IS ACDEV) ALREADY IS SET UP
	MOVEI	2,INBUF1	;SET UP INPUT BUFFER HEADER
	OPEN	IN1,0		;INIT DEVICE
	 JRST	ERRI		;DEVICE CAN'T BE INITIALIZED

	INBUF	IN1,2		;DO LOOKUP ON FIRST FILE NAME
	LOOKUP	IN1,INDIR1
;** EDIT 24	  CTLSE3+13.	ILG	29-JAN-75
	JRST	ERRIA1		;[24]ERROR RETURN
	MOVEI	T,HBUF1
	PUSHJ	PP,HEADER	;CREATE HEADER LINE- FILE #1
	MOVE	T,EXTFL1	;RESET T INCASE NO 2ND FILE
	TLNE	FR,EOF2SW	;PREMATURE EOF SET
	JRST	NOINP2		;YES, NO SECOND FILE

	PUSHJ	PP,NAME1
	TLNN	FR,CTYPF	;ANY FILE DESCRIPTOR TYPED?
	JRST	CTLSER		;NO, ERROR
	SKIPN	ACDEV
	MOVSI	ACDEV,'DSK'	;"DSK" IS DEFAULT
	MOVEM	ACDEV,INDEV1
	SKIPE	ACFILE
	MOVEM	ACFILE,INDIR1	;INSERT FILE NAME AND EXTENSION
	CAIN	ACDEL,"."	;PERIOD MEANS EXPLICIT EXTENSION
	MOVEM	ACEXT,INDIR1+1
	MOVEM	ACPPN,INDIR1+3	;SAVE PROGER IN DIRECT BLOCK
	MOVEM	ACPPN,INDPPN	;SAVE P,P AGAIN

	MOVEI	0,AL		;INIT DEVICE IN ASCII LINE MODE
	MOVEI	2,INBUF2	;BUFFER HEADER FOR 2ND INPUT FILE
	OPEN	IN2,0		;INIT 2ND DEVICE
	 JRST	ERRI		;INIT FAILED

	INBUF	IN2,2		;LOOKUP ON SECOND FILE NAME
	LOOKUP	IN2,INDIR1
;** EDIT 24	 SETBIN-11.	ILG	29-JAN-75
	JRST	ERRIA2		;[24]
	MOVEI	T,HBUF2
	PUSHJ	PP,HEADER	;CREATE HEADER LINE- FILE #2

	TLNE	FR,ASCSW	;ASCII SWITCHES SEEN
	JRST	INICTL		;YES, LEAVE WELL ALONE
;**;[53] ADD ONE LINE AT SETBIN: - 6L.  LLN, 15-DEC-77
	SETZ	T,		;[53] RESET DEFAULT MODE
	TLNE	FR,BINSW	;BINARY SWITCHES SEEN?
	JRST	SETBIN		;YES, CHANGE MODE TO BINARY
	MOVE	T,EXTFL1	;GET DEFAULT EXT MODE
	IOR	T,EXTFL2	;FOR BOTH FILES
	TLNN	T,BINSW		;BINARY WIN OVER ASCII
	JRST	INICTL		;ASCII
SETBIN:	SETSTS	2,BIN		;CHANGE TO BINARY MODE
NOINP2:	MOVEI	0,(POINT 36,,35)
	IOR	FR,T		;SET MODE BINARY
	SETSTS	1,BIN
	HRLM	0,INBUF1+1	;CHANGE FROM ASCII
	HRLM	0,INBUF2+1
INICTL:	MOVEI	0,0		;INIT OUTPUT DEVICE
	MOVE	1,OUTDEV
	MOVSI	2,CTOBUF
	OPEN	CTL,0
	 JRST	ERRA		;INIT FOR OUTPUT FAILED

	MOVE	TT,OUTDEV	;CAN OUTPUT DEVICE DO OUTPUT
	DEVCHR	TT,
	TLNN	TT,1
;** EDIT 24	 INICTL+8.	ILG	29-JAN-75
	JRST	ERRONO		;[24]NO
	TLNE	TT,10		;IS OUTPUT DEVICE  TTY?
	TLO	FR,IOTTY	;YES, DO 1 OUTPUT PER LINE

	SKIPN	ACFILE,INDIR1	;IF LAST INPUT FILE NAME WAS NULL,
	MOVE	ACFILE,[SIXBIT /FILCOM/]	; MAKE OUTPUT "FILCOM", BUT
	SKIPN	OUTDIR		;  ONLY IF NO OUTPUT FILENAME SPECIFIED
	MOVEM	ACFILE,OUTDIR
	MOVSI	ACEXT,'SCM'	;ASSUME ASCII
	TLNE	FR,BINSW	;BINARY?
	MOVSI	ACEXT,'BCM'	;BCM IF BINARY
	SKIPL	OUTEXT		;OUTPUT EXTENSION GIVEN?
	SKIPE	OUTDIR+1	;OR ONE IMPLIED?
	SKIPA			;RIGHT, NO NEED FOR CHANGE
	MOVEM	ACEXT,OUTDIR+1	;USE DEFAULT
	ENTER	CTL,OUTDIR	;AND TRY TO ENTER OUTPUT FILE NAME
;**EDIT 24	INICTL+21.	ILG	29-JAN-75
	JRST	ERROEF		;[24]
	OUTPUT	CTL,
;FIND OUT HOW MUCH CORE IS AVAILABLE AND SET POINTERS AND LIMITS

	HRRZ	W1,.JBFF
	ADDI	W1,20		;GUARANTEE AN INITIAL 20 WORDS
	CORE	W1,		;  FOR TEXT BUFFERS
	  JRST	NORERR		;DIDN'T GET IT, ERROR

	AOS	W1,.JBFF
	HRRZM	W1,LBUFP1	;SET 1ST ADDRESS FILE 0
	SETZM	1(W1)		;FORCE NULLS INTO BUFFER
	HRRZM	W1,LBUFP2	;DITTO FILE 2
	MOVE	W1,.JBREL
	SUB	W1,.JBFF	;COMPUTE SPACE AVAILABLE
	HRRZS	W1
	LSH	W1,-1		;AVAILABLE SPACE/2
	ADDB	W1,LBUFP2	;INPUT POINTER FILE 2 STARTS HALF WAY THROUGH BUFFER
	SETZM	1(W1)		;FORCE NULLS INTO BUFFER

	HRLOI	0,377777
	MOVEM	0,OLDNUM+0	;ANY LINE # IS SMALLER THAN
	MOVEM	0,OLDNUM+1	;  THIS ONE

	SETOB	F1,TOP1		;INITIALIZE TOP OF EACH FILE
	SETOB	F2,TOP2		;THE TOP IS THE HIGHEST LINE THAT WE HAVE EXAMINED
	TLNE	FR,BINSW	;BINARY COMPARE?
	JRST	BINCOM		;USE WORD BY WORD IF BINARY
	SOS	NUMLIN		;INIT SRCCOM MATCH COND TO "MATCH-1"
	TLNN	FR,USWBIT	;SEE IF UPDATE MODE
	JRST	MAINST		;NO
;** EDIT 21	INICTL+64(END OF NEXT PAGE-1)	JNT	02-OCT-74
	SKIPN	LSEEN		;[21] SEE IF HAD /L
;**;[34] Change one line at MAIN - 2L.  LLN, 15-Oct-76
	SETOM	USWFLG		;[21],[34] No, set a flag
	JRST	MAINST		;START SRCCOM WITH 1ST LINES
;THE FOLLOWING CODE IS THE GUTS OF THE PROGRAM.
;WHEN THE LOOP AROUND MAIN DETECTS THAT TWO LINES ARE NOT A MATCH
;CONTROL GOES OFF TO DETERMINE THE EXTENT OF THESE DIFFERENCES.
;THE TOTAL DIFFERENCES ARE DETERMINED AS FOLLOWS.  FIRST GET TWO 
;MORE LINES. DOES THE ORGINAL LINE IN FILE 1 WHICH DID NOT MATCH
;MATCH THE NEW LINE FROM FILE TWO. IF SO THEN THE ORGINAL LINE
;IN FILE 2 WAS AN INSERTION. (OR A DELETION).  IF NO MATCH THIS 
;WAY TRY IT THE OTHER WAY. IF STILL NO MATCH GET TWO MORE LINES
;TAKE THE NEW LINE FROM FILE 1 AND TRY TO MATCH IT AGAINST ALL THE
;LINES WE HAVE BEEN EXAMINING IN FILE TWO; THEN DO IT THE OTHER
;WAY AROUND. EOF'S ARE DETECTED BY "GETTWO"  WITH NO RETURN SKIP

MAIN:	TRZ	FR,-1		;THIS FOR FILE ONE
	PUSHJ	PP,MOVEUP	;MOVE UP THE BOTTOM, BECAUSE WE ARE FINISHED
				;WITH TWO LINES
	HRRI	FR,1		;NOW FOR FILE TWO
	PUSHJ	PP,MOVEUP	;UP GOES THE BOTTOM POINTER
MAINST:	SETOB	F1,F2		;INITIALIZE LINE POINTERS
	PUSHJ	PP,GETTWO	;GET TWO LINES
	  JRST	MAIN15		;ONE FILE SHORT
	PUSHJ	PP,COMPL	;COMPARE THESE TWO LINES
	JRST	MAIN		;THEY MATCH--LOOK AT NEXT TWO

;WHEN WE GET HERE WE HAVE DETECTD A DIFFERENCE
;NOW THE PROGRAM WILL LOOK AHEAD TO TRY AND FIND THE NEXT TWO
;MATCHING LINES

	AOS	DIFFLG		;SET "DIFFERENCE IN PROGRESS" FLAG
	AOS	ERRCNT		;SET FLAG SHOWING DIFFERENCES FOUND

MAIN10:	PUSHJ	PP,GETTWO	;GET THE NEXT TWO LINES
	  JRST	MAIN15		;ONE FILE SHORT
	SETZ	F1,		;RESET POINTER FOR FIRST FILE TO
				;THE LINE IN WHICH THE DIFFERENCE WAS FOUND

;**;[34] Add two lines at MAIN10 + 3.  LLN, 15-Oct-76
	MOVE	W1,NUMLIN	;[34] Make a temp copy
	MOVEM	W1,TNMLIN	;[34]  in case we are updating
MAIN12:	PUSHJ	PP,COMPL	;NOW SEE IF WE CAN MATCH THAT LINE
	JSP	W1,MULTI	;FOUND 1 LINE MATCH- LOOK FOR MULTIPLE
	CAME	F1,F2		;HAVE WE LOOKED FROM THE MISMATCHED LINE
				;TO THE CURRENT LINE?
	AOJA	F1,MAIN12	;NO--UP LINE POINTER AND TRY AGAIN
	SETZ	F2,		;HAVEN'T FOUND A MATCH THIS TIME
				;NOW TRY IT THE OTHER WAY

MAIN14:	CAML	F2,F1		;LOOKED FAR ENOUGH? (THIS VERSION HAS
				;THE INEFFICIENCY MENTIONED IN THE LIBRARY
				;WRITE UP REMOVED- TWE)
;**;[34] Change one line at MAIN14 + 1.  LLN, 13-Oct-76
	JRST	CHECK		;[34] Probably, check for /U
	PUSHJ	PP,COMPL
	JSP	W1,MULTI	;LOOK FOR MULTI LINE MATCH
	AOJA	F2,MAIN14	;INDEX AND LOOK SOME MORE
;**;[34] Add five lines at MAIN14 + 5.  LLN, 15-Oct-76
CHECK:	SKIPN	USWFLG		;[34] Making special /U checks?
	JRST	MAIN10		;[34] No, looked far enough
	SOSGE	TNMLIN		;[34] Lines to check this time
	JRST	MAIN10		;[34] None, quit
	JRST	MAIN12		;[34] Try MULTI again
;THE MAIN15 CODE HANDLES THE CASE OF EITHER (OR BOTH) FILES
;HAVING NO LINES TO COMPARE. IF BOTH FILES HAVE NO LINES, "FINISH"
;PRINTS OUT ALL LINES IN BOTH FILES (IF ANY) AS DIFFERENCES.
;IF EITHER FILE HAS A NEW LINE, THE SHORTER FILE IS
;SEARCHED FOR A MATCH FOR THAT LINE. THIS CONTINUES (READING A NEW LINE
;FROM THE LONGER FILE) UNTIL NEITHER FILE HAS ANY LINES OR UNTIL A
;MATCH IS FOUND.

MAIN15:	SKIPGE	W1,GETFIL	;DOES EITHER FILE HAVE A LINE?
	JRST	FINISH		;NO
	AOS	DIFFLG		;SET "DIFFERENCE IN PROGRESS" FLAG
	AOS	ERRCNT		;SET "DIFFERENCES FOUND" FLAG
	HRRZM	W1,FIL		;SAVE FILE # THAT HAS LINES
	HRR	FR,W1		;SETUP FR FOR MAIN18
	JUMPL	F1,MAIN18	;TRA IF FILE 1 HAS NO LINES
	JUMPL	F2,MAIN18	;DITTO FILE 2
	TRC	FIL,1		;CHANGE 1 TO 0 (OR VICE VERSA)
	SETOM	F1(FIL)		;LOOK THRU SHORT FILE FOR MATCH
MAIN17:	MOVE	W1,F1(FIL)
	CAML	W1,TOP1(FIL)	;SEARCHED THRU SHORT FILE?
	JRST	MAIN10		;YES, AND NO MATCH
	AOS	F1(FIL)		;INDEX LINE
	PUSHJ	PP,COMPL	;LOOK FOR A MATCHING LINE
	JSP	W1,MULTI	;FOUND A MATCH, NOW LOOK FOR MULTIPLE MATCH
	JRST	MAIN17		;NO MULTI LINE MATCH

MAIN18:	TLNN	FR,USWBIT	;FOR UPDATING, NO LISTING HERE
	PUSHJ	PP,PNTTXT	;ALL LINES ARE GONE FROM 1 FILE,
				;OUTPUT THE OTHER WITHOUT USING CORE
	JRST	MAIN

;AT THIS POINT NEITHER FILE HAS ANY MORE LINES TO BE READ.
;PRINT AS DIFFERENCES ANY LINES REMAINING FOR EITHER FILE.

FINISH:	JUMPGE	F1,MULT8	;PRINT DIFFERENCES IF EITHER BUFFER
	JUMPGE	F2,MULT8	;  HAS ANY LINES IN IT
				;NO LINES ANYWHERE
	MOVE	W1,[POINT 7,[ASCIZ /|
/]]
	TLNE	FR,USWBIT	;"UPDATE" MODE?
	SKIPN	DIFFLG		;YES
	JRST	FIN2		;NO
	PUSHJ	PP,PRINT	;PRINT MESS. IF 2ND FILE IS TRUNCATED 1ST FILE
FIN2:	MOVEI	T,[ASCIZ /No differences encountered/]
	SKIPN	ERRCNT		;ANY DIFFERENCES?
;**;[52] CHANGE AT FIN2: + 2L.  LLN, 9-DEC-77
	JRST	[ TLNN FR,USWBIT;[52] UNLESS WE ARE UPDATING
		  CLOSE CTL,1B30;[52] DON'T PRODUCE AN OUTPUT FILE
		  JRST FIN3 ]	;CONTINUE WITH MESSAGES
	MOVEI	T,[ASCIZ /%files are different/]
	SKIPE	QSW		;/Q MODE?
	MOVEI	T,[ASCIZ /?files are different/]
FIN3:	PUSHJ	PP,TYPMSG	;PRINT MESSAGE
	PUSHJ	PP,CRLF
	JRST	COMP		;END OF SOURCE COMPARE
;THIS SECTION LOOKS FOR MULTI LINE MATCH

MULTI:	SKIPG	NUMLIN		;MULTIPLE LINE TEST?
	JRST	MULT7		;NO
	HRRZM	W1,RTNTMP	;YES, SAVE RETURN ADDRESS
	SETZM	NUMTMP		;INIT MULTI-LINE COUNTER
	MOVEM	F1,TEMPF1	;SAVE CURRENT POINTERS
	MOVEM	F2,TEMPF2
MULT2:	PUSHJ	PP,GETTWO	;GET NEXT TWO LINES
	  JRST	MULT4		;ONE FILE DOESN'T HAVE A LINE
	PUSHJ	PP,COMPL	;COMPARE THEM
	JRST	MULT6		;MATCH, TEST MULTI COUNTER
MULT4:	MOVE	F1,TEMPF1	;NO MATCH, RESET REGS
	MOVE	F2,TEMPF2
	JRST	@RTNTMP		;RETURN TO WHERE WE GOT TO MULTI FROM

MULT6:	AOS	W1,NUMTMP	;INDEX MULTI-LINE COUNTER
;**;[34] Changes at MULT6 + 1.  LLN, 15-Oct-76
	SKIPN	USWFLG		;[34] Update mode check?
	JRST	MULT64		;[34] No, regular one
	CAMGE	W1,TNMLIN	;[34] Test for end
	JRST	MULT2		;[34] Not yet, keep trying
	JRST	MULT66		;[34] Done
MULT64:	CAMGE	W1,NUMLIN	;[34] TEST FOR END
	JRST	MULT2		;TEST NEXT TWO
MULT66:	SUB	F1,W1		;[34] RESET TO 1ST COMPARISON
	SUB	F2,W1
MULT7:	TLNE	FR,USWBIT	;MANUAL UPDATE MODE?
	JRST	MULT9		;YES
MULT8:	TLNE	FR,USWBIT	;CHECK UPDATE MODE
	JRST	MAIN		;FOR UPDATE MODE, GET 2ND FILE PRINTED
	PUSHJ	PP,PNTBTH	;PRINT DIFFERENCES

;GO BACK AND START COMPARING.
;WHEN WE START COMPARING AGAIN THE LINE POINTERA WILL
;BE POINTING TO THE FIRST TWO LINES AFTER THE MATCHING LINES

	ADD	F1,NUMLIN	;CAUSE MOVEUP TO FLUSH ALL THE
	ADD	F2,NUMLIN	;  LINES THAT WERE JUST MATCHED
	JRST	MAIN		;DIFFERENCES PRINTED- LOOK FOR MORE

MULT9:	SUBI	F1,1		;LEAVE POINTERS POINTING TO
	SOJA	F2,MAIN		;  LAST DIFFERENCE
;THIS ROUTINE SETS UP THE POINTERS TO THE TEXT

;MEMORY STORAGE AREA LOOKS LIKE THIS:
;1) BUFFER SPACE FOR FILE # 0 (POINTED TO BY LBUFP1)
;	A) XWD (PAGE #),(WORD COUNT FOR LINE (INCLUDING THIS WORD))
;	   TEXT FOR LINE 0
;	    MORE TEXT FOR LINE 0
;	     & MORE, ENDED WITH A NULL
;	B) MORE LINES (EACH WITH PAGE #,WORD COUNT, AND TEXT
;2) BUFFER SPACE FOR FILE 1 (POINTED TO BY LBUFP2)
;	A) AS ABOVE

SETP:	HRRI	FR,1		;SET UP POINTER FILE 1
	PUSHJ	PP,SETONE
	HRRI	FR,0		;DITTO FILE 0

SETONE:	MOVE	W3,F1(FR)	;GET LINE #
SETON1:	MOVE	TT,OLDNUM(FR)	;GET LAST # COMPUTED FOR
	MOVEM	W3,OLDNUM(FR)	;SAVE NEW # AS OLD
	CAML	W3,TT		;IS NEW LARGER THAN OLD?
	SKIPA	T,OLDPNT(FR)	;YES, START FROM OLD BYTE POINTER
	SKIPA	T,LBUFP1(FR)	;NO, START FROM BEGINNING
	SUB	W3,TT		;LOOP ONLY FROM OLD POINTER
	MOVSI	TT,(ADD T,(T))	;(SET UP IN AC)
	MOVE	TT+2,[JRST SETON2]	;SET UP AC
	MOVE	TT+1,.+1	;SET UP AC
	SOJGE	W3,TT
			;TT/	ADD T,(T)	;ADD IN WORD COUNT FOR LINE
			;TT+1/	SOJGE W3,.-1	;MORE LINES LEFT?
			;TT+2/	JRST SETON2	;NO

SETON2:	HRRZM	T,OLDPNT(FR)	;SAVE POINTER TO THIS LINE
	HRLI	T,(POINT 7,0,35)	;NO, CHANGE TO BYTE POINTER
	MOVEM	T,W1(FR)
	POPJ	PP,

;MOVE UP THE POINTERS WHICH POINT TO THE LINES FROM WHICH WE
;ARE EXAMINING.  THIS IS DONE EVERYTIME A MATCH IS FOUND

MOVEUP:	TLNE	FR,USWBIT	;MANUAL "UPDATE" MODE?
	PUSHJ	PP,UPDATE	;YES
	MOVE	W3,F1(FR)	;GET LINE # FOR THIS FILE
	CAML	W3,TOP(FR)	;GETTING RID OF ALL LINES?
	JRST	MOVEX		;YES, DON'T MOVE MEMORY
	AOS	W3,F1(FR)	;GET LINE # OF LINE TO SAVE
	PUSHJ	PP,SETON1	;GET ADR OF 1ST LINE TO SAVE
	HRL	T,LBUFP1(FR)	;SET UP BLT AC (REVERSED)
	PUSH	PP,T		;SAVE
	AOS	W3,TOP(FR)	;GET 1ST NON-EXISTANT LINE #
	PUSHJ	PP,SETON1	;GET CORRESPONDING 1ST ADR
	POP	PP,W1
	SUB	T,W1		;CALCULATE WORD COUNT OF TRANSFER
	ADD	T,LBUFP1(FR)	;CALCULATE "E" OF BLT AC,E
	MOVSS	W1		;SWITCH AC TO XWD FROM,TO
	BLT	W1,(T)		;AND AWAY WE GO

MOVEX:	SETCM	W2,F1(FR)	;W2_-<(F1)+1>
	ADDM	W2,TOP(FR)	;CHANGE TOP TO ACCOUNT FOR DEAR DEPARTED LINES
	HRLOI	0,377777
	MOVEM	0,OLDNUM(FR)	;FORCE SETON1 TO RECALCULATE
	POPJ	PP,
;LIST ALL OF SECOND FILE, EACH LINE PRECEDED BY VERTICAL BAR-TAB
;  IF IT IS PART OF A MISMATCH (MISMATCH MEANS (F2) .GE. 1)

UPDATE:	TRNN	FR,-1		;SECOND FILE?
	POPJ	PP,		;NO, RETURN
	SETOM	TEMP		;YES, INIT LINE COUNTER
UPDAT1:	AOS	W1,TEMP		;GET NUMBER OF NEXT LINE
	CAMLE	W1,F2		;DONE?
	POPJ	PP,		;YES
	MOVEI	C,174		;PRINT VERTICAL BAR IF
	SKIPN	DIFFLG		;  "DIFFERENCE FLAG" IS SET, OR IF
	SKIPE	F2		;  MORE THAN 1 LINE HAS BEEN LOOKED AT
	PUSHJ	PP,PCHAR
	SETZM	DIFFLG		;CLEAR "DIFFERENCE FLAG"
	MOVEI	C,TAB		;PRINT A TAB
	PUSHJ	PP,PCHAR
	PUSH	PP,F2		;SAVE F2
	MOVE	F2,W1		;GET LINE NUMBER TO PRINT
	PUSHJ	PP,SETONE	;GET BYTE POINTER TO LINE
	MOVE	W1,W2		;GET BYTE POINTER INTO W1
	PUSHJ	PP,PRINT	;GO PRINT LINE
	MOVEI	C,15
	PUSHJ	PP,PCHAR	;PRINT CARRIAGE RETURN
	ILDB	C,W1		;GET LINE TERMINATING CHARACTER
	PUSHJ	PP,PCHAR	;AND PRINT IT
	POP	PP,F2		;RESTORE F2
	JRST	UPDAT1		;GO PRINT MORE LINES, IF ANY
;CODE FOR GETTING TWO LINES
;CALLING SEQUENCE IS:
;	PUSHJ PP,GETTWO
;	   RETURN 1 IF EITHER FILE HAS NO MORE LINES
;	   RETURN 2 IF ONE LINE READ FROM EACH FILE
; C(GETFIL)=THE # OF FILE FOR WHICH A LINE WAS READ (OR -1 IF NONE)

GETTWO:	SETOM	GETCNT		;INIT # LINESOBTAINED
	SETOM	GETFIL		;INIT FILE # LINE CAME FROM
	TRZ	FR,-1		;ZERO RIGHT HALF OF "FR"--SET FOR FIRST FILE
	PUSHJ	PP,GLINE	;GET A LINE FROM FIRST FILE
	HRRI	FR,1		;NOW DO FOR SECOND FILE
	PUSHJ	PP,GLINE
	SKIPLE	GETCNT		;GETCNT .G. 0 IF TWO LINES WERE GOT
	AOS	(PP)		;SKIP IF 2 LINES WERE AVAILABLE
	POPJ	PP,

GLINE:	AOS	W1,F1(FR)	;BUMP THE LINE POINTERS
	CAMG	W1,TOP(FR)	;HAVE WE GONE OVER THE TOP
	JRST	GLEXIT		;NO, LINE WAS AVAILABLE
	SOS	F1(FR)		;NOT CLEAR YET THAT A NEW LINE EXISTS
GLINE1:	HRLS	PAGNUM(FR)	;SAVE PAGE # AT BEGINNING OF LINE
	PUSHJ	PP,GCHAR	;GET A CHARACTER
	TLNE	FR,@EOFTBL(FR)	;END OF FILE?
	POPJ	PP,		;YES, NO LINE
	TLNN	FR,ALLSW	;SKIP IF COMPARING BLANK LINES
	JUMPL	C,GLINE1	;MINUS CHARS INDICATE BLANK LINES
	AOS	W1,F1(FR)	;THERE ARE CHARS FOR A NEW LINE
	MOVEM	W1,TOP(FR)	;THIS LINE IS THE TOP LINE
	PUSHJ	PP,SETONE	;CALCULATE BYTE POINTER
	MOVE	W1,W1(FR)	;GET BYTE POINTER IN W1
	MOVEM	W1,WCADR	;SAVE ADR OF LINE WORD COUNT
	MOVE	W2,PAGNUM(FR)	;PICKUP PAGE # AT BEGINNING OF LINE
	HLLZM	W2,(W1)		;SAVE WITH THIS LINE
	JRST	GLINE3
			
GLINE2:	PUSHJ	PP,GCHAR	;GET NEXT CHAR FOR LINE
GLINE3:	TLNN	W1,760000	;WILL NEXT IDPB GO INTO NEXT WORD?
	PUSHJ	PP,GLCHEK	;CHECK ADDRESS
	IDPB	C,W1		;STORE CHARS IN LINE BUFFER
	JUMPG	C,GLINE2	;NEG CHARACTER IS END OF LINE
	MOVEI	W3,0		;REPLACE LAST CHAR WITH NULL
	DPB	W3,W1
	TLNN	W1,760000	;WILL TERM CHAR GO INTO NEXT WORD?
	PUSHJ	PP,GLCHEK	;YES, CHECK ADDRESS
	IDPB	C,W1		;STORE TERM CHAR AFTER NULL
	MOVE	W3,WCADR	;GET BACK ADR OF WORD COUNT
	SUBI	W1,-1(W3)	;CALCULATE WORD COUNT
	HRRM	W1,(W3)		;SAVE WORD COUNT IN BUFFER
;**;[33] ADDED MANY LINES AT GLINE3: +12L	LLN  13-AUG-76
;**;[33] SEE IF TEXT JUST READ IN IS A LINE-NUMBERED BLANK LINE
	TLNE	FR,ALLSW	;[33] SKIPPING BLANK LINES?
	JRST	GLEXIT		;[33] NO, DON'T CHECK TEXT
	PUSHJ	PP,SETONE	;[33] GET POINTER TO TEXT
	MOVE	W1,W1(FR)	;[33] PUT IN KNOWN PLACE
	MOVEI	W3,1		;[33] SET UP LINE NUMBER BIT
	TDNN	W3,1(W1)	;[33] IS IT SET?
	JRST	GLEXIT		;[33] NO, TEXT IS OK
	AOS	W1		;[33] YES, SKIP LINE NUMBER
	ILDB	T,W1		;[33] GET FIRST CHARACTER
	JUMPE	T,BLANK		;[33] IT'S NULL, LINE IS BLANK
	CAIE	T,11		;[33] IF A TAB, CHECK FURTHER
	JRST	GLEXIT		;[33] 
	ILDB	T,W1		;[33]  SO GET NEXT CHARACTER
	JUMPN	T,GLEXIT	;[33] IF NOT NULL, LINE IS REALLY THERE
BLANK:	SOS	F1(FR)		;[33] NO LINE; DECREMENT COUNT
	JRST	GLINE1		;[33] GET ANOTHER LINE
GLEXIT:	AOS	GETCNT		;INDEX # LINES FOUND
	HRRZM	FR,GETFIL	;SAVE # OF THIS FILE
	POPJ	PP,

GLTBL:	LBUFP2		;POINTS TO TOP ADR FILE 0
	.JBREL		;POINTS TO TOP ADR FILE 1

GLCHEK:	HRRZ	W3,@GLTBL(FR)	;YES,GET HIGHEST ADR FOR THIS BUFFER
	CAIG	W3,3(W1)	;CHECK ADR. (LEAVE 1 WORD FOR WORD
				;COUNT FOR NEXT LINE PLUS 1 WORD
				;SLOP TO BE SAFE
;**;[55] CHANGE ONE LINE AT GLCHEK: + 4L.  LLN, 7-APR-78
	PUSHJ	PP,NOROOM	;[55] NO ROOM IN THE INN
	HLRZM	C,1(W1)		;PUT BIT17 INTO BIT35 (FOR SEQUENCE  #)
	POPJ	PP,
;IF A "CORE" UUO IS INSTALLED HERE, IT MUST ADJUST THE FOLLOWING
;LIST OF LOCATIONS (ALL BY THE AMOUNT THE SECOND BUFFER AREA
;IS MOVED, IF ANY):
;1) BYTE POINTER ADDRESS IN: W1
;2) BUFFER POINTER IN: LBUFP2
;3) 1ST ADDRESS FOR LINE IN: 0(PP) ON PUSH DOWN LIST
;THEN RETURN TO THE IDPB NEAR GLINE2+6


NOROOM:	PUSH	PP,W1		;SAVE BYTE POINTER
	TRC	FR,1		;CHANGE 1 TO 0 (OR VICE VERSA)
	MOVE	W3,TOP(FR)	;GET TOP LINE # FOR "OTHER" FILE
	ADDI	W3,1		;FIND 1ST ADR OF THE NEXT LINE ABOVE TOP
	PUSHJ	PP,SETON1	;GET ADR
	HRRZM	T,HIGH		;SAVE 1ST FREE ADR OF NON-FULL FILE
	HRRZ	T,@GLTBL(FR);GET HIGHEST ADR AVAILABLE TO NON-FULL FILE
	SUB	T,HIGH		;GET SPACE AVAILABLE
	SUBI	T,2		;LEAVE 1 WRD FOR NEXT LINE WORD COUNT
				;PLUS 1 WORD SLOP TO BE SAFE
	TRC	FR,1		;CHANGE FILE # BACK TO THE WAY IT WAS
	MOVEM	T,ROOM		;SAVE ROOM AVAILABLE
	CAIL	T,^D400		;COMPARE WITH 400. (NO MAGIC SIGNIFICANCE)
	JRST	NOR2		;PLENTY ROOM AVAILABLE- DON'T GET MORE CORE

	HRRZ	T,.JBREL
	MOVEM	T,W1		;SAVE THIS .JBREL AS "OLD" .JBREL
	ADDI	T,1		;REQUEST CORE SIZE CONTAINING THIS ADDRESS
NOR1:	CORE	T,		;CORE UUO
	SKIPA	T,ROOM		;FAIL
	JRST	NOR3		;SUCCESS
NOR11:	JUMPG	T,NOR4		;ANY CORE LEFT AT ALL?
NORERR:	JSP	T,ERROUT	;NO, PRINT MESSAGE
	ASCIZ	/?Buffer capacity exceeded and no core available/
NOR3:	HRRZ	T,.JBREL	;CORE UUO SUCCESFUL- GET "NEW" .JBREL
	SUB	T,W1		;FIND OUT HOW MUCH WAS ADDED
	ADDB	T,ROOM		;UPDATE TOTAL ROOM AVAILABLE
NOR33:	TRNE	FR,1		;WHICH FILE NEEDED ROOM?
	JRST	NOR98		;FILE #1, IT JUST GOT IT
			;FILE #0, SHUFFLE CORE
NOR2:	ASH	T,-1		;DIVIDE AVAILABLE SPACE BETWEEN FILES
NOR4:	MOVEM	T,ROOM		;FILE #1 GETS MOVED THIS AMOUNT
	TRNN	FR,1		;WHICH FILE NEEDED ROOOM?
	JRST	NOR5		;FILE #0. MOVE #1 TOWARD 777777
			;FILE #1. MOVE #1 TOWARD 0
NOR6:	MOVNS	T,ROOM		;FILE IS MOVING IN NEGATIVE DIRECTION
	ADDM	T,WCADR		;WORD COUNT ADR FOR FILE# 1 IS MOVED DOWN
	ADDM	T,(PP)		;SAME WITH BYTE POINTER
	MOVE	W1,(PP)		;GET LAST ADR TO MOVE FROM BYTE POINTER
	ADD	T,LBUFP2	;GET "TO" ADR. [(LBUFP2)-D OF M]
	HRL	T,LBUFP2	;GET "FROM" ADR
	BLT	T,(W1)		;BLT T,"E" (T/  XWD "FROM","TO")
	JRST	NOR90

NOR5:	MOVE	W1,T		;GET D OF M
	HRLI	W1,(POP T,(T))	;SETUP- POP T,<D OF M>(T) INTO W1
	MOVE	W2,HIGH		;GET HIGH(+1) ADR OF FILE #1
	SUB	W2,LBUFP2	;GET LENGTH OF FILE #1
	SOS	T,HIGH		;GET LAST ADR IN FILE #1
	HRLI	T,400000(W2)	;PUT WORD COUNT(+400000) IN LEFT HALF
				;400000 AVOIDS PDL OVERFLOW PROBLEM IN AC LOOP
	MOVE	W3,[JRST NOR90]
	MOVE	W2,.+1
	JUMPL	T,W1		;W1/	POP T,<DISTANCE OF MOVE>(T)
			;W2/	JUMPL T,W1
			;W3/	JRST NOR90
;THE ABOVE INSTRUCTIONS ARE A REVERSE BLT AND ARE IN THE AC'S FOR SPEED

NOR90:	MOVE	T,ROOM		;GET DISTANCE FILE #1 WAS MOVED
	ADDM	T,LBUFP2	;MODIFY STARTING ADR OF FILE #1
	HRLOI	0,377777
	MOVEM	0,OLDNUM+1	;FORCE "SETONE" TO RECALCULATE BYTE POINTER
NOR98:	POP	PP,W1
NOR99:	POPJ	PP,

;THIS PAGE CONTAINS ROUTINE FOR COMPARING TWO LINES
;IT HAS TWO RETURNS--CALLING ADR.+1 IF LINES MATCH OR
;CALLING ADR+2 IF NO MATCH

COMPL:	PUSHJ	PP,SETP		;CALCULATE POINTERS TO TEXT
	MOVEM	W1,P1		;P1=TEMP POINTER TO TEXT FOR FIRST FILE
	MOVEM	W2,P2		;P2 FOR SECOND FILE

	MOVEI	W3,1
	TDNN	W3,1(W1)	;TEST SEQUENCE # BIT
;**;[33] ALTERED AND ADDED TEXT STARTING AT COMPL+6L
;**;[33] LLN.  13-AUG-76
	JRST	.+4		;[33] NOT SEQ. #
	AOS	P1		;SKIP OVER SEQ. # AND
	ILDB	W1,P1		;[33] GET CHAR
	CAIN	W1,11		;[33] IS IT A TAB?
	ILDB	W1,P1		;[33] YES, EAT IT
	TDNN	W3,1(W2)	;SAME THING FOR FILE #2
	JRST	COMPL2		;[33]
	AOS	P2
	ILDB	W2,P2		;[33] GET NEXT CHAR
	CAIE	W2,11		;[33] IS IT A TAB?
	JRST	COMPL0		;[33] NO, DON'T EAT
	JRST	COMPL2		;[33] YES, DO EAT

COMPL1:	ILDB	W1,P1		;GET A CHARACTER FROM LINE FROM FIRST FILE
COMPL2:	ILDB	W2,P2		;AND ONE FROM SECOND FILE
COMPL0:	CAME	W1,W2		;THIS IS THE BIG TEST--ARE THEY EQUAL
	JRST	COMPL4		;NO
COMPL7:	CAIN	W1,";"		;YES, COMMENT?
	TLNN	FR,CSWBIT	;YES, SUPPRESS COMMENTS?
	JUMPN	W1,COMPL1	;NO,NO. TEST FOR END OF LINE
	POPJ	PP,		;LINES MATCH, RETURN

COMPL3:	ILDB	W1,P1		;GET NEW CHAR FOR FILE 1
COMPL4:	CAIE	W1,40		;SPACE?
	CAIN	W1,TAB		;OR TAB?
	TLNN	FR,SSWBIT	;AND IS SPACING BEING IGNORED?
	SKIPA			;NO
	JRST	COMPL3		;FLUSH SPACE OR TAB FOR FILE 1

	CAIE	W2,40		;SPACE?
	CAIN	W2,TAB		;OR TAB?
	TLNN	FR,SSWBIT	;AND IS SPACING BEING IGNORED?
	SKIPA			;NO
	JRST	COMPL2		;YES, FLUSH A SPACE OR TAB FOR FILE 2

	CAMN	W1,W2		;ARE THE CHARACTERS NOW THE SAME?
	JRST	COMPL7		;YES, TEST FOR END OF LINES

	CAIE	W1,";"		;COMMENT IN FILE 1?
	CAIN	W2,";"		;OR IN FILE 2?
	TLNN	FR,CSWBIT	;AND ARE COMMENTS BEING IGNORED?
	JRST	CPOPJ1		;NO, FILES DON'T MATCH, SKIP RETURN
	JUMPE	W1,CPOPJ	;YES, OTHER CHAR MUST BE NULL OR ELSE ONE
	JUMPE	W2,CPOPJ	;  LINE IS LONGER THAN OTHER AND FILES DIFFER
CPOPJ1:	AOS	(PP)
CPOPJ:	POPJ	PP,
;WHEN WE GET TO THIS POINT WE HAVE FOUND 
;THE EXTENT OF THE DIFFERENCES AND WE ARE READY TO PRINT
;THESE DIFFERENCES OUT

PNTBTH:	TRZ	FR,-1		;OUTPUT FILE 1
	PUSHJ	PP,PNTTXT	;PRINT FILE 1 DIFFERENCES
	MOVE	W1,[POINT 7,[ASCIZ /****/]]
	PUSHJ	PP,PRINT
	PUSHJ	PP,PCRLF
	HRRI	FR,1		;THEN PRINT FILE 2 DIFFERENCES
	PUSHJ	PP,PNTTXT
	MOVE	W1,[POINT 7,[ASCIZ /**************/]]
	PUSHJ	PP,PRINT
	JRST	PCRLF		;PRINT CARRIAGE RETURN-LINE FEED

;THIS SUBROUTINE PRINTS ALL THE TEXT IN THE
;BUFFER SPECIFIED BY C(FR)R. I. E. FILE 1 OR FILE 2

PNTTXT:	SETOM	TEMP		;START POINTER AT -1
	SETOM	PAGEN		;GUARANTEE PAGE # MISMATCH- THEREFORE PRINT IT
PNTTX1:	AOS	W1,TEMP		;INDEX LINE COUNTER
	CAMLE	W1,F1(FR)	;PRINTED ALL LINES?
	POPJ	PP,		;YES, RETURN
	PUSH	PP,F1		;NO, SAVE LINE POINTERS
	PUSH	PP,F2
	SETZB	F1,F2		;F1=F2=0
	MOVEM	W1,F1(FR)	;SET UP EITHER FOR F1 OR F2
	PUSHJ	PP,SETONE	;CALCULATE BYTE POINTERS TO TEXT
	MOVE	W1,W1(FR)	;UNNECESSARY FOR FILE 1- MOVES BYTE PNT FILE 2
	PUSHJ	PP,PLINEN	;PRINT: 1)	TEXT
	PUSHJ	PP,PCRLF
	POP	PP,F2
	POP	PP,F1		;RESTORE REGS
	JRST	PNTTX1		;FINISH OUT ALL LINES

;THE FOLLOWING CODE IS USED TO OUTPUT A LINE OF TEXT
PLINEN:	MOVEI	C,"1"(FR)
	PUSHJ	PP,PCHART	;PRINT 1 OR 2
	MOVEI	C,")"
	PUSHJ	PP,PCHART	;PRINT )
	HLRZ	C,(W1)		;GET PAGE NUMBER FOR THIS LINE
	CAME	C,PAGEN		;IS IT THE SAME AS PREVIOUS LINE?
	PUSHJ	PP,PGNUM	;PRINT NEW PAGE NUMBER
	MOVEI	C,TAB		;PRINT TAB
	PUSHJ	PP,PCHART

PRINT:	ILDB	C,W1		;GET CHARACTER
	JUMPN	C,.-2		;LOOP UNTIL A NULL SHOWS UP
	POPJ	PP,


TCRLF:			;THIS TEST IS FOR BINARY COMPARE ON TTY
			;ONLY PRINT HEADER ONCE, SINCE TAKES UP SPACE
			;ON VT05'S ETC
	TLNN	FR,IOTTY	;IS OUTPUT TO TTY?
	JRST	PCRLF		;NO, GIVE EACH PAGE A HEADER
	SKIPE	ERRCNT		;COUNT IS ZERO FIRST TIME IN
	JRST	CRLF		;NOT FIRST TIME

PCRLF:			;THIS CODE OUTPUTS A CARRAIGE RETURN-LINE
			;FEED AND DECREMENTS THE LINE COUNT

	PUSHJ	PP,CRLF
	SOSN	LINCNT		;DECREMENT THE LINES/PAGE COUNT
	TLO	FR,PAGSW	;THIS MEANS WE GET A NEW HEADING
	POPJ	PP,

PGNUM:	MOVEM	C,PAGEN		;SAVE NEW PAGE # AS OLD
PGNUM1:	IDIVI	C,12		;STANDARD DECIMAL PRINT ROUTINE
	HRLM	C+1,(PP)
	SKIPE	C
	PUSHJ	PP,PGNUM1
	HLRZ	C,(PP)
	ADDI	C,"0"
	JRST	PCHART
;THIS PAGE CONTAINS ROUTINES FOR CHARACTER OUTPUT

;CHARACTERS OUTPUTED AS A STRING OF TEXT COME THROUGH HERE

PCHART:	JUMPE	C,CPOPJ		;ZERO MEANS A CARRIAGE RETURN
				;IF SO WE ARE THROUGH WITH LINE
	CAIL	C,11		;IS CHAR BETWEEN 11 (TAB) AND
	CAILE	C,15		;  15 (CARRIAGE RETURN), OR
	CAIL	C," "		;  .GE. THAN 40 (SPACE)?
	JRST	PCHAR		;YES, PRINT AS IS
	MOVSI	C,100(C)	;NO, CONTROL CHAR --SAVE
	HRRI	C,"^"		;THIS IS CONTROL SYMBOL
	PUSHJ	PP,PCHAR	;OUTPUT THE "^"
	MOVSS	C		;AND NOW FOR THE LETTER

PCHAR:	TLNN	FR,USWBIT	;NO HEADERS FOR UPDATE MODE
	TLZN	FR,PAGSW	;DO WE NEED A NEW HEADING
	JRST	TYO		;NO--SIMPLE CHARACTER OUTPUT
	SETOM	LINCNT		;YES
;THIS CODE OUTPUTS A HEADING COMPRISES OF THE TITLE OF
;EACH FILE AFTER "FILE 1)" AND "FILE 2)"

	MOVEM	16,SAVEXS+16	;SAVE ACCUMULATORS WHILE OUTPUTING HEADING
	MOVEI	16,SAVEXS
	BLT	16,SAVEXS+15	;ACCUMULATORS ARE NOW SAVED
	TLNE	FR,ENDSW	;DON'T BOTHER IF NO ERRORS DETECTED
	JRST	PCHAR1
	MOVEI	C,FF		;FOR NEW PAGE, ISSUE FORM FEED
	TLNN	FR,NOFORM	;IF 1, SUPPRESS FORM FEED
	PUSHJ	PP,TYO
	MOVE	W1,[POINT 7,[ASCIZ /File 1)	/]]
	PUSHJ	PP,PRINT
	MOVE	W1,[POINT 7,HBUF1]
	PUSHJ	PP,PRINT	;PRINT FILE 1 NAME
;**;[51] ADD TWO LINES AT PCHAR: + 19L.  LLN, 5-OCT-77
	MOVE	W1,[POINT 7,HBUF1D]	;[51]
	PUSHJ	PP,PRINT	;[51] AND ITS CREATION DATE
	PUSHJ	PP,PCRLF
	MOVE	W1,[POINT 7,[ASCIZ /File 2)	/]]
	PUSHJ	PP,PRINT
	MOVE	W1,[POINT 7,HBUF2]
	PUSHJ	PP,PRINT	;PRINT FILE 2 NAME
;**;[51] ADD TWO LINES JUST BEFORE PCHAR1:.  LLN, 5-OCT-77
	MOVE	W1,[POINT 7,HBUF2D]	;[51]
	PUSHJ	PP,PRINT	;[51] AND ITS CREATION DATE
PCHAR1:	PUSHJ	PP,CRLF		;FOLLOWED BY TWO CARRIAGE RETURN FINE FEEDS
	PUSHJ	PP,CRLF
	MOVEI	LPP		;RESET LINES/PAGE COUNT
	MOVEM	LINCNT
	MOVSI	16,SAVEXS	;AND RESTORE ACS
	BLT	16,15
	MOVE	16,SAVEXS+16
	TLZ	FR,NOFORM	;CLEAR SUPPRESS FF FLAG AFTER RESTORING AC'S
	SKIPE	QSW		;Q LISTING ONLY?
	JRST	QFIN		;YES, GIVE UP ON FIRST ERROR
	JRST	TYO		;DON'T FORGET ABOUT THAT ORGINAL CHARACTER

;THE CODE ON THIS PAGE IS FOR HANDLING INPUT ERRORS
;THERE ARE TWO TYPES OF ERRORS--EITHER THE FILE IS NOT FOUND
;OR THE DEVICE IS NOT AVAILABLE--THE FORMAT FOR THESE MESSAGES
;IS THE SAME FORMAT USED FOR THE "TECO" MESSAGES.




ERRIA1:	SKIPA	T,[[ASCIZ/?Input error for input file 1- /]]  ;
ERRIA2:	MOVEI	T,[ASCIZ/?Input error for input file 2- /]	;
ERRIA:	HRRZ	FIL,INDIR1+1	;SAVE ERROR CODE
	PUSHJ	PP,TYPMSG	;TYPE FIRST PART OF MESSAGE
	MOVE	T,INDIR1	;GET FILE NAME
	PUSHJ	PP,PNTSIX	;PRINT
	HLLZS	T,INDIR1+1	;GET EXTENSION FREED FROM GARBAGE
	JUMPE	T,NOEXT		;ANY EXTENSION?
	MOVEI	C,"."		;YES, TYPE DOT
	PUSHJ	PP,TYO
	MOVE	T,INDIR1+1	;GET EXTENSION
	PUSHJ	PP,PNTSIX	;PRINT
NOEXT:	PUSHJ	PP,ERCODP	;PRINT ERROR CODE
	MOVEI	T,[ASCIZ/) /]	;IN CASE OUT OF BOUNDS
	CAIG	FIL,ERRLN	;JUST PRINT CLOSE PARENS
	SKIPE	T,ERRTAB(FIL)	;PICK UP ERROR MESSAGE
	PUSHJ	PP,TYPMS0
	JRST	CARR		;THIS WILL OUTPUT TWO C.R. AND EXIT

ERRTAB:	[ASCIZ/) File not found/]	; 0
	[ASCIZ/) Non-existent UFD/]	; 1
	[ASCIZ/) Protection failure/]	; 2
	[ASCIZ/) File being modified/]	; 3
	0				; 4 NOT APPLICABLE
	0				; 5
	[ASCIZ/) UFD or RIB error/]	; 6
	0				; 7
	0				;10
	0				;11
	0				;12
	0				;13
	[ASCIZ/) No room or quota exceeded/] ;14
	[ASCIZ/) Write-lock error/]	;15
	[ASCIZ/) Not enough monitor table space/] ;16
	0				;17
	0				;20
	[ASCIZ/) Cannot supersede UFD/] ;21
	0				;22
	[ASCIZ/) SFD not found/]	;23
	[ASCIZ/) Search list empty/]	;24
	[ASCIZ/) SFD Nesting too deep/]	;25
	[ASCIZ/) Path error/]		;26
	0				;27
	[ASCIZ/) File cannot be updated/] ;30
	0				;31
	0				;32
	ERRLN==.-ERRTAB-1	;MAXIMUM ERROR CODE KNOWN


ERRA:	MOVE	T,OUTDEV	;OUTPUT INIT FAIL
	MOVEM	T,INDEV1

ERRI:	MOVEI	T,[ASCIZ /?Device /]
	PUSHJ	PP,TYPMSG	;TYPE BEGINING OF MESSAGE
	MOVE	T,INDEV1
	PUSHJ	PP,PNTSIX
	MOVEI	T,[ASCIZ /: Not available/]
	PUSHJ	PP,TYPMS0	;TYPE REST OF MESSAGE
	JRST	CARR		;INSERT CARRIAGE RETURNS AND EXIT


ERCODP:	MOVEI	C," "		;PRINT A SPACE
	PUSHJ	PP,TYO		;
	MOVEI	C,"("		;AND OPEN PARENS
	PUSHJ	PP,TYO		;
	MOVEI	T,(FIL)		;PICK UP ERROR CODE
ERCOD1:	IDIVI	T,10		;GET A DIGIT
	HRLM	TT,(PP)		;STASH IT
	SKIPE	T		;DONE?
	PUSHJ	PP,ERCOD1	;NO
	HLRZ	C,(PP)		;GET THE DIGIT
	ADDI	C,"0"		;ASCII-SIZE IT
	PUSHJ	PP,TYO		;OUT IT
	POPJ	PP,		;AND THATS IT
PNTSIX:	MOVE	TT,[POINT 6,T]	;INIT SIXBIT BYTE POINTER
PNTS1:	TLNN	TT,770000	;FINISHED WITH WORD?
	POPJ	PP,		;YES
	ILDB	C,TT		;NO, GET CHARACTER
	JUMPE	C,PNTS1		;FLUSH SPACES
	ADDI	C,40		;CHANGE TO ASCII
	PUSHJ	PP,TYO
	JRST	PNTS1
CRLF:	MOVEI	C,15		;OUTPUT A CARRIAGE RETURN-LINE FEED
	PUSHJ	PP,TYO
	MOVEI	C,12		;NOW THE LINE FEED

TYO:	SOSG	CTOBUF+2	;DECREMENT BUFFER COUNT
	PUSHJ	PP,DMPOUT	;BUFFER WAS FULL
	IDPB	C,CTOBUF+1	;DEPOSIT CHAR.
	CAIN	C,12		;LINE FEED?
	TLNN	FR,IOTTY	;WHILE DOING 1 OUTPUT PER LINE?
	POPJ	PP,		;NO
DMPOUT:	OUT	CTL,		;YES, OUTPUT BUFFER
	POPJ	PP,		;OK
	JSP	T,ERROUT
	ASCIZ	/?Output device error/

;** EDIT 24	 ERRO	ILG	29-JAN-75
ERRONO:	MOVEI	T,[ASCIZ/?Output device error- /]	
	PUSHJ	PP,TYPMSG			;[24]
	MOVE	T,OUTDEV			;[24]AND DEVICE
	PUSHJ	PP,PNTSIX			;[24]CANT DO OUTPUT
	MOVEI	T,[ASCIZ/: cannot do output/]	;[24]
	PUSHJ	PP,TYPMS0			;[24]
	JRST	CARR				;[24]FINISH UP
ERROEF:
	MOVE	T,OUTDIR	;[24]SET UP DIR
	MOVE	TT,OUTDIR+1	;[24]
	MOVEM	T,INDIR1	;[24]FOR TYPEOUT
	MOVEM	TT,INDIR1+1	;[24]
	MOVEI	T,[ASCIZ/?Output ENTER error for /]
	JRST	ERRIA		;[24]
ERRCOR:	MOVEI	T,[ASCIZ /?2K core needed and not available/]
	PUSHJ	PP,TYPMSG
	EXIT			;PRINT MESSAGE AND EXIT

ERROUT:	PUSHJ	PP,TYPMSG	;OUTPUT ERROR
	JRST	CARR		;THROW IN TWO CR AND TRY AGAIN

TYPB:	PUSHJ	PP,TYPTAB
	PUSHJ	PP,TYCELL
	PUSHJ	PP,TYPSP
TYCELL:	MOVEI	TT,6		;CALCULATER CONTENTS A A MEMORY WORD
			;WHICH IS STORED IN AC T
			;SHIFT A CHAR. INTO ACC AND ADD 60
			;DO IT TO MAKE IT ASCII; DO THIS 6 TIMES

	MOVEI	C,0
	LSHC	C,3
	ADDI	C,"0"
	PUSHJ	PP,PCHAR
	SOJG	12,TYCELL+1
	POPJ	PP,

TYPSP:	MOVEI	C," "
	JRST	TYO

TYPTB2:	PUSHJ	PP,TYPTAB
TYPTAB:	MOVEI	C,TAB
	JRST	TYO

TYCNT:	AOS	ERRCNT
	HRLZ	T,CNT
	JRST	TYCELL



;ROUTINES FOR OUTPUTING ERROR MESSAGES

TYPMSG:	PUSHJ	PP,INITTY	;INTIALIZE TTY
	PUSHJ	PP,CRLF		;OUTPUT A CARRIAGE RETURN
TYPMS0:	HRLI	T,(POINT 7,,)	;THIS IS POINTER FOR ERROR MESSAGE
	SKIPA
	PUSHJ	PP,TYO
TYPMS1:	ILDB	C,T		;LOAD A CHAR. FROM ERROR MESSAGE
	JUMPN	C,.-2		;ALL ERROR MESSAGES END WITH A ZERO
	POPJ	PP,		;THROUGH WITH ERROR MESSAGE

CARR:	PUSHJ	PP,CRLF		;COMMON EXIT FOR ERROR MESSAGES
	PUSHJ	PP,CRLF
	JRST	COMP		;GO TO VERY BEGINNING

;INITIALIZE TTY FOR ERROR MESSAGES
INITTY:	CLOSE	CTL,
	RELEAS	CTL,
	INIT	CTL,1
	SIXBIT	/TTY/
	XWD	CTOBUF,CTIBUF
	HALT
	INBUF	CTL,1
	OUTBUF	CTL,1
	POPJ	PP,

;HELP MESSAGE TEXT

;**;[45] ADD ONE LINE AT HELP:.  LLN, 2-JUN-77
HELP:	PUSHJ	PP,EAT		;[45] READ TO END OF LINE
	MOVE	1,['FILCOM']	;NAME OF HELP FILE
	PUSHJ	PP,.HELPR	;READ IT
	JRST	COMPGO		;PRINT * AGAIN

;ROUTINE TO GET A LEGITIMATE CHARACTER

;**;[44] Changes in GCHAR:  routine.  LLN, 22-Apr-77
GCHAR:	SKIPN	OLDCHR(FR)	;[44] CHARACTER LEFT FROM LAST TIME?
	JRST	GCHAR0		;[44] NO, PROCEED AS USUAL
	MOVE	C,OLDCHR(FR)	;[44] YES, USE IT INSTEAD OF A NEW ONE
	SETZM	OLDCHR(FR)	;[44] ZERO THE FLAG
	JRST	GCHR00		;[44] SKIP CHECKS ALREADY MADE
GCHAR0:	TLNE	FR,@EOFTBL(FR)	;[44] EOF SEEN?
	JRST	NULL		;YES, RETURN NULL
	SOSG	@CNTTBL(FR)	;DECREMENT BUFFER COUNT
	JSP	C,@[EXP GCHAR1,GCHAR2](FR)	;BUFFER EMPTY- DO "INPUT"
	SKIPN	@CNTTBL(FR)	;DID WE GET ANY DATA
	JRST	GCHAR		;NO
	ILDB	C,@BYTTBL(FR)	;YES, GET A CHARACTER
	JUMPE	C,GCHAR		;GET RID OF NULLS
	CAIE	C,LF		;LINE FEED?
	CAIN	C,VT		;NO-VERTICAL TAB?
	JRST	EOL		;YES, RETURN WITH LINE-END FLAG SET
	CAIN	C,CR		;CARRIAGE RETURN?
	JRST	[SETOM CRSEEN(FR)	;[44] YES, POSSIBLY FLUSH
		 JRST GCHAR]	;[44] SO GO GET ANOTHER
	CAIN	C,FF		;IS IT A FORM FEED?
	JRST	FORM		;YES
	SKIPN	CRSEEN(FR)	;[44] WAS LAST CHARACTER A CR?
	JRST	GCHR00		;[44] NO, WE HAVE WHAT WE WANT
	MOVEM	C,OLDCHR(FR)	;[44] YES, SAVE THIS ONE FOR NEXT TIME
	MOVEI	C,CR		;[44] RETURN A CARRIAGE-RETURN
	JRST	EOL		;[44] AS AN EOL CHARACTER
GCHR00:	HRL	C,@SEQTBL(FR)	;[44] GET SEQUENCE # BIT (IF IT EXISTS)
	TLZ	C,777776	;TURN OFF ALL BUT SEQ. # BIT
	POPJ	PP,		;NO, RETURN WITH CHAR

GCHAR1:	INPUT	IN1,		;INPUT FOR FILE 1
	STATO	IN1,762000	;ERRORS OR END OF FILE?
	JRST	(C)		;NO
	STATO	IN1,742000	;YES, EOF?
	JRST	EOF		;YES END OF FILE
	JSP	T,ERROUT
	ASCIZ	/?File 1 read error/

GCHAR2:	INPUT	IN2,
	STATO	IN2,762000
	JRST	(C)
	STATO	IN2,742000
	JRST	EOF
	JSP	T,ERROUT
	ASCIZ	/?File 2 read error/

SEQTBL:	Z	@INBUF1+1	;POINTS TO ADR OF LAST CHAR FILE #0
	Z	@INBUF2+1	;DITTO FILE #1

BYTTBL:	INBUF1+1		;ADR OF BYTE POINTER FILE #0
	INBUF2+1		;DITTO FILE #1

EOFTBL:	EOF1SW		;EOF FLAG FOR FILE 1
	EOF2SW		;EOF FLAG FOR FILE 2

CNTTBL:	INBUF1+2		;POINTS TO FILE 1 CHAR COUNT
	INBUF2+2		;DITTO FILE 2

EOF:	TLO	FR,@EOFTBL(FR)	;SET EOF FLAG
NULL:	TDZA	C,C		;THEN RETURN NULL CHAR
FORM:	AOS	PAGNUM(FR)	;INDEX PAGE NUMBER
EOL:	TLO	C,(1B0)		;SET BIT 0 TO SHOW END-OF-LINE
;**;[44] ADD ONE LINE AT EOL: + 1L.  LLN, 22-APR-77
	SETZM	CRSEEN(FR)	;[44] ZERO A FLAG
	POPJ	PP,

;HERE TO SKIP REST OF FILES, AND TAKE A QUICK EXIT.

QFIN:	AOS	ERRCNT		;ENSURE AT LEAST ONE ERROR SEEN
;**	[30]	CHANGE @ QFIN+4	29-APR-76	LCR.
	JRST	FIN2		;[30] TAKE QUICK EXIT.


;**	[30]	THE FOLLOWING LINES WERE DELETED BY EDIT [30]
;**	[30]	29-APR-76	LCR.
;
;	PUSH	PP,[EXP QFIN2]	;FOR EOF
;QFIN1:	JSP	C,GCHAR1	;DO INPUT
;	SETOM	INBUF1+2	;CLEAR WORD COUNT
;	JRST	QFIN1		;TRY AGAIN
;
;QFIN2:	TLNE	FR,EOF2SW	;ONLY ONE FILE?
;	JRST	FIN2		;SHOULD NOT HAPPEN BUT!!
;	ANDI	FR,1		;INDEX BY 1 FOR FILE 2
;	PUSH	PP,[EXP FIN2]	;FOR EOF
;QFIN3:	JSP	C,GCHAR2	;INPUT
;	SETOM	INBUF2+2
;	JRST	QFIN3		;NO. LOOP
NAME1:	SETZB	ACDEV,ACDEL	;ZERO REGISTERS WHICH WILL RETURN THE NAMES
	SETZB	ACFILE,ACEXT
	SETZB	ACPPN,EXTFL2	;INIT PROJ,PROG NUMBER TO [0,0]
	TLZ	FR,CTYPF	;CLEAR COMMAND TYPED FLAG

NAME3:	MOVSI	ACPNTR,(POINT 6,0)	;SET POINTER
	SETZB	TT,0		;THE SIXBIT NAME WILL BE STORED IN THE AC0

GETIOC:	PUSHJ	PP,TTYIN	;GET INPUT CHARACTER
;**;[45] CHANGES AT GETIC1:.  LLN, 2-JUN-77
GETIC1:	CAIN	C,32		;[45] AN EOF TERMINATES A FILE NAME
	JRST	[SETOM	XITFLG	;[45]   AND CAUSES US TO EXIT LATER
		 JRST	TERM]	;[45] HANDLE WHAT WE HAVE
	CAILE	C,15		;[45] THIS IS ANOTHER WAY TO GET A FILE NAME
	CAIN	C,33		;ALT MODE?
	JRST	TERM		;YES
	CAIE	C,"_"		;ONE KIND OF SEPERATOR
	CAIN	C,","		;THIS ALSO MEANS WE HAVE FINISHED A TERM
	JRST	TERM		;TERM HAS BEEN READ
	CAIN	C,"/"		;IS THERE A SWITCH?
	JRST	GETSW		;YES
	TLO	FR,CTYPF	;SET COMMAND TYPED FLAG
	CAIN	C,":"		;HAVE WE BEEN GETTING A DEVICE NAME
	JRST	DEVICE		;YES
	CAIN	C,"."		;OR A FILE NAME
	JRST	NAME		;YES
	CAIN	C,"["		;THIS CHAR STARTS A PROJ,PROG NUMBER
	JRST	GETPP
		;ALL OTHER CHARACTERS SHOULD BE ALPHANUMERIC FOR FILENAMES
	CAIL	C,"A"
	CAILE	C,"Z"
	JRST	[CAIL C,"0"	;NOT ALPHABETIC, IS IT NUMERIC?
		CAILE C,"9"
		JRST CTLSER	;NOT ALPHANUMERIC, COMMAND ERROR
		JRST .+1]
	TRC	C,40		;CONVERT TO SIXBIT
	TLNE	ACPNTR,770000	;HAVE WE STORED SIX BYTES?
	IDPB	C,ACPNTR	;NO
	JRST	GETIOC		;GET ANOTHER CHAR.

TTYIN:	SOSG	CTIBUF+2	;DECREMENT CHARACTER COUNT, ANY LEFT?
	INPUT	CTL,		;NO, GET A BUFFER FULL
	ILDB	C,CTIBUF+1	;GET CHARACTER
	JUMPE	C,TTYIN		;FLUSH NULLS
	CAIE	C,176
	CAIN	C,175
	MOVEI	C,33		;CHANGE ALL ALT MODES TO NEW
	CAIN	C,"="
	MOVEI	C,"_"		;= WILL EVENTUALLY REPLACE _
	CAIL	C,"A"+40
	CAILE	C,"Z"+40
	JRST	.+2
	TRZ	C,40		;CHANGE LOWER CASE TO UPPER CASE
	CAIE	C," "		;SKIP BLANKS
	CAIN	C,TAB		;AND TABS
	JRST	TTYIN
	POPJ	PP,		;NO, EXIT
DEVICE:	SKIPA	ACDEV,0		;DEVICE NAME
NAME:	MOVE	ACFILE,0	;FILE NAME
	MOVE	ACDEL,C		;SET DELIMITER
	JRST	NAME3		;GET NEXT SYMBOL

TERM:	JUMPE	ACDEL,.+3	;IF NO PREVIOUS DELIMITOR, OR
	CAIE	ACDEL,":"	;IF PREVIOUS DELIMITER
	JRST	TERM1
	MOVE	ACFILE,0	;SET FILE
TERM1:	CAIE	ACDEL,"."	;IF PERIOD,
	POPJ	PP,
	HLLZ	ACEXT,0		;SET EXTENSION
	HLRZS	0		;PUT EXT IN RH
	MOVSI	T,EXTBL-EXTBLE	;NEGATIVE WORD COUNT
	CAIE	0,@EXTBL(T)	;MATCH EXT?
	AOBJN	T,.-1
	HLLZ	T,EXTBL(T)	;GET FLAGS
	MOVEM	T,EXTFL2	;SAVE  THEM
	POPJ	PP,		;EXIT

EXTBL:	XDFBIT,,'SAV'
	XDFBIT,,'LOW'
	XDFBIT,,'SVE'
	HSGBIT,,'SHR'
	HSGBIT,,'HGH'
	WDFBIT,,'REL'
	WDFBIT,,'XPN'
	WDFBIT,,'CHN'
	WDFBIT,,'DMP'
	WDFBIT,,'BIN'
	WDFBIT,,'RIM'
	WDFBIT,,'RTB'
	WDFBIT,,'RMT'
	WDFBIT,,'BAC'
	WDFBIT,,'BUG'
	WDFBIT,,'CAL'
	WDFBIT,,'DAE'
	WDFBIT,,'DCR'
	WDFBIT,,'MSB'
	WDFBIT,,'OVR'
	WDFBIT,,'QUC'
	WDFBIT,,'QUE'
	WDFBIT,,'QUF'
	WDFBIT,,'SFD'
	WDFBIT,,'SYS'
	WDFBIT,,'UFD'
	EXEBIT,,'EXE'
EXTBLE:	0			;END OF TABLE
GETSW:	PUSHJ	PP,TTYIN	;A SWITCH HAS BEEN DETECTED
	MOVSI	T,SWTBL-SWTBLE	;SET UP NEG. COUNT FOR TABLE SEARCH
	CAIE	C,@SWTBL(T)	;FOUND CHAR? (INDIRECT=INDEX=0)
	AOBJN	T,.-1
	JUMPGE	T,GETSW1	;JUMP IF NOTHING FOUND
	TDOA	FR,SWTBL(T)	;TURN ON FLAG (GARBAGE IN RIGHT)
GETSWE:	SETOM	QSW		;SET /Q SEEN
	JRST	GETIOC		;GET NEXT PART OF COMMAND

GETSW1:	CAIN	C,"H"		;REQUEST FOR HELP?
	JRST	HELP		;YES
	CAIN	C,"Q"		;/Q?
	JRST	GETSWE		;YES
	SETZ	T,		;START WITH ZERO
	PUSHJ	PP,GETOC2	;BUILD OCTAL NUMBER IN T
	JUMPE	T,CTLSER	;ERROR IF NO NUMBER
	MOVEM	T,NUMLIN	;SAVE AS # EXTRA LINES TO MATCH (AFTER 1ST)
;**;[34] Change, add text at GETSW1 + 8L.  LLN, 15-Oct-76
	CAIN	C,"L"		;[34] TEST FOR LIMIT SWITCHES
	JRST	[SETOM LSEEN	;[34] We saw the /L switch
		 JRST  SETLIM+1]	;[34] Set up limits
	CAIN	C,"U"		;EITHER UPPER OR LOWER
	JRST	SETLIM		;FOUND ONE
	JRST	GETIC1

SETLIM:		SKIPA	UPPER,T		;UPPER LIMIT /0000U
	MOVE	LOWER,T		;LOWER LIMIT /0000L
	JRST	GETIOC		;GET MORE COMMAND

SWTBL:	SSWBIT,,"S"		;/S SUPPRESSES COMPARING SPACES, TABS
	CSWBIT!SSWBIT,,"C"	;/C DON'T COMP. COMMENTS OR SPACING
	ALLSW,,"B"		;/B ALLOWS COMPARING BLANK LINES
	ASWBIT,,"A"		;/A COMPARE LINE BY LINE (ASCII)
	WSWBIT,,"W"		;/W COMPARE WORD FOR WORD (BINARY)
	XSWBIT,,"X"		;/X EXPAND SAV FILE FIRST (BINARY)
	EXEBIT,,"E"		;/E COMPARE EXE FILES [25]
	USWBIT+ALLSW,,"U"	;/U MANUAL UPDATE MODE
SWTBLE:		;END OF TABLE

GETPP:	PUSHJ	PP,GETOCT	;BUILD THE PROJ,PROG NUMBER
	CAIN	C,"-"		;WAS THIS DASH? (DEFAULT PATH)
	JRST	[ JUMPN T,CTLSER;MUST BE ONLY CHAR THEN
		  JRST DEFPTH ]	;GO DEFAULT THE PATH
	CAIE	C,","
	JRST	CTLSER
	HRLZ	ACPPN,T		;PUT PROJ NUMBER IN LEFT HALF
	PUSHJ	PP,GETOCT
	HRR	ACPPN,T		;PUT PROG NUM IN RIGHT HALF
;** EDIT 23	GETPP+10	IB	03-JAN-75
	GETPPN	T,		;[23] GET JOB'S PPN
	JFCL
	TLNN	ACPPN,777777	;[23] PROJ NUMBER 0?
	HLL	ACPPN,T		;[23] YES, PUT JOB'S PROJ NUMBER IN LEFT HALF
	TRNN	ACPPN,777777	;[23] PROG NUMBER 0?
	HRR	ACPPN,T		;[23] YES, PUT JOB'S PROG NUMBER IN RIGHT HALF
	CAIN	C,"]"		;SIMPLE PPN?
	JRST	GETIOC		;YES,CONTINUE WITH COMMAND
	MOVE	T,FILCNT	;GET FILE WE ARE DOING
	MOVE	T,[EXP OUTDIR,INDIR1](T) ;GET PROPER FILE
	MOVEM	ACPPN,PTHPPN(T)	;STORE PPN
	MOVEI	ACPPN,PTHADR(T)	;SET PPN TO POINT TO PATH BLOCK
	MOVEI	T,PTHSFD(T)	;SET UP FOR INPUT OF SFDS
	HRLI	T,-MAXSFD	;SET UP COUNTER TOO
GETPP1:	CAIN	C,"]"		;CLOSED WITH BRACKET?
	JRST	GETIOC		;YES,CONTINUE COMMAND SCANNING
;**;[50] ADD FIVE LINES AT GETPP1: + 2L.  LLN, 4-OCT-77
	CAIN	C,33		;[50] ESCAPE?
	JRST	TERM		;[50] YES, DONE WITH THIS
	CAIE	C,32		;[50] MAYBE AN END OF FILE?
	CAIG	C,15		;[50] LF, FF, ETC.?
	JRST	TERM		;[50] YES, CONTINUE SCANNING
	SKIPGE	T		;COUNT NEGATIVE?
	CAIE	C,","		;IS THIS SFD SPECIFICATION?
	JRST	CTLSER		;NO, INDICATE ERROR
	PUSHJ	PP,RD6		;READ THE SFD NAME
	JUMPE	TT,CTLSER	;IF NULL,ITS ERROR
	MOVEM	TT,0(T)		;STORE SFD
	SETZM	1(T)		;INSURE NULL TERMINATOR
	AOBJN	T,.+1		;INCREMENT BOTH PARTS OF SFD POINTER
	JRST	GETPP1		;LOOP FOR NEXT ONE

GETOCT:	MOVEI	T,0		;BUILD AN OCTAL NUMBER
GETOC1:	PUSHJ	PP,TTYIN
GETOC2:	CAIL	C,"0"
	CAILE	C,"7"
	POPJ	PP,		;RETURN ON A NON OCTAL DIGIT
	LSH	T,3
	ADDI	T,-"0"(C)
	JRST	GETOC1

RD6:	PUSH	PP,T		;SAVE T REG
	MOVE	T,[POINT 6,TT]	;STORE INTO TT
	SETZ	TT,		;CLEAR ARGUMENT
RD61:	PUSHJ	PP,TTYIN		;GET A CHARACTER
	CAIL	C,"0"		;LESS THAN 0?
	CAILE	C,"Z"		;OR GREATER THAN Z?
	JRST	TPOPJ		;YES,RETURN
	CAILE	C,"9"		;LESS THAN 9 OR
	CAIL	C,"A"		;GREATER THAN A?
	JRST	RD62		;ITS OK
TPOPJ:	POP	PP,T		;RESTORE TEMP REGISTER
	POPJ	PP,		;RETURN
RD62:	SUBI	C," "		;CONVERT TO SIXBIT
	TRNN	TT,77		;IF WORD NOT FULL,
	IDPB	C,T		;STORE BYTE 
	JRST	RD61		;LOOP FOR NEXT CHARACTER

DEFPTH:	MOVE	T,FILCNT	;GET FILE INDEX
	MOVE	T,[EXP OUTDIR,INDIR1](T) ;GET RIGHT DIR BLOCK
	MOVEI	ACPPN,PTHADR(T)	;PPN IS 0,,PATH BLOCK ADDRESS
	SETOM	PTHADR(T)	;READ DEFAULT PATH
	MOVEI	TT,PTHADR(T)	;POINT TO PATH BLOCK
	HRLI	TT,MAXSFD+4	;LENGTH OF AREA AVAILABLE
	PATH.	TT,		;ASK MONITOR FOR DEFAULT PATH
	  JRST	NOPTH		;NO AVAILABLE
	PUSHJ	PP,TTYIN		;GET NEXT CHARACTER
	CAIN	C,"]"		;CLOSES IT RIGHT?
	JRST	GETIOC		;RIGHT,GET REST OF STRING
	JRST	CTLSER		;OTHERWISE,COMPLAIN

NOPTH:	JSP	T,ERROUT	;IF PATH. UUO FAILED
	ASCIZ	/?PATH. UUO REQUIRED TO DEFAULT FILE PATH/

;**;[45] ADD NEW ROUTINE AT NOPTH: + 2L.  LLN, 2-JUN-77
;**;[45] WARNING -- INSERT AFTER THE ASCIZ STATEMENT, NOT
;**;[45] AFTER THE JSP AT NOPTH:.
EAT1:	PUSHJ	PP,TTYIN	;[45] GET A CHARACTER INTO C
EAT:	CAIG	C,14		;[45] IN THE RANGE OF FORM FEED
	CAIGE	C,12		;[45] DOWN TO LINE FEED?
	CAIN	C,33		;[45] NO, IS IT AN ALTMODE?
	POPJ	PP,		;[45] YES! RETURN WITH EOL CHAR
	CAIN	C,7		;[45] IS IT A ^G?
	POPJ	PP,		;[45] YES, THAT ENDS LINE TOO
	CAIE	C,32		;[45] IS IT A ^Z?
	JRST	EAT1		;[45] NO, EAT ANOTHER CHARACTER
	SETOM	XITFLG		;[45] IT'S ^Z, MARK TO EXIT LATER
	POPJ	PP,		;[45] RETURN
;CREATE PAGE HEADER FOR LISTING FILES CONSISTING OF:
	;DEVICE:FILENAME.EXT[PROJ,PROG,SFD,SFD,..,SFD] CREATED MMHH DAY-MONTH-YEAR

HEADER:	MOVEI	TT,IN1		;ASSUME FIRST FILE
;**;[51] CHANGES AT HEADER: + 1L.  LLN, 5-OCT-77
	SETZM	TEMP		;[51] SET SO WITH TEMP
	CAIE	T,HBUF1		;IS IT?
	JRST	[MOVEI	TT,IN2	;[51] NO
		 AOS	TEMP	;[51] MARK WITH TEMP
		 JRST	.+1]	;[51] RETURN TO MAINLINE CODE
	MOVEM	TT,PTHBLK+.PTFCN;STORE AS FUNCTION
	HRLI	T,440700	;MAKE ADDRESS INTO BYTE POINTER
	MOVEM	T,HPOINT	;AND SAVE FOR FUTURE USE
	MOVE	TT,[MAXSFD+4,,PTHBLK] ;SET UP FOR PATH.
	SETZM	PTHBLK+.PTPPN	;CLEAR PPN AND
	SETZM	PTHBLK+.PTPPN+1	;FIRST SFD FROM LIST
	PATH.	TT,		;DO IT
	  SKIPA	T,INDEV1	;USE DEVICE FROM LOOKUP BLOCK IF FAILS
	MOVE	T,PTHBLK+.PTFCN	;OTHERWISE USE THE PATH. DEVICE
	PUSHJ	PP,HEDST6
	MOVEI	C,":"
	PUSHJ	PP,HEDDPB	;DEPOSIT COLON INTO HEADER
	DEVCHR	T,		;GET DEVICE CHARACTERISTICS
	TLNN	T,(1B15)	;DOES DEVICE HAVE A DIRECTORY?
;**;[51] CHANGE AT HEAD2: - 9L.  LLN, 5-OCT-77
	JRST	[PUSHJ	PP,HEAD8	;[51] DEPOSIT A NULL
		 JRST	PRETTY]	;[51] CLEAN UP HEADER AND RETURN
	SKIPE	T,INDIR1
	PUSHJ	PP,HEDST6	;IF FILE NAME NOT NULL, PRINT IT
	HLLZ	T,INDIR1+1	;ISOLATE EXTENSION
	JUMPE	T,HEAD2		;DON'T PRINT IF EXTENSION NULL
	MOVEI	C,"."
	PUSHJ	PP,HEDDPB	;PUT DOT INTO HEADER
	HLLZ	T,INDIR1+1
	PUSHJ	PP,HEDST6	;PRINT EXTENSION
HEAD2:	SKIPN	T,PTHBLK+.PTPPN	;GET PPN FROM PATH, IF AVAILABLE
	MOVE	T,INDPPN	;OTHERWISE USE LOOKUP PPN
	JUMPE	T,HEAD4		;SKIP WHOLE THING IF STILL NO PPN
	MOVEI	C,"["		;PRINT IT
	PUSHJ	PP,HEDDPB
	SKIPE	PTHBLK+.PTPPN+1	;ANY SFD'S?
	JRST	PRTPTH		;IF PATH (SFDS) , PRINT DIFFERENTLY
	PUSH	PP,T		;SAVE PROJ,PROG NUMBER
	HLRZS	T		;CLEAR PROG NUMBER
	PUSHJ	PP,HED8		;PRINT PROJECT #
	MOVEI	C,","
	PUSHJ	PP,HEDDPB
	POP	PP,T		;RESTORE PROG NUMBER
	ANDI	T,-1		;ISOLATE IT
	PUSHJ	PP,HED8		;PRINT PROGRAMMER #
HEAD3:	MOVEI	C,"]"
	PUSHJ	PP,HEDDPB

;**;[51] ADD 10 LINES AT HEAD4:.  LLN, 5-OCT-77
HEAD4:	MOVE	TT,HPOINT	;[51] GET THE BYTE POINTER
	MOVEM	TT,HBPT2	;[51] ASSUME 2ND FILE AND STORE
	SKIPN	TEMP		;[51] WAS IT THE FIRST FILE?
	MOVEM	TT,HBPT1	;[51] YES, STORE IT RIGHT
	SETZ	C,		;[51] MAKE A NULL
	PUSHJ	PP,HEDDPB	;[51] TERMINATE THE FILESPEC
	MOVE	TT,[POINT 7,HBUF2D]	;[51] CREA. DATE POINTER
	SKIPN	TEMP		;[51] SECOND FILE?
	MOVE	TT,[POINT 7,HBUF1D]	;[51] NO, TRY AGAIN
	MOVEM	TT,HPOINT	;[51] SET UP FOR HEDDPB

	MOVE	T,[ASCII /	crea/]
	PUSHJ	PP,HEDST7	;PUT "	CREA" INTO BUFFER
	MOVE	T,[ASCII /ted: /]
	PUSHJ	PP,HEDST7
	LDB	T,[POINT 11,INDIR1+2,23]	;GET CREATION TIME
	IDIVI	T,^D60		;CHANGE TO HOURS AND MINUTES
	PUSH	PP,T+1		;SAVE MINUTES
	PUSHJ	PP,HED10	;PRINT HOURS
	POP	PP,T
	PUSHJ	PP,HED10	;PRINT MINUTES
	MOVEI	C," "
	PUSHJ	PP,HEDDPB	;PUT A SPACE AFTER THE TIME
HEDDAT:	LDB	T,[POINT 12,INDIR1+2,35]	;GET LOW 12 BITS OF DATE
	LDB	T+1,[POINT 3,INDIR1+1,20]	;GET HIGH 3 BITS OF DATE
	DPB	T+1,[POINT 3,T,23]		;MERGE THE TWO PARTS
	IDIVI	T,^D31		;STRIP OFF DAY OF MONTH
	PUSH	PP,T		;SAVE THE REST
	MOVEI	T,1(T+1)
	PUSHJ	PP,HED10	;PRINT DAY
	POP	PP,T
	IDIVI	T,^D12
	PUSH	PP,T		;SAVE YEAR
	MOVE	T,MONTAB(T+1)	;GET MONTH TEXT
;**;[47] CHANGE ONE LINE AT HEDDAT: +11L.  LLN, 3-OCT-77
	PUSHJ	PP,HEDST7	;[47] PRINT IT IN ASCII
	POP	PP,T
	MOVEI	T,^D1964(T)	;GET YEAR
	PUSHJ	PP,HED10	;PRINT YEAR
;**;[51] ADD TWO LINES AT HEDDAT: + 15L.  LLN, 5-OCT-77
	PUSHJ	PP,HEAD8	;[51] DEPOSIT A NULL
	JRST	PRETTY		;[51] CLEAN UP HEADER AND RETURN
;**;[51] ADD MANY LINES AT HEDDAT: + 15L.  LLN, 5-OCT-77
PRETTY:	SKIPN	TEMP		;[51] ARE WE ON THE 2ND FILE?
	POPJ	PP,		;[51] NO, CLEAN UP HEADERS LATER
	SKIPE	HBUF1D		;[51] DOES EITHER FILE
	SKIPN	HBUF2D		;[51]   LACK A CREATION DATE?
	POPJ	PP,		;[51] YES, NOTHING TO CLEAN UP
	HLRZ	TT,HBPT1	;[51] FIND 1ST FILE'S LAST CHAR
	HRLZI	T,-5		;[51] AOBJN COUNTER
PRET1:	CAME	TT,PRET4(T)	;[51] T'TH CHAR IN THE LAST WORD?
	AOBJN	T,PRET1		;[51] NO, TRY AGAIN
	HRRZ	TT,HBPT1	;[51] HOW MANY FULL WORDS?
	SUBI	TT,HBUF1	;[51] GET THAT BY SUBTRACTION
	IMULI	TT,5		;[51] GET NO. OF CHARS
	ADDI	TT,1(T)		;[51]  IN THE 1ST FILESPEC
	MOVEM	TT,TEMP		;[51] SAVE IT
	HLRZ	TT,HBPT2	;[51] NOW DO THE SAME
	HRLZI	T,-5		;[51] CALCULATION FOR THE
PRET2:	CAME	TT,PRET4(T)	;[51] SECOND FILE
	AOBJN	T,PRET2		;[51]
	HRRZ	TT,HBPT2	;[51] ADDRESS OF LAST WORD
	SUBI	TT,HBUF2	;[51] NO. OF FULL WORDS
	IMULI	TT,5		;[51] CHARS IN THOSE WORDS
	ADDI	TT,1(T)		;[51] PLUS SOME LEFT OVER

	CAMN	TT,TEMP		;[51] ARE THE COUNTS THE SAME?
	POPJ	PP,		;[51] YES, WE ARE DONE!
	MOVE	T,HBPT1		;[51] NO, ASSUME THE 1ST IS LESS
	CAMG	TT,TEMP		;[51] IS THE 2ND LESS?
	MOVE	T,HBPT2		;[51] YES, POINT TO ITS STRING
	SUB	TT,TEMP		;[51] GET THE DIFFERENCE IN LENGTH
	MOVMS	TT		;[51] MAKE SURE IT'S POSITIVE
	MOVEI	C," "		;[51] PAD THE STRING WITH SPACES
PRET3:	IDPB	C,T		;[51] ADD A SPACE
	SOJG	TT,PRET3	;[51] LOOP AROUND
	SETZ	C,		;[51] GET A NULL
	IDPB	C,T		;[51] END THE STRING WITH IT
	POPJ	PP,		;[51] WE ARE DONE

PRET4:	350700		;[51] LEFT HALVES OF ASCII BYTE POINTERS
	260700		;[51]
	170700		;[51]
	100700		;[51]
	010700		;[51]
HEAD8:	MOVEI	C,0		;PUT NULL INTO BUFFER
HEDDPB:	IDPB	C,HPOINT
	POPJ	PP,

HEDST7:	SKIPA	TT,[POINT 7,T]	;PRINT 7 BIT ASCII
HEDST6:	MOVE	TT,[POINT 6,T]	;PRINT SIXBIT
HEDS2:	TLNN	TT,760000
	POPJ	PP,		;DONE
	ILDB	C,TT
	JUMPE	C,HEDS2
	TLNN	TT,000100
	ADDI	C,40		;FOR SIXBIT, CONVERT TO ASCII
	PUSHJ	PP,HEDDPB	;OUTPUT CHARACTER
	JRST	HEDS2

HED8:	TDZA	W3,W3		;PRINT OCTAL NUMBERS
HED10:	MOVEI	W3,2		;PRINT DECIMAL NUMBERS
	MOVE	W2,W3		;FORCE 2 DIGITS FOR DECIMAL NUMBERS
HED10A:	IDIVI	T,8(W3)
	HRLM	T+1,(PP)
	SOSG	W2		;FORCE DIGITS UNTIL COUNT EXPIRES
	SKIPE	T
	PUSHJ	PP,HED10A
	HLRZ	C,(PP)
	ADDI	C,"0"
	JRST	HEDDPB

;**;[47] CHANGE 12 LINES AT MONTAB:.  LLN, 3-OCT-77
MONTAB:	ASCII	/-Jan-/
	ASCII	/-Feb-/
	ASCII	/-Mar-/
	ASCII	/-Apr-/
	ASCII	/-May-/
	ASCII	/-Jun-/
	ASCII	/-Jul-/
	ASCII	/-Aug-/
	ASCII	/-Sep-/
	ASCII	/-Oct-/
	ASCII	/-Nov-/
	ASCII	/-Dec-/
PRTPTH:	HLRZ	T,PTHBLK+.PTPPN		;GET PATH PPN
	PUSHJ	PP,HED8			;INSERT INTO HEADER
	MOVEI	C,","			;SEPARATE PROJ,PROG
	PUSHJ	PP,HEDDPB		;
	HRRZ	T,PTHBLK+.PTPPN		;GET PROG NUMBER
	PUSHJ	PP,HED8			;STORE INTO HEADER
	SETZ	W1,			;START AT BASE OF SFDS
PRTPLP:	MOVEI	C,","			;SEPARATE PPN,SFDS BY COMMA
	PUSHJ	PP,HEDDPB		;
	MOVE	T,PTHBLK+.PTPPN+1(W1)	;GET AN SFD NAME
	PUSHJ	PP,HEDST6		;STORE INTO HEADER
	SKIPN	PTHBLK+.PTPPN+2(W1)	;NEXT SFD THERE?
	JRST	HEAD3			;NO,FINISH UP
	AOJA	W1,PRTPLP		;ELSE LOOP FOR NEXT SFD
;HERE FOR BINARY COMPARE

BINCOM:	TLNE	FR,EOF2SW	;NO HEADER IF ONLY ONE FILE
	TLZ	FR,PAGSW	;FAKE AS NOT NEW PAGE
				;SORT OUT CONFLICTING SWITCHES AND EXTENSIONS
	TLNE	FR,WSWBIT		;EXPLICIT /W?
	TLZ	FR,XSWBIT!XDFBIT	;YES, THEN DON'T EXPAND
	TLNE	FR,XSWBIT		;EXPLICIT /X?
	TLZ	FR,HSGBIT!WDFBIT	;YES
	TLC	FR,XDFBIT!HSGBIT	;MUTUALLY EXCLUSIVE BITS
	TLCN	FR,XDFBIT!HSGBIT	;THERFORE THEY BETTER NOT BE BOTH ON
	TLZ	FR,XDFBIT!HSGBIT	;THEY WERE , YOU LOSE
	TLNE	FR,HSGBIT!WDFBIT	;WAS ONE FILE NOT IN SAV FORMAT?
	TLZ	FR,XDFBIT		;THEN IGNORE OTHER EXT
	TLNE	FR,XDFBIT!WDFBIT	;WAS ONE FILE NOT A HIGH SEGMENT
	TLZ	FR,HSGBIT	;YES, THEN IGNORE ONE THAT WAS
				;END OF THIS MESS
	TLNN	FR,HSGBIT	;TEST FOR EXT OF SHR, OR HGH
	TDZA	CNT,CNT		;NO, START AT 0
	MOVEI	CNT,400000	;YES, START AT HIGH SEG ADDRESS
	TLNN	FR,XSWBIT!XDFBIT	;NEED TO EXPAND?
	JRST	COMP1		;NO
	JRST	SAV1		;YES

	TRZ	FR,-1		;INDEX BY 0 FOR FILE 1
	JSP	C,GCHAR1
READ1:	SOSGE	INBUF1+2
	JRST	READ1-2		;BUFFER EMPTY
	ILDB	W1,INBUF1+1
	AOS	(PP)
	POPJ	PP,

READ2A:	HRRI	FR,1		;INDEX BY 1 FOR FILE 2
	TLNE	FR,EOF2SW	;PREMATURE EOF
	JRST	ZPOPJ		;YES, AVOID I/O ERROR
	JSP	C,GCHAR2
READ2:	SOSGE	INBUF2+2
	JRST	READ2A		;BUFFER EMPTY
	ILDB	W2,INBUF2+1
	AOSA	(PP)
ZPOPJ:	SETZ	W2,		;RETURN NUL CHARS.
	POPJ	PP,

COMP1:	TLNE	FR,EXEBIT	;EXE FILE? [25]
	JRST	EXSTUF		;YES. GO ELSEWHERE [25]
	PUSHJ	PP,READ1	;GET WORD FROM FIRST FILE
	JRST	COMP10		;HERE IF A READ FAILURE
	PUSHJ	PP,READ2	;NOW GET WORD FROM SECOND FILE
	JRST	COMP12		;HERE IF READ FAILURE
	CAME	W1,W2		;THIS IS THE BIG TEST
	PUSHJ	PP,COMP2	;IT FAILED--THERE IS A DIFFERENCE
	AOJA	CNT,COMP1	;NO DIFFERENCE--BUMP COUNT AND TRY AGAIN

;COMP2 CHANGED 1 INSTRUCTION [22]
COMP2:	CAMGE	CNT,LOWER	;[22] IS LINE NUMBER IN BOUNDS?
	POPJ	PP,		;NO,TRY NEXT ONE
;COMP2+2 CHANGED 1 INSTRUCTION [22]
	CAMLE	CNT,UPPER	;[22] HAVE WE FINISHED?
	JRST	FIN2		;YES,SO EXIT QUICKLY
	HRLZ	T,CNT		;GET LINE NUMBER FOR PRINT OUT
	PUSHJ	PP,TYCELL	;GO PRINT IT
	AOS	ERRCNT		;BUMP ERROR COUNT
	MOVE	T,1		;NO GET WORD FROM FIRST FILE
	PUSHJ	PP,TYPB		;PRINT IT WITH SPACES  BETWEEN HALF WORDS
	MOVE	T,2		;NOW WORD FROM SECOND FILE
	tlne	fr,exebit	;is this an exe file? [27]
	tlnn	fr,eof2sw	;yes, is there a 2nd file? [27]
	skipa			;no to either
	jrst	tcrlf		;yes just print crlf [27]
	PUSHJ	PP,TYPB		;AND PRINT IT
	MOVE	T,1		;NOW "OR" THE WORDS
	XOR	T,2
	TLNN	T,-1		;IF ONLY ADDRESS FIELD IS DIFFERENT
	JRST	COMP3		;HANDLE IT DIFFERENTLY
	PUSHJ	PP,TYPB		;NOW PRINT OUT THE "OR"ED WORD
	JRST	TCRLF		;OUTPUT A CARRIAGE RETURN-LINE FEED
COMP3:	MOVE	T,W1
	SUB	T,W2		;SUBTRACT ADDRESSES
	JUMPGE	T,.+2
	MOVNS	T
	MOVSS	T		;PUT IN LEFT HALF
	PUSHJ	PP,TYPTAB	;TYPE A TAB
	MOVEI	W1,7		;NEED 7 SPACES FOR ALLIGNMENT
	PUSHJ	PP,TYPSP	;TYPE A SPACE
	SOJG	W1,.-1		;LOOP
	PUSHJ	PP,TYCELL	;AND ADDRESS
	JRST	TCRLF		;AND CONTINUE

;COMP10 CHANGED 1 INSTR [22]
COMP10:	CAMG	CNT,UPPER	;[22] OUT OF BOUNDS?
	PUSHJ	PP,RDFIL2	;READ WORD FROM FILE 2 (REG OR EXE)

	JRST	FIN2
;COMP10+3 CHANGED 1 INSTR [22]
	CAMGE	CNT,LOWER	;[22]
	AOJA	CNT,COMP10	;GET NEXT WORD
	PUSHJ	PP,TYCNT	;TYPE LINE COUNT
	PUSHJ	PP,TYPTB2	;TWO TABS
	MOVE	T,W2
	PUSHJ	PP,TYPB
	PUSHJ	PP,TCRLF
	AOJA	CNT,COMP10

;COMP12 CHANGED 1 INSTR [22]
COMP12:	CAMGE	CNT,LOWER	;[22]
	JRST	COMP13
	PUSHJ	PP,TYCNT
	MOVE	T,W1
	PUSHJ	PP,TYPB
	PUSHJ	PP,TCRLF
;COMP12+6 CHANGED 1 INSTR [22]
	CAMGE	CNT,UPPER	;[22]
COMP13:	PUSHJ	PP,RDFIL1
	JRST	FIN2
	AOJA	CNT,COMP12

;COME HERE IF WE ARE COMPARING TWO EXE FILES. THIS OPERATION
; IS SOMEWHAT SIMILAR TO COMPARING TWO BINARY
; FILES EXCEPT THAT WE MUST ALSO CYLE THRU THE FILE DIRECTORY
; AS WE GO.
;
;FIRST, WE MUST READ IN THE DIRECTORY AND STORE IT SOMEPLACE.
EXSTUF:	TRZ	FR,-1		;SET FILE 1
EXSTF2:	PUSHJ	PP,EXERED	;READ THE FIRST WORD OF EXE FILE
	SETZM	DIRCTR		;CLEAR COUNTER OF DIRECTORY LENGTH
	HLRZ	T,W1		;GET LEFT HALF OF IT
	CAIE	T,SV.DIR	;IS THIS A PROPER EXE FILE?
	JRST	EXERR0		;NO, GO PRINT APPROPRIATE ERROR MSG
	TLZ	W1,-1		;CLEAR HEADER CODE AND LEAVE LENGTH
	ADDM	W1,DIRCTR	;BUMP COUNTER
	SOS	W1		;=LENGTH OF DATA IN DIRECTORY
	MOVEM	W1,@[EXP DLNG1,DLNG2](FR)	;STORE LENGTH
	HRRZ	TT,.JBFF##	;GET TOP OF FREE SPACE
	MOVEM	TT,@[EXP DPTR1,DPTR2](FR)	;SET DIRECTORY POINTER
	ADDB	W1,.JBFF##	;=TOP OF NEW LOW SEGMENT
	CAMG	W1,.JBREL##	;IS THERE ENOUGH ROOM ALREADY?
	JRST	.+3		;YES
	CORE	W1,		;NO, GET MORE CORE TO HOLD DIRECTORY
	 JRST	CORERR		;NOT ENOUGH CORE, FATAL ERROR
	HRRZ	T,.JBFF##	;GET START OF FREE SPACE
	SUB	T,@[EXP DLNG1,DLNG2](FR)
	HRRZ	TT,@[EXP DLNG1,DLNG2](FR)	;GET LENGTH OF DIR
	PUSHJ	PP,EXERED	;READ A WORD FROM DIRECTORY
	MOVEM	W1,(T)		;STORE WORD IN FREE CORE
	AOS	T		;BUMP POINTER
	SOJG	TT,.-3		;LOOP UNTIL MOVED ENTIRE DIRECTORY
GETBLK:	PUSHJ	PP,EXERED	;GET NEXT WORD IN FILE
	HLRE	T,W1		;..AND ITS HEADER CODE
	JUMPL	T,EXERR0	;MUST BE POSITIVE
	CAIN	T,SV.END	;END BLOCK?
	JRST	GOTEND		;YES
	TLZ	W1,-1		;ISOLATE LENGTH
	ADDM	W1,DIRCTR	;BUMP TOTAL LENGTH
	PUSHJ	PP,EXERED	;SKIP OVER IT
	SOJGE	W1,.-1
	JRST	GETBLK		;GET NEXT BLOCK
GOTEND:	TLZ	W1,-1		;JUST IN CASE END-BLOCK INCREASES
				; IN THE FUTURE, ADD ITS LENGTH IN
	ADDM	W1,DIRCTR
	HRRZ	T,DIRCTR	;GET AMOUNT TO SKIP OVER
	IDIVI	T,^D512		;=# OF PAGES IN DIRECTORY
	MOVEI	T,^D512		;TT NOW HOLDS REMAINDER, WHICH IS
				; THE OFFSET INTO THE LAST PAGE
				; OF THE DIRECTORY
	SUB	T,TT		;=FREE SPACE ON LAST PAGE OF DIRECTORY
	PUSHJ	PP,@[EXP READ1,READ2](FR)	;PASS OVER DIRECTORY
	JRST	EXERR0		;
	SOJG	T,.-2		;LOOP UNTIL 1ST DATA PAGE IS IN
	tlne	fr,eof2sw	;2nd file ? [27]
	jrst	got2		;no [27]
	TRNN	FR,-1		;ARE WE READING IN FILE 1?
	AOJA	FR,EXSTF2	;YES, BUMP TO FILE 2 AND READ IT IN

;FALL THRU TO NEXT PAGE WHEN BOTH DIRECTORIES ARE READ IN
;WE MUST NOW SET UP THE CORRECT POINTERS AND COUNTERS FOR EACH
; DIRECTORY.
got2:	TRZ	FR,-1		;SET FILE 1
	PUSHJ	PP,MKNTRY	;SET UP AN IOWD FOR 1ST DIRECTORY ENTRY
	MOVE	S1,T		;RETURN WITH IOWD IN T
	tlne	fr,eof2sw	;2nd file? [27]
	jrst	exloop		;no [27]
	AOS	FR		;SET FILE 2
	PUSHJ	PP,MKNTRY	;SET UP IOWD FOR 1ST ENTRY HERE ALSO
	MOVE	S2,T		;SAVE IT IN S2
;**;[54] CHANGE 3 LINES AT GOT2: + 8L.  LLN, 13-FEB-78
	MOVE	CNT,S1		;[54] ASSUME FILE 1 BEGINS 1ST
	CAMLE	CNT,S2		;[54] WHICH IS LOWER?
	MOVE	CNT,S2		;[54] FILE 2 IS, SET CNT TO BE THE STARTING
				; ADDR OF THE THE LOWER ADDRESS IN EITHER
				; FILE.

;HERE IS THE MAIN COMPARISON LOOP:
EXLOOP:	PUSHJ	PP,EXRED1	;READ A WORD FROM FILE1
;**;[54] CHANGE ONE LINE AT EXLOOP: + 1L.
	 JRST	[HRLOI	S1,377777	;[54] MAKE S1 TO BE VERY HIGH NUMBER SO
		 JRST	COMP10]	; SO S2 WILL CONTINUE TO PRINT
	PUSHJ	PP,EXRED2	;READ WORD FROM FILE2
;**;[54] CHANGE ONE LINE AT EXLUP2: - 6L.  LLN, 13-FEB-78
	 JRST	[HRLOI	S2,377777	;[54] SAME FOR S2
		 JRST	COMP12]
	CAIGE	CNT,73		;DON'T COMPARE BELOW 73 UNLESS...
	CAIN	CNT,41		;IT IS JOB41
	SKIPA			;OK, GO COMPARE THEM
	AOJA	CNT,EXLOOP	;IGNORE THESE LOCATIONS
EXLUP2:	tlnn	fr,eof2sw	;don't compare if only 1 file [27]
	CAME	W1,W2		;HERE IT IS!!!!!!!
	PUSHJ	PP,COMP2	;NO MATCH, PRINT LINE
	AOJA	CNT,EXLOOP	;BUMP ADDRESS AND LOOP


;**;[43] Change to MKNTRY comments.  LLN, 12-Jan-77
;Subroutine to form pointers from the current directory entry
;
;Call:
;	PUSHJ	PP,MKNTRY
;	Return here always
;
;On return, T will contain the address for the next word in
;the file.  EX1CNT or EX2CNT, as appropriate, will contain the
;negative of the number of words covered by this directory
;entry.
;
MKNTRY:	MOVE	TT,@[EXP DPTR1,DPTR2](FR)	;GET DIRECTORY POINTER
	LDB	T,[POINT 9,1(TT),8]	;GET REPEAT COUNT OF THIS ENTRY
	AOS	T		;=# OF PAGES IN THIS ENTRY
;**;[43] Change five lines starting at MKNTRY: + 3L.  LLN, 12-Jan-77
	IMUL	T,[-^D512]	;[43] =# OF WORDS IN THIS ENTRY
	MOVEM	T,@[EXP EX1CNT,EX2CNT](FR)	;[43] Store away
	HRRZ	T,1(TT)		;[43] GET PROCESS PAGE #
	LSH	T,9		;[43] MAKE INTO AN ADDRESS
	MOVEI	TT,40		;ASSUME THIS IS THE LOW SEG
	TRNN	T,-1		;IF THIS IS USER VIRTUAL PAGE 0
	PUSHJ	PP,SKPEXE	;SKIP UP TO LOC 41
	POPJ	PP,		;RETURN WITH ANSWER IN T



;SUBROUTINE TO READ ONE WORD FROM AN EXE FILE
;CALL:
;	PUSHJ	PP,EXRED1
;	 HERE IF EOF
;	HERE WITH WORD IN W1
;
EXRED1:	SETZ	W1,		;CLEAR WORD WHERE IT IS TO GO
;**;[54] CHANGE ONE LINE AT EXRED1: + 1L.  LLN, 13-FEB-78
	CAMGE	CNT,S1		;[54] DO THE FILE COUNTS MATCH UP?
	JRST	CPOPJ1		;NO, THIS FILE IS AHEAD OF THE
				; OTHER ONE, SO EXIT AS IF THE NEXT
				; WORD WERE A ZERO
;**;[43] Change at EXRED1 + 3.  LLN, 12-Jan-77
	AOJ	S1,		;[43] Bump address
	AOSGE	EX1CNT		;[43]   and word count
	JRST	EXRD1A		;[43] Go get it
	MOVEI	T,2		;IF WE DIDN'T JUMP, THEN WE HAVE
				; EXHAUSTED THE CURRENT DIRECTORY ENTRY
				; AND WE MUST GET ANOUTHER ONE
	ADDM	T,DPTR1		;BUMP DIRECTORY POINTER BY 2
	TRZ	FR,-1		;SET FILE 1
	SOS	DLNG1		;DECREMENT LENGTH
	SOSG	DLNG1		;..IS THERE MORE IN THE DIRECTORY?
	POPJ	PP,		;NO, EXIT WITH ZERO
	PUSHJ	PP,MKNTRY	;MAKE A NEW IOWD FROM THIS DIRECT ENTRY
	MOVE	S1,T		;RESET S1
	SOS	S1		;MAKE SURE HIGH SEG IS NOT 1 OFF
	PUSHJ	PP,SETCNT	;RESET CNT TO LOWER OF S1,S2
EXRD1A:	HRRZ	T,@DPTR1	;GET CURRENT FILE PAGE #
	JUMPE	T,CPOPJ1	;IF ALLOCATED-BUT-ZERO, PRETEND THIS
				; IS A ZERO WORD
	JRST	READ1		;GO READ A WORD FROM FILE
;SUBROUTINE TO READ A WORD FROM EXE FILE #2
;
;CALLING CONVENTIONS SAME AS EXRED1
;
EXRED2:	SETZ	W2,		;CLEAR WORD
;**;[54] CHANGE ONE LINE AT EXRED2: + 1L.  LLN, 13-FEB-78
	CAMGE	CNT,S2		;[54] DO ADDRESSES MATCH?
	JRST	CPOPJ1		;NO, EXIT WITH 0
;**;[43] Change at EXRED2: + 3.  LLN, 12-Jan-77
	AOJ	S2,		;[43] Bump address
	AOSGE	EX2CNT		;[43]  and word count
	JRST	EXRD2A		;[43] Go get it
	MOVEI	T,2		;DIRECTORY ENTRY IS THRU...
	ADDM	T,DPTR2		;...MAKE A NEW ONE
	HRRI	FR,1		;SET FILE 2
	SOS	DLNG2		;DECREMENT LENGTH
	SOSG	DLNG2		;MORE DIRECTORY ENTRIES?
	POPJ	PP,		;NO
	PUSHJ	PP,MKNTRY	;MAKE A NEW IOWD
	MOVE	S2,T		;SAVE IT IN S2
	SOS	S2		;ADJUST IT
	PUSHJ	PP,SETCNT	;ADJUST CNT
;**;[54] CHANGE ONE LINE AT EXRD2A: - 2L.  LLN, 13-FEB-78
	CAMGE	CNT,S2		;[54] DID WE JUST LEAP AHEAD OF FILE 1?
	JRST	CPOPJ1		;YES,DEFER READ UNTIL FILE 1 CATCHES UP
EXRD2A:	HRRZ	T,@DPTR2	;GET FILE PAGE #
	JUMPE	T,CPOPJ1	;IF ABZ, XIT WITH ZERO
	JRST	READ2		;GET A WORD FROM FILE 2


;SUBROUTINE TO READ A WORD FROM EITHER A REGULAR BINARY FILE
; OR AN EXE FILE. THIS ROUTINE IS CALLED ONLY ON EOF FROM 
; ONE OF THE FILES.
;
RDFIL1:	TLNN	FR,EXEBIT	;IS THIS AN EXE FILE?
	JRST	READ1		;NO, REGULAR READ
	JRST	EXRED1		;YES, EXE READ

RDFIL2:	TLNN	FR,EXEBIT	;EXE FILE?
	JRST	READ2		;NO
	JRST	EXRED2		;YES
;SUBROUTINE TO READ ONE WORD FROM EITHER
; EXE FILE
;
;CALL:
;	PUSHJ	PP,EXERED
;	RETURN HERE IF EOF (ERROR IF SO)
;	HERE WITH WORD IN W1
EXERED:	SETZB	W1,W2		;CLEAR BOTH
	PUSHJ	PP,@[EXP READ1,READ2](FR)	;READ A WORD
	 JRST	EXERR0		;BAD FORMAT (PREMATURE EOF)
	SKIPN	W1		;DID IT COME FROM FILE 1?
	MOVE	W1,W2		;NO, MOVE WORD TO W1
	POPJ	PP,		;RETURN


;SUBROUTINE TO SKIP OVER PART OF AN EXE FILE
;
;CALL:
;	MOVE	T,CURRENT-IOWD-POINTER
;	MOVEI	TT,# OF LOCS TO SKIP
;	PUSHJ	PP,SKPEXE
;	 RETURN HERE ALWAYS
;
SKPEXE:	PUSHJ	PP,@[EXP READ1,READ2](FR)
	 JRST	EXERR0		;ERROR
;**;[43] Change at SKPEXE + 2L.  LLN, 12-Jan-77
	AOSLE	@[EXP EX1CNT,EX2CNT](FR)	;[43]
	JRST	EXERR0		;[43] Should not occur
	AOJ	T,		;[43]
	SOJG	TT,SKPEXE	;[43] LOOP
	POPJ	PP,		;RETURN


;ROUTINE TO SET CNT TO LOWER OF S1,S2
;
;**;[54] CHANGE 3 LINES AT SETCNT:.  LLN, 13-FEB-78
SETCNT:	MOVE	CNT,S1		;[54] ASSUME IT'S S1
	CAMLE	CNT,S2		;[54] IS IT?
	MOVE	CNT,S2		;[54] NO
	POPJ	PP,
;THIS CODE EXPANDS SAV FILES BEFORE COMPARING THEM

READ1X:	PUSHJ	PP,READ1	;GET A WORD
;**;[32] CHANGED READ1X+1	LLN  27-JUL-76
	JRST	SAV9		;[32] EOF SEEN
	MOVE	S1,W1		;STORE AOBJN WORD
	JUMPGE	W1,SAVER1	;NOT SAV FORMAT
	MOVEI	CNT,1(S1)	;JUST INCASE NO 2ND FILE
	POPJ	PP,

READ2X:	PUSHJ	PP,READ2	;SAME FOR SECOND WORD
;**;[32] CHANGED READ2X+1	LLN  27-JUL-76
	JRST	SAV19		;[32]
	MOVE	S2,W2
	JUMPGE	W2,SAVER2
	POPJ	PP,

SAV1:	SETZB	S1,S2
READX1:	PUSHJ	PP,READ1X
	JUMPL	S2,SAV2
READX2:	PUSHJ	PP,READ2X
SAV2:	MOVEI	CNT,1(S1)	;GET FIRST LOCATION
	CAILE	CNT,1(S2)	;IS IT SMALLER OF THE TWO?
	MOVEI	CNT,1(S2)	;NO,SO USE S2

SAV3:	SETZB	W1,W2
	CAIE	CNT,1(S1)	;DO WE WANT THIS WORD
	JRST	.+4		;NO
	AOBJN	S1,.+1
	PUSHJ	PP,READ1
;**;[32] CHANGED SAV3+5		LLN  27-JUL-76
	JRST	SAV9		;[32]
	CAIE	CNT,1(S2)
	JRST	.+4
	AOBJN	S2,.+1
	PUSHJ	PP,READ2
;**;[32] CHANGED SAV3+^D10	LLN  27-JUL-76
	JRST	SAV19		;[32]
	CAME	W1,W2
	PUSHJ	PP,COMP2
	JUMPGE	S1,READX1	;GET ANOTHER AOBJN WORD
	JUMPGE	S2,READX2
	AOJA	CNT,SAV3

SAVER1:	HLRZS	S1
	XORI	S1,(JRST)
	TRNN	S1,777000	;TEST FOR TRANSFER WORD
;**;[32] CHANGED SAVER1+3	LLN  27-JUL-76
	JRST	SAV9		;[32]
	JSP	T,ERROUT
	ASCIZ	/?File 1 not in SAV format/

SAVER2:	HLRZS	S2
	XORI	S2,(JRST)
	TRNN	S2,777000
;**;[32] CHANGED SAVER2+3	LLN  27-JUL-76
	JRST	SAV19		;[32]
	JSP	T,ERROUT
	ASCIZ	/?File 2 not in SAV format/

SAV14:	HLRZ	S1,W2
	XORI	S1,(JRST)
	TRNN	S1,777000
	JRST	FIN2
	MOVE	S2,W2
;**;[32] ADDED LABEL AT SAV14+5		LLN  27-JUL-76
SAV9:	MOVEI	CNT,1(S2)	;[32]
;SAV10 CHANGED 1 INSTR [22]
SAV10:	CAMG	CNT,UPPER	;[22]
	PUSHJ	PP,READ2
	JRST	FIN2
	JUMPGE	S2,SAV14
;SAV10+4 CHANGED 1 INSTR [22]
	CAMGE	CNT,LOWER	;[22]
	JRST	SAV10A
	PUSHJ	PP,TYCNT
	PUSHJ	PP,TYPTB2
	MOVE	T,W2
	PUSHJ	PP,TYPB
	PUSHJ	PP,TCRLF
SAV10A:	AOBJN	S2,.+1
	AOJA	CNT,SAV10

SAV24:	HLRZ	S2,W1
	XORI	S2,(JRST)
	TRNN	S2,777000
	JRST	FIN2
	MOVE	S1,W1
;**;[32] ADDED LABEL AT SAV24+5		LLN  27-JUL-76
SAV19:	MOVEI	CNT,1(S1)	;[32]
;SAV20 CHANGED 1 INSTR [22]
SAV20:	CAMG	CNT,UPPER	;[22]
	PUSHJ	PP,READ1
	JRST	FIN2
	JUMPGE	S1,SAV24
;SAV20+4 CHANGED 1 INSTR [22]
	CAMGE	CNT,LOWER	;[22]
	JRST	SAV20A
	PUSHJ	PP,TYCNT
	MOVE	T,W1
	PUSHJ	PP,TYPB
	PUSHJ	PP,TCRLF
SAV20A:	AOBJN	S1,.+1
	AOJA	CNT,SAV20

;ERROR MESSAGES FOR EXE FILE PROCESSING
;
;
;COME HERE IF EITHER FILE WAS NOT A EXE FILE
EXERR0:	TRNE	FR,-1		;WAS IT FILE 1?
	JRST	EXERR2		;NO
	JSP	T,ERROUT	;YES
	ASCIZ	/?FILE 1 NOT IN CORRECT EXE FORMAT/

;HERE IF FILE 2 IS BAD
EXERR2:	JSP	T,ERROUT
	ASCIZ	/?FILE 2 NOT IN CORRECT EXE FORMAT/

;HERE IF CAN'T READ DIRECTORY
CORERR:	JSP	T,ERROUT
	ASCIZ	/?NOT ENOUGH CORE AVAILABLE TO HOLD DIRECTORY/
	RELOC			;IMPURE AREA

PPSET:	BLOCK	LPDL		;PUSH DOWN LIST STORAGE

CTIBUF:	BLOCK	3
CTOBUF:	BLOCK	3
INBUF1:	BLOCK	3
INBUF2:	BLOCK	3
ERRCNT:	BLOCK	1		;DIFFERENCES COUNTER (0 MEANS NO DIFFERENCES)
DIFFLG:	BLOCK	1		;"DIFFERENCE IN PROGRESS" FLAG (0 MEANS NO DIFF)

INDEV1:	BLOCK	1

INDIR1:	BLOCK	4+3+MAXSFD+1
INDPPN:	BLOCK	1		;HOLD PROJECT,PROGRAMMER #

PTHBLK:	BLOCK	MAXSFD+4	;SFDS,OVERHEAD AND 0 DELIMITER WORD

OUTDEV:	BLOCK	1		;OUTPUT DEVICE
OUTEXT:	BLOCK	1		;FLAG FOR EXTENSION SEEN ON OUTPUT
OUTDIR:	BLOCK	4+3+MAXSFD+1

FILCNT:	BLOCK	1		;COUNT OF CURRENT FILE

TOP:				;CONTAINS # LINES ACTUALLY STORED IN BUFFER FOR:
TOP1:	BLOCK	1		;FILE #1
TOP2:	BLOCK	1		;FILE #2

LBUFP:
LBUFP1:	BLOCK	1		;POINTER TO BEGINNING OF LINE STORAGE FOR FILE #1
LBUFP2:	BLOCK	1		;DITTO FILE #2

;**;[44] ADD TWO LINES IN STORAGE.  LLN, 22-APR-77
CRSEEN:	BLOCK	2		;[44] DECIDE WHAT TO DO WITH CR'S
OLDCHR:	BLOCK	2		;[44] HOLDS THE CHAR AFTER THE CR

P1:	BLOCK	1		;BYTE POINTERS USED BY "COMPL" SUBROUTINE
P2:	BLOCK	1

HPOINT:	BLOCK	1		;HOLD BYTE POINTER FOR CREATING HEADERS
;**;[51] CHANGES, ADDITIONS AT HBUF1:.  LLN, 5-OCT-77
;**;[51]  *** KEEP THE NEXT 4 BLOCKS IN ORDER ***
HBUF1:	BLOCK	^D14		;[51] HOLDS HEADER FOR FIRST FILE
HBUF1D:	BLOCK	^D6		;[51] ITS CREATION DATE
HBUF2:	BLOCK	^D14		;[51] FOR SECOND FILE
HBUF2D:	BLOCK	^D6		;[51] ITS CREATION DATE
;**;[51] -- END OF SPECIAL ORDER --

HBPT1:	BLOCK	1		;[51] POINTER TO END OF HBUF1
HBPT2:	BLOCK	1		;[51] POINTER TO END OF HBUF2

PAGNUM:	BLOCK	2		;PAGE NUMBERS FOR THE TWO FILES
				;  LH(# AT BEGIN OF LINE), RH(# AFTER LAST CHAR)
PAGEN:	BLOCK	1		;TEMPORARY FOR PAGE #'S IN PLINEN SUBROUTINE
OLDNUM:	BLOCK	2		;LAST LINE # USED IN "SETONE"
OLDPNT:	BLOCK	2		;LAST BYTE POINTER CALCULATED BY "SETONE"

SAVEXS:	BLOCK	17		;STORAGE FOR AC'S WHEN PRINTING PAGE HEADERS

TEMP:	BLOCK	1
LINCNT:	BLOCK	1
RTNTMP:	BLOCK	1		;RETURN ADDRESS FOR "MULTI" SUBROUTINE
WCADR:	BLOCK	1		;TEMP IN GLINE SUBROUTINE
HIGH:	BLOCK	1		;USED BY NOROOM
ROOM:	BLOCK	1		;USED BY "NOROOM"
GETCNT:	BLOCK	1		;# LINES (-1) "GETTWO" GOT
GETFIL:	BLOCK	1		;# OF FILE FROM WHICH "GETTWO" GOT LINE (.L. 0 IF NONE)
NUMLIN:	BLOCK	1		;# LINES FOR A MATCH
NUMTMP:	BLOCK	1		;TEMP FOR NUMLIN
TEMPF1:	BLOCK	1		;TEMP FOR F1
TEMPF2:	BLOCK	1		;TEMP FOR F2
EXTFL1:	BLOCK	1		;DEFAULT FLAGS FROM EXT OF FILE 1
EXTFL2:	BLOCK	1		;DITTO FOR FILE 2
;** EDIT 21	EXTFL2+1	JNT	04-OCT-74
LSEEN:	BLOCK	1		;[21] -1 IF /0000L SEEN
;**;[34] Add two more storage locations.  LLN, 15-0ct-76
USWFLG:	BLOCK	1		;[34] -1 if /U but not /L
TNMLIN:	BLOCK	1		;[34] Temporary NUMLIN
QSW:	BLOCK	1		;-1 IF /Q SEEN
;**;[45] ADD ONE STORAGE LOCATION AFTER QSW:.  LLN, 2-JUN-77
XITFLG:	BLOCK	1		;[45] -1 IF WE EXIT AFTER COMMAND
;;**[26] CHANGE "Z" PSEUDO-OPS TO "BLOCK"	ILG	29-APRIL-75
;EXE FILE TEMPS
DIRCTR:	BLOCK	1	;TOTAL LENGTH OF ENTIRE DIRECTORY
DPTR1:	BLOCK	1	;POINTER TO DIRECTORY FOR FILE 1
DPTR2:	BLOCK	1	;SAME FOR FILE 2
DLNG1:	BLOCK	1	;COUNTER FOR DIRECTORY LENGTH OF FILE 1
DLNG2:	BLOCK	1	;SAME FOR FILE 2
;**;[43] Add two more storage locations.  LLN, 12-Jan-77
EX1CNT:	BLOCK	1	;[43] Word count for file 1 directory entry
EX2CNT:	BLOCK	1	;[43] Same for file 2
;END OF EXE TEMPS

VAR		;JUST IN CASE

ENDP:
RELOC		;DUMP LITS IN HIGH SEGMENT

;**;[45] CHANGE END STATEMENT AT ENDP: + 3L.  LLN, 2-JUN-77
END FILCOM