Google
 

Trailing-Edge - PDP-10 Archives - bb-l014q-bm_tops20_v6_1_atpch17 - autopatch/compar.mac
There are 10 other files named compar.mac in the archive. Click here to see a list.
	TITLE	COMPAR MODULE FOR SOUPR
	SUBTTL	DEFINITIONS
;HANLEY A. STRAPPMAN
	SEARCH	PRS,JOBDAT,UUOSYM
	SALL
	TWOSEG
	EXTERN	DECO,PUTC,SIXO,ICH,BP,EATCR,CPOPJ1,INDIR
	EXTERN	CRLFO,SAVE3,LSNI,STRO,SWTCH,COLON,DECI
	EXTERN	SPCI,LKP,NTR,WLDMAT,PROMPT,OCLS,ICLS
	EXTERN	OCH,GETBLK,RST,FREMEM,PUR,SWINI
	EXTERN	WILDP,WILDER,SAVE1,SAVE2,SPCO,WLDCNT,CO,EATS,SIXI,CI

;DEFINE AC'S
	F=0				;FLAGS
	A1=12				;ADR PREVIOUS A BLK
	A2=A1+1				;ADR CURRENT A BLK
	B1=14				;ADR PREVIOUS B BLK
	B2=B1+1				;ADR CURRENT B BLK

;FLAGS
	F.LOG==1			;LOG FILENAMES
	F.NUM==10			;NUMBER PATCHES
	F.LET==20			;LETTER PATCHES
	F.BAS==40			;BASE FILE IS WILD
	F.BLNK==100			;COUNT BLANKS

;ASSEMBLY PARAMETERS
	PDLSIZ==100			;SIZE OF PDL
	IFNDEF	LINSIZ,<LINSIZ==^D640/5>;SIZE OF LINE OF TEXT
	IFNDEF	MTCH,<MTCH==3>		;DEFAULT /MATCH
	IFNDEF	FLAGS,<FLAGS==F.LOG>	;DEFAULT FLAGS

;CHANNEL USAGE
	A==1				;INPUT OF A FILE
	B==2				;INPUT OF B FILE
	O==3				;OUTPUT FILE
	SUBTTL	EDIT HISTORY

	VEDIT==1	;COMPLETE VMAJOR=2 AUG 77
	VEDIT==2	;EXTRA CRLF IN FILENAME LOG
			;IF OUTPUT DEVICE IS OUR TTY 9-17-77
	VEDIT==3	;CHANGE SYMBOL NAMES TO FOLLOW CONVENTION 10-14-77
	VEDIT==4	;ADD ERROR RETURN TO OCLS 10-15-77
	VEDIT==5	;SWITCH FROM WILD TO WILDER 10-15-77
	VEDIT==6	;/NUMBER 5-18-79
	VEDIT==7	;MERGE GOT MEREOF IF FILE ENDED IN THE
			;MIDDLE OF AN EDIT 8-18-80
	VEDIT==10	;MAKE LINSIZ BIGGER
	VEDIT==11	;BAD COR FILE IF THE LAST LINE OF A FILE IS
			;DELETED 1-11-81
	VEDIT==12	;DEFAULT WILDCARD IS 2ND SPEC NOT 1ST 9-15-81
	VEDIT==13	;INDIRECT FILES 9-15-81
	VEDIT==14	;/LETTER 10-25-81
	VEDIT==15	;/BASE 12-2-82
	VEDIT==16	;SWITCH.INI 6-18-83
	VEDIT==17	;/BLANK 9-9-84

	VWHO==0
	VMAJOR==2
	VMINOR==0
	LOC	.JBVER
	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT
	SUBTTL	INITIALIZATION
	RELOC	400000

COMPAR:	JFCL				;NO CCL
	MOVE	P,[IOWD PDLSIZ,PDL]	;SETUP PDL
	PUSHJ	P,RST			;RESET
	MOVEI	T1,MTCH			;DEFAULT /MATCH
	MOVEM	T1,MATCH
	MOVEI	F,FLAGS			;DEFAULT FLAGS
	MOVE	P2,[XWD -SWIL,SWN]	;READ SWITCH.INI
	MOVEI	P3,SWX
	PUSHJ	P,SWINI
	 JFCL
	MOVEM	F,SAVFLG		;SAVE FLAGS
	MOVE	T1,MATCH		;SAVE /MATCH
	MOVEM	T1,SAVMAT
