Google
 

Trailing-Edge - PDP-10 Archives - BB-H138A-BM - 3a-sources/syrlib.mac
There are 16 other files named syrlib.mac in the archive. Click here to see a list.
;<BAKER.SYSERR>SYRLIB.MAC.9, 28-Jul-78 12:11:32, Edit by BAKER
;FIX HANDLING OF ZEZO LENGTH HEADER
;<BAKER.SYSERR>SYRLIB.MAC.8, 21-Jul-78 13:21:04, Edit by BAKER
;<BAKER.SYSERR>SYRLIB.MAC.7, 20-Jul-78 17:18:42, Edit by BAKER
;<BAKER.SYSERR>SYRLIB.MAC.6, 20-Jul-78 17:15:21, Edit by BAKER
;FIX HANDLING OF ERROR TYPE '0' IF IT SHOWS UP
;<BAKER.SYSERR>SYRLIB.MAC.5, 12-Jul-78 15:10:48, Edit by BAKER
;<BAKER.SYSERR>SYRLIB.MAC.4, 12-Jul-78 14:47:05, Edit by BAKER
;<BAKER.SYSERR>SYRLIB.MAC.3, 12-Jul-78 11:14:46, Edit by BAKER
;EDITS [753-754]  HALT STATUS & BRIEF BUFFER OVERFLOW PROBLEMS
;<SYSERR>SYRLIB.MAC.16,  5-Jul-78 09:27:32, EDIT BY WOJCIK
;<SYSERR>SYRLIB.MAC.15, 30-Jun-78 16:10:42, EDIT BY IQL-BAKER
;<SYSERR>SYRLIB.MAC.14, 30-Jun-78 16:08:36, EDIT BY IQL-BAKER
;<SYSERR>SYRLIB.MAC.13, 30-Jun-78 15:31:55, EDIT BY IQL-BAKER
;<SYSERR>SYRLIB.MAC.12, 30-Jun-78 09:15:05, EDIT BY WOJCIK
;TO FIX UP FILE HANDLING STUFF FOR /NOW EDIT 751
;<SYSERR>SYRLIB.MAC.11, 28-Jun-78 15:40:05, EDIT BY IQL-BAKER
;MORE /NDEV -- GENERIC ARGUMENT
;<SYSERR>SYRLIB.MAC.10, 27-Jun-78 15:58:22, EDIT BY WOJCIK
;SOME WORK ON /NOW FILE PROCESSING
;<SYSERR>SYRLIB.MAC.9, 26-Jun-78 11:22:10, EDIT BY IQL-BAKER
;REWORK /DEV /NDEV /STR SWITCHES  [745]
;<SYSERR>SYRLIB.MAC.8, 22-Jun-78 15:43:45, EDIT BY IQL-BAKER
;FIX BLTTAB FOR CORRECT NUMBER OF ENTRIES (DX20-TU7X) [TJW]
;<SYSERR>SYRLIB.MAC.7, 22-Jun-78 11:30:02, EDIT BY WOJCIK
;DEFINE NEW EXTERNAL (.TMOHW)
;<SYSERR>SYRLIB.MAC.6, 22-Jun-78 11:25:22, EDIT BY WOJCIK
;<SYSERR>SYRLIB.MAC.4, 22-Jun-78 10:55:51, EDIT BY WOJCIK
;<SYSERR>SYRLIB.MAC.3, 22-Jun-78 10:48:20, EDIT BY WOJCIK
;<SYSERR>SYRLIB.MAC.2, 22-Jun-78 10:19:04, EDIT BY WOJCIK
;<SYSERR>SYRLIB.MAC.1, 22-Jun-78 10:14:24, EDIT BY WOJCIK
;BEGIN INSTALLING ROUTINES TO SUPPORT 163 ENTRIES
;HERE WE BEGIN TRACKING EDITS


	TITLE	SYRLIB -- SYSERR PACKAGE LIBRARY OF COMMON ROUTINES 
	SUBTTL	VERSION 12(763)		K. COYE/ RLD/ PJB/ ES/ TJW




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





	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,SAVE4T,RET4T,HWDUMP,TYPBCD,LSTEB,JFLOOP
	INTERNAL CNIDCD, 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
	INTERNAL SBUSFN,VERED,NEWCMD,T11ACI,TTLS1,DRVTYP,BLKTRN,JSYSER
	INTERNAL COLOUT,SBDOUT

	EXTERNAL ERRTBL,PDLPNT,MDE000,.TMOHW
	;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		;0 SAYS TOPS-10 RECORDED  [200]
	SETZM	KSMON		;CLEAR KS-10 MONITOR FLAG  [750]
	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:	TRNE	F,F.NOW		;[713-TJW] DOING ON-LINE LOGGING?
	 JRST	PAKWAT		;[713-TJW]YES, SLEEP TILL NEXT ENTRY ARRIVES
	PUSHJ	P,GETWD		;GET WORD 0 OF ENTRY
EOFTRY:	LDB	T1,[POINT 9,MASTWD,8]	;[751]PICKUP ENTRY TYPE
						;ALSO ENTRY FOR POST EOF CODE
	MOVEM	T1,ERTYPE

FILCHK:	TLNE	MASTWD,TOPBIT	;[200]1=TOPS-20 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
	AOS	SEQNUM		;BUMP RECORD SEQ NUMBER
	SKPNOW			;[713-TJW] HEADER FILLED IF ON-LINE
	PUSHJ	P,HEADFL	;GO FILL HDBUFF WITH HEADER INFO
	MOVE	T1,HDBUFF+HDRPSN ;GET S/N FROM HDBUFF
	CAML	T1,[^D4096]	;IS IT A KS10 ?  (S/N > 4096.)
	SETOM	KSMON		;YES! - SET FLAG WORD
	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
;THIS CODE ADDED BY EDIT 713
;HERE WHEN WE ARE ON-LINE -REAL-TIME!!
;MAIN ROUTINE 
;CONTROLS IPCF FACILTITY
;AND THE PID HANDLING


ONLLOG::PUSHJ	 P,TRPSET	;[713-TJW]SET UP THE CTRL-C TRAP
	PUSHJ	P,GETPID	;[713-TJW]GET ME A PID
	PUSHJ	P,GIPCID	;[713-TJW]GET IPCC'S PID
	PUSHJ	P,FNDSEL	;[713-TJW]GET SEL'S PID
	MOVE	T1,SELPID	;[713-TJW]SET UP TO SEE IF
	CAIN	T1,0		;[713-TJW]SEL'S PID =0?
	 PUSHJ	P,MAKSEL	;[713-TJW]YES.. MAKE ME SEL
	PUSHJ	P,TELSEL	;[713-TJW]NO..TEL SEL THAT IM HERE
	JRST	PAKWAT		;[713-TJW]AND GO WAIT FOR A MESSAGE

;ROUTINE TO GET US A PID FROM SYSTEM INFO
;CALLED WITH A PUSHJ RETURNS POPJ ALWAYS
;WITH OUR PID STORED IN MYPID


GETPID:	PUSHJ	P,CLRSND	;CLR MSG BLK
	MOVEI	T1,.IPCII	;SET FCN 3
	MOVEM	T1,SMSG		;PUT IT INTO THE MSG
	MOVE	T1,SMSGPT	;GET PTR TO MSG
	MOVEM	T1,SPDB+.IPCFP	;INTO THE PDB
	MOVE	T1,SPDBPT	;POINT AT PDB
	IPCFS.	T1,		;SEND!!
	 JRST	SNDERR		;HANDLE THE ERROR
	PUSHJ	P,CLRRCV	;CLR MSG BLK
	MOVE	T1,RMSGPT	;GET PTR TO MSG
	MOVEM	T1,RPDB+.IPCFP	;INTO THE PDB
	MOVE	T1,RPDBPT	;POINT AT THE PDB
	IPCFR.	T1,		;RECIEVE
	 JRST	RCVERR		;HANDLE ANY ERROR
	MOVE	T1,RMSG+1	;GET MY PID OUT OF THE MSG
	MOVEM	T1,OURPID	;REMEMBER IT
	POPJ	P,0		;AND RETURN


;ROUTINE TO FIND OUT [SYSTEM]ERROR LOGGER'S PID
;CALLED WITH PUSHJ ALWAYS RETURNS POPJ
;WITH SEL'S PID STORED IN SELPID


FNDSEL:	MOVE	T1,SELPTR	;SET UP TO GET SEL'S PID
	GETTAB	T1,		;GET IT
	 FATAL <CAN'T GETTAB SEL'S PID>
	MOVEM	P1,SELPID	;REMEMBER IT
	POPJ	P,0		;RETURN
;ROUTINE TO MAKE US SEL
;CALLED WITH PUSHJ RETURNS POPJ IF IT FAILS


