Google
 

Trailing-Edge - PDP-10 Archives - dec-10-omona-u-mc9 - syrlib.mac
There are 16 other files named syrlib.mac in the archive. Click here to see a list.
	TITLE	SYRLIB -- SYSERR PACKAGE LIBRARY OF COMMON ROUTINES VERSION7(433)	OCT 30, 1972	SUBTTL	K. COYE/ RLD





	SEARCH	SYRUNV	;UNIVERSAL  FOR SYSERR PACKAGE
	SEARCH	SYRLOW		;LOW SEG DEFINITIONS
	SEARCH	SCNMAC		;COMMAND SCANNER UNIVERSAL FOR SCAN









	TWOSEG
	RELOC	400000




	;INTERNALS ARE DEFINED HERE FOR ACCESS FROM OTHER PARTS
	;OF THE SYSERR PACKAGE.

	INTERNAL HEADRD,ABORT,CHRCHK,DATECK,FILERR,TOOBIG,MBCHAR
	INTERNAL CNISUM,BADNAM,MASSVM,DEVCHK,ERRINT,SKIPIT,IDCHK
	INTERNAL STRCHK,DETCHK,DMPENT,HDRLST,PAGXCD,DVCHAR,TMCHAR
	INTERNAL SAYDAY,GETNBS,.OCTLE,.DECML,.ASCIE,.SIXBT,ENTRST,SPACE3
	INTERNAL .HAFWD,.SPECL,.HTIME,.PPNWW,.ODECW,.UDATE,.TASCI,.PPNWT
	INTERNAL .TDIRW,R5VSIX,MONVER,BADADD,TAB031,TYPAST,BLDPTR
	INTERNAL ACLST,SAVE4P,RET4P,HWDUMP,TYPBCD,LSTEB,JFLOOP,CNIDCD
	INTERNAL XORTAB,BITLST,.DVTAB,.MXBLK,.TRBLK,.SUBLK,.SECBK
	INTERNAL WDCNT,COMPAR,SKPRTN,TYPNBS,TITLST,SKIPWD,ADVBFF
	INTERNAL FIXBUF,STBUFF,INPWD,GOSUM,GETWD,FFPRNT,SLPRNT,CLPRNT
	INTERNAL TBPRNT,CHROUT,TTYSIX,MDECHR,FIXNAM,NOTRAN,ACREG





	SALL
	;HEADRD -- ROUTINE TO VERIFY HEADER SECTION OF ENTRY
	;AND XFER HEADER TO HDBUFF
	;BODY OF ENTRY TO WKBUFF
	;THEN DISPATCH TO ENTRY PROCESSOR

HEADRD:	TLZ	F,F.TTYO	;SAY PUT ALL CHARS IN OUTPUT BUFFER
ABORT:	TLZ	F,F.BTCK	;SAY NO BIT CHECKING
	MOVE	P,PDLPNT##	;RESET PDL STACK POINTER
	TLZ	F,F.READ	;CLEAR READING FLAG AND NAME FLAG
	SETZ	S,		;CLEAR SOFTWARE ERROR BITS
CLRBUF:	SETZM	HDVER1		;0= HEADER VER 0
	SETZM	TOPENT	;[200]0 SAYS TOPS10 RECORDED
	SETZM	WKBUFF		;PREPARE TO CLEAR WORKING BUFFER
	MOVE	T1,[XWD	WKBUFF,WKBUFF+1]
	BLT	T1,WKBUFF+WKSIZE-1	;ZAP
	MOVE	T1,[XWD HDBUFF,HDBUFF+1]	;SETUP TO ZAP HEADER BUFFER
	SETZM	HDBUFF
	BLT	T1,HDBUFF+HDSIZE-1	;ZAP

GETWD0:	PUSHJ	P,GETWD		;GET WORD 0 OF ENTRY
EOFTRY:	LDB	T1,[POINT 9,MASTWD,8]	;PICKUP ENTRY TYPE
						;ALSO ENTRY FOR POST EOF CODE
	MOVEM	T1,ERTYPE
FILCHK:	TLNE	MASTWD,TOPBIT	;[200]1=TOPS20 RECORDED
	 PUSHJ	P,[ SETOM	TOPENT ;[400]
		    SETOM	TOPONE
		    POPJ	P,0]
	CAIN	T1,ER.HIA	;DID DAEMON SEE FILE ERROR
	JRST	FILERR		;YUP

EOFCHK:	CAIN	T1,ER.EOF	;IS THIS THE END OF ERROR FILE
	JRST	EOFVER		;WORD WAS WRITTEN IN FILE TO INDICATE EOF
	MOVEM	MASTWD,HDBUFF	;STORE WD0 OF HEADER IN HDBUFF

	;HERE WE CHECK TO SEE IF THIS IS A VALID CODE FOR SYSERR

	CAIGE	T1,NOTMIN
	JRST	.+3  ;ENTRY IS OK
	CAIG	T1,NOTMAX
	JRST	NOTOUR		;[303]OPPS
	PUSHJ	P,ERRINT	;OK GO FIND HIS INDEX
	PUSHJ	P,SIZCHK	;[303]FIND ENTRY SIZE

	SKIPN	HEADWC		;HDR LENGTH =0
	  JRST	HEADST		;YES
	SKIPN	ENTRWC		;BODY = 0?
	  JRST	ENTRST
	CAILE	T1,WKSIZE+HDSIZE	;IS ENTRY LARGER THAN BUFFERS
	JRST	TOOBIG		;YES
	PUSHJ	P,HEADFL	;GO FILL HDBUFF WITH HEADER INFO
	TLNE	F,F.DATE	;DOES USER DESIRE DATE CONSTRAINTS
	PUSHJ	P,DATECK	;YES GO DO IT
	JRST	CHRCHK

HEADST:	WARN	<ZERO LENGTH HEADER FOUND!>
	JRST STBUFF		;RE-SYNC!!
ENTRST:	WARN	<ZERO LENGTH ENTRY FOUND!>
	JRST STBUFF


;CODE MOVED AND RENAMED WITH EDIT 303
SIZCHK:	LDB	T1,[POINT 6,MASTWD,23]	;GET HDR VER
	SKIPE	T1		;0=VER 0
	SETOM	HDVER1		;REMEMBER
	SKIPE	HDVER1		;DID WE JUST SET IT?
	LDB	T1,[POINT 3,MASTWD,26]	;YES
	SKIPN	HDVER1		;CHECK AGAIN
	LDB	T1,[POINT 3,MASTWD,29]	;GET 3 BITS OF HDR LENGTH
	MOVEM	T1,HEADWC	;SAVE WHICHEVER WE GOT
	SKIPE	HDVER1		;TRY AGAIN
	LDB	T1,[POINT 9,MASTWD,35]	;VER 1=GET 9BITS OF BODY LENGTH
	SKIPN	HDVER1		;VER 0?
	LDB	T1,[POINT 6,MASTWD,35]	;YES, GET 6 BITS
	MOVEM	T1,ENTRWC	;SAVE EITHER
	ADD	T1,HEADWC
	MOVEM	T1,TOTWC	;SAVE TOTAL # WDS IN ENTRY
	POPJ	P,0

;ROUTINE ADDED WITH EDIT 303
NOTOUR:	PUSHJ	P,SIZCHK	;FIND THE ENTRY LENGTH
	MOVE	T1,TOTWC
	SUBI	T1,1		;ALREADY HAVE WD 0 OF HEADER
	MOVEM	T1,ENTRWC	;SETUP AND
	JRST SKIPIT		;SKIP TO NEXT ENTRY
	;END EDIT 303
	;CHRCHK -- ROUTINE TO DETERMINE IF THIS ENTRY SHOULD BE LISTED
	;EXITS TO SKIPIT IF ENTRY NOT DESIRED
	;ELSE XFERS ENTRY TO WORK BUFFER AND DISPATCHES TO ENTRY PROCESSOR
	;SPECIFIED IN PCSTBL WORD

CHRCHK:	MOVE	T1,ERTYPE
	PUSHJ	P,ERRINT	;FIND OUR INDEX FOR THE CURRENT ENTRY
	SKIPN	T1,ERRIND	;PICKUP ENTRY TYPE
	JRST	XFRBUF		;ALWAYS PASS ENTRY TYPE 0
	MOVE	T1,ERTYPE	;CORRECT INDEX TO ENTCHR TABLE
	MOVE	T2,ENTCHR(T1)	;PICKUP ENTRY CHAR WORD
	TLZ	F,F.BTCK	;CLEAR EXAMINE ENTRY FLAG
	TLNN	T2,E.LALL!E.LNXM!E.LPAR!E.LPER!E.LSUM	;ANY LISTING DESIRED
	JRST	SKIPIT		;SKIP THIS ENTRY
	TLNE	T2,E.LNXM!E.LPAR!E.LPER!E.LSUM	;ANY REASON TO DO BIT CHECKING?
	TLO	F,F.BTCK	;YES-SET FLAG TO DO IT LATER
	MOVE	T3,ERTYPE	;GET CORRECT INDEX
	AOS	ENTCHR(T3)	;NO- BUMP COUNTER
	SETZ	WKINDX,		;CLEAR INDEX INTO BUFFER
XFRBUF:	SKIPG	T1,ENTRWC	;PICKUP ENTRY LENGTH AND CHECK FOR LEGALITY
	JRST	ENTRST		;OPPS TRY TO RESYNC
	MOVNS	T1		;PUT -LENGTH IN T1
	MOVS	WKINDX,T1	;SETUP FOR AOBJ USE
	HRRI	WKINDX,0	;SET RH OF WKINDX TO 0
	TLO	F,F.READ	;NOW LETS DO BUFFER XFER
XFRMOR:	PUSHJ	P,GETWD		;LOOP HERE TO FILL WK BUFFER
	MOVEM	MASTWD,WKBUFF(WKINDX)
	AOBJN	WKINDX,XFRMOR	;IS ALL OF ENTRY IN WKBUFF

XFRDUN:	TLZ	F,F.READ	;SAY THAT BUFFER XFER COMPLETED
	MOVE	T1,ERTYPE
	cain	t1,er.why	;edit#110 reload?
	pushj	p,sumupd##	;yes, update perm counters
	MOVE	T1,ERTYPE	;GET TYPE OF ENTRY
	CAIN	T1,ER.DPE	;DISK ENTRY?
	PUSHJ	P,DVCHAR	;SETUP DEVICE TYPE ETC
	MOVE	T1,ERTYPE
	CAIN	T1,ER.MAG	;MAGTAPE ENTRY?
	PUSHJ	P,TMCHAR	;SETUP
	MOVE	T1,ERTYPE	;AGAIN
	CAIN	T1,ER.MDE	;MASBUS ENTRY?
	PUSHJ	P,MDECHR	;DO THIS ALSO
	move	t1,ERTYPE	;and restore
	CAIN	T1,SEC%MB	;IS THIS A MASSBUS ENTRY FOR TOPS20?
	PUSHJ	P,MBCHAR	;YES-GO SET UP CHARACTERISTICS
	MOVE	P4,ERRIND
	TLNE	F,F.BTCK	;DO WE NEED TO EXAMINE ENTRY TO DETERMINE LISTING
	PUSHJ	P,@BITCHK##(P4)	;GO DO BIT CHECKING
	SKIPN	ERRIND		;[417]
	 JRST	.+3
	TRNE	F,F.REM
	JRST	REMDAT
	SKIPE	ERRIND		;NO HEADER IF NOT FOR THIS SEGMENT
	PUSHJ	P,HDRLST	;OUTPUT HEADER TYPE,DATE,TIME,UPTIME
	MOVE	T2,ALLIND
	HRRZ	T1,PCSTBL##(T2)	
	HLRZ	CTINDX,PCSTBL(T2)	;PICKUP CONTROL TABLE ADDRESS
	JRST	(T1)		;DISPATCH TO ENTRY PROCESSOR SPECIFIED BY PCSTBL


	;ROUTINE TO MOVE RAW DATA ENTRY TO OUTPUT "DAT" FILE
	;IN IMAGE BINARY.  USED WITH /REMOTE SWITCH
	;ADDED WITH [417]

REMDAT::	HRLZ	P1,HEADWC	;SETUP PNTR FOR HEADER
	MOVNS	P1,P1
	HRRI	P1,0

REMDA1:	MOVE	T1,HDBUFF(P1)	;GET A HEADER WORD
	SOS	HEADWC		;ADJUST # DONE
	PUSHJ	P,PUTDAT	;OUTPUT IT
	AOBJN	P1,REMDA1	;AGAIN IF REQ'D

;NOW FOR THE BODY OF THE ENTRY
	HRLZ	P1,ENTRWC
	MOVNS	P1,P1
	HRRI	P1,0
REMDA2:	MOVE	T1,WKBUFF(P1)	;GET AN ENTRY WORD
	SOS	ENTRWC
	PUSHJ	P,PUTDAT
	AOBJN	P1,REMDA2	;AGAIN
	JRST	ABORT		;NO LISTING FOR THIS ENTRY-GETNEXT


	SUBTTL	ENTRY LEVEL SUBROUTINES
	;DATECK -- SUBROUTINE TO COMPARE DATE OF THIS ENTRY AGAINST
	;/BEFORE AND /SINCE IF SPECIFIED BY USER
	;CALL	PUSHJ	P,DATECK
	;
	;RETURN	POPJ	P,	IF WITHIN RANGE
	;	JRST	ABORT	IF OUT OF RANGE
DATECK:	MOVE	MASTWD,HDBUFF+HDRDAT	;PICKUP DATE/TIME WORD IN HEADER
	CAML	MASTWD,STDATE	;IS ENTRY DATE PRIOR TO DEFINED START DATE
	CAML	MASTWD,ENDATE	;IS ENTRY DATE PAST DEFINED END DATE
	JRST	SKIPIT		;YES TO EITHER SAYS DONT DO THIS ENTRY
	POPJ	P,