COMMAN:	PUSHJ	P,RST			;RESET
	SETZM	ZER			;ZERO CORE
	MOVE	T1,[XWD ZER,ZER+1]
	BLT	T1,ZER+ZERSIZ-1
	PUSHJ	P,PARSE			;PARSE THE COMMAND LINE
	JRST	COMMAN
	SUBTTL	PARSE THE COMMAND LINE
PARSE:	MOVE	P2,[XWD -SWL,SWN]	;PROMPT USER
	MOVEI	P3,SWX
	PUSHJ	P,PROMPT
	 POPJ	P,
	PUSHJ	P,INDIR			;DO INDIRECT FILE
	MOVE	T1,[XWD HGH,LOW]	;COPY NON-NULL DATA
	BLT	T1,LOW+LOWSIZ-1
	SETZM	Q			;CLEAR THE STRING (1ST WORD)
	MOVE	F,SAVFLG		;DEFAULT FLAGS
	MOVE	T1,SAVMAT		;DEFAULT /MATCH FROM SWITCH.INI
	MOVEM	T1,MATCH
	MOVEI	P1,OSPC			;PASS ADR O SPC
	PUSHJ	P,SPCI			;GET OUTPUT SPC
	 POPJ	P,
	PUSHJ	P,EATS			;EAT EQUAL
	 POPJ	P,
	CAIE	C,"="
	FATAL	COMSYN,<Syntax error>
	PUSHJ	P,CI
	 POPJ	P,
	MOVEI	P1,ASPC			;GET A SPC
	PUSHJ	P,SPCI
	 POPJ	P,
	PUSHJ	P,EATS			;EAT COMMA
	 POPJ	P,
	CAIE	C,","
	FATAL	COMSYN,<Syntax error>
	PUSHJ	P,CI
	 POPJ	P,
	MOVE	T1,[XWD ASPC,BSPC]	;STICKY SPC
	BLT	T1,BSPC+SPCSIZ-1
	MOVEI	P1,BSPC			;GET B SPC
	PUSHJ	P,SPCI
	 POPJ	P,
	MOVE	P2,[XWD -SWL,SWN]	;PARSE SWITCHES
	MOVEI	P3,SWX
	PUSHJ	P,SWTCH
	 POPJ	P,
	PUSHJ	P,EATCR			;TEST FOR BREAK CHAR
	 POPJ	P,
	PUSHJ	P,BP
	 FATAL	COMSYN,<Syntax error>
	MOVEI	P1,BSPC			;ASSUME B IS WILD
	MOVEI	P2,ASPC			;AND A IS NOT
	TRNE	F,F.BAS			;TRUE?
	EXCH	P1,P2			;NOPE, SWITCH THEM
	PUSHJ	P,WILDP			;WILD?
	 EXCH	P1,P2			;NO, SWITCH AGAIN
	MOVEI	P2,MAIN			;WILDCARD LOOKUP
	PUSHJ	P,WILDER
	 JFCL
	POPJ	P,
	SUBTTL	MAINSTREAM

MAIN:	PUSHJ	P,SAVE3			;SAVE P1-P3
	AOS	WLDCNT			;COUNT IT
	MOVEI	P2,ASPC			;MATCH WLD SPCS
	MOVEI	P3,ASPC2
	PUSHJ	P,WLDMAT
	MOVEI	P2,BSPC
	MOVEI	P3,BSPC2
	PUSHJ	P,WLDMAT
	MOVEI	P2,OSPC
	MOVEI	P3,OSPC2
	PUSHJ	P,WLDMAT
	MOVE	T1,ASPC2+.SBNAM		;OUTPUT DEFAULT TO INPUT
	SKIPN	OSPC2+.SBNAM
	MOVEM	T1,OSPC2+.SBNAM
	PUSHJ	P,LOG			;DO LOGGING
	 POPJ	P,
	MOVEI	T1,A			;LOOKUP A FILE
	MOVEM	T1,ICH
	MOVEI	P1,ASPC2
	PUSHJ	P,LKP
	 POPJ	P,
	MOVEI	T1,B			;LOOKUP B FILE
	MOVEM	T1,ICH
	MOVEI	P1,BSPC2
	PUSHJ	P,LKP
	 POPJ	P,
	MOVEI	T1,O			;ENTER OUTPUT FILE
	MOVEM	T1,OCH
	MOVEI	P1,OSPC2
	PUSHJ	P,NTR
	 POPJ	P,
	MOVEI	T1,1			;PAGE 1 LINE 0
	MOVEM	T1,PAG
	SETZM	LIN
	SETZM	CHKSUM			;RESET CHECK SUM
	SETZM	NUMBR			;NO PATCHES YET
	SETOM	LETTR
	MOVEI	T1,AMEM			;DELETE CORE IN CASE RESTART
	PUSHJ	P,PUR
	MOVEI	T1,BMEM
	PUSHJ	P,PUR
