/1 OS8 SOURCE COMPARE (SRCCOM)
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1972,1973,1974,1975,1977 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/LAST EDITED 4/28/77
/
/
/COPYRIGHT 1973,1977
/DIGITAL EQUIPMENT CORPORATION
/MAYNARD, MASS. 01754
/
/PDP-8 SOURCE COMPARISON PROGRAM
/STOLEN FROM PDP-10 SRCCOM BY R. LARY

VERSION=	4		/CHANGE EVERY MAJOR EDIT
PATCH="A

	IFNDEF	CORE	<CORE=2	/DEFAULT IS 8K SYSTEM>
	MPARAM=7643	/COMMAND DECODER PARAMETER BLOCK

	IFZERO	CORE-2	<F1=0	/FIELD FOR FILE 1
			F2=10	/FIELD FOR FILE 2
			LNBEG=2000   /BEGINNING OF LINE BUFFER
>
	IFZERO	CORE-4	<F1=20
			F2=30
			LNBEG=20
>
			BUFLIM=FBLOCK-1001 /END OF LINE BUFFER
			INBUF=FBLOCK-1000	 /INPUT BUFFER
/SRCCOM FIELD 0 PAGE 0

	FIELD 0

	XR=10

	*20
SCT,	0		/TEMPORARY
OFILNM,	ZBLOCK	4	/OUTPUT FILE NAME
IFPTR,	0		/TEMPORARY
SETUP1,	NOPUNCH
	*7556		/JAM PARAMETERS UP AGAINST TOP OF USER CORE
FBLOCK,	ENPUNCH

/LAYOUT OF FILE PARAMETER TABLE
/THERE IS A COPY OF THIS TABLE IN FIELDS F1 AND F2. EACH COPY
/CONTAINS ALL THE INFORMATION ABOUT THE FILE WHOSE BUFFERS
/ARE IN THE SAME FIELD


PGNUM,	1		/CURRENT INPUT PAGE
CURLIN,	0		/CURRENT LINE (IN LINE BUFFER)
TOPLIN,	0		/NUMBER OF LINES IN LINE BUFFER
TMPLIN,	0		/TEMPORARY STORAGE FOR "CURLIN"
OLDLIN,	1		/LINE OPTIMIZATION COUNTER
OLDPTR,	LNBEG		/LINE OPTIMIZATION POINTER
		/THE NEXT SEVERAL WORDS ARE A SUBROUTINE
		/WHICH READS A BUFFER IN FROM THE INPUT FILE
INTEMP,	0		/SHIFT REGISTER FOR "GCHAR" ROUTINE
	CIF 0
	JMS I	INHNDL
INCHCT,	7777		/COUNT OF CHARACTERS IN BUFFER
INPTR,	0		/POINTS TO CURRENT WORD IN BUFFER
INREC,	0		/CONTAINS CURRENT INPUT RECORD
	ISZ	INTEMP	/SUBROUTINE SKIPS ON INPUT ERROR
	CIF 10
	JMP I	INTEMP
INHNDL,	0		/POINTS TO ENTRY POINT OF INPUT HANDLER

INEOF,	0		/END-OF-FILE INDICATOR
INRCNT,	0		/COUNT OF RECORDS REMAINING IN THIS FILE
	IFNZRO	.-7600	<_ERROR_>
	*SETUP1+.-FBLOCK/PUT ASSEMBLER LOCATION COUNTER BACK
	SETUP2=.


	/CORE ALLOCATION FOR 8K SYSTEM

/		FIELD 0
/
/0000-0377	CONTROL CODE
/0400-0777	INPUT HANDLER 1
/1000-1377	INPUT HANDLER 2
/1400-1777	OUTPUT HANDLER
/2000-6555	FILE 1 LINE BUFFER
/6556-7555	FILE 1 INPUT BUFFER
/7556-7577	FILE 1 CONTROL BLOCK
/
/		FIELD 1
/
/0000-1377	SRCCOM PROPER
/1400-1777	OUTPUT BUFFER
/2000-6555	FILE 2 LINE BUFFER
/6556-7555	FILE 2 INPUT BUFFER
/7556-7577	FILE 2 CONTROL BLOCK
/
/
/	FORMAT OF LINE BUFFER:
/	THE LINE BUFFER CONSISTS OF SOURCE LINES. THE FIRST WORD
/	OF EACH LINE IS A LENGTH WORD GIVING THE LENGTH OF THE
/	LINE (INCLUDING THE LENGTH WORD ITSELF) AS A POSITIVE
/	NUMBER.  THE NEXT WORD IS THE NUMBER OF THE SOURCE PAGE
/	ON WHICH THIS LINE WAS FOUND.  SUBSEQUENT WORDS CONTAIN THE
/	CHARACTERS OF THE LINE ITSELF, PACKED ONE PER WORD.