FILERR:	WARN	<DAEMON HAS FLAGGED ERROR IN SYSTEM ERROR FILE>
	JRST	STBUFF		;PROCESS NEXT ENTRY

TOOBIG:	WARN	<FILE ENTRY LARGER THAN WORKING BUFFER>
	JRST	STBUFF		;GO PROCESS NEXT ENTRY



	;EOFVER MODIFIED BY EDIT 115 TO SUPPORT RE-SYNCING THE ERROR
	;FILE.

EOFVER:	PUSHJ	P,GETWD		;TRY TO GET ANOTHER WORD AFTER EOF
	SKIPE	MASTWD		;=0?
	 JRST	EOFVE1		;NO-OLD FILE FORMAT
	PUSHJ	P,ADVBFF	;TRY TO GET NEXT BLOCK
	WARN	<EOF MARKER FOUND IN BODY OF SYSTEM ERROR FILE>
	JRST	HEADRD		;START ON NEXT ENTRY,SINCE THIS IS
				;1ST BLOCK OF ANOTHER FILE WE SHOULD
				;BE IN SYNC AND THE NEXT WORD HAD 
				;BETTER BE THE START OF AN ENTRY!!!

EOFVE1:	WARN	<EOF MARKER FOUND IN BODY OF SYSTEM ERROR FILE>
	JRST	EOFTRY

VOIDTY:	MOVEM	T1,BADTYP	;SAVE BAD ERROR TYPE
	SETZM	ERRIND		;LET NORMAL DISPATCH TAKE PLACE TO DUMP BUFFER AT DMPBUF
	POPJ	P,		;RETURN



	;DVCHAR -- SUBROUTINE TO GET DEVICE CHARACTERISTICS AND
	;	PUT CONTROLLER TYPE, DEVICE NAME INDEX INTO
	;	STORAGE FOR LATER USE
	;CALL	PUSHJ	P,DVCHAR
	;
	;RETURN	CALL+1

DVCHAR:	MOVE	P3,WKBUFF+HDENAM	;PICKUP DEVICE NAME
	HRLZI	T1,NAMLTH##	;SETUP TO CALL SCAN
	MOVNS	T1,T1		;-NAMLTH TO LH OF T1
	HRRI	T1,NAMTBL##-1	;FINISH SETUP
	PUSHJ	P,.NAME		;DO TABLE LOOKUP
	  JRST BADNAME
	TLZ	T1,-1		;CLEAR LH OF T1
	SUBI	T1,NAMTBL	;CALC OFFSET IN NAME TABLE
	MOVEM	T1,DVINDX	;SAVE IT
	MOVE	T1,WKBUFF+HDEDCR	;PICKUP DEVCHR WORD
	SETZ	T2,		;ASSUME IT IS AN RC10
	TRNE	T1,1B25		;IS IT A RP10
	MOVEI	T2,1		;YES
	TRNE	T1,1B24		;IS IT A RH10?
	MOVEI	T2,4		;YES.
	MOVEM	T2,KONTYP	;SAVE THIS FACT
	SKIPN	T2		;RC10?
	 JRST	RCCHK
	CAIN	T2,1		;RP10?
	 JRST	RPCHK
	MOVEI	T2,4		;MUST BE RS04 ON RH10
	MOVEM	T2,MDEDTP
	POPJ	P,
RCCHK:	TRNE	T1,1B32		;RD10=0
	MOVEI	T2,1
	MOVEM	T2,MDEDTP
	POPJ	P,0
RPCHK:	MOVEI	T3,2
	TRNE	T1,1B31		;RP02?
	MOVEI	T3,3		;MUST BE RP03
	MOVEM	T3,MDEDTP
	POPJ	P,0

	;TMCHAR -- COPY OF DVCHAR  FOR MAGTAPE

TMCHAR:	MOVE	P3,WKBUFF+MAGNAM
	TRNE	P3,7777	;EDIT 132 FUNNY NAME?
	 PUSHJ	P,FIXNAM	;YES GO FIXIT
	HRLZI	T1,NAMLTH	;SETUP TO CALL SCAN
	MOVNS	T1,T1		;-NAMLTH TO LH OF T1
	HRRI	T1,NAMTBL-1	;FINISH SETUP
	PUSHJ	P,.NAME
	JRST	BADNAM
	TLZ	T1,-1
	SUBI	T1,NAMTBL
	MOVEM	T1,DVINDX
	MOVEI	T1,3
	MOVEM	T1,KONTYP
	POPJ	P,0
	;MDECHR - SAME AGAIN FOR MASSBUS DEVICES

MDECHR:	MOVE	P3,WKBUFF+MDENAM
	HRLZI	T1,NAMLTH	;SETUP TO CALL SCAN
	MOVNS	T1,T1		;-NAMLTH TO LH OF T1
	HRRI	T1,NAMTBL-1	;FINISH SETUP
	PUSHJ	P,.NAME				;LET SCAN DO WORK
	 JRST	BADNAM
	TLZ	T1,-1
	SUBI	T1,NAMTBL
	MOVEM	T1,DVINDX
	MOVE	P3,WKBUFF+MDENAM
	HRLZI	T1,MASLTH##
	MOVNS	T1,T1		;-MASLTH TO LH OF T1
	HRRI	T1,MASNAM##-1
	PUSHJ	P,.NAME
	 JRST BADNAM
	TLZ	T1,-1
	SUBI	T1,MASNAM
	MOVEM	T1,MASIND
	MOVE	T2,WKBUFF+MDETYP
	MOVEI	T3,4			;SET FOR RH10 BUT
	TLNN	T2,1B32			;IF OTHER THEN
	 MOVEI	T3,5			;SET FOR OTHER
	MOVEM	T3,KONTYP		;SAVE EITHER
	MOVEM	T3,MASKON		;TWICE
	MOVE	T2,WKBUFF+MDEDDT
	ANDI	T2,77		;TYPE ALONE
	CAIN	T2,2		;RS04?
	 MOVEI	T1,4
	CAIN	T2,20		;RP04
	 MOVEI	T1,5
	CAIN	T2,21		;RP05
	 MOVEI	T1,6
	CAIN	T2,22		;RP06
	MOVEI	T1,7
	MOVEM	T1,MDEDTP
	POPJ	P,0

	;EDIT 132
FIXNAM:	SETZ	P4,0	;SOME STORAGE
	LSHC	P3,-^D6	;REAL # TO P4
	LSH	P3,-^D12	;UNWANTED
	ROTC	P3,^D18	;CORRECTED
	POPJ	P,0		;NOW GO BACK



	;MBCHAR - SETS UP STORAGE OF UNIT TYPE,CONTROLLER TYPE, BUILDS
	;A UNIT NAME,  AND SETS UP INDEX TO TABLES

MBCHAR:	MOVE	T1,WKBUFF+MB%TYP	;GET TYPES
	LDB	T2,[POINT 3,T1,17]	;CONTROLLER TYPE
	SKIPN	T2			;VALID?
	 JRST	MBCHA2			;NOPE!!
	MOVEI	T3,5			;ASSUME RH20
	CAIE	T2,2			;IS IT REALLY?
	 MOVEI	T3,4			;NO SAY RH10
	MOVEM	T3,MASKON		;SAVE IT
	LDB	T2,[POINT 4,T1,35]	;GET UNITTYPE
	HRRZ	T1,WKBUFF+MB%REG+6	;GET DEV TYPE
	ANDI	T1,77
	CAIN	T1,12			;TU45?
	 MOVEI	T2,4			;SAY SO
	CAIN	T1,20		;[315]RP04?
	 MOVEI	T2,1
	CAIN	T1,21		;RP05?
	 MOVEI	T2,5
	CAIN	T1,22		;RP06?
	 MOVEI	T2,6		;END OF [315]
	SKIPN	T2			;VALID?
	 JRST	MBCHA3			;NO???
	MOVEM	T2,MDEDTP		;AND SAVE IT
	HRLZI	T1,'DPX'		;ASSUME A DSK TYPE DEVICE
	CAIN	T2,2			;RS04?
	 HRLZI	T1,'FSX'
	CAIN	T2,3			;TU16?
	 HRLZI	T1,'MTX'
	CAIN	T2,4			;TU45?
	 HRLZI	T1,'MTX'
	MOVE	T2,WKBUFF+MB%CAD	;GETCHANNEL #
	ADDI	T2,20			;CONVERT TO SIXBIT
	DPB	T2,[POINT 6,T1,17]	;STORE IT
	MOVE	T2,WKBUFF+MB%UAD	;GET UNIT ADDR
	ADDI	T2,20			;CONVERT TO SIXBIT
	DPB	T2,[POINT 6,T1,23]	;FINISH THE UNIT NAME
	;EDIT 221
	HRRZ	T2,WKBUFF+MB%REG+11	;GET SLAVE #
	MOVE	T3,MDETYP
	CAIGE	T3,3			;TAPE?
	 SETZ	T2,T2			;NOCLEAR IT
	ANDI	T2,7		;STRIP IT
	ADDI	T2,20			;TO SIXBIT
	DPB	T2,[POINT 6,T1,29]
	;END EDIT 221
	MOVEM	T1,WKBUFF+MB%NAM	;SET IT FOR LATER
	HRRZI	T2,55			;SIXBIT 'M'
	LSH	T1,6		;SHIFT LEFT 1 SIXBIT CHAR
	DPB	T2,[POINT 6,T1,5]	;CHANGE NAME TO 'MXXX'
	MOVE	P3,T1			;SETUP
	HRLZI	T1,MASLT2##
	MOVNS	T1,T1
	HRRI	T1,MASNA2##-1
	PUSHJ	P,.NAME		;THIS WILL FIND INDEX TO THIS UNIT'S
				;PHYSICAL ADDR (CHN#,UNIT #)
	 JRST	BADNAM			;OPPS
	TLZ	T1,-1
	SUBI	T1,MASNA2		;SET A POINTER OR INDEX
	MOVEM	T1,MASIND			;AND STORE IT
	HRLZ	T2,MASKON		;GET KON TYPE BACK
	HRR	T2,MDEDTP		;AND UNIT TYPE
	MOVE	T3,M000T(T1)		;PREVIOUS CHN&UNIT TYPE
			;FOR THIS PHYSICAL ADDR
	SKIPN	T3	;SEEN THIS UNIT BEFORE?
	 JRST	MBCHA1	;NO SO DON'T CHECK
	CAMN	T2,T3	;HAS THE UNIT TYPE CHANGED INTHE ERROR FILE?
	 POPJ	P,0	;NO -- THIS CHECK WILL FAIL IF THE SYSTEM
		;HAS BENEN RECONFIGURED AROUND A BAD CONTROLLER 
			;IE CHN#0 IS NOW USED FOR RP04'S INSTEAD OF TU16'S

	POPJ	P,0;ADD CODE HERE TO COMPLAIN OF CHANGE,DO SUMMARY

MBCHA1:	MOVEM	T2,M000T(T1)		;SAVE CURRENT VALUE
	POPJ	P,0

MBCHA2:	WARN	<CODE 111-CONTROLLER TYPE=0,ABORTING ENTRY!>
	JRST	ABORT		;THAT'S ALL FOE THIS ENTRY
MBCHA3:	WARN	<CODE 111-UNIT TYPE =0,ABORTING ENTRY!>
	JRST ABORT

	;CNISUM -- SUBROUTINE TO PERFORM CONI BIT SUMMATION
	;CALL P2=RETRY ERROR WORD FOR TOPS20,OFFSET TO ETRY WORD FOR TOPS10

		;	P3 = OFFSET OF CONI WORD TO SUMMATE.
	;NOTE THAT DVINDX AND KONTYP MUST BE SETUP FOR CORRECT DEVICE
		;	PUSHJ	P,CNISUM
	;
	;RETURN	CALL+1

CNISUM:	MOVE	T1,DVINDX	;PICKUP INDEX AS SPECIFIED BY DEVICE
	HLRZ	P1,DEVDSP##(T1)	;PICKUP POINTER TO COUNTER BLOCKS
	MOVE	T3,P2	;PICKUP RETRY WORD
	SKIPN	TOPENT		;P2 HOLDS OFFSET IF TOPS10 RECORDED
	MOVE	T3,WKBUFF(P2)	;P2 HOLDS OFFSET NOT VALUE
	TLNN	T3,ERRHRD	;HARD ERROR
	HRRZ	P1,DEVDSP(T1)	;NO-PICKUP SOFTPOINTER
	MOVE	T3,WKBUFF(P3)		;PICKUP 1CONI WORD
	MOVE	T1,KONTYP	;PICKUP CONTROLLER TYPE
	AND	T3,KONMSK##(T1)	;PICKUP CONTROLLER MASK FOR ERROR BITS
	LSH	T3,@MINERB##(T1)	;SHIFT WORD TO CORRESPOND TO FIRST POSSIBLE
					;ERROR BIT IN WORD
DOJFFO:	JFFO	T3,INCREM	;LOOK FOR ERROR BIT
	JRST	JFDONE		;HERE WHEN ALL BITS DONE

INCREM:	MOVE	T1,KONTYP	;PICKUP CONTROLLER TYPE
	MOVE	T1,ERINDX##(T1)	;PICKUP ADDRESS OF ERR BIT TO INDEX BIT CONVERTER
	ADD	T1,T4		;INDEX INTO TABLE BY ERR BIT
	MOVE	T2,(T1)		;GET THE CORRELATED INDEX VALUE
	ADD	T2,P1		;ADD IN DEVICE OFFSET PASSED TO HERE
	AOS	(T2)		;INCREM COUNTER
	ROT	T3,(T4)		;MOVE BIT TO SIGN LOCATION
	TLZ	T3,400000	;CLEAR IT
	MOVNS	T4		;COMP SHIFT COUNT
	ROT	T3,(T4)		;RESTORE WORD TO ORIGINAL POSITION
	JRST	DOJFFO		;LOOP TILL ALL BITS DONE
JFDONE:	POPJ	P,		;JUST DO NORMAL RETURN

	;CNISU2 -- SUBROUTINE TO PERFORM CONI BIT SUMMATION
	;CALL P2=RETRY ERROR WORD FOR TOPS20,OFFSET TO ETRY WORD FOR TOPS10

		;	P3 = OFFSET OF CONI WORD TO SUMMATE.
	;NOTE THAT DVINDX AND KONTYP MUST BE SETUP FOR CORRECT DEVICE
		;	PUSHJ	P,CNISU2
	;
	;RETURN	CALL+1

CNISU2::	MOVE	T1,DVINDX	;PICKUP INDEX AS SPECIFIED BY DEVICE
	HLRZ	P1,DEVDS2##(T1)	;PICKUP POINTER TO COUNTER BLOCKS
	MOVE	T3,P2	;PICKUP RETRY WORD
	SKIPN	TOPENT		;P2 HOLDS OFFSET IF TOPS10 RECORDED
	MOVE	T3,WKBUFF(P2)	;P2 HOLDS OFFSET NOT VALUE
	TLNN	T3,ERRHRD	;HARD ERROR
	HRRZ	P1,DEVDS2(T1)	;NO-PICKUP SOFTPOINTER
	MOVE	T3,WKBUFF(P3)		;PICKUP 1CONI WORD
	MOVE	T1,KONTYP	;PICKUP CONTROLLER TYPE
	AND	T3,KONMSK##(T1)	;PICKUP CONTROLLER MASK FOR ERROR BITS
	LSH	T3,@MINERB##(T1)	;SHIFT WORD TO CORRESPOND TO FIRST POSSIBLE
					;ERROR BIT IN WORD
	JFFO	T3,INCREM	;LOOK FOR ERROR BIT
	JRST	JFDONE		;HERE WHEN ALL BITS DONE

BADNAM:	MOVE T2,P3	;GET THE BAD NAME
	PUSHJ	P,TTYSIX	;LIST IT IN SIXBIT
	WARN	<UNKNOWN DEVICE NAME FOUND IN ENTRY-ABORTING ENTRY>
	JRST	ABORT

	;MASSVM -- SIMILAR TO CNISUM BUT FOR MASSBUS DEVICES
	;P1 = WORD TO SUMMATE
	;P2 = LH  ADDR OF HARD ERROR COUNTER TABLE FOR THIS REG
	; 	ON THIS DEVICE
	;	RH  ADDR OF SOFT ERROR COUNTER
	;P3=  RETRY WORD( HARD OR SOFT ERROR BIT = 1B1)
	;KONTYP MUST BE SET TO POINT AT THIS REGISTER
	; CALL:  PUSHJ	P,MASSVM

MASSVM:	HLRZ	P4,P2		;POINT AT HARD ERROR
	TLNN	P3,ERRHRD		;BUT IF SOFT
	HRRZ	P4,P2		;CHANGE IT
	MOVE	T2,KONTYP	;GET INDEX FOR THIS REG
	MOVE	T1,P1		;GET WORD
	AND	T1,KONMSK(T2)	;ERROR BITS ONLY PLEASE
	LSH	T1,@MINERB(T2)	;MOVED OVER

MASJFF:	JFFO	T1,MASINC	;DI IT
	 POPJ	P,0		;ALL DONE, GO BACK

MASINC:	MOVE	T4,KONTYP
	MOVE	T4,ERINDX(T4)
	ADD	T4,T2
	MOVE	T3,(T4)
	ADD	T3,P4		;T3 NOW = ADDRESS + OFFSET
	AOS	(T3)		;ADD ONE TO COUNTER
	ROT	T1,(T2)		
	TLZ	T1,400000		;CLEAR THE BIT
	MOVNS	T2		;CHANGE SHIFT DIRECTION
	ROT	T1,(T2)		;MOVE IT BACK
	JRST	MASJFF		;DO NEXT

	;DEVCHK -- ROUTINE TO CHECK DEVICE NAME IN ENTRY
	;AGAINST WHAT USER SAID. CAN CHECK FOR "DPA" OR JUST "DP"
	;INSTEAD OF "DPA3"
	;SETUP  P3=OFFSET OF DEVICE NAME IN WKBUFF
	;CALL   PUSHJ P,DEVCHK
	;RETURNS POPJ IF NAMES CHECK
	;JRST ABORT OTHERWISE. CHANGED WITH EDIT 304

DEVCHK:	MOVE	T1,WKBUFF(P3)	;PICKUP ENTRY DEVICE NAME
	CAMN	T1,DEV		;SAME AS ONE USER SPECIFIED?
	POPJ	P,		;YES, LIST IT
	MOVE	T3,DEV	;SETUP
	PUSHJ	P,.MKMSK	;BUILD A MASK
	MOVE	T2,WKBUFF(P3)
	AND	T2,T1	;GET CORRES BITS
	CAME	T2,DEV	;NOW A MATCH?
	 JRST	ABORT	;SORRY...
	POPJ	P,0



	;NDVCHK--ADDED WITH EDIT 325  PERFORMS OPPOSITE FUNCTION
	;	OF DEVCHK ROUTINE TO SUPPORT "/NDEV:" SWITCH

NDVCHK::	MOVE	T1,WKBUFF(P3)	;PICKUP ENTRY DEVICE NAME
	CAMN	T1,NDEV		;SAME AS ONE USER SPECIFIED?
	JRST	ABORT		;YES,DON'T LIST IT
	POPJ	P,0		;NO,RETURN TO OUR CALLER TO CHECK FURTHER

	;ROUTINE TO FIND INDEX INTO TABLES OF ENTRY INFO
	;BASED ON ERROR CODE	.
	;CALL	T1=ERROR CODE
	;	PUSHJ	P,ERRINT
	;RETURN +1 IF INDEX FOUND AND ST]ORED IN ERRIND
	;ELSE JRST SKIPIT AFTER WARNING USER

