Google
 

Trailing-Edge - PDP-10 Archives - cust_sup_cusp_bb-x130c-sb - 10,7/unscsp/soup/comerg.mac
There are 3 other files named comerg.mac in the archive. Click here to see a list.
TITLE	COMERG	VERSION 3	
SUBTTL	CORRECTION FILE MERGER		CWRU/CAM

;EDIT==6

;COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
	HISEG

	TAB=11
	A1=1
	A2=2
	A3=3
	A4=4
	A5=5
	A6=6
	A7=7
	L=10
	NOTL=11
	CNFLCT=12
	CHAR=13
	RETURN=14
	ERROR=15
	COLCON=17
	MINUS=55
	COMMA=54
	COLON=72
	ZERO=60
	NINE=71
	SPACE=40
	LF=12
	FF=14
	CR=15





	EXTERN	STZERO,TEMP,TEMP2,ERRNO,CORLER,CONNO,COLOND,EOF,EOSF
	EXTERN	COUNTR,FERR,FIRS.T,A,B,SAVEMC,SAVEUC,MCSTIN,ASWIT
	EXTERN	EOL,ENZERO
	EXTERN	ERHDM,ERTRM,CNHDM,CNTRM,COMCM,GOTCOM

	EXTERN	LINENO,LINEIN,MANCOR,UCOR,MRGOUT,LSTOUT,LOGOUT
	EXTERN	I,NUMCNV
	ENTRY	COMERG


	DEFINE	FCAL(A,B,C) <XLIST
	JSP	RETURN,A
		B
		C
	LIST>



ERHDMP:	POINT	21,ERHDM+6,35
ERTRMP:	POINT	21,ERTRM+6,35
CNHDP:	POINT	22,CNHDM+11,21
CNTRP:	POINT	22,CNTRM+11,21
WHICHP:	POINT	28,ERHDM+10,27
WHICTP:	POINT	28,ERTRM+10,27
COMCMP:	POINT	22,COMCM+4,21
COMCMR:	POINT	22,COMCM+7,35


MCUC:	"MANF"
	"USER"
SAVECL:	JFCL	SAVEMC(A5)
	JFCL	SAVEUC(A5)
INR:	MANCOR
	UCOR



COMERG:
	SETZM	STZERO		;ZERO DATA AREA
	MOVE	0,[XWD	STZERO,STZERO+1];
	BLT	0,ENZERO-1	;
	SETZB	L,NOTL		;
	SETZB	ERROR,CNFLCT	;
	SETZ	COLCON,		;


	SETOM	COUNTR
	SETOM	COUNTR+1	; SPECIAL FIX SO -0 WORKS
	AOJ	NOTL,		;SET NOTL TO NOT(L)
CMRG.1:	PUSHJ	16,@INR(L)	;GET CHAR
	+	I		;
	JRST	EOF499		;EOF
	MOVE	CHAR,I		;LOAD CHAR
	CAIN	CHAR,MINUS	;IS CHAR - ?
	JRST	GOTMIN		;YES
	SKIPL	FERR(L)		;NO- IS ERR ON ?
	JSP	A6,ERRHDR	;NO- OUTPUT ERROR HEADER
	JRST	CMRG.1		;GET NEXT CHAR
GOTMIN:	PUSHJ	16,@INR(L)	;GET CHAR
	+	I
	JRST	EOF500		;EOF
	MOVE	CHAR,I		;LOAD CHAR
	JSP	A6,GETCLN	;GET CORRECTION LINE
	SKIPE	FERR(L)		;ERROR ON ?
	JSP	A6,ERRTR	;OUTPUT TRAILER
	JUMPG	L,P100		;GOT BOTH - ?
	AOJA	L,CMRG.1	;NO- GET SECOND

P100:	SETZB	L,NOTL		;
	SETZ	COLCON,
	MOVE	A5,A		;
	CAMGE	A5,A+1		;A(MC) >= A(UC) ?
	AOJ	NOTL,		;NO-SET NOTL
	CAML	A5,A+1		;A(MC) < A(UC) ?
	AOJ	L,		;NO-SET L
	MOVE	A5,A(L)		;
	CAMLE	A5,COUNTR(NOTL)	;A(L)<= COUNTR(NOTL) ?
	JRST	P121		;
	CAMLE	A5,COUNTR(L)	;A(L) > COUNTR(L) ?
	JRST	P140		;YES