LOOP:	MOVEI	A2,AMEM			;POINT A TO 0TH BLK
	MOVEI	B2,BMEM			;POINT B TO 0TH BLK
	PUSHJ	P,GETA			;GET NEXT A BLK
	 POPJ	P,
	PUSHJ	P,GETB			;GET NEXT B BLK
	 POPJ	P,
	PUSHJ	P,EQ			;EQUAL?
	 JRST	NOTA
	SKIPN	2(A2)			;YES, EOF?
	JRST	SUM			;YES
	PUSHJ	P,DELA			;DELETE A BLK
	PUSHJ	P,DELB			;DELETE B BLK
	JRST	LOOP
LOOP2:	MOVE	P1,A1			;SAVE A POSITION
	MOVEI	A2,AMEM			;FIND A BLK THAT MATCH LAST B BLK
BLOOP:	MOVE	A1,A2
	HRRZ	A2,(A1)
	PUSHJ	P,NE
	 POPJ	P,
	JUMPE	T1,DISPER		;WIN
	CAME	P1,A1
	JRST	BLOOP
;HERE WHEN LAST B BLK DOESN'T MATCH ANY A BLK
NOTB:	MOVE	P1,B1			;SAVE B POSITION
	MOVEI	B2,BMEM			;FIND B BLK THAT MATCH LAST A BLK
ALOOP:	MOVE	B1,B2
	HRRZ	B2,(B1)
	PUSHJ	P,NE
	 POPJ	P,
	JUMPE	T1,DISPER		;WIN
	CAME	P1,B1
	JRST	ALOOP
;HERE WHEN LAST A BLK DOESN'T MATCH ANY B BLK
NOTA:	PUSHJ	P,GETA			;GET ANOTHER A BLK
	 POPJ	P,
	PUSHJ	P,GETB			;GET ANOTHER B BLK
	 POPJ	P,
	SKIPN	1(B1)			;IS FILE B SHORTER THAN FILE A?
	JRST	NOTB			;YES, TEST IF LAST A MATCH ANY B
	JRST	LOOP2