ERRINT:	MOVEI	T2,ALLLTH##	;GET LENGTH OF TABLE
	SETZB	T3,T4		;WORK SPACE
ERRIN1:	MOVE	T3,ALLTBL##(T4)	;GET NEXT INDEX VALUE
	CAMN	T1,T3		;MATCH?
	JRST	ERRIN2		;YES
	AOS	T4	;UPDATE 
	CAIE	T4,ALLLTH+1	;END OF TABLE?
	JRST	ERRIN1		;NO YET
	WARN	<EXPECTED ERROR CODE NOT FOUND IN TABLE OF SUBJECT ERROR CODES>
	MOVEM	T1,ERRIND
	JRST	DMPENT		;EDIT 141
ERRIN2:	MOVEM	T4,ALLIND	;STORE GOOD INDEX VALUE

	;NOW CHECK TO SEE IF THIS SEGMENT PROCESSES IT
	MOVEI	T2,ERRLTH##	;GET LENGTH OF TABLE
	SETZB	T3,T4		;WORK SPACE
ERRIN3:	MOVE	T3,ERRTBL##(T4)	;GET NEXT INDEX VALUE
	CAMN	T1,T3		;MATCH?
	JRST	ERRIN4		;YES
	AOS	T4	;UPDATE 
	CAIE	T4,ERRLTH+1	;END OF TABLE?
	JRST	ERRIN3		;NO YET

	;IF NOT FOUND ON 2ND SEARCH THIS SEGMENT DOESN'T PROCESS
	;THE ENTRY,BUT WILL GET CORRECT SEGMENT
	;VIA "PROCS-" ROUTINE.  PART OF EDIT #120.
	SETZ	T4,		;SO CLEAR IT
	MOVEM	T4,ERRIND	;AND STORE IT
	POPJ	P,0		;THEN RETURN
ERRIN4:	MOVEM	T4,ERRIND	;STORE INDEX VALUE
	POPJ	P,0		;GO BACK
	;SKIPIT -- SUBROUTINE TO SKIP CURRENT ENTRY IF INVALID
	;CALL	JRST	SKIPIT
	;
	;RETURN	JRST	ABORT

SKIPIT:	MOVE	T1,ENTRWC	;PICKUP TOTAL # WORDS IN HEADER
	PUSHJ	P,SKIPWD	;GO MANUALLY ADVANCE INPUT BUFF POINTER
	JRST	ABORT		;RESET AND GET NEXT ENTRY



	;IDCHK -- SUBROUTINE TO CHECK IF VALUE OF ID
	;IN WKBUFF MATCHES ID USER TYPED.
	;SETUP  P3=OFFSET OF IDWORD IN WKBUFF
	;CALL   PUSHJ  P,IDCHK
	;RETURN POPJ   P,0    IF VALUES MATCH
	;       JRST ABORT      IF NOT.

IDCHK:	MOVE	T1,WKBUFF(P3)	;GET VALUE IN ENTRY
	CAME	T1,ID		;MATCH?
	JRST	ABORT		;NO
	POPJ	P,0		;YES
	;STRCHK - ROUTINE TOCHECK STR NAME IN ENTRY IF /STR SWITCH
	;IS USED VERY SIMILIAR TO IDCHK

STRCHK:	MOVE	T1,WKBUFF(P3)	;GET ENTRY STR
	CAMN	T1,STR			;MATCH?
	 POPJ	P,0			;YES
	AND	T1,STR			;COVER DSKB VS DSKB0
	CAME	T1,STR			;NOW MATCH
	 JRST	ABORT			;SORRY
	POPJ	P,0			;YOU WIN



	;DETCHK-ROUTINE TO TEST IF USER SAID /DETAIL
	;CALL PUSHJ
	;RETURN IF HE SAID /DETAIL ELSE JRST ABORT

DETCHK:	TLNE	F,F.DET	;SAID /DETAIL?
	 POPJ	P,0	;YES HE DID
	TYPEIT	<
=====REST OF INFORMATION AVAILABLE BY USING /DETAIL SWITCH=====
>
	JRST	ABORT	;NOW START NEXT ENTRY

	;HEADFL -- SUBROUTINE TO FILL THE HEADER BUFFER FROM I/O BUFF
	;CALL	PUSHJ	P,HEADFL
	;RETURN	CALL+1
	;HEADER BUFFER FILLER AS SPECIFIED BY HEADWC

HEADFL:	SETZ	WKINDX,		;CLEAR INDEX
	SKIPG	T1,HEADWC	;PICKUP # OF WORDS IN HEADER
	FATAL	<ENTRY WITH ZERO LENGTH HEADER SPECIFIED>
	SUBI	T1,1		;WD0 IS ALREADY IN HDBUFF
	MOVNS	T1
	MOVS	WKINDX,T1	;SETUP FOR AOBJ USE
	HRRI	WKINDX,1	;START AT HDBUFF+1
	TLO	F,F.READ	;SAY THAT EOF IS CLACKERS
XFRHDR:	PUSHJ	P,GETWD
	MOVEM	MASTWD,HDBUFF(WKINDX)	;STORE IT
	AOBJN	WKINDX,XFRHDR	;LOOP
	TLZ	F,F.READ	;SAY DONE WITH FILLING
	MOVE	T1,HDBUFF+HDRDAT	;PICKUP DATE/TIME OF ENTRY
	MOVEM	T1,FILEND	;CONTINUE TO SAVE AS POSSIBLE LAST ENTRY
	TLNE	F,F.ONCE	;IS THIS FIRST ENTRY SEEN IN FILE
	JRST	HDRDUN		;SKIP FOLLOWING ONCE-ONLY CODE
	MOVEM	T1,FILEST	;SAVE
	MOVE	T1,HDBUFF+HDRPSN	;GET SERIAL #
	MOVEM	T1,SYSSER		;SAVE IT FOR SYSERS
	TLO	F,F.ONCE	;SAY ONCE-ONLY CODE IS DONE
HDRDUN:	POPJ	P,		;RETURN

	;DMPENT -- SUBROUTINE TO DUMP UNRECOGNIZED ENTRY
	;JRST	DMPENT
	;REWRITTENWITH EDIT 205
	;RETURN	JRST	ABORT
DMPENT:	WARN	<DUMPING UNKNOWN ERROR TYPE IN OCTAL>
	TYPEIT	<DUMPING UNKNOWN ERROR IN OCTAL
>
	TYPEIT	<
ERROR CODE =	>
	MOVE	T1,ERRIND	;GET OFFSET
	PUSHJ	P,.TOCTW

	PUSHJ	P,.TCRLF
	MOVE	P1,HDBUFF		;GET WORD 0
	LDB	T1,[POINT 6,P1,23]	;GET HDR VER
	SKIPE	T1		;0=VER 0
	SETOM	HDVER1		;REMEMBER
	SKIPE	HDVER1		;DID WE JUST SET IT?
	LDB	T1,[POINT 3,P1,26]	;YES
	SKIPN	HDVER1		;CHECK AGAIN
	LDB	T1,[POINT 3,P1,29]	;GET 3 BITS OF HDR LENGTH
	MOVEM	T1,HEADWC	;SAVE WHICHEVER WE GOT
	SKIPE	HDVER1		;TRY AGAIN
	LDB	T1,[POINT 9,P1,35]	;VER 1=GET 9BITS OF BODY LENGTH
	SKIPN	HDVER1		;VER 0?
	LDB	T1,[POINT 6,P1,35]	;YES, GET 6 BITS
	MOVEM	T1,ENTRWC	;SAVE EITHER
	ADD	T1,HEADWC
	MOVEM	T1,TOTWC	;SAVE TOTAL # WDS IN ENTRY
	PUSHJ	P,HEADFL		;FILL UP HEADER BUFFER
	SKIPG	T1,ENTRWC	;PICKUP ENTRY LENGTH AND CHECK FOR LEGALITY
	JRST	ENTRST
	MOVNS	T1		;PUT -LENGTH IN T1
	MOVS	WKINDX,T1	;SETUP FOR AOBJ USE
	HRRI	WKINDX,0	;SET RH OF WKINDX TO 0
	TLO	F,F.READ	;NOW LETS DO BUFFER XFER