MAKSEL:	MOVE	T1,PRIVPT	;SET UP TO GET PRIV WORD
	GETTAB	T1,		;GET IT
	 FATAL <CAN'T GETTAB PIVILEGE WORD>
	MOVE	T2,[JP.IPC]	;THIS IS THE BIT
	TLN	T1,T2		;DO I HAVE IPCF PRIVS?
	 FATAL <THERE IS NO [SYSTEM]ERROR LOGGER AND YOU HAVE NO PRIVILEGES TO BE ONE>
	PUSHJ	P,CLRSND	;CLEAR MSG BLK
	MOVEI	T1,.IPCWP	;SET FCN
	MOVEM	T1,SMSG		;GET IT INTO THE MSG BLK
	MOVEI	T1,.IPCPL	;GET ITEM NUMBER
	MOVEM	T1,SMSG+1	;INTO THE MSG
	MOVE	T1,OURPID	;GET MY PID
	MOVEM	T1,SMSG+2	;INTO THE MSG
	MOVE	T1,IPCPID	;GO GET IPCC'S PID
	MOVEM	T1,SPDB+.IPCFR	;USE IT AS RECVRS PID
	MOVE	T1,SMSGPT	;GET PTR TO MSG
	MOVEM	T1,SPDB+.IPCFP	;INTO THE PDB
	MOVEI	T1,IP.CFP	;SET THE PRIV BIT
	MOVEM	T1,SPDB+.IPCFL	;AND PUT IT INTO THE PDB
	MOVE	T1,SPDBPT	;GET PTR TO PDB
	IPCFS.	T1,		;SEND!!
	 JRST	SNDERR		;GO HANDLE THE ERROR
	PUSHJ	P,CLRRCV	;CLR MSG BLK
	MOVE	T1,RMSGPT	;GET PTR TO MSG
	MOVEM	T1,RPDB+.IPCFP	;INTO THE PDB
	MOVE	T1,RPDBPT	;POINT AT PDB
	IPCFR.	T1,		;RECIEVE
	 JRST	RCVERR		;HANDLE THE ERROR
	MOVE	T1,SELPTR	;GET 
	GETTAB	T1,		;SEL'S PID
	 FATAL <CAN'T GETTAB SEL'S PID>
	CAME	T1,OURPID	;SELPID=MYPID?
	 POPJ	P,0		;NO- SOMEONE ELSE BEAT ME TO IT
	MOVEM	T1,SELPID	;YES MOVE PID INTO SELPID
	WARN <INITIALIZED AS [SYSTEM]ERROR LOGGER>
	SETOM	SELFLG		;SET THE FLAG
	PUSHJ	P,QUOSET	;CRANK UP MY QUOTAS
	AOS	(P)		;AND RETURN
	POPJ	P,0		;PLUS ONE
;ROUTINE TO TELL SEL THAT WE HAVE BECOME ACTIVE
;CALLED WITH PUSHJ ALWAYS RETURNS POPJ


TELSEL:	PUSHJ	P,CLRSND	;CLR SENDER PAKET
	MOVE	T1,CNCTMS	;PUT CONNECT MSG
	MOVEM	T1,SMSG		;INTO THE MSGBLK
	MOVE	T1,CMSGPT	;SEND ONLY 1 WORD
	MOVEM	T1,SPDB+.IPCFP	;SO WE CAN TELL
	MOVE	T1,SELPID	;GET MASTERS PID
	MOVEM	T1,SPDB+.IPCFR	;INTO MSG
	MOVE	T1,SPDBPT	;SET UP FOR SEND
	IPCFS.	T1,		;SEND PACKET
	 JRST	SNDERR		;ERROR ON SEND
	WARN <INITIALIZED AS SLAVE ERROR LOGGER>
	POPJ	P,0		;RETURN TO MAINLINE
;SOME UTILITY ROUTINES TO FOOL AROUND WITH THE MESSAGE AREAS


CLRSND:	MOVE	T2,CLRSMS	;CLR MSG AREA..BLT ZEROS
	SETZM	SPDB+.IPCFL
	BLT	T2,SMSG+7
	POPJ	P,0


CLRRCV:	MOVE	T2,CLRRMS	;CLR MSG AREA..BLT ZEROS
	SETZM	RPDB+.IPCFL
	BLT	T2,RMSG+7
	POPJ	P,0


MOVR2S:	MOVE	T1,MOVSMR	;BLT SND MSG TO RCVD MSG
	BLT	T1,SMSG+7
	POPJ	P,0


MOVS2R:	MOVE	T1,MOVRMS	;BLT RCVD MSG TO SND MAG
	BLT	T1,RMSG+7
	POPJ	P,0
;ROUTINE TO WAIT FOR EITHER AN IPCF INTERRUPT OR
;THE END OF 15 SECONDS


PAKWAT:	MOVSI	T1,(HB.IPC)	;SETUP FOR IPC WAKEUP
	HRRI	T1,^D15000	;OR END OD 15 SECS
	HIBER	T1,		;SLEEP!!
	 FATAL <HIBER UUO FAILED>
	JRST	FNDWHY		;GO FIND OUT WHY WE WOKE


;ROUTINE TO FIND OUT WHY WE WOKE UP


FNDWHY:	PUSHJ	P,CLRRCV	;CLR MSG AREA
	MOVE	T1,RPDBPT	;PUT ANSWER IN REVR BLK
	IPCFQ.	T1,		;ANYTHING IN IPCF QUE?
	 FATAL <IPCFQ UUO FAILED>
	HRR	T1,RPDB+.IPCFL	;GET INTERESTING FLAGS
	HLL	T1,RPDB+.IPCFP	;AND LENGTH
	JUMPE	T1,CHKSEL	;IF 0 THEN NO MSGS SO GO CHECK THE WORLD
	JRST	RCVPAK		;YES SOMETHING GO PROCESS
;ROUTINE TO LOOK AROUND AT THE WORLD AND DECIDE THAT IT HAS CHANGED
;AND THEN GET ME ONTO THE PARTY LINE


