Google
 

Trailing-Edge - PDP-10 Archives - bb-d868b-bm_tops20_v3a_2020_dist - 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	;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	;GET S/N WORD  [610]
	ANDI	T1,SYS.SN		;GET S/N ALONE
	PJRST	.ODECW

CSHPNT:	TYPEIT	<  ** THIS ENTRY COPIED FROM A SAVED CRASH **>
	PJRST	.TCRLF


	;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,  ;REMOVED IN EDIT # [724]
;	CLOSE	OUTCHN,
;	EXIT
	SUBTTL MISC LIBRARY ROUTINES

	;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	TOPENT		;TOPS-20 RECORDED?
	 PJRST	GETNB1		;YES! - TRY TOPS-20 STYLE
GETNB2:	PUSHJ	P,.CNTDT
	MOVEM	T1,MSTIMX	;STORE FRACTIONAL PART OF DAY IN MSTIMX
	MOVE	T1,T2		;PUT 12 BIT DATE IN T1 AS RETURNED FROM .CNTDT
	PJRST	.TDATE	;GO TYPE DATE

GETNB1:	SKIPN	TOPMON		;TOPS-20 RUNNING?
	 PJRST	GETNB2		;NO! - MUST DO TEN STYLE
	MOVE	T2,T1		;DATE TIME TO T2
	HRROI	T1,DATLOC	;WHERE TO PUT THE STRING
	HRLZI	T3,202000	;JSYS OPTION FLAGS
	ODTIM			;CREATE ASCIZ STRING
	HRRZI	T1,DATLOC
	PJRST	.TSTRG	;NOW DUMP THE ASCIZ.
	SUBTTL	WORD LEVEL SUBROUTINES

;THIS CODE ADDED BY EDIT 726-TJW
;HERE TO TYPE OUT ASCII STORED IN FUNNY PDP11 FORMAT
;CALLED WITH PUSHJ WITH 11 WORD IN P2 RETURNS POPJ

T11ACI:	CAIN	P2,0		;DONT WANT TO TYPE NULLS
	POPJ	P,0
	LDB	T1,[POINT 7,P2,17]
	PUSHJ	P,.TCHAR
	LDB	T1,[POINT 7,P2,9]
	PUSHJ	P,.TCHAR
	LDB	T1,[POINT 7,P2,35]
	PJRST	.TCHAR

;END EDIT 726

.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/3 SEC(TOPS-10) 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] TOPS-20 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
PTSTRG::	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
	;	WORD MUST BE LEFT JUSTIFIED IN T1.
	;LSTRJ - WILL DO IT WITH THE NUMBER IN T1 RIGHT JUSTIFIED  [724]