P121:	MOVE	A5,COUNTR(L)	;
	CAML	A5,A(NOTL)	;COUNTR(L) GE A(NOTL)
	JRST	P140		;YES
P125:
	SKIPE	CNFLCT		;CONFLICT ?
	JSP	A6,CNFTRR	;YES-TURNOFF & OUTPUT TRAILER
	SKIPE	EOF(NOTL)	;EOF OTHER FILE ?
		JRST	ERCHK		;YES
	MOVE	A5,A(NOTL)	;
	CAMG	A5,B(L)		;A(NOTL) >B(L) ?
	JRST	P140		;NO
	CAME	A5,A(L)		;A(NOTL) = A(L) ?
	JRST	ERCHK0		;NO

P140:	SKIPE	COLOND(NOTL)	;IS NOTL A COLON COMMAND
	JRST	COLL		;YES
	SKIPE	COLOND(L)	;IS L A COLON COMMAND ?
	JRST	COLNL		;YES
	JUMPG	CNFLCT,ERCHK	;CONFLICT ON ?
	JSP	A6,CNFHDR	;NO-OUTPUT HEADER
	JRST	ERCHK		;
COLL:	EXCH	L,NOTL		;NEW L=NOTL
COLNL:	AOJ	COLCON,	;SET COLON CONFLICT SWITCH
	JRST	P250		;


ERCHK0:	SKIPE	CNFLCT		;CONFLICT ?
	JSP	A6,CNFTRR	;YES-OUTPUT TRAILER
ERCHK:	MOVE	A5,A(L)		;
	CAMG	A5,COUNTR(L)	;A(L) > COUNTR(L) ?
	JRST	ERRST		;N0- ERROR
	CAMLE	A5,B(L)		;A(L) <= B(L) ?
	JRST	ERRST		;NO_ ERROR
	SKIPE	CORLER(L)	;CORR LINE ERROR ?
ERRST:	JSP	A6,ERRHDR	;YES-OUTPUT ERROR HEADER
DMPCL:	JSP	A7,DUMP		;DUMP CORRECTION
	JUMPG	COLCON,P440	;COLCON ?
	MOVE	A5,B(L)		;
	CAML	A5,COUNTR(L)	;B(L) < COUNTR(L) ?
	MOVEM	A5,COUNTR(L)	;NO 
	JUMPLE	ERROR,P440	;YES-ERROR
	JSP	A6,ERRTR	;YES-OUTPUT ERROR TRAILER
P440:	JSP	A6,GETCLN	;GET NEXT CORRECTION LINE
	MOVEI	COLCON,0	;RESET COLCON
	JRST	P100		;TRY AGAIN
DUMP:
	MOVNI	A5,1
	JUMPG	COLCON,DMPOVR
	AOS	LINENO
	JUMPG	CNFLCT,DP1	;
	JUMPE	ERROR,DMPOVR	;
DP1:	SOS	LINENO		;
	JSP	RETURN,LINEIN	;
DMPOVR:	AOJ	A5,		;
	CAML	A5,MCSTIN(L)	;HAVE WE DUMPED ALL OF CORR LINE
	JRST	FDUMP		;YES
	MOVE	CHAR,@SAVECL(L)	;LOAD CHAR FROM STORE
	MOVEM	CHAR,I		;
	FCAL	MRGOUT,[0],I	;OUTPUT CHAR
	JUMPG	CNFLCT,DMPLIS	;CONFLICT ?
	JUMPE	ERROR,DMPOVR	;ERROR ?
DMPLIS:	FCAL	LSTOUT,[0],I	;LSTOUT
	JRST	DMPOVR		;GET NEXT CHAR
P250:
FDUMP:	MOVE	A5,MCSTIN(L)	;
	MOVE	CHAR,@SAVECL(L)	;GET LAST SAVED
P300:	SETZM	EOL		;NOT EOL