;HERE WITH A2 AND B2 POINTING TO 1ST LINES
;THAT ARE EQUAL
DISPER:	SETZ	T2,			;COUNT MODIFIED A LINES
	MOVEI	T1,AMEM
	HRRZ	T1,(T1)
	CAME	A2,T1
	AOJA	T2,.-2
	MOVEM	T2,COUNTA
	SETZ	T2,			;COUNT MODIFIED B LINES
	MOVEI	T1,BMEM
	HRRZ	T1,(T1)
	CAME	B2,T1
	AOJA	T2,.-2
	MOVEM	T2,COUNTB
	MOVEI	A1,AMEM			;POINT A TO 1ST BLK
	HRRZ	A2,AMEM
	MOVEI	B1,BMEM			;POINT B TO 1ST BLK
	HRRZ	B2,BMEM
	MOVEI	C," "			;COMMANDS BEGIN WITH SPACE
	PUSHJ	P,PUTC
	 POPJ	P,
	MOVEI	P1,'REP'		;ASSUME REPLACE
	SKIPN	COUNTB			;DELETE?
	MOVEI	P1,'DEL'		;YES
	SKIPN	COUNTA			;INSERT?
	MOVEI	P1,'INS'		;YES
	HRLZ	T1,P1			;SAY WHICH
	PUSHJ	P,SIXO
	 POPJ	P,
	MOVEI	C," "
	PUSHJ	P,PUTC
	 POPJ	P,
	HRRZ	T1,1(A2)		;LINE
	PUSHJ	P,DECO
	 POPJ	P,
	MOVEI	C,"/"
	PUSHJ	P,PUTC
	 POPJ	P,
	HLRZ	T1,1(A2)		;PAGE
	PUSHJ	P,DECO
	 POPJ	P,
	MOVE	T1,SIX			;EITHER TYPE OF NAME?
	OR	T1,Q
	JUMPE	T1,NONAME		;NO
	MOVEI	T1,[BYTE (7)11,";"]	;TAB SEMICOLON
	PUSHJ	P,STRO
	 POPJ	P,
	MOVE	T1,SIX			;OUTPUT SIXBIT NAME
	PUSHJ	P,SIXO
	 POPJ	P,
	PUSHJ	P,DOLET			;LETTER IT
	 POPJ	P,
	PUSHJ	P,DONUM			;NUMBER IT
	 POPJ	P,
	SKIPN	Q			;QUOTED EXTENSION?
	JRST	NONAME			;NO
	MOVEI	T1,Q			;YES, OUTPUT THE QUOTE
	PUSHJ	P,STRO
	 POPJ	P,
NONAME:	PUSHJ	P,CRLFO
	 POPJ	P,
DELLOP:	SOSGE	COUNTA			;MORE TO DELETE?
	JRST	DELDON			;NO
	LDB	T1,[POINT 7,2(A2),6]	;GET 1ST CHAR
	MOVEI	T2,1			;IS IT SPECIAL?
	LSH	T2,(T1)
	TDNE	T2,[1400036000]
	JRST	DELLP1
	MOVEI	C,11			;NO, TYPE A TAB
	PUSHJ	P,PUTC
	 POPJ	P,
DELLP1:	MOVEI	T1,2(A2)		;TYPE THE LINE
	PUSHJ	P,STRO
	 POPJ	P,
	PUSHJ	P,DELA			;DELETE IT
	JRST	DELLOP			;TRY FOR MORE
DELDON:	CAIE	P1,'REP'		;DELIMIT REP
	JRST	INSLOP
	MOVEI	T1,[ASCIZ / WIT
/]
	PUSHJ	P,STRO
	 POPJ	P,
INSLOP:	SOSGE	COUNTB			;MORE TO INSERT?
	JRST	LOOP			;NO
	LDB	T1,[POINT 7,1(B2),6]	;GET 1ST CHAR
	MOVEI	T2,1			;IS IT SPECIAL?
	LSH	T2,(T1)
	TDNE	T2,[1400036000]
	JRST	INSLP1
	MOVEI	C,11			;NO, TYPE A TAB
	PUSHJ	P,PUTC
	 POPJ	P,
INSLP1:	MOVEI	T1,1(B2)		;TYPE THE LINE
	PUSHJ	P,STRO
	 POPJ	P,
	PUSHJ	P,DELB			;DELETE IT
	JRST	INSLOP			;TRY FOR MORE
SUM:	MOVEI	T1,[ASCIZ / SUM /]	;CHECKSUM
	PUSHJ	P,STRO
	 POPJ	P,
	HRRZ	T1,CHKSUM		;THE SUM
	ADDI	T1,1
	PUSHJ	P,DECO
	 POPJ	P,
	PUSHJ	P,CRLFO
	 POPJ	P,
	PUSHJ	P,OCLS			;CLOSE FILES
	 JFCL
	MOVEI	T1,A
	MOVEM	T1,ICH
	PUSHJ	P,ICLS
	MOVEI	T1,B
	MOVEM	T1,ICH
	PUSHJ	P,ICLS
	JRST	CPOPJ1
;ROUTINE TO NUMBER THE PATCHES
DONUM:	TRNN	F,F.NUM			;NUMBER IT?
	JRST	CPOPJ1			;NO
	AOS	T1,NUMBR		;YES, BUMP THE NUMBER
	PJRST	DECO			;TYPE IT OUT