LSTRJ::	MOVN	T3,T2		;ROTATE RIGHT  (-)
	IMULI	T3,3		;3 BITS PER OCTAL DIGIT
	ROT	T1,(T3)		; FALL INTO OLD CODE
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,[PUSHJ P,.TCOMA
		PJRST .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
	IDIVI	T1,^D26			; [735]
	JUMPE	T1,MONVS2
	ADDI	T1,"A"-1		; [735]
	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

MN2VER::	TYPEIT	<
	MONITOR VERSION:	>
	PUSHJ P,DAEVER+2	;[504]USE SOME CODE FOR FREE
	TYPEIT	<
	U-CODE VERSION:		>
	LDB	T1,[POINT 9,HDBUFF+HDRPSN,17]	;GET VER # FROM HEADER
	PUSHJ	P,.TOCTW		;IN OCTAL
	POPJ	P,0			;ABOVE 4 LINES ADDED WITH [540]

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
	IDIVI	T1,^D26			; [735]
	JUMPE	T1,DAEVS2
	ADDI	T1,"A"-1		; [735]
	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:/

;ROUTINE TO TYPE OUT DEVICE NAME FOR BRIEF 111

DRVTYP:	MOVE	T2,MDEDTP		;GET DEVICE TYPE
	MOVE	T1,MDE000(T2)		;GET NAME OUT OF TABLE
	PJRST	.TSIXN			;TYPE IT OUT AND RETURN

;ROUTINE TO TYPE OUT CYL/SURF/SEC GIVEN LBN AND DRIVE TYPE

BLKTRN:	MOVE	P1,MDEDTP		;GET DEVICE TYPE
	HRRZ	T2,BLTTAB(P1)		;GET ADDRESS TO DISPATCH TO
	PJRST	@T2			;GO TO IT!!


BLTTAB:	0,,DUMPOS		;NONEXISTANT DEVICE
	5,,DSKPOS		;RP04
	4,,DSKPOS		;RS04
	0,,TAPPOS		;TU45
	0,,TAPPOS		;TU16(TM02)
	6,,DSKPOS		;RP05
	7,,DSKPOS		;RP06
	0,,DSKPOS		;RP07
	0,,DSKPOS		;RP08
	10,,DSKPOS		;RM03
	0,,TAPPOS		;TM03
	0,,TAPPOS		;TU77
	0,,TAPPOS		;TM78
	0,,TAPPOS		;TU78
	0,,TAPPOS		;DX20
	0,,TAPPOS		;TU70
	0,,DUMPOS		;TU71
	0,,DUMPOS		;TU72-E



DUMPOS:	POPJ	P,0		;NO TRANSLATION..RETURN NOW


TAPPOS:	TYPEIT	< FILE/RECORD >
	HLRZ	T1,WKBUFF+MB%LOC	;GET LOCATION
	PUSHJ	P,.ODECW		;TYPE OUT FILE
	TYPEIT	</>
	HRRZ	T1,WKBUFF+MB%LOC
	PJRST	.ODECW

;ROUTINE TO TYPE OUT CYL./SURF./SEC./ GIVEN MDEDTP IN P1

DSKPOS:	TYPEIT	< CYL/SURF/SEC= >
	MOVE	P2,WKBUFF+MB%LOC
	HLRZ	T1,BLTTAB(P1)
	MOVE	P1,T1
	CAMGE	P2,.MXBLK(P1)
	 JRST	DSKPO1
	SUB	P2,.MXBLK(P1)
	JRST	.-3

DSKPO1:	IDIV	P2,.TRBLK(P1)
	MOVE	T1,P2
	PUSHJ	P,.ODECW
	TYPEIT	</>
	MOVE	P2,P3
	IDIV	P2,.SUBLK(P1)
	MOVE	T1,P2
	PUSHJ	P,.ODECW
	TYPEIT	</>
	MOVE	P2,P3
	IMUL	P2,.SECBK(P1)
	MOVE	T1,P2
	PJRST	.ODECW
;ROUTINE TO TYPEOUT 4 COLUMNS OF OCTAL NUMBERS
;CALL		MOVE P2,[XWD -NUMBER OF WORDS,OFFSET TO FIRST]
;		PUSHJ	P,COLOUT
;PRESERVES P REGS CLOBBERS T REGS

COLOUT:	PUSH	P,P1
	PUSH	P,P2
	MOVE	P1,[XWD -4,0]
COLLUP:	PUSHJ	P,.TTABC
	MOVE	T1,WKBUFF(P2)
	MOVEI	T2,^D12
	PUSHJ	P,LST36
	AOBJN	P1,NOCRTM
	PUSHJ	P,.TCRLF
	MOVE	P1,[XWD -4,0]
NOCRTM:	AOBJN	P2,COLLUP
	POP	P,P2
	POP	P,P1
	POPJ	P,0

;SBDOUT - ROUTINE TO PROCESS S-BUS FUNCTION SUB-TABLE IN
;	   KL CPU STATUS BLOCK ENTRY (163)
;
;	POINTER TO SUBTABLE IS IN P2 -- CHANGED WITH EDIT [754]

SBDOUT:	ADDI	P2,WKBUFF+1	;POINT AT FUNCTION 0 FOR CONTROLLER
SBDOU1:	PUSHJ	P,.TCRLF
	PUSHJ	P,.TTABC
	HRRZ	T1,-1(P2)	;GET CONTROLLER NUMBER
	PUSHJ	P,.TOCTW
	PUSHJ	P,.TTABC
	MOVE	T1,0(P2)	;GET FUNCTION 0
	MOVEI	T2,^D12
	PUSHJ	P,LSTRJ
	PUSHJ	P,.TTABC
	MOVE	T1,1(P2)	;GET FUNCTION 1
	MOVEI	T2,^D12
	PUSHJ	P,LSTRJ
	HLRO	T1,-1(P2)	;GET -# OF FUNCTIONS FOR LAST CONTROLLER
	SUB	P2,T1		;ADVANCE POINTER (SUBTRACT NEG #)
	AOBJN	P2,SBDOU1	;DO NEXT CONTROLLER
	 POPJ	P,0		;ALL DONE
	;A LITTLE ROUTINE 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

SAVE4T:	MOVEM T1,SAVEAC+4
	MOVEM T2,SAVEAC+5
	MOVEM	T3,SAVEAC+6
	MOVEM T4,SAVEAC+7
	POPJ	P,0
RET4T:	MOVE	T1,SAVEAC+4
	MOVE	T2,SAVEAC+5
	MOVE	T3,SAVEAC+6
	MOVE	T4,SAVEAC+7
	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
	SKIPN	P2		;[510] IF NO AT END WORDS
	 JRST	LSTFB0		;SKIP THAT CODE
	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
LSTFB0:	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 BE 4 CHAR OR
	ASCIZ/RM10/		; LESS TO CORRECTLY INDEX INTO TABLE
	ASCIZ/RP02/		; (4 CHARACTERS AND NULL IN ONE WORD)
	ASCIZ/RP03/
	ASCIZ/RS04/
	ASCIZ/RP04/
	ASCIZ/RP05/
	ASCIZ/RP06/
	ASCIZ/RM03/		;  [601]

.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
	^D121360		;BLOCKS/PACK RM03  (820 CLY/PACK)

.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
	^D148			;BLOCKS/CYL RM03  (LAST 2 SECTORS LOST)

.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
	^D30			;BLOCKS / SURFACE FOR RM03

.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
	1			;1 SECTOR / BLOCK FOR RM03
	;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
	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 TOPS-20
	 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	GOSUM		;DO SUMMARY AND QUIT  [724]
	TLNN	F,F.DISK	;THIS ONLY WORKS FOR DISKS
	 JRST	GOSUM		;SO DONT GO FURTHER  [724]
	HRLZM	T1,INPFIL+3	;STORE IT IN SPEC.
	LOOKUP	INPCHN,INPFIL	;TRY FOR IT
	 JRST	GOSUM		;NOT THERE WRAP UP  [724]
	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


	;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 TOPS-20
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
FIXBU2:	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:	SKIPE	TOPMON		;TOPS-20 RUNNING?
	 JRST	FIXBU2		;YES-ASSUME VERSION BEFORE RELEASE 2
	SETZM	BUFOFF		;NO, TROUBLE-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:	TLNN	F,F.LSUM	;WANT SUMMARY ?  [724]
	 JRST	GOSTRT		;NO! - CLOSE AND EXIT
	TRNE	F,F.SEQ		;/SEQ ?  [724]
	 JRST	GOSTRT		;YES! - CLOSE AND EXIT
	TRNE	F,F.BRF		;/BRIEF ?  [724]
	 JRST	GOSTRT		;YES! - CLOSE AND EXIT
	TRNE	F,F.REM		;/REMOTE ?
	 JRST	GOSTRT		;YES! - 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.

	;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


;	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


;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:	SETZM	BRFDAT		;FORCE NEW DATE LINE IN BRIEF MODE
	MOVE	T1,[-PAGLIN]	;RESET PAGE LENGTH
	MOVEM	T1,LINCNT
	AOS	T1,PAGNUM	;INCREMENT PAGE NUMBER
	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,

;START  EDIT [724] CHANGES

	;CRCCMD - OUTPUTS CHARACTERS AND TRIES TO PLACE CARRIAGE RETURNS
	; AT APPROPRIATE LOCATIONS - ALSO INDENTS OVERFLOW LINES
	;
	;CALLED BY	PUSHJ P,CRCCMD    WITH THE COMMAND IN 'T1'

CRCCMD:	CAIN	T1,CCF7		;DO IT NOW ?
	 POPJ	P,		;WAIT !
	PUSH	P,P1		;SAVE 'P1' - WE NEED IT !
	MOVEI	P1,OUTSIZ	;GET LENGTH OF OUTPUT BUFFER
	SUB	P1,OUTCNT	;FIND # OF CHARACTERS IN BUFFER
	JUMPE	P1,CRCEXT	;LEAVE IF NO CHARACTERS IN BUFFER
	MOVE	T2,[POINT 7,OUTBUF] ;POINT AT START OF BUFFER
	MOVEM	T2,OUTBYT
	CAIN	T1,CCF6		;CONTAINS FF's or CR's ?
	 JRST	CRCMD6		;YES!
	JUMPN	T1,CRCMDA	;CCF0 ?
	MOVNI	T2,BRFTAB	;YES! - GET LINE OVERFLOW INDENT
	ADD	T2,BRIEF	;FIND MAX # OF CHARACTERS ON LINE
	CAMLE	P1,T2		;WILL THE BUFFER FIT ON A FULL LINE?
	 JRST	CRCMD1		;NO! - WE'LL TRY CR's AT SPACES
CRCMDA:	CAMG	P1,CHRCNT	;WILL IT FIT ON THIS LINE?
	 PJRST	CRCMD0		;YES! - NO NEED TO LOOK FOR SPACES
	CAIN	T1,CCF1		;CCF1 ?
	 JRST	CRCMD1		;YES! - CHECK FOR SPACES
	PUSHJ	P,NWLINE	;NO! - START A NEW LINE
	JRST	CRCMD0		;LIST IT !

	;CRCMD0 - ALLOW CR AT END OF BUFFER ONLY

CRCMD0:	ILDB	T1,OUTBYT	;GET CHARACTER
	SOS	CHRCNT		;COUNT CHARACTERS
	PUSHJ	P,OUTCHA
	SOJG	P1,CRCMD0	;DONE?
	JRST	CRCEND		;CLEAN UP & LEAVE

	;CRCMD1 - ALLOW CR AT SPACES OR AT END OF BUFFER  [727]
	;	OR AT A REAL CR

CRCMD1:	MOVE	T2,OUTBYT	;GET BUFFER POINTER
	SETZ	T3,		;ZERO COUNTER

CRC1A:	ILDB	T1,T2		;GET CHARACTER
	CAIE	T1," "		;SPACE ?
	 JRST	CRC1B		;NO! - DON'T SAVE INFO
	MOVE	T4,T3		;SAVE # OF CHARACTERS BEFORE THIS SPACE
	MOVEM	P1,SPACNT	;SAVE # OF CHARACTERS LEFT IN BUFFER
CRC1B:	AOS	T3		;COUNT CHARACTER
	SOSL	CHRCNT		;LINE OVERFLOW ?
	SOJG	P1,CRC1A	;NO! - END OF BUFFER ?
				;YES! - SHOULD NEVER DO THIS!!!
	JUMPE	T4,CRC1E	;SKIP IF NO CHARACTERS
	MOVE	P1,T4		;GET CHARACTER COUNT
CRC1D:	ILDB	T1,OUTBYT	;GET CHARACTER
	PUSHJ	P,OUTCHA	;OUTPUT IT
	SOJG	P1,CRC1D	;DONE?
CRC1E:	MOVE	P1,SPACNT	;GET # OF CHARACTERS LEFT IN BUFFER BACK
	PUSHJ	P,NWLINE	;YES! - START A NEW LINE
	CAMG	P1,CHRCNT	;WILL IT FIT ON THIS LINE?
	 JRST	CRCMD0		;YES! - NO NEED TO LOOK FOR SPACES
	JRST	CRCMD1		;NO! - KEEP LOOKING FOR SPACES

	;CRCMD2			NOT ASSIGNED
	;CRCMD3			NOT ASSIGNED
	;CRCMD4			NOT ASSIGNED
	;CRCMD5			NOT ASSIGNED

	;CRCMD6 - CR's or FF's in BUFFER  (DO AS IS!)

CRCMD6:	ILDB	T1,OUTBYT	;GET CHARACTER
	SOS	CHRCNT		;COUNT CHARACTERS
	CAIN	T1,12		;LINE FEED?
	 PUSHJ	P,NEWLIN	;ADJUST POINTERS
	CAIN	T1,14		;FORM FEED?
	 PUSHJ	P,NEWPAG	;ADJUST POINTERS
	PUSHJ	P,OUTCHA
	SOJG	P1,CRCMD6	;DONE?
	JRST	CRCEND		;CLEAN UP & LEAVE

CRCEND:	MOVE	T1,[POINT 7,OUTBUF] ;POINT AT START OF BUFFER
	MOVEM	T1,OUTBYT
	MOVEI	T1,OUTSIZ	;RESET BUFFER COUNTER
	MOVEM	T1,OUTCNT
CRCEXT:	POP	P,P1		;RESTORE 'P1'
	POPJ	P,		;RETURN

NEWLIN:	AOS	LINCNT		;INCREMENT LINE COUNT
NEWPAG:	MOVE	T3,BRIEF	;GET LINE WIDTH
	MOVEM	T3,CHRCNT	;RESET CHARACTER COUNT
	POPJ	P,		;RETURN

	;STARTS A NEW LINE & DOES INDENT

NWLINE:	PUSH	P,P1		;SAVE 'P1' - WE NEED IT AGAIN !
	MOVEI	T1,15		;CARRIAGE RETURN
	PUSHJ	P,OUTCHA
	MOVEI	T1,12		;LINE FEED
	PUSHJ	P,OUTCHA
	PUSHJ	P,NEWLIN	;ADJUST POINTERS
	MOVEI	P1,BRFTAB	;GET INDENT VALUE
NWLIN2:	MOVEI	T1," "		;SPACE
	SOS	CHRCNT		;COUNT CHARACTERS
	PUSHJ	P,OUTCHA
	SOJG	P1,NWLIN2	;DO INDENT
	POP	P,P1		;RESTORE 'P1'
	POPJ	P,		;RETURN

	;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
	; CHANGED WITH EDIT [754]

CHROUT:	TRNN	F,F.BRF		;/BRIEF ?
	 PJRST	OUTCHA		;NO! - OUTPUT CHARACTER NOW
	IDPB	T1,OUTBYT	;SAVE CHARACTER IN OUTPUT BUFFER
	SOSLE	OUTCNT		;BUFFER OVERFLOW ?
	POPJ	P,		;NO! - RETURN
	MOVEI	T1,CCF6		;YES! - DUMP BUFFER NOW!
	PJRST	CRCCMD		;	WITH NO CARRIAGE CONTROL

OUTCHA:	TLNN	F,F.TTYO	;OUTPUT TO TTY?
	 PJRST	PUTCHR		;NO! - PUT IN OUTPUT BUFFER AND RETURN
TTYOUT:	OUTCHR	T1		;YES! - DO OUTPUT
	POPJ	P,		;RETURN

;END EDIT [724] CHANGES

	;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>


	;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
	;START EDIT [521]

	;BYTE.8 -- OUTPUTS A WORD IN 'T1' IN 8 BIT BYTES
	;CALL:	MOVE	T1,WORD
	;	PUSHJ	P,BYTE.8
	;USES T1,T2,T3,T4,P1

	;BYTE.X -- OUTPUTS A WORD IN 'T1' IN 'T2' BIT BYTES
	;CALL:	MOVE	T1,WORD
	;	MOVEI	T2,SIZE
	;	PUSHJ	P,BYTE.X
	;USES T1,T2,T3,T4,P1

BYTE.8::MOVEI	T2,^D8			;SET UP FOR 8 BIT BYTES
BYTE.X::MOVE	T3,[POINT 0,T2]		;GET BASE POINTER
	DPB	T2,[POINT 6,T3,11]	;COMPLETE POINTER
	MOVEI	T4,^D36
	IDIV	T4,T2			;CALCULATE # OF BYTES IN WORD
	MOVE	T2,T1			;SAVE WORD
BYTE.N:	SOJL	T4,BYTE.S		;DONE? - DO SHORT BYTE
	 ILDB	T1,T3			;NO! - GET NEXT BYTE
	PUSHJ	P,.TOCTW		;OUTPUT IN OCTAL
	PUSHJ	P,.TCOMA		;OUTPUT COMA
	JUMPA	0,BYTE.N		;NEXT BYTE

BYTE.S:	JUMPE	P1,BYTE.E		;ANY SHORT BYTE?
	 DPB	P1,[POINT 6,T3,11]	;YES! - RESET POINTER
	ILDB 	T1,T3			;GET SHORT BYTE
	PUSHJ	P,.TOCTW		;OUTPUT IN OCTAL
BYTE.E:	POPJ	P,0			;LEAVE

	;END EDIT [521]
	SUBTTL	JSYS ERROR HANDLING ROUTINE

;EDIT [737]

JSYSER:	MOVEI	T1,"?"
	PBOUT
	ERCAL	JS.ERR
	MOVEI	T1,.PRIOU	;PRIMARY OUTPUT DEVICE IS THE DESTINATION
	MOVE	T2,[.FHSLF,,-1]	;CURRENT PROCESS,,LAST ERROR
	SETZ	T3,		;NO CHARACTER LIMIT
	ERSTR
	ERCAL	JS.ERR		;FAILURE, UNDEFINED ERROR NUMBER - CAN'T HAPPEN?
	PUSHJ	P,JS.ERR	;FAILURE, BAD DESTINATION or STRING TO BIG ??
	MOVEI	T1,15		;SUCCESS! - DO CARRIAGE RETURN
	PBOUT
	ERCAL	JS.ERR
	MOVEI	T1,12		;LINE FEED
	PBOUT
	ERCAL	JS.ERR
	POPJ	P,		;RETURN

JS.ERR:	FATAL	< ERROR IN JSYS ERROR RECOVERY
>

LIBLIT:	[ENDLIB: -1]		;GIVES ADDRESS TO ALL LITERALS WHEN USING DDT

	END