P310:	SKIPE	EOL		;EOL ?
	JRST	P360		;YES
	CAIL	CHAR,LF		;
	CAILE	CHAR,FF		;FEED CHAR ?
	CAIA
	SETOM	EOL		;YES- SET EOL
	JUMPN	COLCON,P330	;NO- COLCON ?
	MOVEM	CHAR,I		;
	FCAL	MRGOUT,[0],I	;MRGOUT
	JUMPG	CNFLCT,DMPCLL	;CONFLICT ?
	JUMPE	ERROR,P330	;ERROR ?
DMPCLL:	FCAL	LSTOUT,[0],I	;LSTOUT
P330:	PUSHJ	16,@INR(L)	;GET CHAR
	+	I
	JRST	EOF500
	MOVE	CHAR,I		;LOAD CHAR
	JRST	P310		;


P360:	CAIN	CHAR,MINUS	;IS CHAR MINUS ?
	JRST	P400		;NO
	JUMPG	COLCON,P300	;
	AOS	LINENO		;INCREMENT LIST LINE NUMBER
	JUMPG	ERROR,P365	;
	JUMPE	CNFLCT,P300	;
P365:
	SOS	LINENO		;WE HAVE INCREMENTED LINENUM ALREADY
	JSP	RETURN,LINEIN	;INSERT LINENUM 
	JRST	P300		;

P400:	PUSHJ	16,@INR(L)	;GET CHAR
	+	I	
	JRST	EOF500		;EOF
	MOVE	CHAR,I		;
	CAIN	CHAR,MINUS	;IS CHAR MINUS ?
	JRST	P425		;YES
	CAIN	CHAR,SPACE	;
	JRST	P425		;CONTINUE DUMPING
	JRST	0(A7)		;RETURN

P425:	JUMPG	COLCON,P300	;- OR SPACE
	AOS	LINENO		;INCREMENT LINENO
	MOVEI	A6,MINUS	;
	MOVEM	CHAR,TEMP
	FCAL	MRGOUT,[0],A6	;MRGOUT
	JUMPG	CNFLCT,P427	;CONFLICT ?
	JUMPE	ERROR,P428
P427:
	SOS	LINENO		;DECREMENT LINENO
	JSP	RETURN,LINEIN	;INSERT LINENUM
	FCAL	LSTOUT,[0],A6	;
P428:	MOVE	CHAR,TEMP
	JRST	P300		;
GETCLN:
	SETZM	GOTCOM
	SETZB	A5,MCSTIN(L)	;
	SETZM	A(L)		;
	SETZM	B(L)		;
	SETZM	CORLER(L)	;
	SETZM	COLOND(L)	;
	SETZB	A1,FIRS.T
	MOVEI	A1,MINUS	;
	MOVEM	A1,@SAVECL(L)	;STORE A MINUS
	MOVEI	A1,0		;ZERO SUM
	SETOM	ASWIT		;
P40:	CAIL	CHAR,ZERO	;
	CAILE	CHAR,NINE	;IS CHAR A NUMBER ?
	JRST	P50		;NO
	SETOM	FIRS.T
	SETZM	GOTCOM
	IMULI	A1,12		;SUM=OLDSUM*10+CHAR-48
	ADD	A1,CHAR		;
	SUBI	A1,ZERO		;
P20:	AOJ	A5,
	MOVEM	CHAR,@SAVECL(L)	;STORE CHAR
	PUSHJ	16,@INR(L)	;GET CHAR
	+ 	I
	JRST	IGIVUP		;SHOULDNT HAPPEN HERE-EOF
	JRST	P40		;
P50:	SKIPL	FIRS.T		;HAVE WE GOT AN NUMBER ?
	JRST	PCHK		;ERROR
	SKIPL	ASWIT		;IS THIS A ?
	JRST	GOTB		;NO-B
	MOVEM	A1,A(L)		;STORE BINARY A
	SETZB	A1,ASWIT	;
	CAIE	CHAR,COMMA	;
	JRST	P55
	SETOM	GOTCOM		;
	JRST	P20
P55:
	MOVE	A1,A(L)		;INSERTION OR COLON
	MOVEM	A1,B(L)		;STORE A(L) IN B(L)