;ROUTINE TO LETTER THE PATCHES
DOLET:	TRNN	F,F.LET			;LETTER IT?
	JRST	CPOPJ1			;NO
	AOS	T1,LETTR		;YES, BUMP THE NUMBER
	;PJRST	R26O			;TYPE IT OUT

;ROUTINE TO OUTPUT A NUMBER IN RADIX 26
;T1 PASSES THE NUMBER
R26O:	IDIVI	T1,^D26
	HRLM	T2,(P)
	JUMPE	T1,R26O1
	PUSHJ	P,R26O
	 POPJ	P,
R26O1:	HLRZ	C,(P)
	ADDI	C,"A"
	PJRST	CO
;ROUTINE TO TYPE OUT LOG MESSAGE
LOG:	TRNN	F,F.LOG			;LOGGING?
	JRST	CPOPJ1			;NO
	SETOM	OCH			;OSELECT TTY
	PUSHJ	P,CRLFO
	 POPJ	P,
	MOVEI	P1,OSPC2		;TYPE O SPEC
	PUSHJ	P,SPCO
	 POPJ	P,
	MOVEI	C,"="
	PUSHJ	P,CO
	 POPJ	P,
	MOVEI	P1,ASPC2		;TYPE A SPEC
	PUSHJ	P,SPCO
	 POPJ	P,
	MOVEI	C,","
	PUSHJ	P,CO
	 POPJ	P,
	MOVEI	P1,BSPC2		;TYPE B SPEC
	PUSHJ	P,SPCO
	 POPJ	P,
	MOVE	T1,OSPC2+.SBDEV		;OUTPUT DEV IS OUR TTY?
	DEVCHR	T1,
	TLNE	T1,(DV.TTA)
	JRST	CRLFO			;YES, EXTRA CRLF
	JRST	CPOPJ1
;ROUTINE TO GET A BLK
GETA:	MOVE	A1,A2			;ADVANCE TO NEXT BLK
	HRRZ	A2,(A1)
	JUMPN	A2,CPOPJ1		;EASY IF REALLY EXISTS
	PUSHJ	P,SAVE2			;SAVE P1-P2
	SETZM	LINE			;CLEAR BLOCK
	MOVE	T1,[XWD LINE,LINE+1]
	BLT	T1,LINE+LINSIZ-1
	MOVE	P1,[POINT 7,LINE]	;BP TO BLK
	MOVEI	P2,LINSIZ*5		;CHAR COUNT
	MOVEI	T1,A			;ISELECT A
	MOVEM	T1,ICH
GETALP:	SOJLE	P2,[ERR ER.EAT,"?",COMLTL,<Line too long>]
	PUSHJ	P,LSNI			;GET A CHAR
	 JRST	GETAER
	IDPB	C,P1			;STORE IT
	MOVE	T1,CHKSUM		;ADD TO CHECKSUM
	ROT	T1,1
	ADDI	T1,1(C)
	MOVEM	T1,CHKSUM
	PUSHJ	P,BP			;LOOP UNTIL BREAK CHAR
	 JRST	GETALP
GETADN:	IBP	P1			;MAKE ASCIZ
	SUBI	P1,LINE			;LENGHT-1
	HRRZI	T1,3(P1)		;GET SOME CORE
	PUSHJ	P,GETBLK
	 POPJ	P,
	MOVE	A2,T2			;ADR IN A2
	HRRM	A2,(A1)			;LINK TO LIST
	ADDI	T1,-1(A2)		;ADR LAST WORD
	ADDI	T2,2			;BLT LINE TO BLK
	HRLI	T2,LINE
	BLT	T2,(T1)
	AOS	T1,LIN			;STORE SEQUENCE
	HRL	T1,PAG
	MOVEM	T1,1(A2)
	CAIE	C,14			;FORM FEED?
	JRST	CPOPJ1
	AOS	PAG			;YES, BUMP PAGE
	SETZM	LIN
	JRST	CPOPJ1
GETAER:	TRNE	C,IO.ERR		;QUIT IF ERROR
	POPJ	P,
	JRST	GETADN