NODFMS,	"N;"O;" ;"D;"I;"F;"F;"E;"R;"E;"N;"C;"E;"S;0
SETUP,	0		/ROUTINE TO SET UP FILE PARAMETERS
	TAD	[SETUP1-SETUP2
	DCA	SCT
	TAD	[TAD SETUP1
	DCA	INST2
	TAD	[FBLOCK-1
	DCA	XR
INST2,	HLT		/MOVE THE SKELETON PARAMETER BLOCK
	DCA I	XR	/UP INTO THE DESIRED FIELD
	ISZ	INST2
	ISZ	SCT
	JMP	INST2
	RDF
	TAD	[6201
	DCA	SETCDF	/SAVE FIELD NUMBER
	CDF 10
	TAD I	IFPTR
	CDF 0
	SNA
	JMP I	[INERR1	/NO INPUT FILE - BAD
	CIF 10
	JMS I	[200	/ASSIGN DEVICE HANDLER
	1
DVPAGE,	0
	HLT		/NEVER HOPPEN
	CDF 10
	TAD I	IFPTR
	AND	[7760	/COMPUTE FILE LENGTH
	SZA
	TAD	[17
	CLL CML RTR
	RTR
	DCA	SCT	/SAVE IT AWAY TEMPORARILY
	ISZ	IFPTR
	TAD I	IFPTR
SETCDF,	HLT		/RESET DATA FIELD
	DCA I	[INREC	/SAVE STARTING BLOCK NUMBER
	TAD	SCT
	DCA I	[INRCNT	/SAVE FILE LENGTH
	TAD	DVPAGE
	DCA I	[INHNDL	/SAVE DEVICE HANDLER ENTRY POINT
	ISZ	IFPTR
	JMP I	SETUP	/RETURN
	*200		/INITIALIZATION CODE
SRCCOM,	ISZ	NOCHN
	CIF 10
	JMS I	[7700
	10		/BRING USR INTO CORE
SRCCD,	TAD	NOCHN	/HAVE WE BEEN CHAINED TO?
	SNA CLA
	JMP	NOSRCD	/YES
	CIF 10
	JMS I	[200
	5		/COMMAND DECODE
	0		/NO DEFAULT EXTENSIONS
NOSRCD,	TAD	[7617
	DCA	IFPTR	/SET IFPTR POINTING TO FILE 1
	TAD	[401
	DCA	DVPAGE	/FILE 1 HANDLER GOES IN 400-777
	CDF F1
	JMS	SETUP	/SET UP FILE 1 PARAMETER AREA
	TAD	[1001
	DCA	DVPAGE	/FILE 2 HANDLER GOES INTO 1000-1377
	CDF F2
	JMS	SETUP	/SET UP FILE 2 PARAMETER AREA
	TAD	[1401
	DCA	OUPAGE	/OUTPUT HANDLER GOES INTO 1400-1777
GTOUHN,	CDF 10
	TAD I	[7600	/GET OUTPUT DEVICE #
	CDF 0
	SZA		/IS THERE ONE?
	JMP	ASSOUT
	DCA	TTYNO
	CIF 10		/NO - LOOK UP "TTY"
	JMS I	[200
	12		/INQUIRE
	5524		/=2424+3100 = TTY
TTYNO,	0
	0
	JMP	OUERR1	/NO TELETYPE
	TAD	TTYNO
	CDF 10
	DCA I	[7600
	JMP	GTOUHN	/BACK TO GET IT AGAIN
ASSOUT,	CIF 10
	JMS I	[200
	1
OUPAGE,	0
	JMP	OUERR1
	TAD	[-4
	DCA	SCT
	TAD	[7600
	DCA	XR
	TAD	[DCA OFILNM
	DCA	INST1
	CDF 10		/MOVE OUTPUT FILE NAME INTO FIELD 0
	TAD I	XR
INST1,	HLT
	ISZ	INST1
	ISZ	SCT
	JMP	INST1-1
	TAD	PFILNM
	DCA	ORCNO	/SET UP ENTER
	TAD	OFILNM+3
	SNA
	TAD	[1423	/ASSUMED OUTPUT EXTENSION = .LS
	DCA	OFILNM+3
	TAD I	[7600
	CDF 0
	CIF 10
	JMS I	[200
	3
ORCNO,	0		/POINTS TO FILE NAME
OLEN,	0
	JMP	OUERR1
	CIF 10
	JMS I	[200
	11		/KICK USR OUT OF CORE
	DCA	OCOUNT
	CDF CIF 10
	TAD	ORCNO
	DCA I	[OUREC
	TAD	OUPAGE
	JMP I	.+1
	SRCOPT		/GO SET UP OPTION SWITCHES AND COMPARE
OCLOSE,	CIF 10
	JMS I	[7700
	10		/GET USR INTO CORE
	CDF CIF 10
	TAD I	[7600	/GET OUTPUT DEVICE NUMBER
	CDF 0
	JMS I	[200
	4		/CLOSE OUTPUT FILE
PFILNM,	OFILNM
OCOUNT,	0		/COUNT OF BLOCKS WRITTEN
	JMP	OUERR1	/ERROR ON CLOSE
SRCATS,	ISZ	NOCHN	/IN CASE WE LOOP, CLEAR "CHAINED TO" FLAG
	CDF 10
	TAD I	[MPARAM-1	/GET ALTMODE FLAG
	CDF 0
	SPA CLA
	JMP I	[7605	/GO AWAY IF ALTMODE
	JMP	SRCCD	/GO BACK FOR MORE

NOCHN,	0

INERR1,	RDF
	CLL RTR
	RAR
	TAD [-4
OUERR1,	TAD	[4005
NOROOM,	TAD	[260
	DCA	SETUP
	TAD	[277
	JMS	TYPE	/OUTPUT "?N" WHERE N IS THE ERROR NUMBER
	TAD	SETUP
	JMS	TYPE
	TAD	[215
	JMS	TYPE
	TAD	[212
	JMS	TYPE
	TAD	SETUP
	SPA CLA		/IS THE USR IN CORE?
	JMP	SRCATS	/YES - DON'T LOAD IT
	CIF 10
	JMS I	[7700	/NO - LOAD IT
	10
	JMP	SRCATS

TYPE,	0
	TLS
	TSF
	JMP	.-1
	CLA
	JMP I	TYPE
/	PAGE 0 LITERALS
	FIELD 1
	/PAGE 0 FOR SRCCOM

	*0
T1,	0
T2,	0
T,	0
CT,	0

	XR1=11
	XR2=12

	*20

/***************   SRCCOM SWITCHES   ***************

CSW,	0	/"C" SWITCH - ON=-257, MEANING IGNORE COMMENTS
		/            OFF=+521, MEANING COMPARE COMMENTS
SSW,	0	/"S" SWITCH - ON=-240, MEANING IGNORE SPACES & TABS
		/            OFF=-200, MEANING COMPARE SPACES&TABS
TSW,	0	/"T" SWITCH - ON=20  , MEANING CONVERT TABS ON OUTPUT
		/	     OFF=0   , MEANING PRINT TABS ON OUTPUT
XSW,	0	/"X" SWITCH - ON=1   , MEANING DON'T INPUT COMMENTS
		/	     OFF=0   , MEANING INPUT COMMENTS INTO CORE
ALLSW,	0	/"B" SWITCH - ON=2000, MEANING COMPARE BLANK LINES
		/            OFF=0   , MEANING IGNORE BLANK LINES
NUMLIN,	0	/NUMERICAL ARGUMENT - NUMBER OF LINES CONSTITUTING
		/A MATCH - SET TO -3 IF NO NUMERICAL ARGUMENT

MLIMIT,	0
GETCNT,	0
GETFIL,	0
CHAR,	0
IPTR,	0
NUMTMP,	0
PLNCNT,	0
PNTPGN,	0
OUHNDL,	0		/THESE 5 WORDS ARE USED BY OUTPUT ROUTINE
OUCHCT,	0
OUPTR,	0
OUXPTR,	0
OUTEMP,	0
TABCT,	0
DIFFS,	0		/DIFFERENCES FOUND FLAG

CTCCHK,	0
	TAD	[200
	KRS		/GET A CHAR FROM THE TELETYPE
	TAD	[-203	/CHECK FOR EITHER PARITY ^C
	SNA CLA
	KSF		/WITH THE KEYBOARD FLAG UP
	JMP I	CTCCHK	/NOPE
	CDF CIF 0	/YUP - RETURN TO OS/8
	JMP I	[7600
	PAGE

SETONE,	0		/ROUTINE TO FIND WHERE A LINE IS
	TAD I	[CURLIN	/GET LINE NUMBER
	DCA	TLNNUM	/SAVE IT AWAY
	TAD I	[OLDPTR	/GET THE POINTER TO THE LATEST LINE
SETOPT,	DCA	T	/SAVE THE STARTING POINTER
	TAD	TLNNUM	/GET THE TARGET LINE
	CMA CLL
	TAD I	[OLDLIN	/IS IT BEFORE OR AFTER THE LATEST LINE?
	SZL
	JMP	SETRST	/BEFORE - WE MUST START SEARCHING FROM LINE 1
	DCA	CT	/AFTER - START SEARCHING FROM LATEST LINE
TLOOP,	ISZ	CT
	JMP	KEEPON	/NOT THERE YET
	TAD	TLNNUM	/WE FOUND IT - MAKE THIS LINE
	DCA I	[OLDLIN	/THE NEW "LATEST LINE"
	TAD	T	/TO SPEED UP
	DCA I	[OLDPTR	/FUTURE SEARCHES.
	CLA CMA
	TAD	T
	JMP I	SETONE	/RETURN POINTER FOR AUTO-XR
KEEPON,	TAD I	T
	TAD	T	/ADD LENGTH OF THIS LINE TO POINTER
	DCA	T	/TO GET POINTER TO NEXT LINE
	JMP	TLOOP
TLNNUM,	0		/TEMPORARY FOR SETONE - DO NOT USE ANYWHERE ELSE

SETRST,	CLA IAC		/RESET THE "LATEST LINE" POINTERS TO THE FIRST
	DCA I	[OLDLIN	/LINE, SINCE THE LINE WE SEEK IS BEFORE
	TAD	[LNBEG	/THE CURRENT "LATEST LINE"
	JMP	SETOPT	/GO BACK AND FIND THE LINE
MOVEUP,	0		/SUBR TO DELETE LINES FROM CORE
	TAD I	[CURLIN	/GET FIRST LINE NOT TO BE DELETED
	CIA
	TAD I	[TOPLIN
	DCA I	[TOPLIN	/REDUCE THE NUMBER OF LINES IN THE BUFFER
	TAD I	[TOPLIN	/GET NEW LINE COUNT
	SNA		/IF ALL LINES DELETED, DON'T MOVE CORE
	JMP	MOVXIT	/JUST CLEAN UP AND GET OUT
	IAC
	JMS	SETONE	/GET POINTER TO LAST LINE+1
	CIA
	DCA	MLIMIT	/SAVE AS LIMIT ON MOVE
	IAC
	JMS	SETONE	/GET POINTER TO THE FIRST LINE NOT TO DELETE
	DCA	XR1
	TAD	[LNBEG-1
	DCA	XR2
MLOOP,	TAD I	XR1
	DCA I	XR2	/AREN'T AUTO-XRS WONDERFUL
	TAD	XR1
	TAD	MLIMIT	/(ACTUALLY, NO)
	SZA CLA
	JMP	MLOOP
MOVXIT,	CLA IAC		/AFTER MOVING CORE AROUND, WE MUST
	DCA I	[OLDLIN	/RESET THE "LATEST LINE" POINTERS TO THE FIRST
	TAD	[LNBEG	/LINE SINCE IT IS THE ONLY ONE WHICH
	DCA I	[OLDPTR	/HAS A KNOWN POSITION.
	JMP I	MOVEUP
COMPL,	0		/SUBROUTINE TO COMPARE TWO LINES
	CDF F1
	JMS	SETONE	/GET POINTER TO CURRENT LINE IN FILE 1
	TAD	[2	/SKIP OVER PROLOGUE
	DCA	XR1
	CDF F2
	JMS	SETONE	/GET POINTER TO CURRENT LINE IN FILE 2
	TAD	[2	/SKIP OVER PROLOGUE
	DCA	XR2
COMP1,	CDF F1
	TAD I	XR1	/GET A CHAR FROM FILE 1
	DCA	T1
COMP2,	CDF F2
	TAD I	XR2
	DCA	T2	/AND A CHAR FROM FILE 2
COMP0,	TAD	T2
	CIA
	TAD	T1
	SZA CLA		/ARE THEY EQUAL?
	JMP	COMP4	/NO
COMP5,	TAD	T1
	SZA
	TAD	CSW	/IF AT END OF LINE, OR IF AT A "/"
	SZA CLA		/AND "IGNORE COMMENTS" SWITCH ON,
	JMP	COMP1
	JMP I	COMPL	/TAKE "LINES MATCH" RETURN

COMP3,	CDF F1
	TAD I	XR1	/GET THE NEXT CHAR FROM FILE 1
	DCA	T1
COMP4,	TAD	T1
	TAD	SSW	/IF T1 IS A BLANK OR A TAB
	SZA
	TAD	[27	/(27=BLANK-TAB)
	SNA CLA		/AND WE ARE IGNORING BLANKS,
	JMP	COMP3	/THEN IGNORE T1
	TAD	T2
	TAD	SSW	/DO THE SAME WITH T2
	SZA
	TAD	[27
	SNA CLA
	JMP	COMP2
	TAD	T1
	CIA
	TAD	T2	/NOW THAT WE HAVE (MAYBE) ELIMINATED BLANKS
	SNA CLA		/ARE T1 AND T2 STILL UNEQUAL?
	JMP	COMP5	/NO - THERE'S STILL HOPE
	TAD	T1	/YES - NOW TEST COMMENT SWITCH
	CMA
	AND	T2
	TAD	CSW	/IF T1 IS A CARRIAGE RETURN AND T2 IS A "/"
	SNA CLA		/WITH THE COMMENT SWITCH ON WE'VE SUCEEDED
	JMP I	COMPL	/SO TAKE "LINES MATCH" RETURN
	TAD	T2
	CMA
	AND	T1	/SAME IF T2=CARRIAGE RETURN AND T1="/"
	TAD	CSW
	SZA CLA
	ISZ	COMPL	/OTHERWISE TAKE "LINES DON'T MATCH" RETURN
	JMP I	COMPL

GETTWO,	0		/SUBROUTINE TO GET A LINE FROM EACH FILE
	CLA CLL CMA RTL
	DCA	GETCNT
	DCA	GETFIL	/ZERO INDICATOR AS TO WHICH FILE IS NULL
	CDF F1
	JMS I	[GLINE	/GET A LINE FROM FILE 1
	CDF F2
	JMS I	[GLINE	/DITTO FILE 2
	ISZ	GETCNT	/HOW MANY LINES DID WE GET?
	JMP I	GETTWO	/LESS THAN TWO - TAKE EOF RETURN
	ISZ	GETTWO
	JMP I	GETTWO	/TAKE NORMAL RETURN

	PAGE
GLINE,	0		/SUBROUTINE TO GET A LINE FROM A FILE
	TAD I	[CURLIN
	CIA
	TAD I	[TOPLIN
	SZA CLA		/IS THE LINE IN CORE?
	JMP	GLEXIT	/YES
	CLA IAC
	JMS I	[SETONE	/GET POINTER TO THIS LINE
	DCA	XR1
	CLA CLL CML RTL
	DCA I	XR1	/SET WORD COUNT TO 2
	TAD	XR1
	DCA	T	/SAVE POINTER TO LENGTH WORD
	JMS	CTCCHK	/CHECK FOR ^C TYPED
	ISZ	XR1
GLINE2,	JMS	GCHAR	/MAIN LOOP - GET A CHARACTER
	JMS I	[TSTXSW	/SEE WHETHER WE SHOULD INPUT COMMENTS
	CLA CLL CMA RAL
	TAD	CHAR
	TAD	ALLSW	/IF THE CHAR IS A CARRIAGE RETURN AND THE
	TAD I	T	/"B" SWITCH IS OFF AND THE LINE COUNT IS 2,
	SNA CLA		/THEN WE SHOULD IGNORE THIS BLANK LINE.
	JMP	GLINE2
	TAD	CHAR
	DCA I	XR1	/SALT IT AWAY
	TAD	XR1
	CLL
	TAD	[4-BUFLIM	/COMPARE AGAINST END OF BUFFER
	SNL CLA
	JMP	.+3
	CDF CIF 0	/LINE OVERFLOWS CORE - BAD!
	JMP I	[NOROOM	/TELL THE WORLD
	ISZ I	T	/BUMP COUNTER OF WORDS IN LINE
	TAD	CHAR
	SZA CLA		/WAS IT A CARRIAGE RETURN?
	JMP	GLINE2	/NO
	ISZ I	[TOPLIN	/YES - BUMP COUNT OF LINES IN CORE
	ISZ T
	TAD I [PGNUM
	DCA I T
GLEXIT,	ISZ	GETCNT	/BUMP COUNTER OF # OF LINES GOTTEN
	RDF
	TAD	[6201
	DCA	GETFIL	/INDICATE THAT THIS FILE WAS NOT NULL
	ISZ I	[CURLIN	/BUMP CURRENT LINE POINTER
	JMP I	GLINE
GCHAR,	0		/SUBROUTINE TO GET A CHAR FROM A FILE
	TAD I	[INPTR
	DCA	IPTR	/SAVE POINTER TO CURRENT BUFFER WORD
	ISZ I	[INCHCT	/BUMP CHAR COUNTER
	JMP	GETIN
	TAD I	[INEOF	/END OF BUFFER
	SZA CLA		/END OF FILE??
	JMP	GEOF+1	/YES
	CLA CLL CML RTL
	TAD I	[INRCNT	/BUMP COUNT OF REMAINING RECORDS BY 2
	SZL		/OVERFLOW?
	ISZ I	[INEOF	/YES - SET END OF FILE FLAG
	SNL
	DCA I	[INRCNT	/RESTORE COUNTER IF NO OVERFLOW
	CLL CMA CML RTL
	RTL
	RTL
	TAD	[401	/COMPUTE INPUT CONTROL WORD
	RDF
	DCA I	[INCHCT
	TAD	[INBUF
	DCA I	[INPTR	/PUT BUFFER ADDRESS INTO CALLING SEQUENCE
	RDF
	TAD	[6203
	DCA	.+1
	NOP		/SET INSTRUCTION FIELD TO DATA FIELD
	JMS I	[INTEMP	/CALL SUBR TO READ IN BUFFER
	JMP	.+4	/NO ERROR
	SPA CLA		/FATAL ERROR?
	JMP I	[INERR	/YES
	ISZ I	[INEOF	/NO - SET END OF FILE FLAG
	ISZ I	[INREC
	ISZ I	[INREC	/BUMP RECORD NUMBER BY 2
	TAD	[10
	DCA I	[INTEMP	/INITIALIZE SHIFT REGISTER
	TAD I	[INCHCT
	CLL RAL
	TAD I	[INCHCT
	AND	[7600
	CMA
	DCA I	[INCHCT	/COMPUTE CHAR COUNT FROM BUFFER CONTROL WD
	JMP	GCHAR+1	/START ALL OVER WITH NEW BUFFER
GETIN,	TAD I	[INTEMP
	SPA		/IF WE HAVE A CHAR IN THE SHIFT BUFFER
	DCA I	IPTR	/WRITE OVER THE CURRENT BUFFER WORD WITH IT
	DCA I	[INTEMP	/AND ZERO THE SHIFT BUFFER
	TAD I	IPTR	/GET THE CURRENT BUFFER WORD
	AND	[7400
	CLL  RAL
	TAD I	[INTEMP
	RTL		/SHIFT THE HIGH ORDER 4 BITS
	RTL		/INTO THE SHIFT BUFFER
	SMA		/DID WE GET A COMPLETE CHARACTER?
	ISZ I	[INPTR	/NO - BUMP WORD POINTER
	DCA I	[INTEMP
	TAD I	IPTR
	AND	[177	/USE LOW ORDER 7 BITS OF THE CURRENT WORD
	SZA		/AS THE CHARACTER
	TAD	[-177	/IGNORING BLANK TAPE, RUBOUTS, LINE-FEEDS
	SZA		/AND VERT. TABS
	TAD	[177-13
	SZA
	IAC
	SNA
	JMP	GCHAR+1
	TAD	[12-14
	SNA
	JMP	FFEED	/FORM FEED IS SPECIAL
	TAD	[14-32
	SNA
	JMP	GEOF	/^Z SIGNIFIES END-OF-FILE
	TAD	[32-15
	SZA
	TAD	[215	/AND CARRIAGE RETURN IS MAPPED INTO 0
	DCA	CHAR
	JMP I	GCHAR

FFEED,	ISZ I	[PGNUM	/BUMP THE PROPER PAGE COUNT ON A FORM FEED
	JMP	GCHAR+1	/BUT OTHERWISE IGNORE IT

GEOF,	ISZ I	[INEOF	/SET END-OF-FILE FLAG
	CLA CMA
	DCA I	[INCHCT	/FORCE AN EMPTY BUFFER
	JMP I	GLINE	/RETURN FROM GLINE WITHOUT SETTING GETFIL

	PAGE
/	INITIALIZATION
STARTC,	JMS I	[OUSETP	/INITIALIZE OUTPUT BUFFER POINTERS
	CLA IAC
	DCA	PNTPGN	/FUDGE PNTPGN WHILE PRINTING HEADER LINES
	TAD	[HEDING-1
	JMS I	[PNTHDG	/PRINT SRCCOM HEADING LINE
	JMS I	[GETTWO	/GET TITLE LINES
	JMP	FINISH	/ONE FILE IS EMPTY - ABORT COMPARISON
	CDF F1
	JMS I	[PNTTXT	/PRINT FILE 1 HEADER
	CDF F2
	JMS I	[PNTTXT	/AND FILE 2 HEADER
	DCA	PNTPGN	/INITIALIZE PAGE NUMBER
	STA
	DCA	DIFFS	/INITIALIZE FLAG TO NO DIFFERENCES

/	MAIN LOOP

MAIN,	CDF F1
	JMS I	[MOVEUP
	CDF F2
	JMS I	[MOVEUP	/DELETE ANY USELESS LINES
MAINST,	CDF F1
	DCA I	[CURLIN
	CDF F2
	DCA I	[CURLIN
	JMS I	[GETTWO	/GET TWO INPUT LINES
	JMP	MAIN15	/ONE FILE IS EMPTY
	JMS I	[COMPL	/COMPARE THE LINES
	JMP	MAIN	/EQUAL - DELETE AND CONTINUE
	DCA	DIFFS	/UNEQUAL - CLEAR "NO DIFFERENCES" FLAG

MAIN10,	JMS I	[GETTWO	/GET TWO MORE LINES
	JMP	MAIN15	/ONE FILE RAN OUT
	CDF F1
	DCA I	[CURLIN	/INITIALIZE FILE 1 LINE NO.
MAIN12,	ISZ I	[CURLIN	/BUMP TO NEXT LINE IN FILE 1
	JMS I	[COMPL	/COMPARE NEW LINE FROM FILE 2
	JMS	MULTI	/WITH THIS LINE FROM FILE 1
	CDF F2		/AND IF MATCH IS FOUND CHECK MULTIPLE LINES
	TAD I	[CURLIN
	CIA
	CDF F1
	TAD I	[CURLIN
	SZA CLA		/THROUGH WITH FILE 1 LINES?
	JMP	MAIN12	/NO
	CDF F2
	CLA IAC
	DCA I	[CURLIN	/NOW INITIALIZE FILE 2 LINE NO.
MAIN14,	TAD I	[CURLIN
	CIA
	CDF F1
	TAD I	[CURLIN
	SNA CLA		/HAVE WE EXHAUSTED FILE 2 LINES?
	JMP	MAIN10	/YES - NO MATCH AT ALL
	JMS I	[COMPL	/NO - COMPARE ALL FILE 2 LINES
	JMS	MULTI	/AGAINST NEW FILE 1 LINE
	CDF F2		/AND, IF MATCH, CHECK MULTIPLE LINES
	ISZ I	[CURLIN	/GO TO NEXT FILE 2 LINE
	JMP	MAIN14	/AND LOOP

MAIN15,	TAD	GETFIL
	SNA		/FIND WHICH FILE WAS EMPTY
	JMP	FINISH	/BOTH - ALL DONE
	DCA	MAIN18
	CDF F1
	TAD I	[CURLIN
	CDF F2
	SZA CLA
	TAD I	[CURLIN
	SNA CLA		/IS EITHER FILE EXHAUSTED IN CORE?
	JMP	MAIN18	/YES - PRINT ALL OF OTHER FILE
	TAD	MAIN18	/GET CDF OF LONG FILE
	CIA
	TAD	[4402+F1+F2	/COMPUTE CDF OF SHORT FILE
	DCA	MAIN17
MAIN17,	NOP
	TAD I	[CURLIN
	CMA CLL
	TAD I	[TOPLIN
	SNL CLA		/IS CURLIN < TOPLIN?
	JMP	MAIN10	/NO - WE STILL HAVE SOME COMPARING TO DO
	ISZ I	[CURLIN
	JMS I	[COMPL
	JMS	MULTI
	JMP	MAIN17

MAIN18,	NOP		/SET DF TO DATA FIELD OF LONG FILE
	JMS I	[PNTTXT	/PRINT IT
	JMP	MAIN

FINISH,	CDF F1
	TAD I	[CURLIN
	CDF F2
	TAD I	[CURLIN
	SZA CLA		/ARE BOTH CORE BUFFERS EMPTY?
	JMS I	[PNTBTH	/NO - PRINT THEM
	JMP I	[EOCOMP
/	MULTI-LINE COMPARATOR
MULTI,	0
	CDF F1
	TAD I	[CURLIN
	DCA I	[TMPLIN
	CDF F2
	TAD I	[CURLIN
	DCA I	[TMPLIN	/STORE CURLIN AWAY IN A TEMPORARY
	TAD	NUMLIN
	DCA	NUMTMP	/GET COUNT OF LINES TO COMPARE
	JMP	MULT6

MULT2,	JMS I	[GETTWO	/GET TWO LINES
	JMP	MULT4	/ONE FILE HAS NO MORE
	JMS I	[COMPL	/COMPARE THEM
	JMP	MULT6	/THEY COMPARE - KEEP GOING
MULT4,	JMS	SWAPCT	/RESET OLD CURLIN
	JMP I	MULTI
MULT6,	ISZ	NUMTMP	/LINE COUNT EXHAUSTED?
	JMP	MULT2	/NO - KEEP COMPARING
	JMS	SWAPCT	/RESTORE OLD CURLIN
	JMS I	[PNTBTH	/PRINT OUT DIFFERENCES
	TAD	[-10
	JMS I	[PNTAST	/PRINT OUT SEPARATOR
	JMS	SWAPCT	/RE-SWAP FOR DELETION
	JMP	MAIN	/DELETE THRU MATCHING LINES AND CONTINUE

SWAPCT,	0
	CDF F1
	JMS	SWAPX	/SWAP CURLIN AND TMPLIN FOR FILE 1
	CDF F2
	JMS	SWAPX	/DITTO FOR FILE 2
	JMP I	SWAPCT
SWAPX,	0
	TAD I	[CURLIN
	DCA	NUMTMP
	TAD I	[TMPLIN
	DCA I	[CURLIN
	TAD	NUMTMP
	DCA I	[TMPLIN
	JMP I	SWAPX

	PAGE
PNTBTH,	0		/PRINT BOTH TEXT BUFFERS
	TAD	[212
	JMS I	[OCHAR	/SEPARATOR
	CDF F1
	JMS	PNTTXT	/PRINT FILE 1 BUFFER
	TAD	[-4
	JMS	PNTAST	/PRINT SEPARATOR
	CDF F2
	JMS	PNTTXT	/PRINT FILE 2 BUFFER
	TAD	[212
	JMS I	[OCHAR	/SEPARATOR
	JMP I	PNTBTH

PNTTXT,	0		/PRINT A TEXT BUFFER
	TAD I	[CURLIN
	CIA
	DCA	PLNCNT	/GET # OF LINES TO PRINT
PNTLP,	DCA	TABCT	/ZERO TAB COUNTER (IN CASE "T" SW ON)
	RDF
	CLL RTR
	RAR		/GET FILE NUMBER
	TAD	[261	/260 FOR 12K VERSION
	JMS I	[OCHAR
	TAD	[251
	JMS I	[OCHAR	/PRINT RPAR
	TAD	PLNCNT
	IAC
	JMS I	[SETONE	/GET POINTER TO LINE
	IAC
	DCA	XR1
	TAD I	XR1	/GET THE PAGE NUMBER OF THE LINE
	DCA	T
	TAD	T
	CIA
	TAD	PNTPGN
	SNA CLA		/DID THE PAGE NUMBER JUST CHANGE?
	JMP	PNTTAB	/NO - DON'T PRINT IT
	TAD	TENTAD
	DCA	PNTTAD
	TAD	T
	DCA	PNTPGN	/UPDATE THE CURRENT PAGE NUMBER
	CLA CLL CMA RTL
	DCA	CT	/PRINT 3 DECIMAL DIGITS
DIGLP1,	DCA	T1
	JMP	.+3
DIGLP2,	DCA	T
	ISZ	T1
	TAD	T
PNTTAD,	HLT		/ADD IN A POWER OF 10
	SMA
	JMP	DIGLP2	/KEEP GOING
PN7200,	CLA
	ISZ	PNTTAD	/GOT A DIGIT - GO TO NEXT POWER OF 10
	TAD T1
	TAD	[260
	JMS I	[OCHAR	/PRINT DIGIT
	ISZ	CT	/THROUGH?
	JMP	DIGLP1	/NO
PNTTAB,	TAD	TSW
	SNA CLA		/SHOULD WE SIMULATE TABS?
	JMP	PNTCHR	/NO
	TAD	[240	/YES - PRINT A BLANK
	JMS I	[OCHAR
	TAD	TABCT
	AND	[7
	SZA CLA		/KEEP PRINTING BLANKS UNTIL WE REACH A MULTIPLE OF
	JMP	PNTTAB	/EIGHT COLUMNS.
PNTCLP,	TAD I	XR1	/GET A CHARACTER FROM THE LINE
	SNA		/END?
	JMP	PNTCR	/YES
	TAD	[-211
	SNA		/IS IT A TAB?
	JMP	PNTTAB	/YES
PNTCHR,	TAD	[211	/NO - RESTORE THE CHAR
	JMS I	[OCHAR
	JMP	PNTCLP	/PRINT IT AND LOOP
PNTCR,	TAD	[215	/PRINT CRLF
	JMS I	[OCHAR
	TAD	[212
	JMS I	[OCHAR
	ISZ	PLNCNT
	JMP	PNTLP	/LOOP FOR EACH LINE IN BUFFER
	JMP I	PNTTXT
PNTAST,	0		/ROUTINE TO PRINT ASTERISKS
	DCA	CT	/SAVE COUNTER
	TAD	["*
	JMS I	[OCHAR
	ISZ	CT
	JMP	.-3	/PRINT REQUIRED NUMBER OF ASTERISKS
	TAD	[215
	JMS I	[OCHAR	/TERMINATE THE LINE
	TAD	[212
	JMS I	[OCHAR
	DCA	PNTPGN	/KILL CURR. PAGE NUMBER
	JMP I	PNTAST

EOCOMP,	ISZ	DIFFS	/ANY DIFFERENCES?
	JMP	.+4	/YES
	CDF 0		/MESSAGE IN FIELD 0
	TAD	[NODFMS-1
	JMS I	[PNTHDG	/NO - PRINT MESSAGE
	TAD	PN7200	/ROUTINE TO FINISH UP OUTPUT
	DCA	CT
	TAD	[214
	JMS I	[OCHAR	/TERMINATE THE OUTPUT FILE
	TAD	[232	/WITH A FORM FEED AND A ^Z
	JMS I	[OCHAR
	ISZ	CT
	JMP	.-2	/FILL WITH ZEROS TO FORCE BUFFER OUT
	CDF CIF 0
	JMP I	.+1	/GO TO FIELD 0 TO FINISH UP AS WE WILL BE
	OCLOSE		/OVERLAYED BY THE USR DURING THE CLOSE

TENTAD,	TAD	.+1	/TABLE OF POWERS OF TEN
	-144
	-12
	-1

INERR,	RDF		/INPUT ERROR - ERROR NUMBER=FILE NUMBER
	CLL RTR
	RAR
	IFZERO	CORE-2	<IAC>
	IFZERO	CORE-4	<TAD	[-1>
	CDF CIF 0
	JMP I	[NOROOM	/GO TO COMMON ERROR ROUTINE

PNTHDG,	0		/ROUTINE TO PRINT A LITERAL LINE
	DCA	XR1	/POINTER TO LINE IN AC
	TAD	PNTHDG
	DCA	PNTTXT	/WE WORK BY FAKING OUT PNTTXT
	STA
	DCA	PLNCNT	/SET LINE COUNTER TO 1
	JMP	PNTCLP

	PAGE
OCHAR,	0		/LOW LEVEL OUTPUT ROUTINE
	AND	[377
	DCA	OUTEMP
	ISZ	TABCT	/BUMP TAB COUNTER
	RDF
	TAD	[6201
	DCA	OCDF
	CDF 10
	TAD	OUCHCT	/GET CHAR COUNTER - CHAR COUNTER COUNTS
	RTR		/FOUR TIMES FOR EACH THREE CHARACTERS.
	CML		/WHEN THE LOW ORDER BITS OF THE COUNT ARE 10,
	SZL SPA CLA	/ITS TIME TO SQUEEZE A CHAR INTO THE HIGH
	JMP	OUNORM	/ORDER BITS - OTHERWISE JUST STORE IT
	ISZ	OUCHCT	/WE MUST SQUEEZE - BUMP OUCHCT AN EXTRA
	TAD	OUTEMP	/TIME
	RTL
	RTL
	AND	[7400
	TAD I	OUXPTR	/FIRST WORD OF DOUBLET
	DCA I	OUXPTR
	TAD	OUTEMP
	RTR
	RTR
	RAR
	AND	[7400
	TAD I	OUPTR	/SECOND WORD OF DOUBLET
	JMP	OUCOMN

OUNORM,	TAD	OUPTR
	DCA	OUXPTR	/REMEMBER LAST WORD
	ISZ	OUPTR
	TAD	OUTEMP
OUCOMN,	DCA I	OUPTR
	ISZ	OUCHCT	/BUMP CHAR COUNT
	JMP	OCDF	/RETURN
	CIF 0		/CHAR COUNT OVFLO - OUTPUT BUFFER
	JMS I	OUHNDL
	4210
	1400
OUREC,	0
	JMP	OUERR2
	JMS	OUSETP	/INITIALIZE FOR NEXT BUFFER
	ISZ	OUREC	/BUMP RECORD NUMBER
	CDF 0
	ISZ I	[OCOUNT	/BUMP CLOSING COUNT
	ISZ I	[OLEN	/AND LENGTH OF HOLE
	JMP	OCDF
OUERR2,	CLL CML RTL	/OUTPUT ERROR OR FILE TOO BIG - GENERATE
	IAC		/A 3 OR A 4 MESSAGE, RESPECTIVELY
	CDF CIF 0
	JMP I	[NOROOM
OCDF,	HLT	/RESTORE DATA FIELD
	JMP I	OCHAR	/RETURN
OUSETP,	0
	TAD	[7000	/4 COUNTS FOR 2 WORDS
	DCA	OUCHCT
	TAD	[1377
	DCA	OUPTR
	JMP I	OUSETP

TSTXSW,	0		/SUBROUTINE TO IGNORE COMMENTS ON INPUT
	TAD	CHAR	/IF "X" SWITCH SET
	TAD	[-257
	SNA CLA
	TAD	XSW	/IF XSW IS OFF OR THE CURRENT CHAR ISN'T A /
	SNA CLA
	JMP I	TSTXSW	/RETURN
	JMS I	[GCHAR
	TAD	CHAR	/SKIP CHARACTERS UNTIL CARRIAGE RETURN
	SZA CLA
	JMP	.-3
TSTXLP,	CLA CLL CMA RAL
	TAD I	T
	SNA CLA		/ARE WE AT THE BEGINNING OF A LINE?
	JMP I	TSTXSW	/YES - GLINE WILL DELETE IT IF NECESSARY
	TAD	XR1
	DCA	TX
	TAD I	TX
	TAD	[-240
	SZA		/IS THE PREVIOUS CHARACTER A SPACE
	TAD	[240-211
	SZA CLA		/OR A TAB?
	JMP I	TSTXSW	/NO
	CMA
	TAD	XR1
	DCA	XR1	/BACK UP CHAR PTR
	CMA
	TAD I	T
	DCA I	T	/AND CHAR CTR
	JMP	TSTXLP	/LOOP
TX,	0
SRCOPT,	DCA	OUHNDL
	TAD I	[MPARAM
	CMA
	AND	[1000	/"C" OPTION
	TAD	[-257
	DCA	CSW
	CLA CLL CML RTR
	AND I	[MPARAM
	DCA	ALLSW	/"B" OPTION
	TAD I	[MPARAM+1
	CMA
	AND	[40	/"S" OPTION
	TAD	[-240
	DCA	SSW
	TAD I	[MPARAM+1
	AND	[20	/"T" OPTION
	DCA	TSW
	CLA IAC
	AND I	[MPARAM+1
	DCA	XSW	/"X" OPTION
	TAD I	[MPARAM+3
	CIA		/GET NEGATIVE OF NUMERICAL ARGUMENT
	SNA
	CLA CLL CMA RTL	/DEFAULT VALUE IS 3
	DCA	NUMLIN	/TO NUMBER OF LINES NECESSARY FOR A MATCH
	JMP I	.+1
	STARTC

HEDING,	"S;"R;"C;"C;"O;"M;" ;"V;VERSION+"0;PATCH;212;0
/PAGE 0 LITERALS FOR FIELD 1
	$-$-$	/END OF ASSEMBLY OF SRCCOM