DMPMOR:	PUSHJ	P,GETWD		;LOOP HERE TO FILL WK BUFFER
	MOVEM	MASTWD,WKBUFF(WKINDX)
	AOBJN	WKINDX,DMPMOR	;IS ALL OF ENTRY IN WKBUFF

HEADDM:	TYPEIT	<HEADER:
>
	SETZ	WKINDX,		;ZERO WORKING INDEX BUFFER
	MOVE	T1,HEADWC	;PICKUP HEADER ZE
	MOVNS	T1
	MOVS	WKINDX,T1	;SET_P FOR AOBJ USE
	HRRI	WKINDX,0	;CLEAR RH OF WKINDX
	ADDI	WKINDX,HDBUFF	;SET FOR START AT HDBUFF
	PUSHJ	P,DUMPIT	;DUMP HEADER
BODYDM:	TYPEIT	<
BODY:
>
	SETZ	WKINDX,
	MOVE	T1,ENTRWC	;PICKUP BODY OF ENTRY SIZE
	MOVNS	T1
	MOVS	WKINDX,T1	;SETUP FOR AOBJ USE
	HRRI	WKINDX,0	;CLEAR RH OF WKINDX
	ADDI	WKINDX,WKBUFF	;SET START OF DUMP AT WKBUFF
	PUSHJ	P,DUMPIT
	JRST	ABORT		;GO PROCESS NEXT ENTRY
DUMPIT:	MOVE	P1,(WKINDX)	;PICKUP CORRECT WORD
	PUSHJ	P,.TCRLF
	MOVE	T1,P1		;PUT WORD IN T1 FOR OUTPUT
	PUSHJ	P,.TXWDW	;GO OUTPUT IT
	AOBJN	WKINDX,DUMPIT	;LOOP TILL ENTRY DUMPED
	POPJ	P,		;RETURN

	;HDRLST -- SUBROUTINE TO TYPE HEADER INFORMATION
	;SUCH AS ENTRY TYPE, DATE OF LOGGING
	;TIME OF LOGGING, AND UPTIME OF SYSTEM AT TIME OF LOGGING
	;CALL	PUSHJ	P,HDRLST
	;
	;RETURN	CALL+1

HDRLST:	MOVE	T1,LINCNT
	MOVE	P4,ERRIND	;PICKUP ENTRY TYPE
	ADD	T1,LINE##(P4)	;ADD COUNT OF LINES IN NEXT ENTRY TO CURRENT LINE COUNT
	MOVEM	T1,LINCNT	;SAVE NEW LINE COUNT
	CAILE	T1,PAGLM	;EXCEEDING PAGE LIMIT SPECIFIED?
	PUSHJ	P,PAGXCD	;YES-WRAP UP WITH SUMMARY
	CAILE	T1,0		;CAN WE PRINT THIS ENTRY WITHOUT OVERFLOWING PAGE?
	JRST	HDRPNT		;GO DO HEADER TYPEOUT
	PUSHJ	P,.TCRLF
	PUSHJ	P,.TCRLF
	TYPEIT	<***********************************************
>
	HLRZ	T1,HDBUFF+HDRCOD
	TRNE	T1,CSHENT	;ENTRY EXTRACTED FROM A CRASH?
	 PUSHJ	P,CSHPNT	;YES-SAY SO
	MOVE	T1,ERRIND
	MOVE	T1,TYPMES##(T1)	;PICKUP APPROPIATE TEXT MESSAGE FOR HEADER
	PUSHJ	P,.TSTRG
	SKIPE	TOPENT	;TOPS20 RECORDED?
	 JRST HDRLSA	;YES
	TYPEIT	< LOGGED ON >
HDRLS1:	MOVE	T1,HDBUFF+HDRDAT	;PICKUP DATE OF ENTRY CURRENTLY BEING PROCESSED
	PUSHJ	P,GETNBS
	PUSHJ	P,.TCRLF
	TYPEIT	<AT >
	MOVE	T1,MSTIMX
	PUSHJ	P,.TTIME	;GO CONVERT TO HH:MM:SS AND OUTPUT
HDRLSB:	TYPEIT	<      MONITOR UPTIME WAS >
	HLRZ	T1,HDBUFF+HDRUPT	;PICKUP LH OF NBS DATE/TIME WORD
	CAIE	T1,0
	PUSHJ	P,SAYDAY	;DECODE #DAYS UPTIME IF ANY
	HRRZ	T1,HDBUFF+HDRUPT	;PICKUP RH OF DATE/TIME WORD
	HRL	T1,DUMDAY##	;PUT DUMMY NON-ZERO DAY IN LH
	PUSHJ	P,.CNTDT	;CONVERT TO 12 BIT FORMAT
	PUSHJ	P,.TTIME	;GO DECODE UPTIME AS HH:MM:SS
	SKIPE	HDVER1		;MORE TO LIST
	 PUSHJ	P,HD1PNT	;DO S/N

	TYPEIT	<
***********************************************
>
	POPJ	P,


	;MODIFIED WITH EDIT 426
HDRLSA:	PUSHJ	P,.TCRLF
	PUSH	P,P1	;SAVE AC5
	TYPEIT	< LOGGED ON >
	MOVE	T2,HDBUFF+HDRDAT
	SKIPN	TOPMON		;TOPS20 RUNNING?
	 PJRST	HDRLS1	;NO,DO TEN STYLE
	HRLZI	T4,400000		;USE DAYLIGHT SAVINGS AND LOCAL ZONE
	ODCNV
	HRROI	T1,DATLOC	;WHERE TO STORE IT
	HRLZI	P1,202000	;FORMAT FOR OUTPUT
	ODTNC
	HRRZI	T1,DATLOC	;ADDR ONLY
	PUSHJ	P,.TSTRG	;NOW LIST IT
	POP	P,P1		;RESTORE AC5
	JRST	HDRLSB		;NOW RETURN



	;HDRPNT -- SUBROUTINE TO DO PAGE HEADER AND GIVE FORM FEED
	;CALL	JRST	HDRPNT
	;
	;RETURN	JRST	HDRLST

HDRPNT:	PUSHJ	P,TITLST	;GO DO TITLE INFO
	JRST	HDRLST		;NOW  TYPE ENTRY


	;ROUTINE TO PRINT VERSION 1 ENTRY HEADER
	;CALLED FROM HDRLST WITH PJRST

HD1PNT:	TYPEIT	<
	DETECTED ON SYSTEM # >
	MOVE	T1,HDBUFF+HDRPSN	;S/N
	PUSHJ	P,.ODECW
	POPJ	P,0

CSHPNT:	TYPEIT	<  ** THIS ENTRY COPIED FROM A SAVED CRASH **>
	PUSHJ	P,.TCRLF
	POPJ	P,0
	;PAGXCD -- SUBROUTINE TO HANDLE EXCEEDED PAGE LIMIT OCCURENCE
	;CALL	PUSHJ	P,PAGXCD
	;
	;RETURN	CALLS SUMLST AND EXITS

PAGXCD:	WARN	<EXCEEDED PAGE LIMIT...PERFORMING SUMMARY>
	TYPEIT	<

*************   PAGE LIMIT EXCEEDED **************>
	JRST GOSUM	;EDIT 120 SUMMARY REQUIRES AN OVERLAY!!

	CLOSE	INPCHN,
	CLOSE	OUTCHN,
	EXIT

	;SAYDAY -- SUBROUTINE TO EXAMINE LH OF NBS DATE/TIME WORD AND TYPEOUT
	;# OF DAYS REPRESENTED IN DECIMAL
	;SETUP	T1=LH NBS DATE/TIME WORD
	;CALL	PUSHJ	P,SAYDAY
	;
	;RETURN	CALL+1

SAYDAY:	PUSH	P,T1		;SAVE T1
	PUSHJ	P,.TDECW	;TYPE OUT # IN T1
	POP	P,P4
	SUBI	P4,1		;GET # DAYS -1
	JUMPG	P4,SAYDA1	;WASSYSTEM UP FOR MORE THAN 1 DAY
	TYPEIT	< DAY >
	JRST	SAYRET		;RETURN TO CALLER
SAYDA1:	TYPEIT	< DAYS >
SAYRET:	POPJ	P,

	;GETNBS -- SUBROUTINE TO OUTPUT DATE IN MM-DD-YYYY FORMAT
	;GETNBS -- CONVERTS FROM NBS FORMAT TO MM-DD-YYYY
	;SETUP	T1=NBS DATE/TIME WORD
	;CALL	PUSHJ	P,GETNBS


GETNBS:	SKIPE	TOPMON	;[323]TOPS20 RUNNING?
	 PJRST	GETNB1		;YES-DO TOPS20 STYLE
GETNB2:	PUSHJ	P,.CNTDT
	MOVEM	T1,MSTIMX	;STORE FRACTIONAL PART OF DAY IN MSTIMX
	MOVE	T1,T2		;PICKUP 12 BIT DATE IN T1 AS RETURNED FROM .CNTDT
	PUSHJ	P,.TDATE	;GO TYPE DATE
	POPJ	P,0

GETNB1:	SKIPN	TOPENT	;TOPS20 RUNNING TOPS20 ENTRY?
	PJRST	GETNB2
	PUSH	P,P1		;SAVE AC5[430]
	MOVE	T2,T1		;DATE TIME TO T2
	HRLZI	T4,400000	;DAYLIGHT & LOCAL TIME
	ODCNV
	HRROI	T1,DATLOC
	HRLZI	P1,202000
	ODTNC
	HRRZI	T1,DATLOC
	PUSHJ	P,.TSTRG	;NOW DUMP THE ASCIZ.
	POP	P,P1	;RESTORE AC5
	POPJ	P,0

	SUBTTL	WORD LEVEL SUBROUTINES

.OCTLE:	HRRZ	T1,P1		;PICKUP POINTER TO ASCIZ TEXT
	PUSHJ	P,.TSTRG
	MOVE	T1,P2		;PICKUP WORD TO BE OUTPUT
	PJRST	.TOCTW		;SIGNED NUM TYPEOUT

.DECML:	HRRZ	T1,P1		;PICKUP POINTER TO ASCIZ TEXT
	PUSHJ	P,.TSTRG
	MOVE	T1,P2		;PICKUP WORD TO BE OUTPUT
	PUSHJ	P,.ODECW
	POPJ	P,		;GO AWAY

.ASCIE:	HRRZI	P2,WKBUFF(T2)
	HRRZ	T1,P1		;PICKUP POINTER TO ASCIZ TEXT
	PUSHJ	P,.TSTRG
	MOVE	T1,P2		;PICKUP WORD TO BE OUTPUT
	PJRST	.TSTRG

.SIXBT:	HRRZ	T1,P1		;PICKUP POINTER TO ASCIZ TEXT
	PUSHJ	P,.TSTRG
	MOVE	T1,P2		;PICKUP WORD TO BE OUTPUT
	PJRST	.TSIXN

.HAFWD:	HRRZ	T1,P1		;PICKUP POINTER TO ASCIZ TEXT
	PUSHJ	P,.TSTRG
	MOVE	T1,P2		;PICKUP WORD TO BE OUTPUT
	PJRST	.TXWDW

.SPECL:	PUSHJ	P,(P1)
	POPJ	P,
	;SUBROUTINE TO TYPE OUT A TIME WORD WHERE
	; LH = # DAYS, NOT DATE
	; RH =  1/3SEC(TOPS10) SINCE MIDNIGHT

.HTIME:	MOVE	T1,P1		;GET CORRESPONDING ASCIZ TEXT POINTER
	PUSHJ	P,.TSTRG	;DUMP IT
HTIME2::	HLRZ	T1,P2		;GET # DAYS INTO T1
	SKIPE	T1		;IF 0 DONT BOTHER OR
	PUSHJ	P,SAYDAY	;OUTPUT DAY OR DAYS
	HRRZ	T1,P2		;GET TIME SINCE MIDNIGHT
	SKIPE	TOPENT		;[201]TOPS20 RECORDED
	 MULI	T1,^D333	;CONVERT TO 1/3 SECONDS
	PJRST	.TTIME		;NOW OUTPUT WHAT YOU GOT

	;PPNWW--SUBROUTINETO DUMP [P,PN]

.PPNWW:	HRRZ	T1,P1
	PUSHJ	P,.TSTRG
	MOVE	T1,P2
	PJRST	.TPPNW


.ODECW:	PUSHJ	P,.TDECW	;GO TYPEOUT IN DECIMAL
	TYPEIT	<.>
	POPJ	P,		;SCRAM


.UDATE:	MOVE	T1,P1	;DUMP COMMENTS
	PUSHJ	P,.TSTRG
	MOVE	T1,P2
	PJRST	GETNBS		;UNIVERSAL FORMAT DATE DUMPER


.TASCI:	MOVE	T1,P1		;PTR TO COMMENTS
	PUSHJ	P,.TSTRG
	SKIPN	P2			;ANYTHING IN BUFFER?
	 POPJ	P,0			;NO-RETURN IMMED.
	MOVEI	T1,WKBUFF(P2)		;OUR POINTER TO FILE'S TEXT
	SKIPN	0(T1)		;ANYTHING THERE?
	 POPJ	P,0		;NOPE
	PJRST	.TSTRG