;ROUTINE TO GET B BLK
GETB:	MOVE	B1,B2			;ADVANCE TO NEXT BLK
	HRRZ	B2,(B1)
	JUMPN	B2,CPOPJ1		;EASY IF REALLY EXISTS
	PUSHJ	P,SAVE2			;SAVE P1-P2
	SETZM	LINE			;CLEAR BLOCK
	MOVE	T1,[XWD LINE,LINE+1]
	BLT	T1,LINE+LINSIZ-1
	MOVE	P1,[POINT 7,LINE]	;BP TO BLK
	MOVEI	P2,LINSIZ*5		;CHAR COUNT
	MOVEI	T1,B			;ISELECT B
	MOVEM	T1,ICH
GETBLP:	SOJLE	P2,[ERR ER.EAT,"?",COMLTL,<Line too long>]
	PUSHJ	P,LSNI			;GET A CHAR
	 JRST	GETBER
	IDPB	C,P1			;STORE IT
	PUSHJ	P,BP			;LOOP UNTIL BREAK CHAR
	 JRST	GETBLP
GETBDN:	IBP	P1			;MAKE ASCIZ
	SUBI	P1,LINE			;LENGHT-1
	HRRZI	T1,2(P1)		;GET SOME CORE
	PUSHJ	P,GETBLK
	 POPJ	P,
	MOVE	B2,T2			;ADR IN B2
	HRRM	B2,(B1)			;LINK TO LIST
	ADDI	T1,-1(B2)		;ADR LAST WORD
	ADDI	T2,1			;BLT LINE TO BLK
	HRLI	T2,LINE
	BLT	T2,(T1)
	JRST	CPOPJ1
GETBER:	TRNE	C,IO.ERR		;QUIT IF ERROR
	POPJ	P,
	JRST	GETBDN
;ROUTINE TO TEST IF A&B FILES ARE NOT EQUAL
;TO BE EQUAL, SEVERAL CONSECUTIVE LINES MUST MATCH
;NOSKIP IF ERROR
;SKIP IF EQUAL WITH T1=0
;SKIP IF NOT EQUAL WITH T1<>0
NE:	PUSH	P,P1			;SAVE P1
	MOVE	P1,MATCH		;# LINES THAT MUST MATCH
	PUSH	P,A1			;SAVE A POSITION
	PUSH	P,B1			;SAVE B POSITION
NELOP:	PUSHJ	P,EQ			;EQUAL?
	 JRST	NEDON			;NO, LOSE
	PUSHJ	P,BLANKP		;BLANK LINE?
	 SUBI	P1,1			;NOT BLANK, COUNT IT
	PUSHJ	P,GETA			;GET A BLK
	 JRST	NEBAD
	PUSHJ	P,GETB			;GET B BLK
	 JRST	NEBAD
	JUMPG	P1,NELOP		;LOOP UNTIL ENOUGH EQUAL
NEDON:	AOS	-3(P)			;SKIP RETURN
NEBAD:	POP	P,B1			;RECALL B POSTION
	HRRZ	B2,(B1)
	POP	P,A1			;RECALL A POSITION
	HRRZ	A2,(A1)
	MOVE	T1,P1			;SAVE # LINES
	POP	P,P1			;RECALL P1
	POPJ	P,

;ROUTINE TO TEST IF A&B BLKS ARE EQUAL
;SKIP IF YES
EQ:	HLRZ	T1,(A2)			;GET SIZE OF A BLK
	HLRZ	T2,(B2)			;GET SIZE OF B BLK
	CAIE	T1,1(T2)		;A SHOULD BE 1 BIGGER
	POPJ	P,
	MOVEI	T1,2(A2)		;ADR A DATA
	MOVEI	T3,1(B2)		;ADR B DATA
EQLOP:	SOJE	T2,CPOPJ1		;QUIT IF NO MORE DATA
	MOVE	T4,(T1)			;COMPARE DATA
	CAME	T4,(T3)
	POPJ	P,
	ADDI	T1,1			;ADVANCE A
	AOJA	T3,EQLOP		;ADVANCE B
;ROUTINE TO TEST IF A LINE IS BLANK
;(I.E. TEST IF IT SHOULD BE COUNTED).
;NOSKIP IF SHOULD BE COUNTED
;SKIP IF SHOULD NOT BE COUNTED
BLANKP:	TRNE	F,F.BLNK		;COUNT BLANK LINES?
	POPJ	P,			;YES, ALWAYS COUNT IF /BLANK
	PUSHJ	P,SAVE1
	MOVEI	P1,2(A2)		;ADDR OF DATA
	HRLI	P1,(POINT 7)		;BUILD A BP