P70:	AOJ	A5,		;INCREMENT SAVE INDEX
	MOVEM	CHAR,@SAVECL(L)	;SAVE CHAR
	CAIN	CHAR,COLON	;IS CHAR A COLON ?
	SETOM	COLOND(L)	;YES
	MOVEM	A5,MCSTIN(L)	;STORE SAVE INDEX
	SKIPE	GOTCOM
	JRST	0(A6)
	CAIN	CHAR,COMMA	;
	JRST	0(A6)		;
	CAIN	CHAR,SPACE	;
	JRST	0(A6)
	CAIN	CHAR,TAB	;
	JRST	0(A6)		;
	CAIN	CHAR,COLON	;
	JRST	0(A6)		;
	CAIL	CHAR,LF
	CAILE	CHAR,CR
	JRST	PCHK2
	JRST	0(A6)
GOTB:
	SKIPG	A1
	MOVE	A1,A(L)
	MOVEM	A1,B(L)		;STORE B(L)
GOTB2:	CAIE	CHAR,COLON	;
	JRST	P70		;WRATUP
PCHK:
	AOJ	A5,
	MOVEM	CHAR,@SAVECL(L)	;STORE LAST CHAR
	MOVEM	A5,MCSTIN(L)	;STORE A5
PCHK2:	MOVEM	A6,TEMP		;STORE A6
	SKIPL	FERR(L)		;
	JSP	A6,ERRHDR	;OUTPUT HEADER
	JSP	A7,DUMP		;DUMP CORRECTION
	JSP	A6,ERRTR	;OUTPUT ERROR TRAILER
	MOVE	A6,TEMP		;RESTORE A6
	JRST	GETCLN		;TRY NEXT CORRECTION LINE
EOF499:	SKIPG	L		;EOSF ON MC OR UC?
	JRST	EOF500		;MC
	SETOM	EOF(L)		;UC, SIMULATE IGIVUP, BUT
	SETZM	EOSF(L)		; REVERSE SENSE OF TEST
	SKIPE	I		; BECAUSE EOF+1=-1
	SETOM	EOSF(L)
	SKIPGE	EOF(NOTL)
	JRST	EOF2
	JRST	IGIVUX

EOF500:
IGIVUP:
	SETOM	EOF(L)		;SET EOF
	SETZM	EOSF(L)		;
	SKIPE	I		;IS IT EOSF ?
	SETOM	EOSF(L)		;YES
	SKIPL	EOF(NOTL)	;EOF ON OTHER FILE ?
	JRST	EOF2		;NO
IGIVUX:	SKIPE	ERROR		;ERROR ?
	JSP	A6,ERRTR	;OUTPUT TRAILER 
	SKIPE	CNFLCT		;CONFLICT ?
	JSP	A6,CNFTRR	;OUTPUT TRAILER
	MOVE	A2,ERRNO	;NUMBER OF ERRS IN MC
	ADD	A2,ERRNO+1	;NUMBER OF ERRS IN UC
	JSP	CHAR,NUMCNV	;EDIT TOTAL NUMBER OF ERRS
	DPB	A3,COMCMP	;DEP IN FINISH MSG
	MOVE	A2,CONNO	;NUMBER OF CONFLICTS
	JSP	CHAR,NUMCNV	;EDIT IT
	MOVEM	A3,COMCM+7	;DEPOSIT IN FINISH  MSG
	FCAL	LOGOUT,[77],COMCM;OUTPUT FINISH MSG
	SKIPL	EOSF		;EOSF MC ?
	JRST	EOFMC		;NO
	SKIPL	EOSF+1		;EOSF UC ?
	JRST	EOFUC		;NO
	MOVEI	0,0
	JRST	PP1		;RETURN
EOFMC:	SKIPL	EOSF+1		;EOSF UC ?
	JRST	EOFB		;EOF ON BOTH
	MOVNI	0,1
PP2:	MOVE	A1,0(16)
	AOSA	(16)
PP1:	MOVE	A1,0(16)
	AOS	(16)
	MOVEM	0,@0(A1)
	POPJ	16,
EOFUC:	MOVEI	0,1		;
	MOVEI	0,1
	JRST	PP1