.PPNWT:	HRRZ	T1,P1
	PUSHJ	P,.TSTRG
	MOVE	T1,P2
	PJRST	.TDIRW		;DO THE REAL TRANSLATION


.TDIRW:	MOVE	P1,T1		;SAVEW THE WORD
	HRLI	T1,-1
	HRRI	T1,DATLOC	;STRING STORAGE
	MOVE	T2,P1		;FIRST HALF
	DIRST
	 JRST	.TDIR1
	HRRZI	T1,DATLOC
	PUSHJ	P,.TSTRG	;DUMP IT
	POPJ	P,0	;GO BACK

.TDIR1:	TYPEIT	<UNKNOWN>
	POPJ	P,0
	

	;LST36 - ROUTINE TO LIST A WORD IN T1 AS (T2) OCTAL
	;	CHARACTERS INCL. LEADING ZEROS. ^D12 IS
	;	DEFAULT VALUE IF T2 IS 0 AND WORD MUST BE LEFT
	;	JUSTIFIED IN T1.

LST36::	PUSHJ	P,SAVE4P	;PRESERVE P1-P4
	MOVE	P1,T2		;# TO PRINT
	SKIPN	T2		;USE DEFAULT?
	 MOVEI	P1,^D12		;YES
	MOVE	T2,T1
LST36A:	MOVEI	T1,0
	ROTC	T1,3		;3 BITS TO T1
	ADDI	T1,60		;CONVERT TO ASCIZ
	PUSHJ	P,.TCHAR	;LIST IT
	CAIN	P1,7		;TIME FOR A DELIMITER?
	 PUSHJ	P,.TCOMA	;YES USE A COMMA
	SOJG	P1,LST36A	;DO ANOTHER
	PUSHJ	P,RET4P		;RESTORE P1-P4
	POPJ	P,0		;RETURN TO OUR CALLER

;RADIX 50 TO SIXBIT CONVERTER FOR PDP-11 WORDS.
;THIS CODE STOLEN FROM FILEX.MAC
;CALL WITH RAD50 VALUE IN RH OF T1
;RETURNS WITH SIXBIT IN RH OF T1
R5VSIX:	SETZM	P1		;CLEAR ANSWER CELL
	MOVE	T3,[POINT 6,P1,17]	;PNTR FOR OUTPUT
	ANDI	T1,177777	;GOOD SIZE
	IDIVI	T1,3100		;GET FIRST CHAR
	PUSH	P,T2		;SAVE OTHER 2
	PUSHJ	P,R5VOU1	;OUTPUT FIRST
	POP	P,T1		;RESTORE 2&3
	IDIVI	T1,50		;SPLIT APART
	PUSH	P,T2		;SAVE THIRD
	PUSHJ	P,R5VOU1	;OUTPUT 2ND
	POP	P,T1		;RESTORE 3RD
	PUSHJ	P,R5VOU1	;CONVERT
	MOVE	T1,P1
	POPJ	P,0		;RETURN

R5VOU1:	IDIVI	T1,6
	LDB	P2,R5VOU2(T2)	;GET CHAR IN SIXBIT
	IDPB	P2,T3		;PUT IT IN P3
	POPJ	P,0		;AND RETURN IT
R5VOU2:POINT	6,R5VTAB(T1),5
	POINT	6,R5VTAB(T1),11
	POINT	6,R5VTAB(T1),17
	POINT	6,R5VTAB(T1),23
	POINT	6,R5VTAB(T1),29
	POINT	6,R5VTAB(T1),35
R5VTAB:	SIXBIT	\ ABCDEFGHIJKLMNOPQRSTUVWXYZ.%0123456789?\

	;SPECIAL DECODING ROUTINES

MONVER:	TYPEIT	(<
	MONITOR VERSION  %>)
	LDB	T1,[POINT 12,P2,29]	;EDIT 106
	PUSHJ	P,.TOCTW		;OUTPUT MAJOR
	LDB	T1,[POINT 6,P2,35]	;NOW MINOR
	JUMPE	T1,MONVC		;IF ANY
	SOS	T1			;MAKE ALPHA OFFSET
	IDIV	T1,"Z"-"A"
	JUMPE	T1,MONVS2
	ADDI	T1,"A"
	PUSH	P,T2
	PUSHJ	P,.TCHAR
	POP	P,T2
MONVS2:	MOVEI	T1,"A"(T2)	;GET LOW LETTER
	PUSHJ	P,.TCHAR
MONVC:	MOVEI	T1,"("
	PUSHJ	P,.TCHAR
	LDB	T1,[POINT 18,P2,17]	;CUST VER
	PUSHJ	P,.TOCTW
	MOVEI	T1,")"
	PUSHJ	P,.TCHAR
	POPJ	P,0
DAEVER::	TYPEIT	(<
	DAEMON VERSION  >)
	LDB	T1,[POINT 9,P2,11]	;EDIT 106
	PUSHJ	P,.TOCTW		;OUTPUT MAJOR
	LDB	T1,[POINT 6,P2,17]	;NOW MINOR
	JUMPE	T1,DAEVC		;IF ANY
	SOS	T1			;MAKE ALPHA OFFSET
	IDIV	T1,"Z"-"A"
	JUMPE	T1,DAEVS2
	ADDI	T1,"A"
	PUSH	P,T2
	PUSHJ	P,.TCHAR
	POP	P,T2
DAEVS2:	MOVEI	T1,"A"(T2)	;GET LOW LETTER
	PUSHJ	P,.TCHAR
DAEVC:	MOVEI	T1,"("
	PUSHJ	P,.TCHAR
	LDB	T1,[POINT 18,P2,35]	;CUST VER
	PUSHJ	P,.TOCTW
	MOVEI	T1,")"
	PUSHJ	P,.TCHAR
	POPJ	P,0

BADADD:	SKIPL	P2,AOBPNT	;GET THE AOBJN POINTER
	POPJ	P,		;EXIT IF NOT NEGATIVE
	TYPEIT	<

ADDRESSES DETECTED BY SWEEP
>
TAB031:	PUSHJ	P,TBPRNT	;HORIZ. TAB
	MOVE	T1,WKBUFF(P2)	;GET AN ADDRESS
	PUSHJ	P,.TOCTW	;DUMP IT IN OCTAL
	PUSHJ	P,.TCRLF	;CRLF
	AOBJN	P2,TAB031	;GET ANOTHER
	POPJ	P,

TYPAST:	TYPEIT	<*  >
	POPJ	P,

BLDPTR:	HRRZ	T1,P1	;OFFSET ALONE
	SUB	T1,HEADWC
	ADDI	T1,WKBUFF
	HRR	P1,T1
	POPJ	P,0



	;ACLST-ROUTINE TO LIST CONTENTS OF 16 AC'S
	;SETUP P1 AS AOBJN POINTER W RH = OFFSET TO 1ST

ACLST:	HLLZ	P2,P1		;SECOND POINTER
	PUSHJ	P,.TCRLF
	MOVE 	T1,ACREG(P2)		;SIXBIT NAME OF REG
	PUSHJ	P,.TSIXN
	PUSHJ	P,.TTABC
	MOVE	T1,WKBUFF(P1)	;VALUE TO DUMP
	PUSHJ	P,.TXWDW		;IN HALF WORD
	AOBJN	P2,.+1
	AOBJN	P1,ACLST+1	;ALWAYS GET TO SECOND AOBJN
	POPJ	P,0		;ALL DONE-RETURN TO CALLER

ACREG:	SIXBIT/    0:/
	SIXBIT/    1:/
	SIXBIT/    2:/
	SIXBIT/    3:/
	SIXBIT/    4:/
	SIXBIT/    5:/
	SIXBIT/    6:/
	SIXBIT/    7:/
	SIXBIT/   10:/
	SIXBIT/   11:/
	SIXBIT/   12:/
	SIXBIT/   13:/
	SIXBIT/   14:/
	SIXBIT/   15:/
	SIXBIT/   16:/
	SIXBIT/   17:/



	;ALITTLEROUTINE TO SAVE AND RETURN P1-P4
SAVE4P:	MOVEM P1,SAVEAC
	MOVEM P2,SAVEAC+1
	MOVEM	P3,SAVEAC+2
	MOVEM P4,SAVEAC+3
	POPJ	P,0