BLNKP1:	ILDB	C,P1			;GET A CHAR
	CAIE	C," "			;SPACE?
	CAIN	C,11			;OR TAB?
	JRST	BLNKP1			;YES
	CAIN	C,15			;CR?
	JRST	BLNKP1			;YES
	PUSHJ	P,BP			;BREAK?
	 POPJ	P,			;NO, LINE IS NOT BLANK
	JRST	CPOPJ1			;YES, LINE IS BLANK
	SUBTTL	DELETE CORE

;ROUTINE TO DELETE A BLK
DELA:	HRRZ	T1,(A2)			;UNLINK IT
	HRRM	T1,(A1)
	HRRZ	T1,FREMEM		;NO, LINK TO FREE LIST
	HRRM	T1,(A2)
	HRRM	A2,FREMEM
	HRRZ	A2,(A1)			;POINT TO NEXT BLK
	POPJ	P,

;ROUTINE TO DELETE B BLK
DELB:	HRRZ	T1,(B2)			;UNLINK IT
	HRRM	T1,(B1)
	HRRZ	T1,FREMEM		;NO, LINK TO FREE LIST
	HRRM	T1,(B2)
	HRRM	B2,FREMEM
	HRRZ	B2,(B1)			;POINT TO NEXT BLK
	POPJ	P,
	SUBTTL	SWITCHES

;/MATCH:N SWITCH
MAT:	PUSHJ	P,COLON			;EAT COLON
	 JRST	CPOPJ1
	PUSHJ	P,DECI			;# LINES TO MATCH
	 JRST	CPOPJ1
	MOVEM	T1,MATCH		;STORE IT
	POPJ	P,			;WIN

;NAME SWITCH
;/NAME:XXXXXX
;/NAME:"XXX XX XXX"
NAM:	PUSHJ	P,COLON			;EAT THE COLON
	 JRST	CPOPJ1
	PUSHJ	P,EATS			;EAT SPACES
	 JRST	CPOPJ1
	CAIN	C,42			;IS 1ST CHAR A QUOTE?
	JRST	NAMQ			;YES,  QUOTE TYPE
	PUSHJ	P,SIXI			;NO, GET SIXBIT NAME
	 JRST	CPOPJ1
	MOVEM	T1,SIX			;STORE IT
	SETZM	Q			;NOT QUOTED TYPE
	POPJ	P,
NAMQ:	PUSHJ	P,CI			;EAT THE QUOTE
	 JRST	CPOPJ1
	PUSHJ	P,SIXI			;GET THE FIRST WORD
	 JRST	CPOPJ1
	MOVEM	T1,SIX			;STORE IT
	PUSHJ	P,SAVE2			;SAVE P1-P2
	MOVE	P1,[POINT 7,Q]		;BP TO STORAGE FOR STRING
	MOVEI	P2,LINSIZ*5-1		;STORAGE SIZE
NAMLOP:	CAIN	C,42			;END QUOTE?
	JRST	NAMEQ			;YES
	PUSHJ	P,BP			;ILLEGAL IF BREAK CHAR
	 SOSGE	P2			;ILLEGAL IF TOO BIG
	JRST	NAMERR			;GO TYPE THE ERROR
	IDPB	C,P1			;NO, STORE IT
	PUSHJ	P,CI			;GET A CHAR
	 JRST	CPOPJ1
	JRST	NAMLOP			;KEEP GOING
NAMEQ:	SETZ	C,			;MAKE ASCIZ
	IDPB	C,P1
	PUSHJ	P,CI			;EAT END QUOTE
	 JRST	CPOPJ1
	POPJ	P,