EOFB:	MOVEI	0,2		;
	MOVEI	0,2
	JRST	PP1
EOF2:	SKIPE	ERROR		;ERROR ?
	JSP	A6,ERRTR	;OUTPUT ERROR TRAILER
	MOVEI	0,377777	;VERY LARGE NUMBER
	MOVEM	0,A(L)		;
	SETZM	COLOND(L)
	JUMPG	COLCON,P100
	MOVE	A5,COUNTR(L)	;
	CAML	A5,B(L)		;COUNTR(L)<B(L) ?
	JRST	P100		;NO
	MOVE	0,B(L)		;
	MOVEM	0,COUNTR(L)	;SET COUNTER TO B
	JRST	P100		;RETURN TO JUNGLE

ERRHDR:	AOS	ERRNO(L)	;INCREMENT ERR NUMBER
	MOVEM	CHAR,TEMP2
	MOVE	A2,ERRNO(L)	;
	JSP	CHAR,NUMCNV		;EDIT ERR NUMBER
	DPB	A3,ERHDMP		;PUT NUMBER IN ERR HEADER MSG
	MOVE	A3,MCUC(L)	;GET WHICH FILE
	DPB	A3,WHICHP	;STORE IN HEADER MSG
		FCAL	MRGOUT,[104],ERHDM;OUTPUT MSG
	JSP	RETURN,LINEIN	;INSERT LINENUM IN LST
	FCAL	LSTOUT,[104],ERHDM;LSTOUT MSG
	SETOM	FERR(L)		;SET ERR FLAG
	MOVE	CHAR,TEMP2
	AOJA	ERROR,0(A6)	;SET ERR REG AND RETURN


ERRTR:	MOVE	A2,ERRNO(L)	;
	MOVEM	CHAR,TEMP2
	JSP	CHAR,NUMCNV	;EDIT ERR NUM
	DPB	A3,ERTRMP	;DEP NUM IN TRAILER MSG
	MOVE	A3,MCUC(L)	;GET WHICH FILE
	DPB	A3,WHICTP	;DEP IN MSG
	FCAL	MRGOUT,[104],ERTRM;OUTPUT TRAILER
	JSP	RETURN,LINEIN	;INSERT LINENO IN LST
	FCAL	LSTOUT,[104],ERTRM;LSTOUT MSG
	SETZB	ERROR,FERR(L)	;RESET ERR INDICATORS
	MOVE	CHAR,TEMP2
	JRST	0(A6)		;RETURN

CNFHDR:	SKIPE	EOF(L)		;NO CONFLICT IF AT EOF
	JRST	0(6)		;SO RETURN
	SKIPE	EOF(NOTL)
	JRST	0(6)		; ANY EOF PRECLUDES CONFLICTS
	AOS	CONNO		;INCREMENT CONFLICT NUMBER
	MOVEM	CHAR,TEMP2
	MOVE	A2,CONNO	;
	JSP	CHAR,NUMCNV	;EDIT CONFLICT NUMBER
	DPB	A3,CNHDP	;DEPOSIT NUMBER IN MSG
	FCAL	MRGOUT,[104],CNHDM;OUTPUT CONFLICT HEADER
	JSP	RETURN,LINEIN	;GET LINENUM FOR LST
	FCAL	LSTOUT,[104],CNHDM;LSTOUT MSG
	MOVE	CHAR,TEMP2
	AOJA	CNFLCT,0(A6)	;SET CONFLICT FLAG AND RETURN


CNFTRR:	
	MOVEM	CHAR,TEMP2
	MOVE	A2,CONNO	;GET CONFLICT NUMBER
	JSP	CHAR,NUMCNV	;EDIT CONFLICT NUMBER
	DPB	A3,CNTRP	;DEPOSIT NUMBER IN TRAILER MSG
	FCAL	MRGOUT,[104],CNTRM;OUTPUT CONFLICT TRAILER
	JSP	RETURN,LINEIN	;LINENUMBER FOR LST
	FCAL	LSTOUT,[104],CNTRM;LSTOUT MSG
	MOVEI	CNFLCT,0	;RESET CONFLICT FLAG
	MOVE	CHAR,TEMP2
	JRST	0(A6)		;RETURN


	END