CHKSEL:	MOVE	T4,SELPID	;GET OLD SELPID
	PUSHJ	P,FNDSEL	;FIND OUT SEL'S PID
	CAMN	T4,SELPID	;SAME AS WE KNOW?
	 JRST	PAKWAT		;YUP..GO BACK TO SLEEP
	MOVEM	T4,SELPID	;SAVE OLD SELPID
	PUSHJ	P,SLEEPR	;NO LET'S WAIT A BIT BEFORE ANYTHING DRASTIC
	MOVE	T4,SELPID	;GET OLD SELPID
	PUSHJ	P,FNDSEL	;LETS SEE IF ANYONE ELSE TOOK UP THE SLACK
	CAMN	T4,SELPID	;SAME AS BEFORE?(SHOULDN'T BE!!)
	 JRST	PAKWAT		;BUT IT WAS?
	MOVE	T4,SELPID	;LETS LOOK AT THIS MORE CLOSELY
	CAIN	T4,0		;NO SEL AROUND?
	 PUSHJ	P,MAKSEL	;NOPE..WE'LL TRY TO BECOME IT
	PUSHJ	P,TELSEL	;YES THERE'S ONE ..ILL TELL HIM I'M HERE
	JRST	PAKWAT		;NOW I CAN GO SLEEP


SLEEPR:	MOVEI	T1,^D35		;SET UP TO SLEEP 35 SECS
	SLEEP	T1,		;SLEEP!!
	POPJ	P,0		;RETURN
;ROUTINE TO RECIEVE A PACKET


RCVPAK:	PUSHJ	P,CLRRCV	;CLR MSG BLK
	MOVE	T2,RMSGPT	;GET PTR TO MSG
	MOVEM	T2,RPDB+.IPCFP	;INTO PDB
	MOVE	T1,RPDBPT	;GET PTR TO PDB
	IPCFR.	T1,		;RECIEVE PACKET
	 JRST	RCVERR		;HANDLE ERROR
	JRST	WHTMSG		;WHAT KIND OF MSG?


;ROUTINE TO FIND OUT WHAT KIND OF PACKET IT WAS


WHTMSG:	MOVE	T1,RPDB+.IPCFL	;GET FLAGS
	TRNE	T1,.IPCFN	;RETURNED PACKET ?
	 JRST	REMPID		;YES IT WAS..GO REMOVE PID
	MOVE	T3,RPDB+.IPCFP	;GET LENGTH,,ADDR WD
	HLRZ	T3,T3		;GET LENGTH ALONE
	CAIE	T3,1		;CONNECT MSG (LEN=1?)
	 JRST	REALMS		;NO ,ITS A REAL MSG
	JRST	MSGTYP		;YES, FIND OUT WHAT KIND
;ROUTINE TO REMOVE A PID FROM THE TABLE OF SLAVE PIDS


REMPID:	MOVE	T1,RPDB+.IPCFR	;GET RECIEVER'S PID
	MOVNI	T4,SLVCNT	;GET -NUMBER OF SLAVES
	HRL	T4,T4		;MAKE IT -SLVNUM,,0
	MOVEI	T2,SLVTBL	;GET THE ADDRESS
	HRR	T4,T2		;MAKE IT -SLVNUM,,SLVPID
REMLUP:	CAMN	T1,(T4)		;ARE PIDS THE SAME?
	 JRST	ZEROIT		;YES GO KILL PID
	AOBJN	T4,REMLUP	;NO  TRY AGAIN
	JRST	PAKWAT		;GO WAIT FOR A PACKET WHEN DONE


;ROUTINE TO KILL THE REQUESTED PID


ZEROIT:	SETZM	(T4)		;KILL THE PID
	SOS	SLVCNT		;MAKE THE COUNT RIGHT 
	PUSHJ	P,CMPTAB	;GO CLEAN UP THE TABLE
	JRST	PAKWAT		;GO WAIT FOR ANOTHER PACKET


;ROUTINE TO CLEAN UP THE SLAVE TABLE WHEN A PID IS REMOVED
;CALLED WITH A PUSHJ RETURNS POPJ


CMPTAB:	SETZ	T3,		;THIS WILL HOLD COUNT OF SLAVES
	MOVNI	T4,SLVCNT	;GET 0,,-SLVNUM
	HRL	T4,T4		;MAKE IT -SLVNUM,,0
	MOVEI	T2,SLVTBL	;GET THE ADDRESS
	HRR	T4,T2		;MAKE IT -SLVNUM,,ADDRESS
CMPLUP:	MOVE	T1,(T4)		;GET A PID
	CAIN	T1,0		;IS IT ZERO?
	 SKIPA 			;YES
	JRST	STKPID		;NO GO STORE IT
STKRTN:	AOBJN	T4,CMPLUP	;DONE IT ENOUGH?
	MOVN	T4,T3		;YES SET UP FOR NEXT STEP
	HRLZ	T4,T4		;MAKE IT -CNT,,0
	MOVEI	T2,SLVTBL	;GET SLVPID ADDRESS
	HRR	T4,T2		;MAKE IT -CNT,,ADDR
STKLUP:	POP	P,T1		;GET PID OFF STACK
	MOVEM	T1,(T4)		;PUT IT AWAY
	AOBJN	T4,STKLUP	;DONE ENOUGH?
	POPJ	P,0		;YES ..RETURN


;ROUTINE TO PUSH A PID ONTO THE STACK
;CALLED WITH A PUSHJ RETURNS POPJ


STKPID:	PUSH	P,T1		;PUT PID ON STACK
	ADDI	T3,1		;COUNT UP NUMBER OF PIDS MOVED
	JRST	STKRTN		;RETURN


;ROUTINE TO CLEAR THE PID TABLE  BEFORE WE RELOAD IT
;CALLED WITH A PUSHJ RETURNS POPJ WITH A CLEAN TABLE


CLRTAB:	MOVE	T2,CLRPTB	;SET UP TO 
	SETZM	SLVTBL		;BLT ZEROS
	BLT	T2,SLVTBL+4	;BLT!!
	POPJ	P,0		;RETURN
;ROUTINE TO DETERMINE WHAT TYPE OF MSG WE RECIEVED
;AND DISPATCH OFF TO HANDLE IT


MSGTYP:	MOVE	T1,RMSG		;GET THE MSG WORD
	CAMN	T1,CNCTMS	;IS IT A CONNECT MSG?
	 JRST	HANSLV		;YES, GO HANDLE NEW SLAVE
	CAMN	T1,OCNTMS	;NO, IS IT AN OK CONNECT MSG?
	 JRST	PAKWAT		;YES  GO WAIT FOR A NEW MSG
	CAMN	T1,NCNTMS	;NO, IS IT A NO CONNECT MSG?
	 FATAL	<CAN'T CONNECT TO [SYSTEM]ERROR LOGGER>
	JRST	PAKWAT		;ITS NOTHING WE KNOW ABOUT..IGNORE IT


;ROUTINE TO HANDLE  SLAVE REQUESTS


HANSLV:	MOVE	T3,SLVCNT	;GET COUNT OF SLAVES
	CAIL	T3,SLVMAX	;5 SLAVES ALREADY?
	 JRST	NOROOM		;YES SEND ERROR MSG
	MOVE	T2,RPDB+.IPCFS	;NO GET SENDERS PID
	MOVEM	T2,SLVTBL(T3)	;INTO SLAVE TABLE
	ADDI	T3,1		;COUNT ONE MORE SLAVE
	MOVEM	T3,SLVCNT	;REMEMBER IT
	JRST	PAKWAT		;GO WAIT FOR ANOTHER PACKET


;HERE WHEN WE HAVE A REAL MESSAGE


REALMS:	SKIPE	SELFLG		;ARE WE SEL?
	 PUSHJ	P,RESEND	;YES, WE NEED TO RESEND THIS
	JRST	PRCFIL		;AND PROCESS IT OURSELVES
;ROUTINE TO OPEN THE INPUT FILE AND GET TO THE RIGHT BLOCK
;AND READ IT IN


PRCFIL:	OPEN	INPCHN,INPBLK
	[ WARN <CAN'T OPEN INPUT DEVICE>
	JRST	GOSTRT]
	LOOKUP	INPCHN,INPFIL
	JRST	[WARN <LOOKUP ERROR ON INPUT FILE >
	JRST	GOSTRT]
	MOVE	T2,RMSG+1
	USETI	INPCHN,(T2)
	IN	INPCHN,
	SKIPA
	FATAL	<ERROR READING ERROR.SYS>
	CLOSE INPCHN,0
	POPJ P,0
;ROUTINE TO RESEND THE MESSAGE TO ALL KNOWN SLAVES


RESEND:	MOVE	T1,SLVCNT	;GET COUNT OF SLAVES
	CAIN	T1,0		;NO SLAVES?
	 POPJ	P,0		;YES RETURN NOW
	PUSHJ	P,CLRSND	;CLR MSG BLK
	PUSHJ	P,MOVR2S	;PUT MSG IN TO BE SENT
	MOVE	T1,SMSGPT	;POINT AT MSG
	MOVEM	T1,SPDB+.IPCFP	;IN PDB
	MOVNI	T1,SLVCNT	;GET 0,,-SLVNUM
	HRL	T1,T1		;MAKE IT -SLVNUM,,0
	MOVEI	T2,SLVTBL	;GET THE ADDRESS
	HRR	T1,T2		;MAKE IT -SLVNUM,,SLVPID
LOOPER:	MOVE	T3,0(T1)	;GET THE ENTRY
	PUSHJ	P,SENDER	;GO PROCESS IT
	AOBJN	T1,LOOPER	;DO IT SLVNUM TIMES
	POPJ	P, 0		;THEN RETURN


;ROUTINE TO DECIDE WETHER TO REALLY SEND THE MESSAGE


SENDER:	CAIN	T3,0		;PID=0?
	POPJ	P,0		;YES RETURN NOW
	PUSHJ	P,ECHO		;NO RESEND THE MSG
	POPJ	P,0		;THEN RETURN


;ROUTINE TO ACTUALLY DO THE SENDING OF THE MESSAGE


ECHO:	MOVEM	T3,SPDB+.IPCFR	;GET THE PID INTO THE MESSAGE
	MOVE	T1,SPDBPT	;POINT AT THE PDB
	IPCFS.	T1,		;SEND!!
	 JRST	SNDERR		;HANDLE THE ERROR
	POPJ	P,0		;RETURN
;ROUTINE TO FIND OUT IPCC'S PID


GIPCID:	MOVE	T1,IPCPT	;SET UP TO GET IPCC'S PID
	GETTAB	T1,		;GET IT
	 FATAL <CAN'T GETTAB IPCC'S PID>
	MOVEM	T1,IPCPID	;PUT IT AWAY
	POPJ	P,0		;AND RETURN
;ROUTINE TO SET MY QUOTAS TO INFINITY


QUOSET:	PUSHJ	P,CLRSND	;CLR MSG BLK
	MOVEI	T1,.IPCSQ	;SET FCN
	MOVEM	T1,SMSG		;IN THE MSG
	MOVE	T1,OURPID	;GET MY PID
	MOVEM	T1,SMSG+1	;INTO THE MSG
	MOVEI	T1,-1		;SET THE QUOTAS TO INFINITY
	MOVEM	T1,SMSG+2	;IN MSG
	MOVEI	T1,IP.CFP	;SET THE PRIV BIT IN FLAGS
	MOVEM	T1,SPDB+.IPCFL	;IN THE FLAGS WORD
	MOVE	T1,SMSGPT	;POINT AT MSG
	MOVEM	T1,SPDB+.IPCFP	;IN PDB
	MOVE	T1,IPCPID	;GET IPCC'S PID
	MOVEM	T1,SPDB+.IPCFR	;USE AS RECIEVERS PID
	MOVE	T1,SPDBPT	;POINT AT PDB
	IPCFS.	T1,		;SEND!!!
	 JRST	SNDERR		;HANDLE ERRORS
	PUSHJ	P,CLRRCV	;CLR MSG BLK
	MOVE	T1,RMSGPT	;POINT AT MSG
	MOVEM	T1,RPDB+.IPCFP	;IN PDB
	MOVE	T1,RPDBPT	;POINT AT PDB
	IPCFR.	T1,		;RECIEVE
	 JRST	RCVERR		;HANDLE THE ERROR
	MOVE	T1,RMSG+2	;GET THE QUOTA
	CAIE	T1,-1		;INFINITE QUOTA?
	 FATAL <FAILED TO SET IPCF QUOTAS TO INFINITY>
	POPJ	P, 0		;YES WE DID IT!!
;ROUTINE TO SEND A MESSAGE TO A WOULD BE SLAVE TELLING HIM WE HAVE NO ROOM
;FOR HIM TO BECOME A SLAVE


NOROOM:	PUSHJ	P,CLRSND	;GO CLR MSG BLK
	MOVE	T1,NCNTMS	;PUT A "NO CONNECT" 
	MOVEM	T1,SMSG		;INTO MSG
	MOVE	T1,CMSGPT	;POINT TO A CONNECT MSG
	MOVEM	T1,SPDB+.IPCFP	;IN PDB
	MOVE	T1,RPDB+.IPCFS	;GET SENDERS PID
	MOVEM	T1,SPDB+.IPCFR	;USE IT AS RECIEVERS PID
	MOVE	T1,SPDBPT	;POINT AT PDB
	IPCFS.	T1,
	 JRST	SNDERR		;GO HANDLE ERRORS
	JRST	PAKWAT		;OR GO WAIT FOR ANOTHER PACKET
;HERE ON A SEND ERROR FROM IPCF


SNDERR:	MOVE	T2,T1		;GET ME THE ERROR CODE
	CAIG	T2,5		;GREATER THAN 5?
	FATAL	<FATAL IPCF ERROR>
	CAIN	T1,6		;ERROR 6?
	 JRST	ERR6CD		;YES ILL HANDLE IT
	CAIN	T1,7		;ERROR 7 ?
	 JRST	ERR7CD		;YES ILL HANDLE IT
	CAIN	T1,10		;ERROR 10 ?
	 JRST	ER10CD		;YES ILL HANDLE
	CAIN	T1,11		;ERROR 11?
	 JRST	ER11CD		;YES 
	FATAL	<FATAL IPCF ERROR>

;HERE ON A RECIEVE ERROR

RCVERR:	HALT .
;ASSORTED ERROR HANDLING ROUTINES


ERR6CD:	MOVE	T1,SPDB+.IPCFR	;GET RECIEVERS PID
	MOVNI	T4,SLVCNT	;GET -NUMBER OF SLAVES
	HRL	T4,T4		;MAKE IT -SLVNUM,,0
	MOVEI	T2,SLVTBL	;GET THE ADDRESS
	HRR	T4,T2		;MAKE IT -SLVNUM,,SLVPID
ERR6LP:	CAMN	T1,(T4)		;IS THIS THE ONE?
	 JRST	ZEROIT		;YES GO KILL IT
	AOBJN	T4,ERR6LP	;NO..GO LOOK AGAIN
	JRST	PAKWAT		;IF YOU DONT FIND IT..I DONT CARE


ERR7CD:	HALT .


ER10CD:	HALT .


ER11CD:	HALT .
;ASSORTED CONSTANT DEFINITIONS


SPDBPT:	XWD PDBLEN,SPDB		;POINTS AT PDB OF SENT MSG
RPDBPT:	XWD PDBLEN,RPDB		;POINTS AT PDB OF RECIEVED MSG
SMSGPT:	XWD MSGLEN,SMSG		;POINTS AT SENT MESSAGE
RMSGPT:	XWD MSGLEN,RMSG		;POINTS AT RECIEVED MESSAGE
CMSGPT:	XWD 1,SMSG		;POINTS AT CONNECT MSG
PRIVPT:	XWD -1,.GTPRV		;GETTAB ARG FOR PRIVS
IPCPT:	XWD .IPCPS,.GTSID	;GETTAB ARG FOR IPCC'S PID
SELPTR:	XWD .IPCPL,.GTSID	;GETTAB ARG FOR SEL'S PID
CLRSMS:	XWD SPDB,SPDB+1		;BLT WD TO CLR SMSG
CLRRMS:	XWD RPDB,RPDB+1		;BLT WD TO CLR RMSG
MOVSMR:	XWD RMSG,SMSG		;BLT WD TO MOVE SMSG TO RMSG
MOVRMS:	XWD SMSG,RMSG		;BLT WD TO MOVE RMSG TO SMSG
CLRPTB:	XWD SLVTBL,SLVTBL+1	;BLT WD TO CLR SLAVE PID TABLE
MOVIBK:	XWD IHANCD,INTBLK	;BLT WD TO SET UP INTERRUPT BLK
CNCTMS: SIXBIT/CNCT/
NCNTMS:	SIXBIT/NOCNCT/
OCNTMS:	SIXBIT/OKCNCT/
IHANCD:	XWD 4,CCTRAP
	XWD 0,ER.ICC
	Z
	Z
;ROUTINE TO SET UP CTRL-C TRAP

TRPSET:	MOVE	T1,MOVIBK	;GET BLT WD
	BLT	T1,INTBLK+3	;BLITTTT!!!
	MOVEI	T1,INTBLK	;[713-TJW]GET ^C TRAP HNDLR BLOCK ADR
	MOVEM	T1,.JBINT	;[713-TJW]PUT IT INTO THE INTERRUPT WORD
	POPJ	P,0		;[713-TJW]RETURN


;ROUTINE TO HANDLE CTRL-C TRAP


CCTRAP:	HLRZ	T3,INTBLK+.ERCCL
	CAIE	T3,ER.ICC
	HALT 	.
	EXIT	0,
	;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:	TRNE	F,F.SEQ		;[532]"/SEQ:"??
	 JRST	SEQCHK		;YES,GO CHECK
	TRNE	F,F.ENT		;[731]/ENTRY?
	 JRST	ENTCHK		;YES
	SKIPN	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
	SKPNOW			;[713-TJW] BUFFERS ALREADY FILLED.
	TLO	F,F.READ	;[713-TJW]NOW LETS DO BUFFER XFER
XFRMOR:	NOTNOW			;[713-TJW]BUFFERS ALREADY FILLED
	 JRST	XFRDUN		;[713-TJW]IF ON-LINE LOGGING
	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	; reload? (1)  [110]
	pushj	p,sumupd##	;yes, update perm counters
	MOVE	T1,ERTYPE	;GET TYPE OF ENTRY
	CAIN	T1,ER.DPE	;DISK ENTRY? (10)
	PUSHJ	P,DVCHAR	;SETUP DEVICE TYPE ETC
	MOVE	T1,ERTYPE
	CAIN	T1,ER.MAG	;MAGTAPE ENTRY? (200)
	PUSHJ	P,TMCHAR	;SETUP
	MOVE	T1,ERTYPE	;AGAIN
	CAIN	T1,ER.MDE	;MASBUS ENTRY? (11)
	PUSHJ	P,MDECHR	;DO THIS ALSO
	move	t1,ERTYPE	;and restore
	CAIN	T1,SEC%MB	;IS THIS A MASSBUS ENTRY FOR TOPS-20? (111)
	PUSHJ	P,MBCHAR	;YES-GO SET UP CHARACTERISTICS
	MOVE	T1,ERTYPE	;NO!			[510]
	CAIN	T1,SEC%DX	;DX20 ENTRY? (112)	[510]
	PUSHJ	P,DXCHAR	;YES! - DO SETUP	[510]
	MOVE	P4,ERRIND
	TLNE	F,F.BTCK	;NEED TO EXAMINE ENTRY TO DETERMINE LISTING?
	PUSHJ	P,[SKIPE ERRIND
			PUSHJ P,@BITCHK##(P4)	;GO DO BIT CHECKING
			POPJ	P,0]
	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
;START [731]
ENTCHK:	MOVE	T1,ERTYPE	;GET CURRENT ENTRY
	CAME	T1,ENTRY		;MATCH ARGUEMENT?
	 JRST	SKIPIT			;NOPE
	JRST	XFRBUF			;YES LIST IT
;END[731]

SEQCHK:	;CHANGED WITH [706] TO FIX KLERROR
	MOVE	T1,[SIXBIT/KLERR/]	;SETUP
	MOVEM	T1,DEV			;& FORCE /DEV CHK
	TLO	F,F.DEV		
	MOVE	T1,ERTYPE
	CAIN	T1,30		;TOPS-10 KLERROR?
	 TLO	F,F.BTCK		;YES,FORCE BIT CHECK
	CAIN	T1,130		;TOPS-20
	 TLO	F,F.BTCK
	MOVE	T1,SEQIND	;CURRENT INDEX
	SKIPN	T2,SEQTAB(T1)	;VALID OR END OF TABLE
	 JRST	GOSUM		;ALL DONE
	CAME	T2,SEQNUM	;MATCH
	 JRST	SEQCK1		;NO,CHECK FURTHER
	AOS	T1		;BUMP INDEX
	MOVEM	T1,SEQIND	;STORE IT
	JRST	XFRBUF		;AND FORCE LISTING
;HERE IF NO MATCH,CHECK FOR KLERROR
SEQCK1:	TLNE	F,F.BTCK		;IF ON
	 JRST	XFRBUF		;GO BACK THEN TO BCKx30 FOR CHECK
	JRST	SKIPIT		;ELSE SKIP[ THIS ENTRY
	;END[706-RLD]
	SUBTTL	NEW COMMAND PROCESSOR - EXECUTES THE 'CMDWRD' MACRO COMMANDS

;START EDIT  [724]
;CALLED FROM PROCSx IF /BRIEF WAS USED IN COMMAND LINE
;COMMANDS MAY CONTAIN 2-4 WORDS EACH

;BUILD THE EFFECTIVE WORD

NEWCMD:	MOVE	T1,ERRIND	;GET THE OFFSET FOR THIS ENTRY TYPE
	HLRZ	CTINDX,ERRTBL(T1) ;GET THE BRIEF CONTROL TABLE POINTER
NWCMD1:	SETZB	P2,OFFSET	;CLEAR SUB-TABLE POINTER & EFFECTIVE WORD
	MOVE	P1,(CTINDX)	;GET FIRST WORD IN COMMAND
	HRRZ	T1,P1		;GET RH OF COMMAND
	CAIN	T1,-1		;ANY EFFECTIVE WORD?
	 JRST	PRETXT		;NO! - DON'T TRY TO BUILD ONE
	LDB	T1,[POINT 2,P1,16] ;GET EFFECTIVE WORD FLAGS
	JRST	@EFWRD(T1)	;BUILD EFFECTIVE WORD

EFWRD:	EFWRD0			;SUB-TABLE & WORD OFFSETS IN WKBUFF
	EFWRD1			;SUB-TABLE OFFSET & BYTE POINTER
	EFWRD2			;REGISTER REFERENCE
	EFWRD3			;REGISTER REFERENCE & BYTE POINTER

EFWRD0:	LDB	T1,[POINT 9,P1,26] ;GET SUB-TABLE OFFSET
	CAIE	T1,777		;ANY SUB-TABLE POINTER ?
	 PUSHJ	P,GETSUB	;YES! - WORD IS IN SUB-TABLE IN 'WKBUFF'
	LDB	P2,[POINT 9,P1,35] ;GET WORD OFFSET
	ADD	P2,OFFSET	;ADD ANY SUB-TABLE OFFSET
	CAMLE	P2,ENTRWC	;OUTSIDE ENTRY?
	JRST	NXTCMD		;YES! - TRY NEXT COMMAND
	MOVE	P2,WKBUFF(P2)	;GET WORD
	TLNE	P1,MSK		;USE MASK?
	AND	P2,2(CTINDX)	;YES!
	JRST	TSTCMD		;EXECUTE TEST COMMAND

EFWRD1:	LDB	T1,[POINT 9,P1,26] ;GET SUB-TABLE OFFSET
	CAIE	T1,777		;ANY SUB-TABLE POINTER ?
	 PUSHJ	P,GETSUB	;YES! - WORD IS IN SUB-TABLE IN 'WKBUFF'
	MOVEI	P2,WKBUFF	;GET LOCATION OF 'WKBUFF'
	ADD	P2,OFFSET	;ADD ANY SUB-TABLE OFFSET
	LDB	P2,2(CTINDX)	;GET BYTE - USES 'P2' AS INDEX REGISTER
	TLNE	P1,MSK		;USE MASK?
	AND	P2,3(CTINDX)	;YES!
	JRST	TSTCMD		;EXECUTE TEST COMMAND

EFWRD2:	MOVE	P2,(P1)		;GET LOWSEG REGISTER
	TLNE	P1,MSK		;USE MASK?
	AND	P2,2(CTINDX)	;YES!
	JRST	TSTCMD		;EXECUTE TEST COMMAND

EFWRD3:	SETZ	P2,		;MAKE SURE 'P2' IS ZERO
	LDB	P2,2(CTINDX)	;GET BYTE - USES 'P2' AS INDEX REGISTER
	TLNE	P1,MSK		;USE MASK?
	AND	P2,3(CTINDX)	;YES!
	JRST	TSTCMD		;EXECUTE TEST COMMAND

;GET SUB-TABLE OFFSET  (OFFSET TO WORD ALREADY IN 'T1')

GETSUB:	CAMLE	T1,ENTRWC	;OUTSIDE ENTRY?
	JRST	SUBQIT		;YES! - CLEAN STACK & TRY NEXT COMMAND
	HRRZ	T1,WKBUFF(T1)	;GET OFFSET WORD
	MOVEM	T1,OFFSET	;SAVE IT
	POPJ	P,		;RETURN

;SUB-TABLE POINTER OUT OF ENTRY RANGE

SUBQIT:	POP	P,T1		;CLEAN UP STACK
	JRST	NXTCMD		;SKIP THIS COMMAND
;EFFECTIVE WORD TEST FUNCTION TABLE
; EXECUTE DISPATCH COMMAND IF TEST IS SATISFIED

NWFUNC:	CAMA	P2,T2	;ALWAYS - ALWAYS EXECUTE DISPATCH COMMAND
	CAML	P2,T2	;IFLT - IF EFFECTIVE WORD LESS THAN VALUE
	CAMLE	P2,T2	;IFLQ - IF EFFECTIVE WORD LESS THAN OR EQUAL TO VALUE
	CAME	P2,T2	;IFEQ - IF EFFECTIVE WORD EQUALS VALUE
	CAMN	P2,T2	;IFNE - IF EFFECTIVE WORD NOT EQUAL TO VALUE
	CAMGE	P2,T2	;IFGQ - IF EFFECTIVE WORD GREATER THAN OR EQUAL TO VALUE
	CAMG	P2,T2	;IFGT - IF EFFECTIVE WORD GREATER THAN VALUE
	CAM	P2,T2	;NEVER - NEVER EXECUTE DISPATCH COMMAND - NO-OP

TSTCMD:	LDB	T1,[POINT 3,P1,2] ;GET TEST FUNCTION
	LDB	T2,[POINT 6,P1,8] ;GET TEST VALUE
	XCT	NWFUNC(T1)	;TEST SATISFIED?
	JRST	NXTCMD		;NO! - TRY NEXT COMMAND
PRETXT:	TLNE	P1,1B29		;POST TEXT?
	JRST	DSPCMD		;YES! - SKIP PRE TEXT ROUTINE & OUTPUT A SPACE
	HLRZ	T1,1(CTINDX)	;NO! - GET TEXT POINTER
	SKIPE	T1		;IS THERE ANY TEXT?
	PUSHJ	P,.TSTRG	;YES! - SEND IT
	SKIPA			;SKIP SPACE FOR POST TEXT
DSPCMD:	PUSHJ	P,.TSPAC	;INSURE A SPACE BETWEEN COMMANDS FOR POST TEXT
	HRRZ	T2,1(CTINDX)	;GET DISPATCH COMMAND ARGUMENT
	LDB	T1,[POINT 2,P1,10] ;GET DISPATCH FUNCTION
	JRST	@DSPCD(T1)	;EXECUTE DISPATCH FUNCTION

DSPCD:	DSPCD0			;EXECUTE 'DO' FUNCTION
	DSPCD1			;EXECUTE 'XFR' FUNCTION
	DSPCD2			;EXECUTE 'TRANSL' FUNCTION
	DSPCD3			;NOT USED - TRY NEXT COMMAND

;DO FUNCTION	***** NOTE - "P" REGISTERS ARE FAIR GAME IN THIS CALL *****

DSPCD0:	MOVE	T1,P2		;SOME ROUTINES ACCEPT ARGUMENTS IN "T1" (KLUDGE)
	SKIPE	T2		;NULL ROUTINE? (ie TEXT ONLY)
	PUSHJ	P,(T2)		;NO! - EXECUTE ROUTINE
	JRST	POSTXT		;DO ANY POST TEXT

;XFR FUNCTION

DSPCD1: MOVEM	T2,CTINDX	;SET UP TRANSFER ADDRESS
	JRST	NXCMD2		;CLEAN UP BUFFER

;TRANSL FUNCTION  ***** NOTE - "P" REGISTERS ARE FAIR GAME IN THIS CALL *****

DSPCD2:	MOVEM	T2,KONTYP	;SAVE TRANSLATION TEXT INDEX
	MOVE	P1,P2		;SETUP FOR TRANSLATOR
	PUSHJ	P,CNIDCD	;GO TRANSLATE
	JRST	POSTXT		;DO ANY POST TEXT

POSTXT:	MOVE	P1,(CTINDX)	;GET COMMAND BACK
	TLNN	P1,1B29		;POST TEXT?
	JRST	NXTCMD		;NO! - SKIP POST TEXT ROUTINE
	HLRZ	T1,1(CTINDX)	;YES! - GET TEXT POINTER
	SKIPE	T1		;IS THERE ANY TEXT?
	PUSHJ	P,.TSTRG	;YES! - SEND IT

DSPCD3:				;NOT USED
NXTCMD:	ADDI	CTINDX,2	;MOVE POINTER TO NEXT COMMAND
	TLNE	P1,BYT		;BYTE POINTER?
	 AOS	CTINDX		;YES! - BUMP IT ONCE MORE
	TLNE	P1,MSK		;MASK WORD?
	 AOS	CTINDX		;YES! - BUMP IT ONCE MORE
NXCMD2:	LDB	T1,[POINT 3,P1,14] ;GET CARRIAGE CONTROL COMMAND
	PUSHJ	P,CRCCMD	;CHECK OUTPUT BUFFER
	JRST	NWCMD1		;START NEXT COMMAND

;END EDIT  [724]
	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

;**********
; START OF HACK FOR DX20/TU70  [512]
;**********

MBCHAR:	LDB	T1,[POINT 5,WKBUFF+MB%TYP,^D35] ;[513]
	CAIGE	T1,.UTDX2		;[706]
	 PJRST	MBCHR1
	CAILE	T1,.UTT72
	  PJRST	MBCHR1			;  THIS IS A REAL 111 - LEAVE!
	MOVE	T1,ERTYPE		;GETBAD ERTYPE
	HRRZ	T2,ENTCHR(T1)		;GET CURRENT COUNT
	SKIPE	T2			;IF NOT ZERO
	SOS	ENTCHR(T1)		;DECREMENT TYPE COUNTER
	AOS	T1			;BUMP 
	AOS	ENTCHR(T1)		;[716-RLD]BUMP CORRECT COUNT
	MOVEM	T1,ERTYPE
	MOVE 	T1,[1B8]
	ADDM	T1,HDBUFF		;FIX ENTRY WORD 0
	MOVE	T1,ERTYPE
	PUSHJ	P,ERRINT		;GO FIX UP NAME, ETC.
	PUSHJ	P,DXCHAR
	POPJ	P,0
;END OF HACK  [512]

MBCHR1:	MOVEI	T1,WKBUFF		;SET BUFFER POINTER
	LDB	T2,[MB.CHN(T1)]		;CONTROLLER TYPE  [513]
	SETZ	T3,			;CLEAR TYPE FLAG  [600]
	CAIN	T2,.RH10		;IS IT AN RH10?
	 MOVEI	T3,..RH10		;YES! - SET FLAG FOR RH10
	CAIN	T2,.RH20		;IS IT AN RH20?
	 MOVEI	T3,..RH20		;YES! - SET FLAG FOR RH20
	CAIN	T2,.RH11		;IS IT AN RH11?  [600]
	 MOVEI	T3,..RH11		;YES! - SET FLAG FOR RH11
	SKIPN	T3			;VALID CONTROLLER?
	 JRST	MBCHA2			;NOPE!!
	MOVEM	T3,MASKON		;YES! - SAVE IT
	LDB	T2,[MB.DEV(T1)]		;GET UNIT TYPE
	HRRZ	T1,WKBUFF+MB%REG+6	;GET DEV TYPE
	ANDI	T1,77
	CAIN	T1,12			;TU45 ON TM02?
	 MOVEI	T2,3			;SAY SO
	CAIN	T1,52			;[536]TU45 ON TM03?
	 MOVEI	T2,3			;SAY SO
	CAIN	T1,20			;RP04?  START [315]
	 MOVEI	T2,1
	CAIN	T1,21			;RP05?
	 MOVEI	T2,5
	CAIN	T1,22			;RP06?
	 MOVEI	T2,6			;  END [315]
	CAIN	T1,TY.RM3		;RM03?  [601]
	 MOVEI	T2,.UTRM3		;YES! - SET IT
	CAIL	T2,.UTMIN		;VALID UNIT TYPE?  [607]
	 CAILE	T2,.UTMAX		;MAYBE! - WITHIN HIGH LIMIT?
	  JRST	MBCHA3			;NO! - REPORT ERROR
	MOVEM	T2,MDEDTP		;AND SAVE IT
	HRLZI	T1,'DPX'		;ASSUME A DSK TYPE DEVICE
	CAIN	T2,2			;RS04?
	 HRLZI	T1,'FSX'
	CAIN	T2,3			;TU45?
	 HRLZI	T1,'MTX'
	CAIN	T2,4			;TU16?
	 HRLZI	T1,'MTX'
	CAIN	T2,13			;TU77?
	 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
	;EDITS [221] - [611]
	SETZ	T2,			;CLEAR AC
	MOVE	T3,MDEDTP		;GET DEVICE TYPE
	CAIN	T3,.UTT45		;TAPE? - TU45?
	 HRRZ	T2,WKBUFF+MB%REG+11	;GET SLAVE #
	CAIN	T3,.UTTM2		;TM02/TU16?
	 HRRZ	T2,WKBUFF+MB%REG+11	;GET SLAVE #
	CAIN	T3,.UTT77		;TU77?
	 HRRZ	T2,WKBUFF+MB%REG+11	;GET SLAVE #
	ANDI	T2,7			;STRIP IT
	ADDI	T2,20			;TO SIXBIT
	DPB	T2,[POINT 6,T1,29]
	;END EDITS [221] - [611]
	MOVEM	T1,WKBUFF+MB%NAM	;SET IT FOR LATER
DXFATE:	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
	HRR	T3,M000T(T1)		;PREVIOUS CHN&UNIT TYPE  [613]
				;FOR THIS PHYSICAL ADDR
	SKIPN	T3		;SEEN THIS UNIT BEFORE?
	 JRST	MBCHA1		;NO SO DON'T CHECK
	CAMN	T2,M000T(T1)	;HAS THE UNIT TYPE CHANGED  [613]
	 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

	WARN	<2 DEVICES AT SAME PHYSICAL ADDRESS - POSSIBLE SUMMARY ERRORS!>	;  [612]
	POPJ	P,0;ADD CODE HERE TO COMPLAIN OF CHANGE,DO SUMMARY

MBCHA1:	MOVEM	T2,M000T(T1)		;SAVE CURRENT VALUE
	MOVE	T1,WKBUFF+MB%CAD	;GET CHAN #   [613]
	IMULI	T1,MAXSDV		;GET CONTROLLER OFFSET
	HLLM	T2,M000T(T1)		;INSURE CONTROLLER TYPE FOR SUM
	POPJ	P,0

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


	;DXCHAR - SETS UP UNIT TYPE, CONTROLLER TYPE
	;[510]	BUILDS UNIT NAME, SETS UP INDEX INTO TABLES

DXCHAR:	MOVE	T1,WKBUFF+DX%TYP	;GET TYPES
	LDB	T2,[POINT 4,T1,17]	;CONTROLLER TYPE	[513]
	CAIE	T2,2			;RH20?
	 JRST	DXCHR1			;NO! - GIVE UP - ABORT
	MOVEI	T3,5			;YES!
	MOVEM	T3,MASKON		;SET TYPE
	LDB	T2,[POINT 5,T1,35]	;GET UNIT TYPE		[513]
	CAIGE	T2,.UTDX2		;ST[704]
	 JRST	DXCHR2
	CAILE	T2,.UTT72
	 JRST	DXCHR2
	CAIN	T2,.UTDX2		;IF DX20, CHECK SENSE BYTES
	 PUSHJ	P,DXTYPE
	;END [704]

DXCHA1:	MOVEM	T2,MDEDTP		;SAVE UNIT TYPE
	HRLZI	T1,'MT '		;CREATE UNIT NAME
	MOVE	T2,WKBUFF+DX%CAD	;GET CHANNEL #
	ADDI	T2,20			;CONVERT TO SIXBIT
	DPB	T2,[POINT 6,T1,17]	;ADD TO UNIT NAME
	MOVE	T2,WKBUFF+DX%UAD	;GET UNIT ADDRESS
	ADDI	T2,20			;CONVERT TO SIXBIT
	DPB	T2,[POINT 6,T1,23]	;ADD TO UNIT NAME
	HRRZ	T2,WKBUFF+DX%MBR	;GET OFFSET FO MASBUSS REGISTERS
	SKIPN	T2			;IF 0,NOT VALID PNTR
	 JRST	DXCHR3			;BETTER QUIT
	MOVE	T2,WKBUFF+DM%DN(T2)	;GET DRIVE INFORMATION
	ANDI	T2,7			;MASK DRIVE #
	ADDI	T2,20			;MAKE IT SIXBIT
	DPB	T2,[POINT 6,T1,29]	;FINISH UNIT NAME
	MOVEM	T1,WKBUFF+DX%NAM	;SAVE IT
	JRST	DXFATE			;ANOTHER BLIND LEAP OF FAITH!!

	;DXCHAR ERROR EXITS

DXCHR1:	WARN	<DX20 ENTRY - NOT CONTROLLER TYPE 2 (RH20), ABORTING ENTRY!>
	JRST	ABORT			;GET NEXT ENTRY

DXCHR2:	WARN	<DX20 ENTRY - ILLEGAL UNIT TYPE, ABORTING ENTRY!>
	JRST	ABORT			;GET NEXT ENTRY
DXCHR3:	WARN <DX20 ENTRY-PNTR TO SUBTABLES IS BLANK,ABORTING ENTRY>
	JRST	ABORT

;ADDED W [704]
DXTYPE:	HRRZ	T1,WKBUFF+DX%DVL	;PNTR TO DEV INFO
	ADDI	T1,DT%SBB		;OFFSET TO SENSE BYTES 4-7
	SKIPN	T3,WKBUFF(T1)		;GET THE VALUE IF PRESENT
	 POPJ	P,0			;EMPTY, RETURN
	LDB	T1,[POINT ^D8,T3,27]	;GET SENSE BYTE 6
	TRNE	T1,1B31			;2x=TU72-E
	 JRST	[MOVEI	T2,.UTT72
		 JRST	DXTYP1]
	MOVEI	T2,.UTT70		;ASSUME TU70
	TRNE	T1,1B28			;ON=TU71
	 MOVEI	T2,.UTT71		;SO SAY SO
DXTYP1:	POPJ	P,0			;TYPE HAS BEEN FOUND IN SENSE BYTES

;END [704]
	;CNISUM -- SUBROUTINE TO PERFORM CONI BIT SUMMATION
	;SETUP	P2=RETRY WORD FOR TOPS-20,OFFSET TO RETRY WORD FOR TOPS-10
	;	P3 = OFFSET OF CONI WORD TO SUMMATE.
	;CALL	PUSHJ	P,CNISUM
	;
	;RETURN	CALL+1
	;NOTE THAT DVINDX AND KONTYP MUST BE SETUP FOR CORRECT DEVICE

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 TOPS-10 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 TOPS-20,OFFSET TO ETRY WORD FOR TOPS-10

		;	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 TOPS-10 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]  [745]

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
	;	EXPANDED TO TEST FOR GENERIC DEVICES  [745]

NDVCHK::MOVE	T1,WKBUFF(P3)	;PICKUP ENTRY DEVICE NAME
	CAMN	T1,NDEV		;SAME AS ONE USER SPECIFIED?
	JRST	ABORT		;YES! - DON'T LIST IT
	MOVE	T3,NDEV		;SETUP
	PUSHJ	P,.MKMSK	;BUILD A MASK OF NON-BLANK CHARACTERS
	MOVE	T2,WKBUFF(P3)
	AND	T2,T1		;MASK ENTRY'S DEVICE WORD
	CAMN	T2,NDEV		;NOW A MATCH?
	 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:	JUMPE	T1,ERRIN0	;DUMP IT IF ERROR CODE '0'  [755]
	MOVEI	T2,ALLLTH##	;GET LENGTH OF TABLE
	SETZB	T3,T4		;WORK SPACE
ERRIN1:	HRRZ	T3,ALLTBL##(T4)	;GET NEXT INDEX VALUE - CHANGED  [724]
	CAMN	T1,T3		;MATCH?
	JRST	ERRIN2		;YES
	AOS	T4	;UPDATE 
	CAIE	T4,ALLLTH+1	;END OF TABLE?
	JRST	ERRIN1		;NOT YET
ERRIN0:	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:	HRRZ	T3,ERRTBL(T4)	;GET NEXT INDEX VALUE - CHANGED  [724]
	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
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:	NOTNOW			;[751] DONT DO THIS IF /NOW
	 JRST ABORT
	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,		;YES
	MOVE	T3,STR		;[526]
	PUSHJ	P,.MKMSK
	MOVE	T2,WKBUFF(P3)
	AND	T2,T1
	CAME	T2,STR
	 JRST 	ABORT
	POPJ	P,0



	;DETCHK-ROUTINE TO TEST IF USER SAID /DETAIL
	;MODIFIED WITH [537] TO SUPPORT LEVEL OF DETAIL
	;CALL W. P1= LEVEL TO CHECK AS MINIMUM
	;CALL PUSHJ
	;RETURN IF HE SAID /DETAIL ELSE JRST ABORT

DETCHK:	TLNE	F,F.DET		;SAID /DETAIL?
	 JRST	DETCH0		;OK,CHECK FURTHER
	TYPEIT	<
=====REST OF INFORMATION AVAILABLE BY USING /DETAIL SWITCH=====
>
	JRST	ABORT		;NOW START NEXT ENTRY
DETCH0:	CAMG	P1,DETAIL	;VALUE .GT. ARGUEMENT
	 POPJ	P,0		;OK-RETURN
	;TEST FAILED, GIVE MESSAGE THEN ABORT ENTRY
	TYPEIT	<
*** MORE INFORMATION AVAILABLE BY USING HIGHER LEVEL OF /DETAIL:
     SWITCH SET AT >

	MOVE	T1,P1		;TYPE OUT PRESENT DETAIL LEVEL  [602]
	PUSHJ	P,.ODECW
	JRST	ABORT
;	START EDIT  [614]
;SBUSFN - ROUTINE TO PROCESS S-BUS FUNCTION SUB-TABLE IN
;	   PARITY INTERRUPT ENTRY (62 & 162)
;
;	POINTER TO SUBTABLE IS IN P2

SBUSFN:	SETZ	P1,
	PUSHJ	P,DETCHK		;CHECK DETAIL SWITCH
	TYPEIT	<
SYSTEM MEMORY CONFIGURATION:
>
	MOVE	P1,P2
	ADDI	P1,WKBUFF+1		;POINT AT FUNCTION 0 FOR CONTROLLER
;[733] FIXED TO CORRECTLY SUPPORT MF20

SBUS01:	HRRZ	P3,-1(P1)		;GET CONTROLLER NUMBER
	MOVE	P2,1(P1)	;GET FUNCTION 1
	TYPEIT	<
CONTROLLER:  #>
	MOVE	T1,P3			;CONTROLLER #
	PUSHJ	P,.TOCTW
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	LDB	T2,[POINT 4,P2,11]	;GET TYPE
	PUSH	P,T2		;SAVE IT
	MOVE	T1,SBSTYP(T2)
	PUSHJ	P,.TSIXN
	PUSHJ	P,.TSPAC
	PUSHJ	P,.TSPAC
	POP	P,T3			;GET MEMORY TYPE BACK
	CAIN	T3,5		;MF20?
	 JRST	SBUSMF		;YES-A FEW DIFFERENCES, GO DO IT
	LDB	T2,[POINT 4,P2,7]	;# OF MODULES
	SETZ	T1,
	TRNE	T2,1B35		;SM0 PRESENT?
	 ADDI	T1,1
	TRNE	T2,1B34		;SM1?
	 ADDI	T1,1
	TRNE	T2,1B33		;SM2?
	 ADDI	T1,1
	TRNE	T2,1B32		;SM3?
	 ADDI	T1,1
	MUL	T1,SBSSIZ(T3)	;TIMES UNIT SIZE
	MOVE	T1,T2			;ANSWER TO T1
	PUSHJ	P,.TDECW
	TYPEIT	< K>
	TYPEIT	<
F0:	>
	MOVE	T1,0(P1)	;GET FUNCTION 0
	PUSHJ	P,.TXWDW
	TYPEIT	<	F1:	>
	MOVE	T1,1(P1)	;GET FUNCTOON 1
	PUSHJ	P,.TXWDW
	TYPEIT	<
	INTERLEAVE MODE:	>
	MOVE	T2,0(P1)	;GET FUNCTION 0
	LDB	T3,[POINT 2,T2,7]
	MOVE	T1,SBSINT(T3)	;POINTER TO ASCIZ OF INT. MODE
	PUSHJ	P,.TSTRG
	TYPEIT	<
	REQ ENABLED:	>
	MOVE	P2,1(P1)		;GET FUNCTION 1
	TRNN	P2,1B32		;0?
	JRST	.+3
	TYPEIT	<0 >
	TRNN	P2,1B33
	JRST	.+3
	TYPEIT	<1 >
	TRNN	P2,1B34
	JRST	.+3
	TYPEIT	<2 >
	TRNN	P2,1B35
	JRST	.+3
	TYPEIT	(3)
	TYPEIT	<
	LOWER ADDRESS BOUNDARY:	>
	MOVE	P2,1(P1)	;GET FUNCTION 1
	LDB	T1,[POINT 8,P2,21]	;GETS ADDRESS BITDS
	LSH	T1,^D14		;MOVED OVER TO CONVERT TO BETTER FORMAT
	PUSHJ	P,.TOCTW
	TYPEIT	<
	UPPER ADDRESS BOUNDARY:	>
	LDB	T1,[POINT 4,P2,25]	;GETS 18-21
	LSH	T1,^D14		;MOVED TO CORRECT PLACE
	LDB	T2,[POINT 4,P2,17]	;GET 14-17
	HRL	T1,T2	;SETSUP 14-21 FOR UPPER ADDR
	TRO	T1,37777	;SET THE OTHER BITS
	PUSHJ	P,.TOCTW
SBUSER:	TYPEIT	<
	ERRORS DETECTED:	>
	MOVE	P2,0(P1)
	LDB	P4,[POINT 6,P2,5]	;6 ERROR BITS
	SKIPN	P4			;ANY SET?
	 PUSHJ	P,[TYPEIT (NONE)
		POPJ	P,0]
	TRNE	P4,1B30			
	 PUSHJ	P,[TYPEIT (CONTR ERR)
		POPJ	P,0]
	TRNE	P4,1B31			;
	 PUSHJ	P,[TYPEIT (CORR ERR)
		POPJ	P,0]
	TRNE	P4,1B32			;INC CYCLE?
	 PUSHJ	P,[TYPEIT (INC CYCLE)
		POPJ	P,0]
	TRNE	P4,1B33			;READ PARITY
	 PUSHJ	P,[TYPEIT (READ PARITY)
		POPJ	P,0]
	TRNE	P4,1B34
	 PUSHJ	P,[TYPEIT (WRITE PARITY)
		POPJ	P,0]
	TRNE	P4,1B35
	 PUSHJ	P,[TYPEIT (ADDR PARITY)
		POPJ	P,0]

SBUS77:	HLRO	T1,-1(P1)	;GET -# OF FUNCTIONS FOR LAST CONTROLLER
	SUB	P1,T1		;ADVANCE POINTER (SUBTRACT NEG #)
	AOBJN	P1,SBUS01	;DO NEXT CONTROLLER YX
	 POPJ	P,0		;ALL DONE
;HERE TO DECODE F0 & F1 FOR MF20, RETURN TO SBUSER TO LIST ERRORS DETECTED
;P1=PNTR,P2=F0,P3=F1

SBUSMF:		TYPEIT	<
F0:	>
	MOVE	T1,0(P1)	;GET FUNCTION 0
	PUSHJ	P,.TXWDW
	TYPEIT	<	F1:	>
	MOVE	T1,1(P1)	;GET FUNCTOON 1
	PUSHJ	P,.TXWDW
	TYPEIT	<
LAST WORD REQUEST:	>
	HLRZ	P4,0(P1)	;GET 0-17 OF F0
	TRNE	P4,1B26
	 PUSHJ	P,[TYPEIT (RQ0)
		POPJ	P,0]
	TRNE	P4,1B27
	 PUSHJ	P,[TYPEIT (RQ1)
		POPJ	P,0]
	TRNE	P4,1B28
	 PUSHJ	P,[TYPEIT (RQ2)
		POPJ	P,0]
	TRNE	P4,1B29
	 PUSHJ	P,[TYPEIT (RQ3)
		POPJ	P,0]
	TRNE	P4,1B30		;READ?
	 PUSHJ	P,[ TYPEIT (- READ )
			POPJ	P,0]
	TRNE	P4,1B31		;WRITE?
	 PUSHJ	P,[ TYPEIT ( WRITE )
			POPJ	P,0]
	TYPEIT	<
LAST ADDRESS HELD:	>
	MOVE	T2,0(P1)	;GET F0
	LDB	T1,[POINT 22,T2,35]	;ADDRESS FIELD
	PUSHJ	P,.TOCTW	;LIST IT
	TYPEIT <
CONTROLLER STATUS:	>
	MOVE	P4,1(P1)	;GET F1
	TRNE	P4,1B25		;DISABLED?
	 PUSHJ	P,[ TYPEIT (DISABLED)
		POPJ	P,0]
	TYPEIT 	< SF2 & SF1= >
	LDB	T1,[POINT 2,P4,27]
	PUSHJ	P,.TOCTW	;IN OCTAL

	JRST	SBUSER		;RETURN TO LIST DETECTED ERRORS
;END OF [733]

SBSTYP:	SIXBIT/CUST/
	SIXBIT/MA20/
	SIXBIT/DMA20/
	SIXBIT/MB20/
	SIXBIT/UNKN/
	SIXBIT/MF20/

SBSSIZ:	0
	^D16
	0
	^D32
	0
	0

SBSINT:	[ASCIZ/OFF-LINE/]
	[ASCIZ/NONE/]
	[ASCIZ/2-WAY/]
	[ASCIZ/4-WAY/]
	;ROUTINE TO DO OUTPUT FOR DMA SBUS FUNCTION
SBDMA:	MOVE	P1,0(P2)		;GET FUNCTION
	TYPEIT	<
	INTERLEAVE MODE:	>
	LDB	T2,[POINT 2,P1,7]	;GET INTERLEAVE MODE
	MOVE	T1,[SIXBIT/4 WAY/]	;ASSUME THE BEST
	CAIN	T2,2
	 MOVE	T1,[SIXBIT/2 WAY/]
	CAIN	T2,1
	 MOVE	T1,[SIXBIT/NONE/]	;WE TRIED
	PUSHJ	P,.TSIXN
	TYPEIT	<
	DMA:
	LAST ADDR HELD:	>
	LDB	T1,[POINT 22,P1,35]	;A FEW ADDR BITS
	PUSHJ	P,.TOCTW
	TYPEIT	<
	ERRORS DETECTED:	>
	LDB	P3,[POINT 6,P1,5]	;6 ERROR BITS
	SKIPN	P3			;ANY SET?
	 PUSHJ	P,[TYPEIT (NONE)
		POPJ	P,0]
	TRNE	P3,1B32			;NXM?
	 PUSHJ	P,[TYPEIT (INC. CYCLE)	;[435]
		POPJ	P,0]
	TRNE	P3,1B33			;READ PARITY
	 PUSHJ	P,[TYPEIT (READ PARITY)
		POPJ	P,0]
	TRNE	P3,1B34
	 PUSHJ	P,[TYPEIT (WRITE PARITY)
		POPJ	P,0]
	TRNE	P3,1B35
	 PUSHJ	P,[TYPEIT (ADDR PARITY)
		POPJ	P,0]
	JRST	SBUS77			;GET NEXT CONTROLLER

;END EDIT  [614]
	;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:	SKIPN	HEADWC		;HDR LENGTH =0  [760]
	  JRST	HEADST		;YES
	SKIPN	ENTRWC		;BODY = 0?
	  JRST	ENTRST
	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 #  [545]  [610]
	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
	SUBTTL	HEADER OUTPUT ROUTINES

	;TITLST -- SUBROUTINE TO OUTPUT PAGE TITLE
	;TTLS1 -- ENTRY POINT FOR SYSERS - DOESN'T DO PAGE LIMIT CHECK
	;CALL	PUSHJ	P,TITLST
	;
	;RETURN	CALL+1

TITLST:	PUSHJ	P,FFPRNT	;DOES FORMFEED AND PAGE LIMIT TEST
TTLS1:	TYPEIT	<SYSERR %>
	PUSHJ	P,VERED		;GO TO ROUTINE TO PRINT VERSION AND EDIT NUMBERS
	TYPEIT <		SYSTEM  >
	MOVE	T1,SYSSER
	ANDI	T1,SYS.SN
	PUSHJ	P,.ODECW
	TYPEIT	<   >
	SKIPE	TOPMON		;TOPS-20 RUNNING?
	 JRST	TITLS1		;YES! - DO TOPS-20 STYLE
	PUSHJ	P,.TDATN	;GO TYPE TODAYS DATE
	PUSHJ	P,.TTIMN	;GO TYPE CURRENT TIME
	JRST	TITLS2		;SKIP OVER TOPS-20 STUFF

TITLS1:	HRROI	T1,DATLOC	;STR CONVERTED ASCIZ HERE
	SETO	T2,		;CURRENT TIME AND DATE
	HRLZI	T3,200		;LISTING OPTION ON DATE AND TIME  (NO SECONDS)
	ODTIM			;CONVERT
	HRRZI	T1,DATLOC
	PUSHJ	P,.TSTRG	;NOW LIST IT

TITLS2:	TYPEIT	<   	PAGE >
	MOVE	T1,PAGNUM	;OUTPUT PAGE #
	PUSHJ	P,.TDECW	; IN DECIMAL
	PUSHJ	P,.TCRLF	; [724]
	POPJ	P,



VERED:	MOVEI	T1,VSYSER	;PICKUP VERSION NUMBER
	PUSHJ	P,.TOCTW

;EDIT 106
IFG <VMINOR>,<
IFG <VMINOR+"A"-"Z">,<	;IF MANY PATCHES
	MOVEI	T1,<<VMINOR-1>/<"Z"-"A">>+"A"
	PUSHJ	P,.TCHAR
>		;END MASSIVE EDITS

	MOVEI	T1,"A"+VMINOR-1-<"Z"-"A">*<<VMINOR-1>/<"Z"-"A">>
	PUSHJ	P,.TCHAR	;THANKS FOR EDIT 106!!!
>
	TYPEIT	<(>
	MOVEI	T1,VEDIT
	PUSHJ	P,.TOCTW
	TYPEIT	<)>

	;MORE OF 106
IFG <VWHO>,<
	MOVNI	T1,VWHO	;IF NON-DEC
	PUSHJ	P,.TDECW	;AND LIST
>
	POPJ	P,
;START EDIT  [724]

	;BRFHDR - PRINTS BRIEF HEADER

BRFHDR:	MOVE	T1,LINCNT	;GET CURRENT LINE COUNT
	ADDI	T1,5		;ADD MAX BRIEF ENTRY LENGTH COUNTING DATE LINE
	CAILE	T1,0		;CAN WE PRINT THIS ENTRY WITHOUT PAGE OVERFLOW
	PUSHJ	P,TITLST	;NO! - START NEW PAGE
	SKIPE	TOPMON		;TOPS-20 RUNNING?		START EDIT [737]
	SKIPN	TOPENT		;YES! - TOPS-20 ENTRY?
	 JRST	BRFHD		;NO! - MUST DO TEN STYLE
	MOVE	T2,HDBUFF+HDRDAT ;GET THE DATE
	HRLZI	T4,40000	;MAKE IT JULIAN DATE
	ODCNV			; RETURNS  [YEAR,,JULIAN DATE]  IN 'T2'
	SKIPA			;SKIP TOPS-10 LINE
BRFHD:	HLLZ	T2,HDBUFF+HDRDAT ;GET DATE ALONE - TOPS-10
	CAME	T2,BRFDAT	;DATE CHANGE?			END EDIT  [737]
	PUSHJ	P,BRFHD2	;YES! - OUTPUT NEW DATE LINE
	PUSHJ	P,.TCRLF	;CR
	MOVE	T1,SEQNUM	;GET SEQ NUMBER
	PUSHJ	P,.ODECW	;OUTPUT IN DECIMAL WITH '.'
	PUSHJ	P,.TSPAC	;OUTPUT SPACE
	SKIPE	TOPENT		;TOPS-20 RECORDED?
	 PJRST	BRFHDB		;YES! - TRY TOPS-20 STYLE
BRFHD0:	MOVE	T1,HDBUFF+HDRDAT ;GET DATE
	PUSHJ	P,.CNTDT	;CONVERT TO STANDARD FORMAT
	PUSHJ	P,.TTIME	;OUTPUT TIME
	MOVEI	T1,CCF6		;STRING CONTAINS FF's & CR's
	PJRST	CRCCMD		;DONE HEADERS - FORCE ALL OF THIS OUT & RETURN

BRFHD2:	MOVEM	T2,BRFDAT	;SAVE LATEST DATE   [737]
	PUSHJ	P,.TCRLF	;CR
	PUSHJ	P,.TCRLF	;CR
	TYPEIT	<SEQ   TIME    >
	SKIPE	TOPENT		;TOPS-20 RECORDED?
	 PJRST	BRFHDA		;YES! - TRY TOPS-20 STYLE
BRFHD3:	MOVE	T1,BRFDAT	;GET DATE BACK
	PUSHJ	P,.CNTDT	;CONVERT TO STANDARD FORMAT
	MOVE	T1,T2		;POSITION DATE
	PUSHJ	P,.TDATE	;OUTPUT DATE
	PJRST	.TCRLF	;DO CR/LF & RETURN

BRFHDA:	SKIPN	TOPMON		;TOPS-20 RUNNING?
	 PJRST	BRFHD3		;NO! - MUST DO TEN STYLE
	HRROI	T1,DATLOC	;WHERE TO STORE IT
	MOVE	T2,HDBUFF+HDRDAT ;GET DATE
	HRLZI	T3,202401	;FORMAT FOR OUTPUT
	ODTIM			;TRANSLATE DATE TO TEXT
	HRRZI	T1,DATLOC	;GET STRING POINTER
	PUSHJ	P,.TSTRG	;NOW LIST IT
	PJRST	.TCRLF	;DO CR/LF & RETURN

BRFHDB:	SKIPN	TOPMON		;TOPS-20 RUNNING?
	 PJRST	BRFHD0		;NO! - MUST DO TEN STYLE
	HRROI	T1,DATLOC	;WHERE TO STORE IT
	MOVE	T2,HDBUFF+HDRDAT ;GET DATE
	HRLZI	T3,400000	;FORMAT FOR OUTPUT
	ODTIM			;TRANSLATE DATE TO TEXT
	HRRZI	T1,DATLOC	;GET STRING POINTER
	PUSHJ	P,.TSTRG	;NOW LIST IT
	MOVEI	T1,CCF6		;STRING CONTAINS FF's & CR's
	PJRST	CRCCMD		;DONE HEADERS - FORCE ALL OF THIS OUT & RETURN

;END EDIT  [724]

	;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:	TRNE	F,F.BRF		;/BRIEF ?  [724]
	PJRST	BRFHDR		;YES! - DO HEADERS BRIEF STYLE
	MOVE	T1,LINCNT
	MOVE	T2,ERRIND	;PICKUP ENTRY TYPE
	ADD	T1,LINE##(T2)	;ADD COUNT OF LINES IN NEXT ENTRY
	MOVEM	T1,LINCNT	;SAVE NEW LINE COUNT
	CAILE	T1,0		;CAN WE PRINT THIS ENTRY WITHOUT PAGE OVERFLOW
	JRST	HDRPNT		;NO! - GO DO HEADER TYPEOUT
	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
	TYPEIT	<
 LOGGED ON >
	SKIPE	TOPENT		;TOPS-20 RECORDED?
	 JRST HDRLSA		;YES! - TRY TOPS-20 STYLE
HDRLS1:	MOVE	T1,HDBUFF+HDRDAT ;PICKUP DATE OF ENTRY CURRENTLY BEING PROCESSED
	PUSHJ	P,GETNBS
	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	<
	RECORD SEQUENCE NUMBER:	>
	MOVE	T1,SEQNUM	;GET SEQ NUMBER
	PUSHJ	P,.ODECW	;IN DECIMAL WITH "."
	TYPEIT	<
***********************************************>
	POPJ	P,


;MODIFIED WITH EDITS  [426], [724]

HDRLSA:	SKIPN	TOPMON		;TOPS-20 RUNNING?
	 PJRST	HDRLS1		;NO! - MUST DO TEN STYLE
	HRROI	T1,DATLOC	;WHERE TO STORE IT
	MOVE	T2,HDBUFF+HDRDAT
	HRLZI	T3,202001	;FORMAT FOR OUTPUT
	ODTIM
	HRRZI	T1,DATLOC	;ADDR ONLY
	PUSHJ	P,.TSTRG	;NOW LIST IT
	JRST	HDRLSB		;NOW RETURN



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

HDRPNT:	PUSHJ	P,TITLST