NAMERR:	ERR	ER.EAT,"?",COMNAM,<Illegal argument to NAME switch>
	JRST	CPOPJ1
	DEFINE	SW,<
	XX	BLANK,<TRO F,F.BLNK>
	XX	NOBLAN,<TRZ F,F.BLNK>
	XX	MATCH,<PUSHJ P,MAT>
	XX	LOG,<TRO F,F.LOG>
	XX	NOLOG,<TRZ F,F.LOG>
	XX	BASE,<TRO F,F.BAS>
	XX	NOBASE,<TRZ F,F.BAS>
	XX	USER,<TRZ F,F.BAS>
	XX	NOUSER,<TRO F,F.BAS>	;;LAST SWITCH IN SWITCH.INI
	XX	EXIT,<JRST EXT##>
	XX	HELP,<PUSHJ P,HELPER##>
	XX	NAME,<PUSHJ P,NAM>
	XX	NUMBER,<TRO F,F.NUM>
	XX	NONUMB,<TRZ F,F.NUM>
	XX	LETTER,<TRO F,F.LET>
	XX	NOLETT,<TRZ F,F.LET>
>

	DEFINE	XX(AA,BB),<SIXBIT /AA/>
SWN:	SW
	SWL==.-SWN
	SWIL==11			;NUMBER OF SWITCHES IN SWITCH.INI

	DEFINE	XX(AA,BB),<BB>
SWX:	SW
	SUBTTL	LOWSEG
	LIT				;PUT LITERALS IN HIGHSEG
	RELOC	0

PDL:	BLOCK	PDLSIZ			;PUSH DOWN LIST
NUMBR:	BLOCK	1			;PATCH NUMBER
LETTR:	BLOCK	1			;PATCH LETTER
LINE:	BLOCK	LINSIZ			;ASCIZ LINE
Q:	BLOCK	LINSIZ			;QUOTED COMMENT
BSPC:	BLOCK	SPCSIZ			;B SPC, WITH WILDCARDS
ASPC2:	BLOCK	SPCSIZ			;A SPC, WITHOUT WILDCARDS
BSPC2:	BLOCK	SPCSIZ			;B SPC, WITHOUT WILDCARDS
OSPC2:	BLOCK	SPCSIZ			;O SPC, WITHOUT WILDCARDS
COUNTA:	BLOCK	1			;COUNT OF MODIFIED A LINES
COUNTB:	BLOCK	1			;COUNT OF MODIFIED B LINES
PAG:	BLOCK	1			;PAGE NUMBER
LIN:	BLOCK	1			;LINE NUMBER
CHKSUM:	BLOCK	1			;CHECKSUM
MATCH:	BLOCK	1			;NUMBER OF LINES THAT MUST MATCH
SAVFLG:	BLOCK	1			;SAVED FLAGS FROM SWITCH.INI
SAVMAT:	BLOCK	1			;SAVED /MATCH FROM SWITCH.INI
;BEGIN REGION TO BE ZEROED
ZER:!
AMEM:	BLOCK	1			;ADR 1ST A BLK
BMEM:	BLOCK	1			;ADR 1ST B BLK
;END REGION TO BE ZEROED
	ZERSIZ==.-ZER
LOW:					;NON-NULL DATA
	RELOC				;BACK TO HIGHSEG
HGH:	PHASE	LOW
;BEGIN DO NOT SEPARATE
;O SPC, WITH WILDCARDS
OSPC:	XWD	SPCSIZ,0		;SIZE OF BLK
	SIXBIT	/DSK/			;DEVICE
	0				;DEVICE MASK
	BLOCK	SFDS+1			;PPN&SFDS
	IFN	SFDS,<0>
	BLOCK	SFDS+1			;PPN&SFDS MASKS
	0				;FILENAME
	0				;FILENAME MASK
	SIXBIT	/COR/			;EXTENSION
	.IOASC				;ASCII MODE
;A SPC, WITH WILDCARDS
ASPC:	XWD	SPCSIZ,0		;SIZE OF BLK
	SIXBIT	/DSK/			;DEVICE
	0				;DEVICE MASK
	BLOCK	SFDS+1			;PPN&SFDS
	IFN	SFDS,<0>
	BLOCK	SFDS+1			;PPN&SFDS MASKS
	0				;FILENAME
	0				;FILENAME MASK
	SIXBIT	/MAC/			;EXTENSION
	.IOASC				;ASCII MODE
SIX:	0				;SIXBIT NAME
;END DO NOT SEPARATE
	DEPHASE
	LOWSIZ==.-HGH
	RELOC	LOW			;BACK TO LOWSEG
	BLOCK	LOWSIZ

	END	COMPAR