RET4P:	MOVE	P1,SAVEAC
	MOVE	P2,SAVEAC+1
	MOVE	P3,SAVEAC+2
	MOVE	P4,SAVEAC+3
	POPJ	P,0


	;HWDUMP -- ROUTINE TO DUMP REGISTER INFORMATION  AT ERROR
	;AT END, DIFF AND TEXT TRANSLATION.
	;IF WORD IN ENTRY IS 0 - NO OUTPUT
	;SETUP P1 = PRINT MODE,,#ITEMS IN LIST
	;	WHERE PRINT MODE 1= HALF WORD OCTAL
	;		         2=  "    "    8 BIT LEFT JUS BYTES(NOT IMPLEMENTED
	;			 3= FULL WORD OCTAL
	;			 4=  "     "   8 BIT LEFT JUSTIFIED BYTES
	;      P2 = ADDR OF ITEM TITLE TABLE, ADDR OF CONTROL TABLE
	;	P3 = OFFSET IN WKBUFF OF "AT ERROR" WORD (1ST),,
	;		OFFSET TO "AT END" WORD
	;CALL- PUSHJ	RETURN POPJ

	;FIRST SOME TABLE GENERATIONS
LISTIT:	XWD	0,NOTRAN
	XWD	0,LSTHO
	XWD	0,LSTHB
	XWD	0,LSTFO
	XWD	0,LSTFB
CHKLXT:	XWD	0,NOTRAN
	XWD	0,CHKLSH
	XWD	0,CHKLSH
	XWD	0,CHKLSF
	XWD	0,CHKLSF
HWDUMP:MOVEM	P1,ITCNT		;SAVE ITERATION COUNT
	MOVEM	P2,ADCNT		;AND ADDR
	MOVEM	P3,OFFCNT		;SAVE FIRST OFFSETS TOO
	SETZM	PASCNT			;OK
HWDCON:	HRRZ	T1,ITCNT		;GET #OF ITERATIONS
	CAMG	T1,PASCNT		;DONE ENOUGH?
	 POPJ	P,0			;YES
	HRRZ	P1,PASCNT		;GET INDEX
	HLRZ	P2,ITCNT		;PRINT MODE
;[307]	PUSHJ	P,@CHKLXT(P2)		;GO SEE IF NEXT ENTRY SHOULD
					;BE PRINTED  =0?
;[307]	 JRST	HWDC00			;NO-JUST UPDATE COUNTER
	PUSHJ	P,.TTABC
	HLRZ	T1,ADCNT		;GET BASE ADDR OF TITLES
	ADD	T1,P1
	MOVE	T1,(T1)		;GET SIXBIT REGISTER NAME
	PUSHJ	P,.TSIXN		;DUMP IT
	PUSHJ	P,.TCOLN
	PUSHJ	P,.TTABC
	PUSHJ	P,@LISTIT(P2)	;GO DO LISTING OF VALUES,RETURN TO
				;WORRY ABOUT ALL X-LATION, CALLED
				;ROUTINES LEAVE WORD TOBE X-LATED
				;IN P2 AND LEAVE P1 INTACT.
	;NOW TO TRANSLATE THOSE ONE'S & ZEROS

	HRRZ	T1,ADCNT		;GET BASE OF CONTROL TABLE
	ADD	T1,P1		;FUTURE CONTENTS OF KONTYP
	HLRE	T1,(T1)
	MOVEM	P1,PASCNT		;SAVE INDX FOR NOW
	JUMPL	T1,HDWC01		;SPECIAL CASE
	MOVEM	T1,KONTYP		;SETTUP
	HRRZ	P4,ADCNT		;SETUP
	ADD	P4,P1			;ADDR OF XXXXDV(BIT/TEXT TABLE)
	HRRZ	P4,(P4)
	AND	P2,KONMSK(T1)		;STRIP UNWANTED BITS
	LSH	P2,@MINERB(T1)		;MOVE IT OVER
	PUSHJ	P,JFLOOP		;GO DECODE
	TLNE	F,F.JFFO		;SEE ANY ERRORS?
	 JRST HDWC02			;YES
	TYPEIT	<NO ERROR BITS DETECTED>
HDWC02:	AOJ	P1,
	MOVEM	P1,PASCNT	;STORE NEW INDX
	PUSHJ	P,.TCRLF		;LOOKS BETTER THIS WAY
	JRST	HWDCON			;START ON NEXT LINE
	;HERE TO CALL SPECIAL BIT TRANSLATORS
HDWC01:	MOVE	T1,P2			;GET ERROR WORD FOR ROUTINE
	HRRZ	P3,ADCNT		;INDEX
	ADD	P3,P1		;SETUP ROUTINE ADDRESS
	HRRZ	P3,(P3)
	PUSHJ	P,(P3)			;GOTO THAT ROUTINE

	;****CALLED ROUTINES MUST LEAVE P1 INTACT****
	PUSHJ	P,.TCRLF		;START NEXT LINE ON PAPER
	AOJ	P1,			;COME BACK HERE
	MOVEM	P1,PASCNT		;STORE NEW VALUE
	JRST	HWDCON			;DO IT OVER AGAIN

	;SMALL DUMMY ROUTINE USED IF NO BIT TRANSLATION
	;IS DESIRED--NOTRAN--
NOTRAN:	POPJ	P,0	;EASY HUH?


HDWXXX:	TYPEIT	<   >
	SETZ	T1,		;MAKE IT BLANK
	POPJ	P,0		;USED TO FILL BLANKS
LSTHO:	HRRZ	T1,OFFCNT	;OFFSET
	ADD	T1,P1	;CURRENT INDEX
	MOVS	P2,WKBUFF(T1)
	HLRZ	T1,P2
	skipn	t1			;anything there?
	PUSHJ	P,HDWXXX
	pushj	P,.TOCTW		;DUMP IT
	PUSHJ	P,.TTABC
	PUSHJ	P,.TTABC		;YET ANOTHER
	HRRZ	T1,P2			;GET ENDING WORD
	skipn	t1			;anything there?
	PUSHJ	P,HDWXXX
	PUSHJ	P,.TOCTW		;AT LEAST THIS IS A GOOD TEST
					;OF PUSHJ' & POPJ'S.
	PUSHJ	P,.TTABC		;KEEP ON TESTIN'
	PUSHJ	P,.TTABC
	HLRZ	T2,P2			;GET LH ALONE
	HRRZ	T1,P2			;RH ALONE
	XOR	T1,T2			;DIFFERENCE TO T1
	skipn	t1
	PUSHJ	P,HDWXXX
	PUSHJ	P,.TOCTW
	PUSHJ	P,.TTABC		;WHY STOP NOW
	PUSHJ	P,.TTABC
	POPJ	P,0		;THAT'S ALL FOLKS
LSTHB:	POPJ	P,0	;FOR NOW

LSTFO:	HLRZ	T1,OFFCNT	;ERROR WORD FIRST
	ADD	T1,P1
	MOVE	T1,WKBUFF(T1)
	MOVE	P4,T1
	PUSHJ	P,.TXWDW
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TTABC
	HRRZ	T1,OFFCNT	;END WORD NOW
	ADD	T1,P1
	MOVE	T1,WKBUFF(T1)
	MOVE	P3,T1
	PUSHJ	P,.TXWDW
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TTABC
	XOR	P3,P4
	MOVE	T1,P3
	PUSHJ	P,.TXWDW
	PUSHJ	P,.TTABC
	MOVE	P2,P4		;WORD TO TRANSLATE
	POPJ	P,0		;GO BACK

LSTFB:	PUSH	P,P1	;SAVE P1
	HLRZ	P2,OFFCNT	;ERROR WORD FIRST
	ADD	P2,P1
	MOVE	P1,WKBUFF(P2)
	MOVE	P4,P1
	PUSHJ	P,TYPBYT	;DUMPIT
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TTABC
	POP	P,P1		;GET INDEX BACK BUT
	PUSH	P,P1		;STILL SAVE IT
	HRRZ	P2,OFFCNT	;END WORD NOW
	ADD	P2,P1	
	MOVE	P1,WKBUFF(P2)
	MOVE	P3,P1
	PUSHJ	P,TYPBYT
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TTABC
	XOR	P3,P4
	MOVE	P1,P3
	PUSHJ	P,TYPBYT
	PUSHJ	P,.TTABC
	POP	P,P1		;RESTORE INDEX
	MOVE	P2,P4		;X-LATE ERROR WORD
	POPJ	P,0


TYPBYT:	LDB	T1,[POINT 8,P1,7]	;GET FIRST
	PUSHJ	P,.TOCTW		;IN OCTAL
	PUSHJ	P,.TSPAC		;SPACE IN BETWEEN
	LDB	T1,[POINT 8,P1,15]	;GET SECOND
	PUSHJ	P,.TOCTW		;IN OCTAL
	PUSHJ	P,.TSPAC		;SPACE IN BETWEEN
	LDB	T1,[POINT 8,P1,23]	;GET THIRD
	PUSHJ	P,.TOCTW		;IN OCTAL
	PUSHJ	P,.TSPAC		;SPACE IN BETWEEN
	LDB	T1,[POINT 8,P1,31]	;GET LAST
	PUSHJ	P,.TOCTW		;IN OCTAL
	POPJ	P,0			;GO BACK

CHKLSH:	HRRZ	T1,OFFCNT	;STARTING OFFSET
	ADD	T1,P1		;CURRENT INDEX
	MOVE	T1,WKBUFF(T1)
	SKIPE	T1		;LIST IT?
	 AOS	0(P)
	POPJ	P,0		;YES

CHKLSF:	HLRZ	T1,OFFCNT	;ERROR WORD FIRST
	ADD	T1,P1		;CURRENT INDEX
	MOVE	T1,WKBUFF(T1)
	SKIPE	T1		;VALUE =0?
	 JRST	SKPRTN		;NO-LIST IT
	HRRZ	T1,OFFCNT	;YES-CHECK END WORD
	ADD	T1,P1		;CURRENT INDEX
	MOVE	T1,WKBUFF(T1)
	SKIPE	T1		;THIS ONE =0?
	 AOS	0(P)		;NO LIST
	POPJ	P,0		;GO BACK EITHER WAY

HWDC00:	AOS	P1	;JUST BUMPCOUNTER
	MOVEM	P1,PASCNT
	JRST	HWDCON	;AND TRY NEXT



	;TYPBCD-- ROUTINE TO TYPE AN 8 CHAR. BCD NUMBER
	;	LEFT JUSTIFIED IN P1

TYPBCD:	PUSH	P,P3			;SAVE IT
	TLZ	F,F.SAWD		;HAVENT SEEN ANY YET
	MOVE	T4,[POINT 4,P1,]	;BUILD BYTE POINTER
	MOVEI	P3,10			;OUR PASS COUNTER
TYPBC0:	SKIPG	P3		;=0?
	 JRST	TYPBC2			;YUP
	ILDB	T1,T4			;GET ONE
	SKIPN	T1		;=0?
	 JRST	TYPBC1			;YA CKECK SOME MORE
	TLO	F,F.SAWD
	PUSHJ	P,.TDECW		;TYPE IT IN DECIMAL
	PUSHJ	P,.TSPAC		;TYPE A SPACE TO FORMAT
	SOJA	P3,TYPBC0		;UPDATE COUNTER
TYPBC1:	TLNN	F,F.SAWD	;SEEN ANY YET?
	JRST	.+3		;NOT YET
	 PUSHJ	P,.TDECW		;YES LIST THIS ONE TOO
	PUSHJ	P,.TSPAC
	SOJA	P3,TYPBC0		;GO GET NEXT
TYPBC2:	POP	P,P3			;RETURN IT
	POPJ	P,0			;RETURN
	;LSTEB -A ROUTINE TO LIST PDP11 DEVICE REGISTERS FROM BYTES PACKED
	;IN THE ERROR FILE AS IN CODE 130 ENTRIES.
	;P1  -# BYTES TO LIST,,ADDRESS TO FIRST
	;P2  ADDR OF REG NAMES(SIXBIT),,ADDR OF CONTROL TABLE


LSTEB:	MOVE	P3,[POINT 16,(P1)]	;BUILD A POINTER
	HLRE	P4,P1			;AND A PASS COUNTER
	MOVEM	P4,PASCNT		;SAVE IT
	SETZ	P4,			;# WE'VE DONE
LSTEB1:	ILDB	T4,P3		;GET A WORD
;[307]	SKIPN	T4		;=0?
;[307]	 JRST	LSTEB2			;YES JUST GET NEXT WORD
	PUSH	P,T4			;SAVE THE WORD
	PUSHJ	P,.TTABC
	HLRZ	T2,P2			;ADDR OF REG NAMES
	ADD	T2,P4
	MOVE	T1,(T2)		;A SIXBIT NAME
	PUSHJ	P,.TSIXN
	PUSHJ	P,.TCOLN
	PUSHJ	P,.TTABC
	POP	P,T1			;GET THE WORD BACK
	PUSH	P,T1			;BUT SAVE IT STILL
	PUSHJ	P,.TOCTW		;DUMP IN OCTAL
	PUSHJ	P,.TTABC
	HRRZ	T1,P2			;GET CONTROL TABLE ADDR
	ADD	T1,P4
	MOVE	T2,(T1)		;THEN THE CONTENTS
	JUMPL	T2,LSTEB3		;SPECIAL XLATION?
	HLRM	T2,KONTYP		;OFFSET TO SETUP
	POP	P,T1			;WORD TO XLATE
	PUSHJ	P,SAVE4P		;SAVE P1-P4
	MOVE	P1,T1			;WHEREIT BELONGS
	TYPEIT	< = >
	PUSHJ	P,CNIDCD		;1 FOR 1 XLATION
	PUSHJ	P,RET4P			;GET P1-P4 BACK
	PUSHJ	P,.TCRLF		;NEXT LINE PLEASE


;NOW UPDATE COUNTERS,THEN START OVER

LSTEB2:	AOS	P4			;# WE'VE DONE
	HRLZI	T1,1B35			;SET BIT 17
	ADD	P1,T1			;+1 TO LH OF P1
	;AOBJNWON'T WORK SINCE THERE ARE TWO BYTES PER WORD

	JUMPL	P1,LSTEB1		;START OVER?
	 POPJ	P,0			;NO-RETURN

	;HERE DO SPECIAL XLATION
	;T2 HAS CONTROL TABLE ENTRY AND WORD TO XLATE
	;IS ON TOP OF PUSHDOWN STACK

LSTEB3:	POP	P,T1			;WORD TO T1
	PUSHJ	P,SAVE4P		;SAVE P1-P4
	PUSHJ	P,0(T2)			;TO SPECIAL ROUTINE
	PUSHJ	P,RET4P			;RESTORE P1-P4
	PUSHJ	P,.TCRLF		;NEXT LINE
	JRST	LSTEB2			;UPDATE AND START OVER

	;JFLOOP -- SUBROUTINE TO DECODE BITS IN WORD AND GIVE ASCIZ EXPANSION
	;SETUP	P2=WORD TO BE DECODED
	;	P4=ADDRESS OF ASCIZ TEXT POINTER TABLE CORRESPONDING TO BITS
	;CALL	PUSHJ	P,JFLOOP
	;
	;RETURN	CALL+1

JFLOOP:	TLZ	F,F.JFFO	;INITIALIZE ERROR FLAG
JFMORE:	JFFO	P2,JFFDCD	;LOOK FOR FIRST NON-ZERO BIT
	POPJ	P,		;ALL DONE
JFFDCD:	MOVE	T1,KONTYP	;PICKUP CONTROLLER TYPE
	MOVE	T1,ERINDX(T1)	;PICKUP ADDRESS OF BIT TO INDEX CONVERTER
	ADD	T1,P3		;SETUP TO ADDRESS OF BIT WE WANT
	MOVE	T2,(T1)		;GET CORRESPONDING INDEX BIT
	ADD	T2,P4		;ADD IN DEVICE OFFSET
	MOVE	T1,@T2		;PICKUP ADDRESS OF TEXT
	TLO	F,F.JFFO	;SAY WE SAY A TEXT-BIT
	PUSHJ	P,.TSTRG	;TYPEIT
JFCONT:	ROT	P2,(P3)		;BRING BIT TO SIGN POSITION
	TLZ	P2,400000	;CLEAR IT
	MOVNS	P3		;NEGATE TO ALLOW RIGHT SHIFT
	ROT	P2,(P3)		;RESTORE IT TO ORIGINAL POSIION
	JRST	JFMORE		;LOOP TILL ALL BITS DONE



	;GENERAL ROUTINE TO DO "ONE-FOR-ONE" BIT TRANSLATION
	; TO TEXT. SETUP P1 =WORD TO BE DECODED
	;	KONTYP = CORRECT INDEX FOR THIS TYPE WORD

CNIDCD:	MOVE	T1,KONTYP	;GET CONTROLLER TYPE.
	AND	P1,KONMSK(T1)	;SAVE ONLY ERROR BITS.
	SKIPN	P1			;ANY BITS SET?
	 JRST	CNIDC1			;NO
	LSH	P1,@MINERB(T1)	;SHIFT LEFT UNTIL FIRST KNOWN
				;ERROR BIT IS IN SIGN BIT
	MOVE 	P4,DEVTYP##(T1)	;GET ADDRESS OF ASCIZ TEXT.
	MOVE	P2,P1		;SETUP WORD TO BE DECODED.
	PUSHJ	P,JFLOOP	;GO DO THE REAL WORK
	POPJ	P,0		;RETURN


CNIDC1:	TYPEIT	< NO ERROR BITS DETECTED>
	POPJ	P,0			;RETURN TO CALLER



	;ADDED WITH EDIT 134
	;XORTAB -- SMALL ROUTINE TO XOR TWO TABLES BEFORE
	;CALLING BITLST,  SETUP P1=ADJUSTED POINTER TO 1 TABLE
	;P2=ADJUSTED POINTER TO THE OTHER,  RETURNS
	;ADJUSTED POINTER TO RESULTING TABLE IN P2.

XORTAB:	HLRZ	T1,P1
	HLRZ	T2,P2
	CAME	T1,T2		;EQUAL LENGTH?
	 WARN	<MEM. CONFIG. TABLES OF DIFFERENT LENGTH?>
	PUSH	P,P2		;SAVE ONE FOR LATER

XORTB1:	MOVE	T1,0(P1)	;GET ONE WORD
	XORM	T1,0(P2)	;OTHER ONE IS IN MEM
	AOBJN	P1,.+1		;ALWAYS TAKE NEXT INSTR.
	AOBJN	P2,XORTB1	;GET NEXT PAIR
	POP	P,P2		;DONE-GET A POINTER TO RETURN
	POPJ	P,0	


	;ADDED WITH EDIT 134
	;BITLST -- A SUBROUTINE TO LIST "FROM XXX"  "TO YYY"
	;INFORMATION FROM A BIT TABLE LOOKING LIKE THE 
	;MONITOR'S NXMTAB.
	;CALLED WITH THE AOBJN POINTER IN P2 WITH PUSHJ
	;RETURNS POPJ WHEN ALL DONE USES P1-P4,T1-T4
	;ALSO SET KFLAG TO 0 IF EACH BIT IN TABLE =
	;1 PAGE OF PHYSICAL CORE ELSE KFLAG=-1 MEANS K OF CORE.

BITLST:	SETZM	WDCTR		;CLEAR AND 
	SETZM	ENDADR		;INITIALIZE
	SETZM	MEMCTR		

WORDLP:	SKIPN	T3,0(P2)	;GET A WORD AND IF 0
	JRST	ZEROWD		;HANDLE ALL 0
	TDC	T3,[-1]		;COMPLEMENT
	TDCN	T3, [-1]	;STILL 0?
	JRST	ONESWD		;HANDLE ALL 1'S

NXTBIT:	SKIPN	ENDADR
	JRST	NXTBT1
	MOVE	T1,[SIXBIT/  TO: /]
	TLNN	T3,1B18
	PUSHJ	P,PNTADR
	JRST	NXTBT2
NXTBT1:	MOVE	T1,[SIXBIT/FROM: /]
	TLNE	T3,1B18
	PUSHJ	P,PNTADR
NXTBT2:	TLNE	T3,1B18		;LEADING 0?
	TDC	T3,[-1]		;NO CONVERT
	JFFO	T3,.+2		;COUNT ZEROS
	 JRST	NEXTWD		;NO ONES GET ANOTHER
	MOVE	T2,WDCTR	;# COUNTED SO FAR IN THIS WORD
	ADD	T2,T4		;+ RESULT LAST JFFO
	CAIL	T2,^D36		;DONE ENOUGH?
	 JRST	NEXTWD		;YES-GET ANOTHER
	ADDM	T4,MEMCTR	;UPDATE # BITS SEEN IN TABLE SO FAR
	LSH	T3,0(T4)	;STRIP OF THOSE COUNTED
	MOVE	T1,[SIXBIT/FROM: /]	;ASSUME LOOKING FOR
				;CHANGE FROM 0 TO 1
	SKIPE	ENDADR		;0=LOOKING FOR CHANGE TO A 1 BIT
				;AND THEN WE PRINT "FROM: XXX"
	 MOVE	T1,[SIXBIT/  TO: /]
	PUSHJ	P,PNTADR	;WE SAW A CHANGE, GO LIST IT
	ADDM	T4,WDCTR	;UPDATE COUNT SEEN IN THIS WORD
	JRST	NXTBT2		;GO DO IT AGAIN

NEXTWD:	MOVN	T1,WDCTR
	ADDI	T1,^D36		;ADJUST
	ADDM	T1,MEMCTR	;UPDATE # BITS LOOKED AT
	SETZM	WDCTR		;CLEAR IT TO START ON NEXT WD
	AOBJN	P2,WORDLP	;ANY MORE WORDS?
	SKIPN	ENDADR		;ARE WE REALLY FINISHED?
	 POPJ	P,0		;THATS ALL
	MOVE	T1,[SIXBIT/  TO: /]	;SET FOR LAST LISTING
	PJRST	PNTADR		;AND LEAVE VIA THAT POPJ
	
ZEROWD:	MOVE	T1,[SIXBIT/  TO: /]	;SETUP
	SKIPE	ENDADR		;ARE WE LOOKING FOR A CHANGE?
	 PUSHJ	P,PNTADR	;YES, GO LIST IT
	JRST	NEXTWD		;GO DO ACCOUNTING A NEXT WORD

ONESWD:	MOVE	T1,[SIXBIT/FROM: /]	;SETUP
	SKIPN	ENDADR		;LOOKING FOR A CHANGEZ?
	 PUSHJ	P,PNTADR	;GO LIST
	JRST	NEXTWD	;ACCOUNTING & NEXT WORD.

PNTADR:	PUSH	P,T3		;SAVE SOME AC'S
	PUSH	P,T4
	PUSHJ	P,.TSIXN	;SIXBIT ALREADY IN T1
	TYPEIT	<  >
	MOVE	T1,MEMCTR	;GET # OF BITS COUNTED
	PUSHJ	P,.TDECW	;GO DUMP IT IN DECMIL
	MOVE	T1,[SIXBIT/ K /]
	SKIPN	KFLAG		;0= 1BIT = 1PAGE
	 MOVE	T1,[SIXBIT/ P /]
	PUSHJ	P,.TSIXN	;SAY EITHER
	SKIPE	ENDADR		;IF 0 START ANOTHER LINE
	 PUSHJ	P,.TCRLF
	SETCMM	ENDADR		;REVERSE THE FLAG
	POP	P,T4
	POP	P,T3
	POPJ	P,0		;GO BACK AND CHECK SOME MORE.
	;TABLES

.DVTAB:	ASCIZ/RD10/	;CAUTION DEVICE NAME MUST 4 CHAR OR LESS TO CORRECTLY INDEX INTO TABLE
	ASCIZ/RM10/
	ASCIZ/RP02/
	ASCIZ/RP03/
	ASCIZ/RS04/
	ASCIZ/RP04/
	ASCIZ/RP05/
	ASCIZ/RP06/
.MXBLK:	^D4000			;4000 BLOCKS PER RD10
	^D2700			;2700 BLOCKS PER RM10B
	^D40000			;40000 BLOCKS PER RP02
	^D80000			;80000 BLOCKS PER RP03
	^D2048			;2048 BLOCKS PER RS04
	^D156180		;154280 BLOCKS PER RP04
	^D156180		;154280 BLOCKS PER RP05
	^D309700		;FOR AN RP06

.TRBLK:	^D20			;20 BLOCKS/TRACK ON RD10
	^D30			;30 BLOCKS/TRACK ON RM10B
	^D200			;200 BLOCKS/CYLINDER ON RP02
	^D200			;200 BLOCKS/CYLINDER ON RP03
	^D32			;32 BLOCKS/TRACK ON RS04
	^D380			;380 BLOCKS/CYL RP04
	^D380			;380 BLOCKS/CYL RP05
	^D380			;380 BLOCKS/CYL RP06

.SUBLK:	0			;RD10 BLOCKS/SURFACE
	0			;RM10B BLOCKS/SURFACE
	^D10			;RP02 BLOCKS/SURFACE
	^D10			;RP03 BLOCKS/SURFACE
	^D0			;RS04 BLOCKS/SURFACE
	^D20			;RP04 BLOCKS/SURFACE
	^D20			;RP05 BLOCKS/SURFACE
	^D20			;RP06 BLOCKS/SURFACE

.SECBK:	4			;4 SECTORS/BLOCK ON RD10
	2			;2 PHYSICAL SECTORS PER RM10B BLOCK
	1			;1 FOR RP02
	1			;AND RP03
	2			;2/BLOCK FOR RS04
	1			;1 PER FOR RP04
	1			;1 PER FOR RP05
	1			;1 PER FOR RP06


	;ROUTINE TO UPDATE RUNNING COUNT OF #WDS READ
	;P1= # TO BE ADDED
	;P3= BASE ADDR OF DEVICE COUNTER TABLES (MTA0HD ETC)

WDCNT:	CAML	P1,[^D1M]	;LESS THAN 1 MILLION WORDS
	 JRST WDCNT1		;NO

WDCNT2:	ADDB	P1,10(P3)	;JUST ADD TO 2ND HALF
	CAMGE	P1,[^D1M]	;RESULT GT 1 MEG
	 POPJ	P,0		;NO ALL DONE
	IDIV	P1,[^D1M]	;YES ADJUST ANS
	ADDM	P1,7(P3)	;ADD NEW QUOTIENT
	MOVEM	P2,10(P3)	;RESTORE NEW PORTION OF A MILLION
	POPJ	P,0

WDCNT1:	IDIV	P1,[^D1M]	;
	ADDM	P1,7(P3)	;ADD QUOTIENT(#MILLION)
	MOVE	P1,P2		;MOVE REMAINDER
	JRST	WDCNT2		;GO CHECK,ADJUST,ANDEXIT

	;COMPAR -- SUBROUTINE CALLED BY SUMMATION ROUTINES
	;TO SEE IF COUNTER IS CHANGED SINCE LAST LOOK
	;CALL	MOVEI	T1,XXXTMP	ADDRESS OF COUNT SINCE LAST RELOAD ENTRY
	;	MOVEI	T2,XXXPER	ADDRESS OF COUNT SINCE START OF SUMMATION
	;	MOVE	T3,CURRENT COUNT
	;	PUSHJ	P,COMPAR
	;
	;RETURN	CALL+1



COMPAR:	TLZ	F,F.CHNG	;CLEAR CHANGE IN COUNT FLAG
	CAME	T3,@T1		;COUNT SAME AS OLD?
	SKIPN	T3		;COUNT =0
	POPJ	P,		;YES TO EITHER ABOVE
	TLO	F,F.CHNG	;SAY COUNT CHANGED SINCE LAST LOOK
	CAML	T3,@T1		;COUNT LESS THAN TEMP?
	JRST	CNTMOR		;NO-COUNT IS MORE THAN TEMP
	MOVE	T4,@T1		;RELOAD OCCURRED THEN ERROR
				;PICKUP TEMP
	ADDM	T4,@T2		;PERM =PERM+TEMP
	SETZM	@T1		;CLEAR TEMP
	ADDM	T3,@T1		;TEMP=CURRENT COUNT
	POPJ	P,
CNTMOR:	movem	t3,@t1	;edit #110
	POPJ	P,


SKPRTN:	AOS	0(P)	;ADD ONE
	POPJ	P,0		;AND USE IT


TYPNBS:	PUSHJ	P,.CNTDT
	PUSH	P,T1
	MOVE	T1,T2
	PUSHJ	P,.TDATE
	TYPEIT	< AT >
	POP	P,T1
	PUSHJ	P,.TTIME
	POPJ	P,0

	;TITLST -- SUBROUTINE TO OUTPUT TITLE BLOCK
	;INFO OUTPUT IS DATE AND TIME AND USER REQUESTED STRING
	;CALL	PUSHJ	P,TITLST
	;
	;RETURN	CALL+1

TITLST:	PUSHJ	P,FFPRNT	;DO FORM FEED
	TYPEIT	<
SYSTEM ERROR REPORT COMPILED ON >
	SKIPE	TOPMON		;TOPS20?
	 JRST	TITLS1
	PUSHJ	P,.TDATN	;GO TYPE TODAYS DATE
	TYPEIT	< AT >
	PUSHJ	P,.TTIMN	;GO TYPE CURRENT TIME

TITLS1:	SETOB	T2,T3	;CURRENT TAD AND DEFAULT OUTPUT FORMAT
	HRROI	T1,DATLOC	;STR CONVERTED ASCIZ HERE
	ODTIM			;CONVERT
	HRRZI	T1,DATLOC
	PUSHJ	P,.TSTRG	;NOW LIST IT

	TYPEIT	<	PAGE >
	MOVE	T1,PAGNUM
	PUSHJ	P,.TDECW
	POPJ	P,

	SUBTTL	I/O BUFFER CONTROL ROUTINES




	;SUBROUTINE SKIPWD	ADVANCES BYTE POINTER MANUALLY TO SKIP WORDS
	;CALL	PUSHJ	P,SKIPWD
	;RETURN
	;T1= # OF WORDS TO SKIP

SKIPWD:	CAMGE	T1,IBUFF+2	;ENOUGH WORDS IN BUFFER TO SKIP AND STAY IN THIS BUFFER?
	JRST	THISBF		;YES STAY HERE
	SUB	T1,IBUFF+2
	PUSH	P,T1		;EDIT 133 SAVE T1
	PUSHJ	P,ADVBFF	;NO- GO GET ANOTHER BUFFER
	POP	P,T1		;EDIT 133 GET IT BACK
	JRST	SKIPWD		;TRY AGAIN
THISBF:	ADDM	T1,IBUFF+1	;INCREMENT BYTE POINTER
	EXCH	T1,IBUFF+2	;UPDATE BYTE POINTER AND WORD COUNT
	SUBM	T1,IBUFF+2
RETRN:	POPJ	P,


	;ADVBFF	SUBROUTINE TO READ ANOTHER BUFFER
	;CALL	PUSHJ	P,ADVBFF
	;RETURN
	;**EDIT 107** ADDED CODE TO LOOK FOR ERROR.X01
	;THRU ERROR.X77 IF ERROR OR EOF DURING READ. ALSO
	;STORES NEW FILES CREATION TIME THEN STARTS TO 
	;PROCESS IT BY GOING TO HEADRD

ADVBFF:	IN	INPCHN,
	PJRST	FIXBUF	;EDIT 115 GO HANDLE 1ST WORD

	STATZ	INPCHN,740000	;WHAT WENT WRONG?
	 PUSHJ	P,ADVBU1	;FILE ERROR COMPLAIN!!
	SKIPE	TOPMON		;IF UNDER TOPS20
	 JRST	GOSUM		;NO EXTENDED FILE HANDLING
	HLRZ	T1,CUREXT	;WHAT FILE WAS THAT
	CAIN	T1,'SYS'	;FIRST?
	MOVEI	T1,'X00'	;CHANGE IT
	ADDI	T1,1		;+1
	TRNN	T1,7		;SIXBIT CARRY?
	ADDI	T1,100-10	;FIX IT
	HRLZM	T1,CUREXT	;PUT IT BACK
	CAILE	T1,'X77'	;THATS FAR ENOUGH
	JRST	ADVBU2		;DO SUMMARY AND QUIT
	TLNN	F,F.DISK	;THIS ONLY WORKS FOR DISKS
	JRST	ADVBU2	;SO DONT GO FURTHER
	HRLZM	T1,INPFIL+3	;STORE IT IN SPEC.
	LOOKUP	INPCHN,INPFIL	;TRY FOR IT
	 JRST	ADVBU2		;NOT THERE WRAP UP
	SETZM	BLKCNT		;START RELATIVE BLOCK COUNTER OVER
	MOVE	T1,INPFIL+.RBTIM	;NEW CREATION DATE/TIME
	HLRZ	T2,CUREXT
	MOVE	T3,T2
	ANDI	T3,77
	SUBI	T3,20
	ANDI	T2,7700
	SUBI	T2,2000
	LSH	T2,-3
	ADD	T2,T3
	MOVEM	T2,CURIND	;CURRENT 01 OR 03 IN OCTAL(I HOPE)
	MOVEM	T1,FILDAT(T2)	;PUT FILDAT AWAY NOW
	PUSHJ	P,TITLST	;START A NEW PAGE
	PUSHJ	P,.TCRLF
	PUSHJ	P,.TCRLF	;SOME SPACE
	TYPEIT	<
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>
	TYPEIT	<

	NOW PROCESSING ERROR.>
	MOVE	T1,CUREXT
	PUSHJ	P,.TSIXN
	TYPEIT	<

	CREATED:	>
	MOVE	T2,CURIND
	MOVE	T1,FILDAT(T2)	;GET DATE
	PUSHJ	P,TYPNBS	;LIST IT TOO
	TYPEIT	<

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>
	PUSHJ	P,FFPRNT	;NEXT PAGE PLEASE
	WARN	<SYRPNF: PROCESSING NEXT ERROR FILE!>
	JRST	HEADRD		;START PROCESSING

	;HERE TO COMPLAIN ABOUT INPUT FILE ERROR

ADVBU1:	WARN	<SYRERI: FATAL ERROR READING INPUT FILE!>
	POPJ	P,0	;TRY FOR NEXT ERROR FILE

	;HERE TO WRAP UP WITH SUMMARY LISTING AND QUIT

ADVBU2:	TLNE	F,F.LSUM	;WANTS IT?
	JRST	GOSUM		;EDIT 120  DO AN OVERLAY FOR SUMMARY.



	;FIXBUF - ROUTINE TO GET,CHECK AND STORE IF
	;NEEDED THE FIRST WORD IN A BUFFER. USED FOR RE-SYNC TO
	;A GOOD ENTRY IN ERROR FILE
	;[410] REMOVED SPECIAL CASE TESTING FOR TOPS20
FIXBUF:	MOVE	T1,IBUFF+1	;GET BYTE POINTER
	ILDB	T2,T1		;USE IT
	LDB	T1,[POINT 9,T2,8]
	CAIE	T1,ER.OFF	;VALID OFFSET WORD?
	 JRST	FIXBU1		;NO-DONT PLAY WITH BUFFER
	PUSHJ	P,GETWD		;NOW GET THAT WORD LEGALLY
				;THIS METHOD PREVENTS MESSING UP
				;GETWD'S POINTERS IF WE DONT WANT
				;THAT FIRST WORD. IE OLD FORMAT
				;ERROR FILES.
	MOVEM	MASTWD,BUFOFF	;NOW SAVE IT
	AOS	BLKCNT		;# BLOCKS SEEN SO FAR
	MOVE	T1,IBUFF+2
	MOVEM	T1,BLKWDS	;# WDS IN THIS BLOCK
	MOVE	T1,IBUFF+1	
	MOVEM	T1,BLKPNT	;ILDB POINTER
	POPJ	P,0		;RETURN TO ADVBFF'S CALLER

FIXBU1:	SETZM	BUFOFF		;MAKE SURE ITS CLEAR
	POPJ	P,0		;RETURN WITH GETWD'S POINTERS OK

	;STBUFF-- ROUTINE TO START AGAIN AT NEXT BLOCK TO GET
	;US BACK IN SYNC IN CASE OF ERROR OR IF NEXT ENTRY
	;STARTS THERE. EDIT #115
STBUFF:	MOVE	P,PDLPNT	;RESET PUSH LIST, WE WILL GO TO HDREAD LATER
	AOS	FILCNT	;[223]COUNT OF ERRORS
	TLZ	F,F.TTYO	;ALL CHARS TO OUTPUT BUFFER
	PUSHJ	P,TITLST	;START ON A FRESH PAGE
	TYPEIT	<

******************************************************
INCONSISTENCY FOUND IN ERROR FILE
******************************************************
>
	TYPEIT	<

	LOGICAL BLOCK IN FILE:  	>
	MOVE	T1,BLKCNT	;GET CURRENT #
	PUSHJ	P,.ODECW	;IN DEC WITH A "."
	TYPEIT	<
	# OF WORDS IN BLOCK:		>
	MOVE	T1,BLKWDS
	PUSHJ	P,.ODECW
	TYPEIT	<
	RELATIVE WORD IN BLOCK:		>
	MOVE	T1,BLKWDS	;STARTING COUNT
	SUB 	T1,IBUFF+2	;CURRENT # LEFT
	PUSHJ	P,.ODECW
	TYPEIT	<

CONTENTS OF THIS BLOCK:

>
STBUFA:	MOVEI	P1,8		;8 WORDS PER LINE
STBUFB:	PUSHJ	P,SPACE3	;DO 3 SPACES
	MOVEI	P2,^D12		;12 CHARS PER WORD
	PUSHJ	P,INPWD		;GET NEXT WORD TO DUMP
	MOVE	T2,T1
STBUFC:	MOVEI	T1,0
	ROTC	T1,3		;3 BITS TO T1
	ADDI	T1,60		;CONVERT TO ASCII
	PUSHJ	P,.TCHAR	;OUTPUT
	SOJG	P2,STBUFC	;NEXT 3 BITS
	MOVE	P2,BLKWDS	;ANY MORE WORDS?
	CAIN	P2,1
	 JRST	STBUFD		;WE'RE DONE
	SOJG	P1,STBUFB	;FINISH THE LINE
	PUSHJ	P,.TCRLF	;NEXT LINE
	JRST	STBUFA		;START AGAIN
STBUFD:	SKIPE	KLEFL2		;IN PROCESS OF BUILDING KLEFIL?
	 PUSHJ	P,KLEDMP##	;YES-DUMP IT IN OCTAL
	PUSHJ	P,TITLST
STBUFE:	PUSHJ	P,ADVBFF		;START AT NEXT BLOCK
	SKIPN	T1,BUFOFF	;OFFSET THERE?
	 JRST	STBUF1		;NO-OLD FILE FORMAT OR BAD MISTAKE?!
	HRRZ	T1,T1		;CLEAR LH
	CAIN	T1,200		;SKIP THIS BLOCK ENTIRELY?
	 JRST	STBUFE		;YES, ENTRY IS MORE THAN THIS BLOCK
	SUBI	T1,1		;ADJUST FOR 1ST WORD
	SKIPE	T1		;IF 0, DON'T
	PUSHJ	P,SKIPWD	;MOVE POINTERS
	WARN	<SYRRNB:  RESTARTING IN NEXT BLOCK OF ERROR FILE>
	JRST	HEADRD		;GO DO IT

STBUF1:	WARN	<SYRCNR:  CANNOT RE-SYNC, TRYING NEXT BLOCK>
	JRST STBUFF	;KEEP ADVANCING UNITL EITHER
			;EOF & THEN NEXT FILE OF EOF
			;AND THEN DO SUMMARY AND CLOSE NICELY.


SPACE3:	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	POPJ	P,0

INPWD:	SOSGE	BLKWDS
	 JRST STBUFD	;FINISHED
	ILDB	T1,BLKPNT
	POPJ	P,0


	;GOSUM--SUBROUTINE TO GET SETUP TO CALL OVRLAY
	;TO GET SYSERS TO DO SUMMARY LISTINGS.
	;ADDED BY EDIT 120

GOSUM:	TRNE	F,F.REM		;/REMOTE?
	 JRST	GOSTRT	;NO SUMMARY[417]
	MOVE	T1,[SIXBIT/SYSERS/]	;THE FILE NAME
	MOVEM	T1,OVRBLK+1		;INTO THE SPEC. AREA
	SETZ	15,
	MOVEM	17,SAVEAC+17
	MOVEI	17,SAVEAC
	BLT	17,SAVEAC+16		;THAT SAVES THE AC'S
	JRST	OVRLAY			;REPLACE THIS MODULE
					;WITH SYSERS AND THEN
					;PERFORM SUMMARY LISTING.

;	SUBROUTINE	GETWD	RETURNS NEXT WORD IN INPUT BUFFER
;	SIMILAR IN NATURE TO GETCHR ROUTINE IN HANDBOOK
;	CALL	PUSHJ	P,GETWD
;	RETURNS WITH WORD IN MASTWD

GETWD:	SOSGE	IBUFF+2
	JRST	GETNXI
GETOK:	ILDB	MASTWD,IBUFF+1
	POPJ	P,

GETNXI:	PUSHJ	P,ADVBFF
	JRST	GETWD

	;SUBROUTINE PUTCHR
	;CALL WITH CHAR TO BE PLACED IN OUTPUT BUFFER IN T1
	;CODE AS IN HANDBOOK

PUTCHR:	SOSG	OBUFF+2
	JRST	PUTOUT
PUTCH:	IDPB	T1,OBUFF+1
	POPJ	P,
PUTOUT:	OUT	OUTCHN,
	JRST	PUTCH
	FATAL	<ERROR DURING OUTPUT>


	;GOSTRT[417] GO BACK TO SYSERR NOT SYSERS

GOSTRT:	CLOSE	INPCHN,
	CLOSE	OUTCHN,
	MOVE	T1,[SIXBIT/SYSERR/]
	MOVEM 	T1,OVRBLK+1
	SETZ	15,
	MOVE	11,OVRBLK
	MOVE	7,OVRBLK+4
	MOVEM	17,SAVEAC+17
	MOVEI	17,SAVEAC
	BLT	17,SAVEAC+16
	JRST	OVRLAY


;ROUTINE TO OUTPUT RAW WORDS TO DAT FILE FOR /REMOTE

PUTDAT::	SOSG	OBUFF+2	;ROOM LEFT THIS BLOCK?
	 JRST	PUTDA2		;NO-GET NEXT BLOCK
PUTDA1:	IDPB	T1,OBUFF+1
	POPJ	P,0
PUTDA2:	OUT	OUTCHN,		;WRITE THIS BLOCK
	JRST	PUTDA3		;INIT NEXT WITH POINTER OFFSET
	FATAL	<ERROR DURING BINARY OUTPUT>

PUTDA3:	PUSH	P,T1		;SAVEWORD TO OUTPUT
	HRLZI	T1,<ER.OFF>B26	;OFFSET ID CODE
	MOVE	T2,HEADWC	;WORDS LEFT IN HEADER OF THIS ENTRY
	CAIN	T2,3		;JUST STARTING AN ENTRY?
	 JRST	PUTDA5		;YES,OFFSET IS 1
	ADD	T2,ENTRWC	;+#WORDS LEFT THIS BODY
	ADDI	T2,2		;+1-WORD WE WERE CALLED TO WRITE AND +1
				;FOR HEADER WORD
	CAIL	T2,177	;MORE THAN ONE BLOCK?
	 MOVEI	T2,200		;YES,SAY NEXT BLOCK
	HRR	T1,T2		;FINISH OFFSET WORD
PUTDA4:	SOS	OBUFF+2
	IDPB	T1,OBUFF+1
	POP	P,T1		;WORD WE WERE CALLED TO WRITE
	JRST	PUTDA1		;WRITE IT AND RETURN

PUTDA5:	HRRI	T1,1		;THIS ENTRY STARTS WITH NEXT WORD
	JRST	PUTDA4		;CONTINUE
	SUBTTL	TELETYPE OUTPUT SUBROUTINES
	;SUBROUTINES TO PUT VARIOUS SPECIAL CHARACTER IN OUTPUT BUFFER

FFPRNT:	MOVE	T1,[-PAGLIN]
	MOVEM	T1,LINCNT
	AOS	T1,PAGNUM
	CAILE	T1,PAGLM	;(EDIT 101)**SPR #10-13,341 (RLD)**
	 JRST	PAGXCD		;**SPR #10-13,341 (RLD)**
	MOVEI	T1,14		;FORM FEED
	PUSHJ	P,CHROUT
	POPJ	P,

SLPRNT:	MOVEI	T1,"/"
	PUSHJ	P,CHROUT
	POPJ	P,

CLPRNT:	MOVEI	T1,":"
	PUSHJ	P,CHROUT
	POPJ	P,


TBPRNT:	MOVEI	T1,"	"		;HORIZ. TAB
	PUSHJ	P,CHROUT
	POPJ	P,


	;CHROUT -- SUBROUTINE CALLED BY SCAN TO OUTPUT CHARS TO TTY
	;IF F.TTYO FLAG SET IN F OR TO PLACE IN OUTPUT BUFFER
	;VIA PUTCHR

CHROUT:	TLNE	F,F.TTYO	;OUTPUT TO TTY?
	JRST	TTYOUT		;YES
	PJRST	PUTCHR		;PUT IN OUTPUT BUFFER AND RETURN

TTYOUT:	OUTCHR	T1		;NO-TOPS10 LET MONITOR DO OUTPUT
	POPJ	P,		;RETURN


	;ROUTINE TO DUMP A SIXBIT WORD IN T2 ON USER'S TTY
	;CALL= PUSHJ
TTYSIX:	MOVEI	T3,6		;PASS COUNT
	MOVE	T4,[POINT 6,T2]	;INIT BYTE PTR.
TTYSXC:	ILDB	T1,T4		;GET A CHAR
	ADDI	T1,40		;CONVERT
	PUSHJ	P,TTYOUT	;DUMP IT
	SOJG	T3,TTYSXC	;AND CONTINUE
	MOVEI	T1,40		;A SPACE
	PJRST	TTYOUT	;AND LEAVE

	END