Google
 

Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 10,56/mac/ipcf.mac
There are 57 other files named ipcf.mac in the archive. Click here to see a list.
TITLE	IPCF - IPCF status program

; This code is a real piece of shit.  If you think I never
; saw a listing of it, you're right!  Will have to clean it
; up someday...

	SEARCH	JOBDAT,MACTEN,SCNMAC,UUOSYM

	SALL
	.DIRECT	FLBLST

	TWOSEG	400000
	RELOC	400000

	.TEXT	|,REL:DPYPAK,REL:MAP,REL:SCAN/SEARCH|
SUBTTL	Table of contents


;               TABLE OF CONTENTS FOR IPCF
;
;
;                        SECTION                                   PAGE
;    1. Table of contents.........................................   2
;    2. Definitions...............................................   3
;    3. Program initialization....................................   7
;    4. Main loop.................................................   8
;    5. Initial parameters........................................   9
;    6. System statistics
;         6.1   Gather system data................................  10
;         6.2   GETTABs...........................................  11
;         6.3   Header display....................................  12
;         6.4   Uptime display....................................  14
;         6.5   [SYSTEM]INFO display..............................  15
;         6.6   Defaults display..................................  16
;         6.7   PID usage display.................................  17
;    7. PID information
;         7.1   Copy PIDTAB.......................................  18
;         7.2   Sort PIDTAB.......................................  19
;    8. Perform GETTABs...........................................  20
;    9. Command scanning
;         9.1   Entry point.......................................  21
;         9.2   Display error text................................  22
;   10. Mode handling
;        10.1   HELP tables.......................................  23
;        10.2   JOB tables........................................  24
;        10.3   PACKET tables.....................................  25
;        10.4   Mode table generation macros......................  26
;        10.5   MODE command......................................  27
;   11. HELP mode
;        11.1   Loop..............................................  28
;        11.2   CONTINUE command..................................  29
;        11.3   HELP command......................................  30
;   12. JOB mode
;        12.1   Loop..............................................  31
;        12.2   Check job and PID.................................  32
;        12.3   Column headers....................................  34
;        12.4   Job number........................................  35
;        12.5   User name.........................................  36
;        12.6   PPN...............................................  37
;        12.7   Program name......................................  38
;        12.8   Quotas............................................  39
;        12.9   Total sends and receives..........................  40
;        12.10  Outstanding sends and receives....................  41
;        12.11  Capabilities......................................  42
;        12.12  PID...............................................  43
;        12.13  System process....................................  44
;        12.14  Job's [SYSTEM]INFO................................  45
;        12.15  PID name..........................................  46
;   13. PACKET mode
;        13.1   Loop..............................................  47
;        13.2   Display packets for a job.........................  48
;        13.3   Header display....................................  50
;        13.4   .IPCFL word display...............................  51
;        13.5   .IPCFS word display...............................  52
;        13.6   .IPCFR word display...............................  53
;        13.7   .IPCFP word display...............................  54
;        13.8   .IPCFU word display...............................  55
;        13.9   .IPCFC word display...............................  56
;        13.10  IPCF Error code and text table....................  57
;        13.11  System sender codes and text table................  58
;        13.12  Return codes and text table.......................  59
;        13.13  Text table searching and typeout..................  60
;   14. Special typeout routines
;        14.1   PID...............................................  62
;        14.2   Justified sixbit word.............................  63
;        14.3   Justified numeric word............................  64
;        14.4   Time..............................................  65
;        14.5   Miscellaneous.....................................  66
;   15. Core allocation...........................................  67
;   16. DPYPAK interface
;        16.1   Initialization....................................  68
;        16.2   Commands..........................................  69
;        16.3   User exit.........................................  72
;        16.4   Initialize display cycle output...................  73
;        16.5   Roll the screen...................................  74
;        16.6   Clean up at end of display cycle..................  75
;        16.7   Output a character................................  76
;        16.8   Save and restore the ACs..........................  77
;   17. Literals..................................................  78
;   18. Data storage..............................................  79
SUBTTL	Definitions


; ACCUMULATORS
;
	T1=1
	T2=2
	T3=3
	T4=4
	P1=5
	P2=6
	P3=7
	  N=P3
	P4=10
	  C=P4
	J=11				;JOB NUMBER
	PID=12				;PID TABLE INDEX
	I=13				;INCLUDED COLUMNS FOR CURRENT MODE
	S=14
	P=17

	PDLSIZ==50			;PDL SIZE
	SLPDEF==^D10			;DEFAULT SLEEP TIME
	SLPMAX==^D60			;MAXIMUM SLEEP TIME
	ERRSIZ==^D132			;NUMBER OF CHARACTERS IN ERROR BUFFER
	FILSIZ==120			;NUMBER OF CHARACTERS IN ASCIZ FILESPEC
	PDBLEN==6			;LENGTH OF PACKET DESCRIPTOR BLOCK
	PMBLEN==12			;LENGTH OF PACKET MESSAGE BLOCK
	NAMLEN==<^D29/5>+1		;LENGTH OF A NAME STRING
; PID block definitions
;
	 ...LOC==.
	 PHASE	0

.PBBLK:!		;START OF PID BLOCK
.PBJOB:! BLOCK	1	;OWNER JOB NUMBER
.PBPTB:! BLOCK	1	;PID TAB ENTRY
.PBPID:! BLOCK	1	;ACTUAL PID
.PBSID:! BLOCK	1	;SPECIAL PID
.PBSNM:! BLOCK	1	;ADDRESS OF SPECIAL PID NAME
.PBNAM:! BLOCK	NAMLEN	;PID NAME
.PBPPN:! BLOCK	1	;OWNER JOB'S PPN
.PBUNM:! BLOCK	2	;OWNER JOB'S USER NAME
.PBPRG:! BLOCK	1	;PROGRAM
.PBQTA:! BLOCK	1	;QUOTAS
.PBTSR:! BLOCK	1	;TOTAL SENDS AND RECEIVES
.PBOSR:! BLOCK	1	;OUTSTANDING SENDS AND RECEIVES
.PBCAP:! BLOCK	1	;CAPABILITIES
.PBINF:! BLOCK	1	;LOCAL [SYSTEM]INFO
.PBLEN:!		;LENGTH OF A PID BLOCK

	 DEPHASE
	 RELOC	...LOC
; MACRO TO GENERATE TABLE OF GETTAB ARGUMENTS AND STORAGE ADDRESSES
;
DEFINE	$GTB	(ARG,ADR),<
	ARG
	ADR
>


; MACRO TO GENERATE SPECIAL PID TABLE GETTAB TABLE STUFF
;
DEFINE	$SID	(ARG),<
	ARG
	SIDTAB+SIDMAX
	SIDMAX==SIDMAX+1
>
; INCLUDE bits for JOB mode

	IJBDEF==IJBJOB!IJBPRO!IJBTOT!IJBOUT!IJBPID!IJBSYS!


; Dispatch offsets used by the HELP processor
;
	.HDVAL==-3			;TYPE OUT CURRENT VALUE
	.HDTXT==-2			;HELP TEXT
	.HDFLG==-1			;FLAGS
	   HD.COM==1B0			   ;COMMAND COMMON TO ALL MODES
	   HD.TOG==1B1			   ;TOGGLE VALUE
SUBTTL	Program initialization


IPCF:	TDZA	T1,T1			;NORMAL ENTRY
	MOVEI	T1,1			;CCL ENTRY
	RESET				;STOP I/O
	SETZM	ZBEG			;CLEAR FIRST DATA WORD
	MOVE	T2,[ZBEG,,ZBEG+1]	;SET UP BLT
	BLT	T2,ZEND-1		;CLEAR ALL DATA STORAGE
	MOVEM	T1,OFFSET		;SAVE CCL OFFSET
	HLRZ	T1,.JBSA		;GET COPY OF .JBFF
	MOVEM	T1,.JBFF		;RESET IT
	SETZ	0,			;CLEAR AC 0
	MOVEI	17,1			;SET UP BLT
	BLT	17,17			;CLEAR ANY JUNK IN THE ACS
	MOVE	P,[IOWD	PDLSIZ,PDL]	;SET UP PDL
	PUSHJ	P,INTINI		;SET UP TRAPPING
	PUSHJ	P,SCNINI		;INIT SCAN
	PUSHJ	P,SCNOPT		;SCAN SWITCH.INI
	PUSHJ	P,MAPPER		;INIT MAP
	  HALT	.
	PUSHJ	P,TTYNEC		;SET TTY NO ECHO
	PUSHJ	P,INITIA		;GET INITIAL MONITOR DATA
	PUSHJ	P,INFSET		;SET UP [SYSTEM]INFO INTERFACE
	PUSHJ	P,DPINI			;FIREUP DPYPAK
	JRST	MAIN			;*** FOR NOW ***
SUBTTL	Top level command scanning


TOPLVL:	OUTSTR	[ASCIZ |? Not implemented yet|]
	EXIT	1,
	JRST	IPCF
SUBTTL	Main loop


MAIN:	SETZM	.LASWD##+15		;*** FAKE OUT SCAN *** (FLCCMD)
	MOVE	P,[IOWD	PDLSIZ,PDL]	;RESET PDL
	PUSHJ	P,COMAND		;TRY TO PROCESS A COMMAND
	PUSHJ	P,DPLIN			;INIT DPYPAK FOR THIS DISPLAY CYCLE
	PUSHJ	P,SYSTEM		;DISPLAY SYSTEM-WIDE INFORMATION
	PUSHJ	P,LDPIDS		;LOAD PID BLOCKS
	PUSHJ	P,AUTO.I		;COMPUTE AUTOMATIC SCROLLING INCREMENT
	MOVE	T1,S.MODE		;GET MODE INDEX
	MOVE	I,S.INCL(T1)		;GET INCLUDE BITS FOR THIS MODE
	PUSHJ	P,@MODPRC(T1)		;DISPATCH
	PUSHJ	P,AUTO.S		;ADVANCE SCROLL COUNTER
	PUSHJ	P,DPCLR			;CLEAN UP AT END OF DISPLAY CYCLE
	SKIPN	T1,S.SLEE		;GET SLEEP TIME
	JRST	MAIN			;0 MEANS NO SLEEP
	SKIPG	T1			;SPECIFIED?
	MOVEI	T1,SLPDEF		;DEFAULT IT
	IMULI	T1,^D1000		;CONVERT TO MILLISECONDS
	TXO	T1,HB.RTL		;WAKE ON LINE INPUT
	HIBER	T1,			;ZZZZZZ
	  JFCL				;IGNORE ERRORS
	JRST	MAIN			;LOOP BACK
SUBTTL	MAP initialization



; Map the running monitor
;
MAPMON:	SETOM	S.FILE			;RESET FIRST WORD
	MOVE	T1,[S.FILE,,S.FILE+1]	;SET UP BLT
	BLT	T1,S.FILE+<FILSIZ/5>	;RESET FILESPEC BLOCK
	PUSHJ	P,MAPPER		;TRY TO MAP THE MONITOR
	  SKIPA				;CAN'T
	POPJ	P,			;RETURN
	MOVEI	T1,[ASCIZ |? Can't map monitor|]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	PUSHJ	P,.MONRT##		;EXIT
	JRST	.-1			;THE FOOL TYPED CONINUE


; Set up mapping
;
MAPPER:	SETZ	T1,			;ASSUME WE'LL LOOK AT THE MONITOR
	MOVE	T2,S.FILE		;GET FIRST WORD OF FILESPEC
	CAME	T2,[-1]			;ONE SPECIFIED?
	MOVEI	T1,1			;YES
	MOVE	T2,[MP.RTM##+.MPMON##]	;ASSUME THE RUNNING MONITOR
	SKIPE	T1			;MONITOR?
	MOVE	T2,[MP.RTM##+MP.EXE##+.MPFIL##] ;A CRASH FILE
	MOVEM	T2,MAPARG##+.MPFNC##	;SAVE FLAGS AND FUNCTION CODE
	MOVEI	T2,^D11			;GET COUNT OF CACHED PAGES TO USE
	MOVEM	T2,MAPARG##+.MPNPC##	;SAVE NUMBER OF PAGES
	SETZM	MAPARG##+.MPSPN##	;DEFAULT STARTING PAGE NUMBER
	SETZM	MAPARG##+.MPDSN##	;DEFAULT SECTION NUMBER IS ZERO
	SKIPN	T1			;MONITOR?
	TDZA	T2,T2			;YES
	MOVEI	T2,S.FILE		;GET ADDRESS OF FILESPEC BLOCK
	MOVEM	T2,MAPARG##+.MPARG##	;SAVE IT
	MOVEI	T1,MAPARG##		;POINT TO BLOCK
	PUSHJ	P,.MAPI##		;INITIALIZE THE PAGE MAPPER
	  POPJ	P,			;CAN'T
	MOVEI	T1,MAPDAT##		;GET PERFORMANCE AND DATA BLOCK ADDR
	MOVEM	T1,MAPPTR		;SAVE PERFORMANCE POINTER
	JRST	.POPJ1##		;RETURN
SUBTTL	SCAN interface -- Initialization


SCNINI:	SETOM	SBEG			;INIT FIRST SWITCH
	MOVE	T1,[SBEG,,SBEG+1]	;SET UP BLT
	BLT	T1,SEND-1		;INIT ALL SWITCH STORAGE
	MOVE	T1,[ISCLEN,,ISCBLK]	;POINT TO ARGUMENT BLOCK
	PUSHJ	P,.ISCAN##		;INITIALIZE SCAN
	MOVE	T2,['IPCF  ']		;OUR NAME
	MOVEM	T2,OPTNAM+0		;SAVE FOR SWITCH.INI SCANNING
	SETOM	COMIDX			;ASSUME NO COMMAND FOUND
	SKIPGE	T1			;RESCAN FOUND A GOOD COMMAND?
	MOVEI	T1,MODEIPC		;DEFAULT
	CAIN	T1,MODEIPCF		;GENERIC?
	MOVEI	T1,MODEJOB		;YES
	MOVEM	T1,COMIDX		;SAVE INVOKING COMMAND (MODE) INDEX
	MOVEM	T1,S.MODE		;SAVE HERE TOO
	MOVE	T2,MODNAM(T1)		;GET INVOKING COMMAND NAME
	MOVEM	T2,OPTNAM+1		;WANT TO SCAN THIS LINE TOO
	POPJ	P,			;RETURN

SCNOPT:	MOVE	T1,S.MODE		;GET THE MODE
	MOVE	T2,[IJBDEF]		;GET DEFAULT SETTINGS
	MOVEM	T2,S.INCL(T1)		;INITIALIZE
	MOVE	T1,[OSCLEN,,OSCBLK]	;POINT TO ARGUMENT BLOCK
	PUSHJ	P,.OSCAN##		;SCAN SWITCH.INI
	MOVEI	T1,1			;ASSUME /AUTO WANTED
	SKIPGE	S.AUTO			;SPECIFIED?
	MOVEM	T1,S.AUTO		;DEFAULT
	SKIPL	S.DPY			;DISPLAY SPECIFIED?
	POPJ	P,			;DONE
	MOVE	T1,[2,,T2]		;SET UP UUO
	MOVEI	T2,.TODIS		;FUNCTION CODE
	MOVNI	T3,1			;-1 MEANS US
	TRMOP.	T1,			;GET DISPLAY BIT
	  MOVEI	T1,0			;CAN'T
	JUMPE	T1,.POPJ##		;RETURN IF HARD COPY
	MOVEI	T1,1			;ELSE FORCE
	MOVEM	T1,S.DPY		;DISPLAY MODE
	POPJ	P,			;RETURN
; .ISCAN argument block
;
ISCBLK:	IOWD	MODNUM,MODNAM	;POINTER TO INVOKING COMMANDS
	XWD	OFFSET,'IPC'	;CCL OFFSET,,TMP FILE NAME
	XWD	0,TTYOUT	;CHARACTER INPUT,,OUTPUT
	XWD	0,0		;LENGTH,,ADDR OF INDIRECT SCAN BLOCK
	XWD	SCNPMT,0	;PROMPT,,MONRET
	XWD	0,0		;FLAGS,,RESERVED
ISCLEN==.-ISCBLK		;LENGTH OF BLOCK


; .OSCAN block
OSCBLK:	IOWD	IPCFL,IPCFN	;IOWD TO SWITCH NAMES
	XWD	IPCFD,IPCFM	;DEFAULTS,,PROCESSOR
	XWD	0,IPCFP		;0,,STORAGE ADDR
	XWD	0,0		;NO HELP
	XWD	2,OPTNAM	;LEN,,ADDR OF OPTION NAMES
OSCLEN==.-OSCBLK		;LENGTH OF BLOCK

; Prompt routine
SCNPMT:	SKIPLE	S.DPY		;/DPY?
	POPJ	P,		;YES--NEVER PROMPT IN THAT MODE
	SKPINL			;CLEAR
	  JFCL			; CONTROL-O
	SKIPGE	T1		;CONTINUATION LINE?
	SKIPA	T1,["#"]	;YES
	MOVEI	T1,"*"		;FIRST LINE PROMPT
	OUTCHR	T1		;TYPE CHARACTER
	POPJ	P,		;RETURN


; EAT TABS AND SPACES
SCNSKP:	SKIPA				;CHECK FIRST
SCNSK1:	PUSHJ	P,.TIALT##		;GET NEXT CHARACTER
	CAIE	C,.CHTAB		;TAB?
	CAIN	C," "			;SPACE?
	JRST	SCNSK1			;YES
	POPJ	P,			;ELSE RETURN
DEFINE	SWTCHS,<

SN	AUTO,S.AUTO
SP	CTX,S.CTX,.SWDEC##,CTX
SN	DPY,S.DPY
SL	INCLUDE,<-1,,SWINCL>,IJB,,FS.OBV!FS.VRQ
SP	JOB,S.JOB,.SWDEC##,JOB
;SL	MODE,S.MODE,MODE,MODEJOB
SN	PERFORMANCE,S.PERF
SP	SLEEP,S.SLEE,.SWDEC##,SLP

>

DM	CTX,777,-1,-1			;DEFAULT CTX IS -1 (ALL)
DM	JOB,777,-1,-1			;DEFAULT JOB IS -1 (ALL)
DM	SLP,SLPMAX,SLPDEF,SLPDEF	;DEFAULT SLEEP TIME
	DOSCAN	(IPCF)
DEFINE	OKEYS	(NAME,LST),<
NAME'.L==0
NAME'.T: IRP	(LST),<
	EXP	<SIXBIT/LST/>
	NAME'.L==:NAME'.L+1
	NAME'LST==<1_<NAME'.L-1>>
	>
>

OKEYS	IJB,<CAPABILITIES,JOBS,LOCAL,NAMES,OUTSTANDING,PIDS,PROGRAMS,PPNS,QUOTAS,SYSTEM,TITLES,TOTALS,USERS>
SWINCL:	MOVE	T1,S.MODE		;GET THE MODE INDEX
	MOVEI	T1,S.INCL(T1)		;POINT TO THE APPROPRIATE MASK
SLKEY:	CAMN	N,[-1,,0]		;SEE IF "NONE"
	JRST	SLNONE			;YES
	CAMN	N,[0,,-1]		;SEE IF "ALL"
	JRST	SLALL			;YES
	HRRZ	T3,N			;GET INDEX
	SUBI	T3,1			;ADJUST
	MOVEI	T2,1			;GET A BIT
	LSH	T2,(T3)			;DIAL A BIT
	CAIL	N,0			;SEE IF NOXYZ
	IORM	T2,(T1)			;NO--SET
	CAIGE	N,0			;SEE IF NOXYZ
	ANDCAM	T2,(T1)			;YES--CLEAR
	JRST	.POPJ1##		;AND RETURN

SLNONE:	SETZM	(T1)			;CLEAR ALL BITS
	JRST	.POPJ1##		;AND RETURN

SLALL:	SETOM	(T1)			;SET ALL BITS
	JRST	.POPJ1##		;AND RETURN
SUBTTL	Character output


; Set terminal echo mode
; Call:	PUSHJ	P,TTYECH	;TURN ON ECHO
;	PUSHJ	P,TTYNEC	;TURN OFF ECHO
;
TTYECH:	TDZA	T3,T3			;SET TTY ECHO
TTYNEC:	MOVX	T3,IO.SUP		;SUPPRESS ECHO
	MOVE	T1,[2,,T2]		;SET UO CLRST. UUO
	MOVSI	T2,'TTY'		;DEVICE TTY
	CLRST.	T1,			;SET TTY NO ECHO
	  JFCL				;CAN'T
	POPJ	P,			;RETURN


TTYOUT:	CAIN	T1,.CHCRT		;CARRIAGE RETURN?
	SETZM	COLUMN			;RESET HORIZONTAL CARRIAGE POSITION
	CAIL	T1,.CHLFD		;A VERTICAL
	CAILE	T1,.CHCRT		; MOTION CHARACTER?
	AOS	COLUMN			;COUNT COLUMNS
	SKIPLE	S.DPY			;DISPLAY?
	PJRST	DPCHR			;YES
	OUTCHR	T1			;TYPE CHARACTER
	POPJ	P,			;RETURN


TTYREF:	SKIPG	S.DPY			;DISPLAY?
	PJRST	.TCRLF##		;NO - A CRLF WILL DO
	PUSHJ	P,DP.SAC	
	PUSHJ	P,DPYREF##
	PJRST	DP.RAC
SUBTTL	Initial parameters


INITIA:	MOVEI	P1,INITAB		;POINT TO TABLE
	PUSHJ	P,GTBS			;DO GETTABS
	  HALT	.
	HRRZS	JOBN			;STRIP OFF THE SEGMENT COUNT
	SOS	JOBN			;ACCOUNT FOR THE NULL JOB
	HRRZS	PIDTAB			;KEEP JUST THE ADDRESS OF PIDTAB
	MOVE	T1,PIDN			;GET MAXIMUM NUMBER OF PIDS
	IMULI	T1,.PBLEN		;COMPUTE WORDS NEEDED FOR PID BLOCKS
	PUSHJ	P,GETCOR		;GET CORE
	DMOVEM	T1,PIDBLK		;STORE WORD COUNT AND ADDRESS
	POPJ	P,			;RETURN

INITAB:	$GTB	(%CNSJN,JOBN)		;JOBN
	$GTB	(%CNTIC,JIFFIE)		;JIFFIE VALUE
	$GTB	(%IPCMP,PIDN)		;LENGTH OF PIDTAB
	$GTB	(<.GTPID,,.GTSLF>,PIDTAB) ;ADDRESS OF PIDTAB
	EXP	0			;TERMINATE TABLE
SUBTTL	System statistics -- Gather system data


SYSTEM:	MOVEI	P1,SYSTAB		;POINT TO SYSTEM TABLE
	PUSHJ	P,GTBS			;DO GETTABS
	  JFCL				;IGNORE ERRORS
	MOVE	T1,[POINT 7,CONFIG]	;SOURCE BYTE POINTER
	MOVE	T2,T1			;COPY IT
	SETZ	T3,			;CLEAR A FLAG

SYST.2:	ILDB	T4,T1			;GET A CHARACTER
	JUMPE	T4,SYST.3		;DONE ALL CHARACTERS?
	JUMPN	T3,SYST.3		;DONE FLUSHING SPACES?
	CAIE	T4,.CHTAB		;A TAB?
	CAIN	T4," "			;A SPACE?
	JRST	SYST.2			;IGNORE IT
	SETO	T3,			;SET FLAG
SYST.3:	IDPB	T4,T2			;STORE IT
	JUMPN	T4,SYST.2		;LOOP IF MORE
	MOVE	T1,[-<6*2>,,MONFIL]	;AOBJN POINTER

SYST.4:	SKIPN	.FXDIR(T1)		;HAVE A WORD?
	JRST	SYST.5			;END OF PATH
	SETOM	.FXDIM(T1)		;SET MASK
	AOBJN	T1,.+1			;ACCOUNT FOR TWO WORD ENTRIES
	AOBJN	T1,SYST.4		;LOOP

SYST.5:	PUSHJ	P,PRTHDR		;PRINT SYSTEM HEADER
	PUSHJ	P,.TCRLF##		;TYPE NEW LINE
	PUSHJ	P,ERRTYP		;TYPE ANY ERROR TEXT WE MIGHT HAVE
	PUSHJ	P,PRTORI		;PRINT ORIGIN OF DISPLAY
	PUSHJ	P,PRTUSE		;PRINT PID USAGE
	PUSHJ	P,.TCRLF##		;TYPE A NEW LINE
	PUSHJ	P,PRTINF		;PRINT [SYSTEM]INFO DATA
	PUSHJ	P,.TCRLF##		;TYPE A NEW LINE
;	PUSHJ	P,PRTDEF		;PRINT SYSTEM DEFAULTS
;	PUSHJ	P,.TCRLF##		;TYPE A NEW LINE
	PUSHJ	P,PRTPRF		;PRINT PERFORMANCE DATA
	POPJ	P,			;RETURN
SUBTTL	System statistics -- GETTABs


SYSTAB:	$GTB	(%CNMBS,MONFIL+.FXDEV)	;MONITOR BOOTSTRAP FILE STRUCTURE
	$GTB	(%CNMBF,MONFIL+.FXNAM)	;MONITOR BOOTSTRAP FILE NAME
	$GTB	(%CNMBX,MONFIL+.FXEXT)	;MONITOR BOOTSTRAP EXTENSION
	$GTB	(%CNMBD,MONFIL+.FXDIR)	;MONITOR BOOTSTRAP DIRECTORY
	$GTB	(%CNSF1,MONFIL+.FXDIR+2) ;MONITOR BOOTSTRAP 1ST SFD
	$GTB	(%CNSF2,MONFIL+.FXDIR+4) ;MONITOR BOOTSTRAP 2ND SFD
	$GTB	(%CNSF3,MONFIL+.FXDIR+6) ;MONITOR BOOTSTRAP 3RD SFD
	$GTB	(%CNSF4,MONFIL+.FXDIR+10) ;MONITOR BOOTSTRAP 4TH SFD
	$GTB	(%CNSF5,MONFIL+.FXDIR+12) ;MONITOR BOOTSTRAP 5TH SFD
	$GTB	(%CNFG0,CONFIG+0)	;SYSTAM NAME (WORD 0)
	$GTB	(%CNFG1,CONFIG+1)	;SYSTAM NAME (WORD 1)
	$GTB	(%CNFG2,CONFIG+2)	;SYSTAM NAME (WORD 2)
	$GTB	(%CNFG3,CONFIG+3)	;SYSTAM NAME (WORD 3)
	$GTB	(%CNFG4,CONFIG+4)	;SYSTAM NAME (WORD 4)
	$GTB	(%CNYER,LOCYER)		;LOCAL YEAR
	$GTB	(%CNMON,LOCMON)		;LOCAL MONTH
	$GTB	(%CNDAY,LOCDAY)		;LOCAL DAY
	$GTB	(%CNHOR,LOCHOR)		;LOCAL HOUR
	$GTB	(%CNMIN,LOCMIN)		;LOCAL MINUTE
	$GTB	(%CNSEC,LOCSEC)		;LOCAL SECOND
	$GTB	(%CNSUP,UPTIME)		;UPTIME
	$GTB	(%CNDTM,UDT)		;UNIVERSAL DATE/TIME
	$GTB	(%SYSPC,STOPCD)		;STOPCODE NAME

	$GTB	(%IPCML,PKTLEN)		;MAXIMUM PACKET LENGTH
	$GTB	(%IPCDQ,DEFQTA)		;DEFAULT QUOTAS
	$GTB	(%IPCTS,PKTSNT)		;TOTAL PACKETS SENT
	$GTB	(%IPCTO,PKTOUT)		;TOTAL PACKETS OUTSTANDING
	$GTB	(%IPCPM,PIDMSK)		;PID MASK
	$GTB	(%IPCNP,PIDNUM)		;NUMBER OF PIDS DEFINED
	$GTB	(%IPCTP,PIDSRL)		;TOTAL PIDS DEFINED SINCE RELOAD
	$GTB	(%IPCIC,PICNUM)		;IPCF PAGES IN CORE
	$GTB	(%IPTWT,TWTNUM)		;TOTAL WORDS TRANSFERED
	$GTB	(%IPTPT,TPTNUM)		;TOTAL PAGES TRANSFERED
	$GTB	(%VMIPC,IPCCNT)		;IPCF PAGES SWAPPED

	SIDMAX==0			;INIT COUNTER
	$SID	(%SIIPC)		;PID OF [SYSTEM]IPCC
	$SID	(%SIINF)		;PID OF [SYSTEM]INFO
	$SID	(%SIQSR)		;PID OF [SYSTEM]QUASAR
	$SID	(%SIMDA)		;PID OF [SYSTEM]MDA
	$SID	(%SITLP)		;PID OF TAPE LABELER (PULSAR)
	$SID	(%SIFDA)		;PID OF FILDAE
	$SID	(%SITOL)		;PID OF TAPE ON-LINE PROCESSOR (QUASAR)
	$SID	(%SIACT)		;PID OF [SYSTEM]ACCOUNTING (ACTDAE)
	$SID	(%SIOPR)		;PID OF OPERATOR INTERFACE (ORION)
	$SID	(%SISEL)		;PID OF SYSTEM ERROR LOGGER (SYSERR)
	$SID	(%SIDOL)		;PID OF DISK ON-LINE PROCESSOR (QUASAR)
	$SID	(%SITGH)		;PID OF [SYSTEM]TGHA
	$SID	(%SINML)		;PID OF DECNET NETWORK MANAGER (NML)
	$SID	(%SIGFR)		;PID O@[cYSTEM]oPXER
	EXP	0			;TERMINATE TABLE
SUBTTL	System statistics -- Header display


PRTHDR:	MOVEI	T1,[ASCIZ |IPCF status of |]
	PUSHJ	P,.TSTRG##		;TYPE INTRO
	MOVEI	T1,CONFIG		;POINT TO SYSTEM NAME
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVEI	T1,[ASCIZ | at |]	;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,LOCHOR		;GET LOCAL HOUR
	MOVEI	T2,"0"			;GET FILLER
	PUSHJ	P,.TDEC2##		;TYPE IT
	PUSHJ	P,.TCOLN##		;TYPE COLON
	MOVE	T1,LOCMIN		;GET LOCAL MINUTE
	MOVEI	T2,"0"			;GET FILLER
	PUSHJ	P,.TDEC2##		;TYPE IT
	PUSHJ	P,.TCOLN##		;TYPE COLON
	MOVE	T1,LOCSEC		;GET LOCAL SECOND
	MOVEI	T2,"0"			;GET FILLER
	PUSHJ	P,.TDEC2##		;TYPE IT

	MOVEI	T1,[ASCIZ | on |]	;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,LOCDAY		;GET LOCAL DAY
	PUSHJ	P,.TDECW##		;TYPE IT
	PUSHJ	P,DASH			;TYPE A DASH
	MOVE	T1,LOCMON		;GET LOCAL MONTH
	MOVEI	T1,MONTAB-1(T1)		;POINT TO MONTH TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,DASH			;TYPE A DASH
	MOVE	T1,LOCYER		;GET LOCAL YEAR
	SUBI	T1,^D1900		;JUST LAST TWO DIGITS
	PUSHJ	P,.TDECW##		;TYPE IT

	PUSHJ	P,PRTUPT		;TYPE UPTIME
	POPJ	P,			;RETURN
MONTAB:	ASCIZ	|Jan|
	ASCIZ	|Feb|
	ASCIZ	|Mar|
	ASCIZ	|Apr|
	ASCIZ	|May|
	ASCIZ	|Jun|
	ASCIZ	|Jul|
	ASCIZ	|Aug|
	ASCIZ	|Sep|
	ASCIZ	|Oct|
	ASCIZ	|Nov|
	ASCIZ	|Dec|
SUBTTL	System statistics -- Uptime display


PRTUPT:	MOVEI	T1,[ASCIZ | Up |]	;INTRODUCTION
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,UPTIME		;GET UPTIME
	IDIV	T1,JIFFIE		;CONVERT TO SECONDS
	PUSHJ	P,TIMOUT		;OUTPUT IT
	POPJ	P,			;RETURN
SUBTTL	System statistics -- [SYSTEM]INFO display


PRTINF:	MOVEI	T1,[ASCIZ |[SYSTEM]INFO is not running|]
	MOVE	T2,SIDTAB+<%SIINF_-^D18> ;INFO PID ALIVE?
	AND	T2,PIDMSK		;KEEP ONLY THE PIDTAB INDEX
	JUMPE	T2,.TSTRG##		;TYPE TEXT AND RETURN IF NO INFO
	MOVEI	T1,[ASCIZ |[SYSTEM]INFO has processed |]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	HRLZ	T1,T2			;GET INDEX IN LH
	HRRI	T1,.GTPID		;GETTAB TABLE
	PUSHJ	P,.MAPG##		;READ THE PID
	  SETZ	T1,			;CAN'T
	AND	T1,PIDMSK		;KEEP JUST THE JOB NUMBER
	PUSH	P,T1			;SAVE JOB NUMBER
	HRLZS	T1			;PUT JOB NUMBER IN LH
	HRRI	T1,.GTIPA		;GETTAB TABLE
	PUSHJ	P,.MAPG##		;READ SEND AND RECEIVE STATS
	  SETZ	T1,			;CAN'T
	LDB	T2,[POINTR (T1,IP.CQD)]	;GET TOTAL SENDS
	LDB	T1,[POINTR (T1,IP.CQC)]	;GET TOTAL RECEIVES
	ADD	T1,T2			;ADD THEM TOGETHER
	PUSHJ	P,.TDECW##		;TYPE NUMBER OF PACKETS
	MOVEI	T1,[ASCIZ | packets in |] ;CHATTER
	PUSHJ	P,.TSTRG##		;TYPE IT
	HRLZ	T1,(P)			;GET JOB NUMBER
	HRRI	T1,.GTJLT		;GETTAB TABLE
	PUSHJ	P,.MAPG##		;READ JOB'S LOGIN TIME
	  SETZ	T1,			;CAN'T
	MOVE	T2,T1			;SAVE TIME
	MOVE	T1,UDT			;GET CURRENT UDT (FOR THIS PASS)
	SUB	T1,T2			;COMPUTE TIME SINCE LOGIN
	HLRZ	T2,T1			;GET NUMBER OF DAYS
	IMUL	T2,[^D24*^D60*^D60]	;COMPUTE NUMBER OF SECONDS
	PUSH	P,T2			;SAVE IT
	HRRZS	T1			;KEEP JUST THE TIME SINCE MIDNIGHT
	PUSHJ	P,.CNTDT##		;CONVERT FROM UDT TO OLD FORMAT
	IDIVI	T1,^D1000		;CONVERT FROM MS TO SECONDS
	POP	P,T2			;GET NUMBER OF DAYS (IN SECONDS)
	ADD	T1,T2			;ADD IT IN
	PUSHJ	P,TIMOUT		;TYPE TIME
	MOVEI	T1,[ASCIZ |; Runtime = |]; GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HRLZ	T1,(P)			;GET JOB NUMBER
	HRRI	T1,.GTTIM		;GETTAB TABLE
	PUSHJ	P,.MAPG##		;READ RUNTIME
	  SETZ	T1,			;CAN'T
	IDIV	T1,JIFFIE		;CONVERT TO SECONDS
	PUSHJ	P,TIMOUT		;TYPE TIME
	POP	P,(P)			;TRIM STACK
	POPJ	P,			;RETURN
SUBTTL	System statistics -- Print origin of display


PRTORI:	SKIPG	S.ORIG			;WANT ORIGIN?
	POPJ	P,			;NO
	MOVE	T1,S.FILE		;GET FIRST WORD OF FILESPEC
	CAME	T1,[-1]			;THE MONITOR?
	JRST	PRTFIL			;A FILE

PRTMON:	MOVEI	T1,[ASCIZ |Monitor was run from: |] ;ASSUME MONITOR
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVEI	T1,MONFIL		;POINT TO SCAN BLOCK
	PUSHJ	P,.TFBLK##		;TYPE FILESPEC
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN

PRTFIL:	MOVEI	T1,[ASCIZ |Crash file: |] ; YES
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,MAPPTR		;GET ADDRESS OF MAP'S DATA BLOCK
	MOVEI	T1,.MPAFS##(T1)		;POINT TO START OF ASCIZ FILESPEC
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVEI	T1,[ASCIZ | (Stopcode was |] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLLZ	T1,STOPCD		;GET STOPCODE NAME
	PUSHJ	P,.TSIXN##		;TYPE IT
	MOVEI	T1,")"			;GET CLOSING PARANTHESIS
	PUSHJ	P,.TCHAR##		;TYPE IT
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	System statistics -- PID usage display


PRTUSE:	MOVE	T1,PIDNUM		;GET PIDS IN USE
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | PIDs in use out of |]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,PIDN			;GET MAXIMUM PIDS ON SYSTEM
	PUSHJ	P,.TDECW##		;TYPE IT
	PUSHJ	P,.TCOMA##		;TYPE A COMA
	PUSHJ	P,.TSPAC##		;TYPE A SPACE
	MOVE	T1,PIDSRL		;GET PIDS SINCE RELOAD
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | defined since reload|]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	PUSHJ	P,.TCRLF##		;NEW LINE

	MOVE	T1,PKTSNT		;GET PACKETS SENT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | sends; Average use = |]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,PKTSNT		;GET PACKETS SENT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,"/"			;GET A SLASH
	PUSHJ	P,.TCHAR##		;TYPE IT
	MOVE	T1,UPTIME		;GET UPTIME
	IDIV	T1,JIFFIE		;GET UPTIME IN SECONDS
	PUSH	P,T1			;SAVE IT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | = |]	;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,PKTSNT		;GET PACKETS SENT
	IDIV	T1,(P)			;T1:= PACKETS/SECOND, T2:= FRACTION
	IMULI	T2,^D100		;MAKE IT DECIMAL
	IDIV	T2,(P)			;T2:= DECIMAL FRACTION OF A SECOND
	MOVEM	T2,(P)			;SAVE FRACTION
	PUSHJ	P,.TDECW##		;TYPE IT
	PUSHJ	P,DOT			;TYPE A PERIOD
	POP	P,T1			;GET FRACTION
	MOVE	T2,["0",,2]		;PAD CHARACTER IS ZERO, 2 COLUMNS
	PUSHJ	P,DECOUT		;TYPE SENDS
	MOVEI	T1,[ASCIZ | packets/second|] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,.TCRLF##		;NEW LINE

	MOVEI	T1,[ASCIZ |Transfered |];GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,TWTNUM		;GET TOTAL WORDS XFERED
	PUSHJ	P,DECOUT		;TYPE IT
	MOVEI	T1,[ASCIZ | words, |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,TPTNUM		;GET TOTAL PAGES XFERED
	PUSHJ	P,DECOUT		;TYPE IT
	MOVEI	T1,[ASCIZ | pages; |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,PKTOUT		;GET OUTSTANDING
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | out, |]	;GET STRING
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,PICNUM		;GET IPCF PAGES IN CORE
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | in core, |]
	PUSHJ	 P,.TSTRG##		;TYPE TEXT
	MOVE	T1,IPCCNT		;GET PAGES SWAPPED
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | swapped|]
	PUSHJ	P,.TSTRG##		;TYPE IT
	POPJ	P,			;RETURN
SUBTTL	System statistics -- Performance data


PRTPRF:	SKIPG	S.PERF			;WANT PERFORMANCE DATA?
	POPJ	P,			;NO
	MOVEI	T1,[ASCIZ |Performance: MAP %|] ;GET INTRODUCTION
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	P1,MAPPTR		;GET MAP'S PERFORMANCE DATA BLOCK ADDR
	MOVE	T1,.MPVER##(P1)		;GET THE VERSION NUMBER
	PUSHJ	P,.TVERW##		;TYPE IT
	MOVEI	T1,[ASCIZ |, |]		;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPCPC##(P1)		;GET CACHED PAGE COUNT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | cached pages, runtime = |] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPRTM##(P1)		;GET TOTAL RUNTIME
	PUSHJ	P,HPTOUT		;TYPE HIGH PRECISION TIME
	MOVEI	T1,[ASCIZ |, |]		;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPEXM##(P1)		;GET COUNT OF EXAMINES
	SUB	T1,.MPPGC##(P1)		;MINUS THE PAGES WE HAD TO CREATE
	IMULI	T1,^D100		;MULTIPLY BY 100 SO WE CAN
	IDIV	T1,.MPEXM##(P1)		; COMPUTE HIT RATIO
	PUSHJ	P,.TDECW##		;TYPE RATIO
	MOVEI	T1,[ASCIZ |% hit ratio|] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,.TCRLF##		;TYPE A NEW LINE

	MOVE	T1,.MPPGC##(P1)		;GET PAGE CREATE COUNT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | creates, |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPPGD##(P1)		;GET PAGE DESTROY COUNT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | destroys, |] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPEXM##(P1)		;GET EXAMINE COUNT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | examines, |] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,.MPGTB##(P1)		;GET GETTAB COUNT
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | GETTABs|]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	PID information -- Load PID blocks


LDPIDS:	PUSHJ	P,.SAVE4##	;SAVE SOME ACS
	SETZM	PIDCNT		;RESET PID COUNT
	SETZM	@PIDBLK+1	;CLEAR FIRST WORD
	MOVE	T1,PIDBLK+1	;POINT TO FIRST WORD
	HRLI	T1,1(T1)	;LH=ADDR+1
	MOVSS	T1		;MAKE A BLT POINTER
	MOVE	T2,PIDBLK+0	;GET LENGTH
	ADD	T2,PIDBLK+1	;COMPUTE END ADDRESS
	BLT	T1,-1(T2)	;CLEAR OUT THE PID BLOCKS
	MOVE	P1,PIDBLK+1	;POINT TO START OF PID BLOCKS
	SETZ	P2,		;CLEAR A COUNTER

LDPI.1:	HRLZ	T1,P2		;GET INDEX
	HRRI	T1,.GTPID
	PUSHJ	P,.MAPG##	;GET A PIDTAB ENTRY
	  JRST	LDPI.5		;END OF TABLE
	JUMPE	T1,LDPI.4	;IGNORE NULL ENTRIES
	MOVEM	T1,.PBPTB(P1)	;SAVE PIDTAB ENTRY
	AND	T1,PIDMSK	;MASK OUT JOB NUMBER
	MOVEM	T1,.PBJOB(P1)	;SAVE IT
	MOVE	T1,.PBPTB(P1)	;GET PIDTAB ENTRY BACK
	ANDCM	T1,PIDMSK	;MASK OUT INDEX
	IOR	T1,P2		;INCLUDE PIDTAB OFFSET
	MOVEM	T1,.PBPID(P1)	;SAVE PID RETURNED FOR UUO USAGE
	PUSHJ	P,SPCPID	;GET SPECIAL PID
	MOVEM	T2,.PBSNM(P1)	;SAVE SPECIAL PID NAME ADDRESS
	MOVEM	T1,.PBSID(P1)	;SAVE IT AWAY
	MOVX	T1,IJBNAM	;GET PID NAME BIT
	MOVE	T2,S.MODE	;AND CURRENT MODE
	SKIPE	OURPID		;WE HAVE A PID?
	TDNN	T1,S.INCL(T2)	;WANT PID NAMES?
	JRST	LDPI.3		;NO TO EITHER
	MOVE	T1,.PBPID(P1)	;GET PID
	PUSHJ	P,PNAMES	;RETURN PID NAME STRING
	  JRST	LDPI.2		;FAILED FOR SOME REASON--TURN OFF DISPLAY
	HRLZ	T2,T1		;GET ADDRESS OF STRING
	HRRI	T2,.PBNAM(P1)	;WHERE TO STORE IT
	BLT	T2,.PBNAM+NAMLEN-1(P1) ;COPY NAME
	JRST	LDPI.3		;ONWARD

LDPI.2:	MOVX	T1,IJBNAM	;GET PID NAME BIT
	MOVE	T2,S.MODE	;AND CURRENT MODE
	ANDCAM	T1,S.INCL(T2)	;TURN OFF PID NAME DISPLAY

LDPI.3:	PUSHJ	P,JBDATA	;GET JOB RELATED DATA
	AOS	PIDCNT		;ACCUMULATE TOTAL PID BLOCKS IN USE
	ADDI	P1,.PBLEN	;POINT TO NEXT BLOCK

LDPI.4:	AOJA	P2,LDPI.1	;LOOP

LDPI.5:	MOVE	P2,PIDCNT	;GET COUNT OF PIDS
	ADDI	P2,1		;COUNT FROM N TO C(PIDCNT)

LDPI.6:	SETOM	.PBJOB(P1)	;MARK BLOCK NOT IN USE
	ADDI	P1,.PBLEN	;POINT TO NEXT BLOCK
	CAMGE	P2,PIDN		;DONE ALL BLOCKS YET?
	AOJA	P2,LDPI.6	;NO--LOOP
	PUSHJ	P,SRTJOB	;SORT THE PIDS BY OWNER JOB NUMBER
	POPJ	P,
SUBTTL	PID information -- Search for special PIDs


; Search for special PIDs
; Call:	MOVE	T1, PIDTAB entry
;	PUSHJ	P,SPCPID
;
; On return, T1:= special PID or -1 if there isn't one, T2:= index
;
SPCPID:	ANDCM	T1,PIDMSK	;MASK OUT JOB NUMBER
	MOVEI	T2,SIDMAX	;SET UP COUNTER

SPCP.1:	MOVE	T3,SIDTAB(T2)	;GET A PID
	ANDCM	T3,PIDMSK	;MASK OUT INDEX INTO PIDTAB
	CAME	T1,T3		;A MATCH?
	SOJGE	T2,SPCP.1	;NO - KEEP LOOKING
	SKIPL	T1,T2		;END OF SPECIAL PID TABLE?
	MOVE	T1,SIDTAB(T2)	;NO--GET SPECIAL PID
	MOVE	T2,SIDNAM(T2)	;GET ADDRESS OF SPECIAL PID NAME
	POPJ	P,		;RETURN
SUBTTL	PID information -- Sort PIDs by owner job number


SRTJOB:	MOVE	P3,PIDCNT	;GET NUMBER OF PID BLOCKS
	IMULI	P3,.PBLEN	;GET LENGTH OF ALL ENTRIES
	ADD	P3,PIDBLK+1	;THE HIGHEST ADDRESS +1

SRTJ.1:	MOVE	P1,PIDBLK+1	;GET ADDRESS OF FIRST PID BLOCK
	MOVEI	P2,.PBLEN(P1)	;POINT TO NEXT ENTRY
	MOVEI	P4,0		;CLEAR CHANGE COUNTER

SRTJ.2:	HRRZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRZ	T2,.PBJOB(P2)	;...
	CAMG	T1,T2		;IN ASCENDING ORDER?
	JRST	SRTJ.3		;YES
	MOVSI	T1,.PBBLK(P1)	;GET START ADDRESS
	HRRI	T1,PBTEMP	;WHERE TO PUT IT
	BLT	T1,PBTEMP+.PBLEN-1 ;COPY IT AWAY TEMPORARILY
	MOVSI	T1,.PBBLK(P2)	;GET START ADDRESS
	HRRI	T1,.PBBLK(P1)	;WHERE TO PUT IT
	BLT	T1,.PBLEN-1(P1)	;COPY IT
	MOVSI	T1,PBTEMP	;GET ADDRESS OF TEMPORARY STORAGE
	HRRI	T1,.PBBLK(P2)	;WHERE TO PUT IT
	BLT	T1,.PBLEN-1(P2)	;COPY IT
	ADDI	P4,1		;COUNT THE CHANGE

SRTJ.3:	MOVE	P1,P2		;POINT TO NEXT BLOCK
	ADDI	P2,.PBLEN	;...
	CAMGE	P2,P3		;CHECKED ALL BLOCKS?
	JRST	SRTJ.2		;NO--LOOP
	JUMPN	P4,SRTJ.1	;DO IT AGAIN IF SOMETHING CHANGED
	POPJ	P,		;RETURN
SUBTTL	PID information -- Get associated job data


JBDATA:	MOVE	P3,S.MODE	;GET MODE INDEX
	MOVE	P3,S.INCL(P3)	;GET INCLUDE BITS FOR THIS MODE

JBD.01:	TXNN	P3,IJBPPN	;PPN
	JRST	JBD.02		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTPPN	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET THE PPN
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBPPN(P1)	;SAVE IT

JBD.02:	TXNN	P3,IJBUSE	;USER NAME?
	JRST	JBD.03		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTNM1	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET THE USER NAME (WORD 1)
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBUNM+0(P1)	;SAVE IT
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTNM2	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET THE USER NAME (WORD 2)
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBUNM+1(P1)	;SAVE IT

JBD.03:	TXNN	P3,IJBPRO	;PROGRAM?
	JRST	JBD.04		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTPRG	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET THE PROGRAM NAME
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBPRG(P1)	;SAVE IT

JBD.04:	TXNN	P3,IJBQUO	;QUOTAS
	JRST	JBD.05		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTIPQ	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET QUOTAS
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBQTA(P1)	;SAVE THEM

JBD.05:	TXNN	P3,IJBTOT	;TOTAL SENDS AND RECEIVES
	JRST	JBD.06		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTIPA	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET COUNTS
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBTSR(P1)	;SAVE THEM

JBD.06:	TXNN	P3,IJBOUT	;OUTSTANDING SENDS AND RECEIVES
	JRST	JBD.07		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTIPP	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET COUNTS
	  SETZ	T1,		;FAILED
	MOVEM	T1,.PBOSR(P1)	;SAVE THEM

JBD.07:	TXNN	P3,IJBCAP	;CAPABILITIES
	JRST	JBD.08		;NO
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTSTS	;JOB STATUS TABLE
	PUSHJ	P,.MAPG##	;READ IT
	  SETZ	T1,		;CAN'T
	SETZ	T2,		;CLEAR AN AC
	TLNE	T1,JACCT	;JACCT?
	TXO	T2,' J    '	;YES
	TLNE	T1,JLOG		;LOGGED IN?
	TXO	T2,'  L   '	;YES
	TRNE	T1,JS.XO	;EXECUTE-ONLY?
	TXO	T2,'    X '	;YES
	PUSH	P,T2		;SAVE CODES
	HRLZ	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTPRV	;PRIVILIGE TABLE
	PUSHJ	P,.MAPG##	;READ THEM
	  SETZ	T1,		;CAN'T
	POP	P,T2		;GET SAVED CODES
	TXNE	T1,JP.IPC	;IPCF PRIVS?
	TXO	T2,'I     '	;YES
	TXNE	T1,JP.POK	;POKE PRIVS?
	TXO	T2,'   P  '	;YES
	MOVEM	T2,.PBCAP(P1)	;SAVE THEM

JBD.08:	TXNN	P3,IJBLOCAL	;LOCAL [SYSTEM]INFO?
	JRST	JBD.09		;NO
	HRL	T1,.PBJOB(P1)	;GET JOB NUMBER
	HRRI	T1,.GTIPI	;GETTAB TABLE NUMBER
	PUSHJ	P,.MAPG##	;GET LOCAL [SYSTEM]INFO PID
	  SETZ	T1,		;FAILED

JBD.09:	POPJ	P,		;RETURN
SUBTTL	Control-C trapping


INTINI:	MOVE	T1,[4,,INTLOC]		;GET BLOCK LENGTH AND INTERRUPT ADDRESS
	MOVEM	T1,INTBLK+.ERNPC	;SAVE IT
	MOVEI	T1,ER.ICC		;INTERRUPT MASK
	MOVEM	T1,INTBLK+.ERCLS	;SAVE CLASS OF INTERRUPTS
	SETZM	INTBLK+.EROPC		;CLEAR OLD PC
	SETZM	INTBLK+.ERCCL		;CLEAR INTERRUPTED CLASS,,CHANNEL
	MOVEI	T1,INTBLK		;POINT TO INTERRUPT BLOCK
	MOVEM	T1,.JBINT		;TELL THE MONITOR
	POPJ	P,			;RETURN


INTLOC:	PUSH	P,INTBLK+.EROPC		;SAVE INTERRUPTING PC
	SETZM	INTBLK+.EROPC		;RE-ENABLE INTERRUPT
	PUSH	P,T1			;SAVE T1
	HLLZ	T1,INTBLK+.ERCCL	;GET INTERRUPT CLASS FLAGS
	JUMPE	T1,INTXIT		;NO INTERRUPT CONDITIONS?
	TLNE	T1,ER.ICC		;CONTROL-C INTERCEPT?
	PUSHJ	P,.EXIT			;YES

INTXIT:	POP	P,T1			;RESTORE T1
	POPJ	P,			;RETURN

SUBTTL	[SYSTEM]INFO interface -- Initialize


INFSET:	MOVEI	T1,664055		;A FAIRLY UNIQUE NUMBER
	MOVEM	T1,ACK			;SAVE IT FOR ACK CODE GENERATION
	PUSHJ	P,GENNAM		;GENERATE A UNIQUE NAME
	PUSHJ	P,GETPID		;ACQUIRE A NAMED PID
	POPJ	P,			;*** FOR NOW ***
SUBTTL	[SYSTEM]INFO interface -- Generate a unique name


; Generate an ASCIZ name to associate with our PID.
; To insure the name is unique,  the job number will
; be appended to the end of the name text.
;
GENNAM:	SETZM	NAM		;CLEAR OUT
	MOVE	T1,[NAM,,NAM+1]	; NAME TEXT
	BLT	T1,NAM+NAMLEN-1	;  STORAGE
	MOVE	T1,[POINT 7,NAM];BYTE POINTER TO NAME
	MOVEM	T1,NAMPTR	;SAVE IT
	MOVEI	T1,NAMTYO	;POINT TO CHARACTER STICKER
	PUSHJ	P,.TYOCH##	;TELL SCAN
	PUSH	P,T1		;SAVE OLD ONE
	MOVE	T1,.MYPPN##	;GET OUR PPN
	PUSHJ	P,.TPPNW##	;TYPE IT
	MOVEI	T1,[ASCIZ |IPCF status |]
	PUSHJ	P,.TSTRG##	;TYPE IT
	PJOB	T1,		;GET OUR JOB NUMBER
	PUSHJ	P,.TDECW##	;TYPE IT
	POP	P,T1		;GET OLD CHARACTER STICKER
	PJRST	.TYOCH##	;RESET IT AND RETURN

NAMTYO:	IDPB	T1,NAMPTR	;STORE CHARACTER
	POPJ	P,		;RETURN
SUBTTL	[SYSTEM]INFO interface -- Acquire a named PID


; Get a named PID from [SYSTEM]INFO.  This routine uses
; the name text generated by GENNAM.

GETPID:	SETZM	OURPID		;WE DON'T HAVE A PID YET
	SETZM	PDB+.IPCFL	;CLEAR FIRST WORD OF PDB
	MOVEI	T1,.IPCII	;REQUEST PID WITH NAME
	MOVEM	T1,PMB+.IPCI0	;LOAD ACK,,FCN-CODE INTO PMB
	MOVE	T1,[NAM,,PMB+.IPCI2];POINTER TO LOAD NAME INTO PMB
	BLT	T1,PMB+.IPCI2+NAMLEN-1;LOAD NAME INTO PMB
	PUSHJ	P,IPCSND	;SEND PACKET
	  SKIPA			;FAILED
	PUSHJ	P,IPCRCV	;RETRIEVE PACKET
	  TDZA	T1,T1		;FAILED--CLEAR OUR PID
	MOVE	T1,PMB+.IPCS1	;GET PID
	MOVEM	T1,OURPID	;SAVE IT
	POPJ	P,		;RETURN
SUBTTL	[SYSTEM]INFO interface -- Read a PID name


PNAMES:	MOVE	T2,T1		;SAVE PID
	SETZM	PDB+.IPCFL	;CLEAR FLAGS
	SETZM	PMB		;CLEAR FIRST WORD
	MOVE	T1,[PMB,,PMB+1]	;SET UP BLT
	BLT	T1,PMB+PMBLEN-1	;CLEAR BLOCK
	MOVEI	T1,.IPCIG	;FUNCTION CODE TO RETURN NAME OF PID
	MOVEM	T1,PMB+.IPCI0	;SET IT
	MOVEM	T2,PMB+.IPCI2	;PUT IN BLOCK FOR INFO
	PUSHJ	P,IPCSND	;SEND TO INFO
	  JRST	.POPJ##		;FAILED
	PUSHJ	P,IPCRCV	;TRY TO RECEIVE A MESSAGE
	  JRST	.POPJ##		;FAILED
	LDB	T1,[POINTR (PDB+.IPCFL,IP.CFE)] ;GET ERROR FIELD
	SKIPE	T1		;ANY ERRORS?
	SETZM	PMB+.IPCS2	;YES--MAKE SURE START OF NAME FIELD IS NULL
	MOVEI	T1,PMB+.IPCS2	;POINT TO START OF RETURNED TEXT
	JRST	.POPJ1##	;RETURN
SUBTTL	[SYSTEM]INFO interface -- Send and receive packets


IPCSND:	MOVE	T1,OURPID	;GET OUR PID
	MOVEM	T1,PDB+.IPCFS	;SENDER IS US
	SETZM	PDB+.IPCFR	;RECEIVER IS [SYSTEM]INFO
	MOVE	T1,[PMBLEN,,PMB];LOAD LENGTH,,ADDR OF PMB
	MOVEM	T1,PDB+.IPCFP	;POINT TO PMB
	SETZM	PDB+.IPCFU	;NO PPN
	SETZM	PDB+.IPCFC	;ZERO CAPABILITY WORD
	AOS	T1,ACK		;ADD ONE TO MAKE UNIQUE ACK-CODE
	HRLM	T1,PMB+.IPCI0	;SAVE IT
	SETZM	PMB+.IPCI1	;NO DUPLICATE PID
	MOVE	T1,[PDBLEN,,PDB];LOAD LENGTH,,ADDR OF PDB
	IPCFS.	T1,		;SEND PACKET
	  POPJ	P,		;LOSE
	JRST	.POPJ1##	;RETURN

IPCRCV:	MOVE	T1,[PDBLEN,PDB]	;LOAD LENGTH,,ADDR OF PDB
	IPCFR.	T1,		;GET PACKET
	  POPJ	P,		;LOSE
	HLRZ	T1,PMB+.IPCS0	;GET ACK-CODE OF PACKET
	CAME	T1,ACK		;COMPARE WITH ACK OF SENT PACKET
	JRST	IPCRCV		;ACKS NOT EQUIVALENT, TRY AGAIN
	JRST	.POPJ1##	;RETURN
SUBTTL	Perform GETTABs


; ROUTINE TO PERFORM GETTABS
; CALL:	MOVE	P1,TABLE OF ARGUMENTS AND ADDRESSES
;	PUSHJ	P,GTBS
;	<NON-SKIP>			;A GETTAB FAILED (P1:= FAILED ADDRESS)
;	<SKIP>				;DONE ALL
GTBS:	SKIPN	T1,(P1)			;GET AN ARGUMENT
	JRST	.POPJ1##		;DONE
	PUSHJ	P,.MAPG##		;SIMULATE A GETTAB UUO
	  SETZ	T1,			;CAN'T
	MOVEM	T1,@1(P1)		;STORE VALUE
	ADDI	P1,2			;ACCOUNT FOR TWO WORD ENTRIES
	JRST	GTBS			;LOOP FOR ALL TABLE ENTRIES
SUBTTL	Command scanning -- Entry point


; Here once per display loop to check and process a command.
; Call:	PUSHJ	P,COMAND
;
COMAND:	SKPINL				;CAN A LINE BE INPUT?
	POPJ	P,			;NO
	MOVEI	T1,0			;CLEAR BLOCK POINTER
	PUSHJ	P,.PSCAN##		;SET UP PARTIAL SCANNER
	  JFCL				;FORGET PROMPT STUFF
	PUSHJ	P,.SIXSW##		;GET A KEYWORD
	JUMPN	N,CMD.1			;HAVE A COMMAND?
	JUMPL	C,CMD.2			;MAYBE JUST EOL?
	JRST	CMD.2			;MIGHT BE JUNK
CMD.1:	MOVE	T2,N			;GET KEYWORD
	MOVE	P1,S.MODE		;GET MODE INDEX
	MOVE	T1,MODCMD(P1)		;GET POINTER TO COMMAND TABLE
	PUSHJ	P,.LKNAM##		;SCAN THE TABLE FOR A MATCH
	  JRST	CMDKEY			;BAD KEYWORD
	MOVE	I,S.INCL(P1)		;GET INCLUDE BITS FOR THIS MODE
	HRRZ	T2,MODCMD(P1)		;GET COMMAND TABLE ADDRESS
	SUB	T1,T2			;COMPUTE INDEX INTO TABLE
	MOVE	T2,MODDSP(P1)		;GET BASE ADDRESS OF DISPATCH FOR MODE
	ADDI	T2,-1(T1)		;OFFSET INTO THE TABLE
	PUSHJ	P,@(T2)			;PROCESS A COMMAND
	MOVE	P1,S.MODE		;GET MODE INDEX AGAIN
	MOVEM	I,S.INCL(P1)		;UPDATE BITS (MAYBE THEY CHANGED)

CMD.2:	JUMPE	C,.POPJ##		;RETURN IF ALTMODE
	CAMN	C,[.CHEOF]		;END OF FILE (^Z)?
	PUSHJ	P,.CTRLZ		;YES - EXIT
	CAME	C,[.CHEOL]		;END OF LINE?
	JRST	CMDJNK			;COMPLAIN
	POPJ	P,			;RETURN

; Popular error returns
;
CMDKEY:	PUSHJ	P,ERRINI		;INIT ERROR PROCESSING
	SKIPG	T1			;MORE THAN ONE MATCH?
	SKIPA	T1,[[ASCIZ |? Unknown keyword "|]]
	MOVEI	T1,[ASCIZ |? Ambiguous keyword "|]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,T2			;GET BAD KEYWORD
	PUSHJ	P,.TSIXN##		;TYPE IT
	MOVEI	T1,""""			;GET CLOSING QUOTE
	PUSHJ	P,.TCHAR##		;TYPE IT
	PJRST	ERRXIT			;FINISH UP ERROR PROCESSING AND RETURN

CMDJOB:	SKIPA	T1,[[ASCIZ |? Illegal job number |]]
CMDCTX:	MOVEI	T1,[ASCIZ |? Illegal context number |]
	JRST	CMDNUM			;GO COMPLAIN
CMDVOR:	MOVEI	T1,[ASCIZ |? Value out of range |]
CMDNUM:	PUSHJ	P,ERRINI		;INIT ERROR PROCESSING
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVE	T1,N			;GET BAD VALUE
	PUSHJ	P,.TDECW##		;TYPE IT
	PJRST	ERRXIT			;FINISH UP ERROR PROCESSING AND RETURN

CMDJNK:	SKIPA	T1,[[ASCIZ |? Junk following command|]]
CMDNEA:	MOVEI	T1,[ASCIZ |? Not enough arguments|]
CMDETX:	PUSHJ	P,ERRINI		;INIT ERROR PROCESSING
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	PJRST	ERRXIT			;FINISH UP ERROR PROCESSING AND RETURN
SUBTTL	Error reporting


; Init the error buffer
; Call:	PUSHJ	P,ERRINI
;
ERRINI:	PUSH	P,T1			;SAVE T1
	PUSHJ	P,.CLRBF##		;CLEASR TYPEAHEAD
	IONEOU	[.CHBEL]		;MAKE A NOISE
	MOVEI	T1,ERRSIZ		;GET SIZE OF BUFFER IN CHARACTERS
	MOVEM	T1,ERRCNT		;SAVE IT
	MOVE	T1,[POINT 7,ERRBUF]	;GET BYTE POINTER
	MOVEM	T1,ERRPTR		;SAVE IT
	SETZM	ERRBUF			;CLEAR FIRST WORD IN BUFFER
	MOVE	T1,[ERRBUF,,ERRBUF+1]	;SET UP BLT
	BLT	T1,ERRBUF+<ERRSIZ/5>	;CLEAR ENTIRE BUFFER
	MOVEI	T1,ERRCHR		;GET CHARACTER PUTTER
	PUSHJ	P,.TYOCH##		;TELL SCAN
	MOVEM	T1,ERRTYO		;SAVE OLD CHARACTER PUTTER
	POP	P,T1			;RESTORE T1
	POPJ	P,			;RETURN


; Exit from error routines
; Call:	PUSHJ	P,ERRXIT
;
ERRXIT:	MOVE	T1,ERRTYO		;GET OLD CHARACTER PUTTER
	PJRST	.TYOCH##		;TELL SCAN AND RETURN


; Store a character
; Call:	MOVE	T1, character
;	PUSHJ	P,ERRCHR
;
ERRCHR:	SOSLE	ERRCNT			;COUNT CHARACTERS
	IDPB	T1,ERRPTR		;SAVE CHARACTER
	POPJ	P,			;RETURN


; Type error text
; Call:	PUSHJ	P,ERRTYP
;
ERRTYP:	MOVEI	T1,ERRBUF		;POINT TO ERROR BUFFER
	SKIPE	(T1)			;HAVE SOMETHING THERE?
	PUSHJ	P,.TSTRG##		;YES
	SETZM	ERRBUF			;SO WE ONLY DO IT ONCE
	PJRST	.TCRLF##		;TYPE CRLF AND RETURN
SUBTTL	Mode handling -- HELP tables


DEFINE	$CMD,<

$ AUTO,.AUTO
$ CONTINUE,.CONTINUE
$ EXIT,.EXIT
$ FILE,.FILE
$ HELP,.HELP
$ JOB,.JOB
$ MODE,.MODE
$ MONITOR,.MONIT
$ ORIGIN,.ORIGI
$ PERFORMANCE,.PERFO
$ REFRESH,.REFRESH
$ SCROLL,.SCROLL
$ SELECT,.SELEC
$ SLEEP,.SLEEP

>
DEFINE	$ (NAME,DISP),<<SIXBIT	/NAME/>>
HLPCMD:	$CMD
HLPCLN==.-HLPCMD			;LENGTH OF TABLE

DEFINE	$ (NAME,DISP),<EXP	DISP>
HLPDSP:	$CMD
SUBTTL	Mode handling -- JOB tables


; Macro to build the command tables
;
DEFINE	$CMD,<

$ AUTO,.AUTO
$ EXIT,.EXIT
$ FILE,.FILE
$ HELP,.HELP
$ JOB,.JOB
$ MODE,.MODE
$ MONITOR,.MONIT
$ ORIGIN,.ORIGI
$ PERFORMANCE,.PERFO
$ REFRESH,.REFRESH
$ SELECT,.SELEC
$ SCROLL,.SCROLL
$ SLEEP,.SLEEP

>
DEFINE	$ (NAME,DISP),<<SIXBIT	/NAME/>>
JOBCMD:	$CMD
JOBCLN==.-JOBCMD			;LENGTH OF TABLE

DEFINE	$ (NAME,DISP),<EXP	DISP>
JOBDSP:	$CMD
SUBTTL	Mode handling -- PACKET tables


DEFINE	$CMD,<

$ AUTO,.AUTO
$ EXIT,.EXIT
$ FILE,.FILE
$ HELP,.HELP
$ JOB,.JOB
$ MODE,.MODE
$ MONITOR,.MONIT
$ ORIGIN,.ORIGI
$ PERFORMANCE,.PERFO
$ REFRESH,.REFRESH
$ SCROLL,.SCROLL
$ SELECT,.SELEC
$ SLEEP,.SLEEP

>
DEFINE	$ (NAME,DISP),<<SIXBIT	/NAME/>>
PKTCMD:	$CMD
PKTCLN==.-PKTCMD			;LENGTH OF TABLE

DEFINE	$ (NAME,DISP),<EXP	DISP>
PKTDSP:	$CMD
SUBTTL	Mode handling -- Mode table generation macros


; Macro to define paralell mode tables
; *** Note the following restrictions ***
;  1. HELP mode must be first
;
DEFINE	$MODES,<

$	(,HLP,^D3,0)
$	(IPCF,JOB,^D3,<IOWD IJB.L,IJB.T>)
$	(JOB,JOB,^D3,<IOWD IJB.L,IJB.T>)
$	(PACKET,PKT,^D0,0)

> ;END OF $MODES MACRO


DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	EXP	<SIXBIT	/NAME/>
	MODE'NAME==.-MODNAM-1
>
MODNAM:	$MODES
MODNUM==.-MODNAM			;LENGTH OF TABLE
MODE.T==MODNAM
MODE.L==MODNUM



DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	EXP	ABV'PRC			;'NAME
>
MODPRC:	$MODES


DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	IOWD	ABV'CLN,ABV'CMD		;'NAME
>
MODCMD:	$MODES


DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	EXP	ABV'DSP			;'NAME
>
MODDSP:	$MODES


DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	EXP	TTL			;'NAME
>
MODTTL:	$MODES


DEFINE	$	(NAME,ABV,TTL,INCLUD),<
	INCLUDE				;'NAME
>
MODINC:	$MODES
SUBTTL	Common commands -- AUTO (Automatic scroll)


	EXP	S.AUTO			;SPECIAL ROUTINE FOR HELP
	EXP	[ASCIZ |Toggle automatic scrolling|] ;HELP TEXT
	EXP	HD.COM!HD.TOG		;FLAGS
.AUTO:	SKIPG	S.DPY			;DISPLAY MODE?
	POPJ	P,			;NO--IGNORE
	SETZM	S.SCRO			;INIT
	MOVEI	T1,S.AUTO		;POINT TO SWITCH STORAGE
	PJRST	TOGGLE			;TOGGLE VALUE AND RETURN


; Here to compute automatic scrolling increment
AUTO.I:	SETZM	ATOFLG			;NO TEXT OUTPUT YET
	SETZM	ATOINC			;NO INCREMENT YET
	SKIPG	S.AUTO			;DOING AUTO SCROLLING?
	POPJ	P,			;NO
	MOVE	T1,MAXL##		;GET MAX NUMBER OF LINES
	SUB	T1,DP.OLN		;MINUS LINES OUTPUT
	MOVEM	T1,ATOINC		;SAVE
	POPJ	P,			;RETURN

; Here to do automatic scrolling
AUTO.S:	SKIPG	S.AUTO			;DOING AUTO SCROLLING?
	POPJ	P,			;NO
	MOVE	T1,S.MODE		;GET CURRENT MODE INDEX
	MOVE	T2,ATOFLG		;GET OUTPUT FLAG FOR AUTO SCROLLING
	SUB	T2,MODTTL(T1)		;TITLE LINES DON'T COUNT
	SKIPGE	T2			;CAN'T DO NEGATIVE
AUTOS1:	MOVEI	T2,0			;RESET
	SKIPN	T2			;ANYTHING OUTPUT THIS TIME THROUGH?
	SETZM	S.SCRO			;NO--RESET
	JUMPE	T2,.POPJ##		;RETURN IF NOTHING OUTPUT THIS PASS
	MOVE	T3,MAXL##		;GET LINES ON THE SCREEN
	SUB	T3,DP.OLN		;COMPUTE UNWRITTEN LINES REMAINING
	JUMPG	T3,AUTOS1		;RESET IF ONLY A PARTIAL SCREEN WRITTEN
	MOVE	T2,ATOINC		;GET AUTO SCROLLING INCREMENT
	SUB	T2,MODTTL(T1)		;TITLE LINES DON'T COUNT
	ADDM	T2,S.SCRO		;ADVANCE FOR NEXT TIME
	POPJ	P,			;AND RETURN
SUBTTL	Common commands -- CONTEXT


	EXP	CTX.H			;MODE TYPER FOR HELP
	EXP	[ASCIZ |Display IPCF activity for a given context|]
	EXP	HD.COM			;FLAGS
CTX:	JUMPLE	C,CTX1			;DEFAULT IF NO ARGUMENTS
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.DECNW##		;GET A DECIMAL NUMBER
	CAMLE	N,T1			;REASONABLE NUMBER
	JRST	CMDCTX			;NOPE
	SKIPN	T1,N			;GET LINES TO SCROLL
CTX1:	MOVNI	T1,1			;DEFAULT TO ALL CONTEXTS
	MOVEM	T1,S.CTX		;SET
	POPJ	P,			;AND RETURN

CTX.H:	SKIPGE	T1,S.CTX		;GET TARGET
	JRST	CTX.H1			;DEFAULT
	MOVE	T2,[" ",,3]		;PAD CHARACTER IS SPACE, 3 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	JRST	CTX.H2			;FINISH UP
CTX.H1:	MOVEI	T1,[ASCIZ |All|]	;DEFAULT TO ALL CONTEXTS
	PUSHJ	P,.TSTRG##		;TYPE IT
CTX.H2:	MOVEI	T1,[ASCIZ |    |]	;MUST SPACE OUT
	PJRST	.TSTRG##		;TYPE AND RETURN
SUBTTL	Common commands -- EXIT and ^Z


	EXP	0			;NO SPECIAL TYPEOUT ROUTINE FOR HELP
	EXP	[ASCIZ |Exit to the monitor (or ^Z)|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.EXIT:	SKIPA	P1,[.MONRT##]		;GO HERE ON EXIT COMMAND
.CTRLZ:	MOVEI	P1,.ALDON##		;DO HERE ON CONTROL-Z
	PUSHJ	P,DPXIT			;CLEAN UP DISPLAY
	PUSHJ	P,TTYECH		;TURN ON ECHO
	PUSHJ	P,(P1)			;DO EXIT OR CONTROL-Z PROCESSING
	PUSHJ	P,INFSET		;GET A NEW PID
	PUSHJ	P,TTYNEC		;TURN OFF ECHO
	PUSHJ	P,DPCON			;THE FOOL TYPED CONTINUE
	PUSHJ	P,.REFRESH		;REFRESH THE SCREEN
	POPJ	P,			;RETURN
SUBTTL	Common commands -- FILE


	EXP	0			;NO SPECIAL HELP
	EXP	[ASCIZ |Read a crash file|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.FILE:	MOVE	T1,[DEFFIL,,SCNBLK]	;SET UP BLT
	BLT	T1,SCNBLK+.FXLEN	;LOAD DEFAULT FILESPEC INTO SCAN BLOCK
	JUMPLE	C,FILE.2		;DEFAULT IF NO ARGUMENTS
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.FILIN##		;GET A FILESPEC
	SETZM	SCNBLK			;CLEAR FIRST WORD
	MOVE	T1,[SCNBLK,,SCNBLK+1]	;SET UP BLT
	BLT	T1,SCNBLK+.FXLEN-1	;CLEAR IT
	MOVEI	T1,SCNBLK		;POINT TO OUR SCAN BLOCK
	MOVEI	T2,.FXLEN		;SCAN BLOCK LENGTH
	PUSHJ	P,.GTSPC##		;GET THE FILESPEC

FILE.1:	MOVEI	T1,SCNBLK		;GET SCAN BLOCK ADDRESS
	MOVE	T2,.FXMOD(T1)		;GET FLAGS
	MOVE	T3,DEFFIL+.FXDEV	;GET DEFAULT DEVICE
	TXNE	T2,FX.NDV		;NULL DEVICE SPECIFIED?
	MOVEM	T3,.FXDEV(T1)		;YES - USE THE DEFAULT
	SKIPN	.FXNAM(T1)		;HAVE A FILE NAME?
	SKIPE	.FXNMM(T1)		;A MASK?
	JRST	FILE.2			;FOOL! CATCH THE ERROR LATER
	MOVE	T3,DEFFIL+.FXNAM	;GET DEFAULT FILE NAME
	MOVEM	T3,.FXNAM(T1)		;NO - DEFAULT IT
	SETOM	.FXNMM(T1)		;AND SET MASK

FILE.2:	MOVE	T3,DEFFIL+.FXEXT	;GET DEFAULT EXTENSION AND MASK
	TXNE	T2,FX.NUL		;NULL EXTENSION?
	MOVEM	T3,.FXEXT(T1)		;YES
	TXNE	T2,FX.DIR		;DIRECTORY SPECIFIED?
	JRST	FILE.3			;YES
	MOVE	T3,DEFFIL+.FXDIR	;GET PPN
	MOVEM	T3,.FXDIR(T1)		;SAE IT
	SETOM	.FXDIM(T1)		;AND SET MASK

FILE.3:	TXNE	T2,FX.TRM		;JUMK TERMINATOR ON FILESPEC?
	JRST	CMDJNK			;YES - LOSER
	MOVEI	T1,FILSIZ		;GET NUMBER OF CHARACTERS
	MOVEM	T1,FILCNT		;SAVE IT
	MOVE	T1,[POINT 7,S.FILE]	;GET BYTE POINTER
	MOVEM	T1,FILPTR		;SAVE IT
	MOVEI	T1,FILTYO		;GET CHARACTER STICKER ADDRESS
	PUSHJ	P,.TYOCH##		;TELL SCAN
	PUSH	P,T1			;SAVE OLD ONE
	MOVEI	T1,SCNBLK		;POINT TO SCAN BLOCK
	PUSHJ	P,.TFBLK##		;CONVERT IT TO ASCII
	POP	P,T1			;RESTORE OLD ROUTINE ADDRESS
	PUSHJ	P,.TYOCH##		;RESET SCAN'S POINTER
	MOVEI	T1,.CHNUL		;GET A NUL
	PUSHJ	P,FILTYO		;TERMINATE STRING

FILE.4:	PUSHJ	P,MAPPER		;RE-INITIALIZE THE PAGE MAPPER
	  SKIPA				;CAN'T
	POPJ	P,			;RETURN
	PUSHJ	P,ERRINI		;START LOADING THE ERROR BUFFER
	MOVEI	T1,[ASCIZ |? Can't read |] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	MOVEI	T1,S.FILE		;POINT TO THE FILESPEC
	PUSHJ	P,.TSTRG##		;TYPE FILESPEC
	PUSHJ	P,ERRXIT		;TERMINATE ERROR TEXT
	PJRST	MAPMON			;TRY TO MAP THE MONITOR
; Default scan block for XPN:CRASH.EXE/PHYSICAL
;
DEFFIL:	'DSK   '
	'CRASH '
	-1
	'EXE',,-1
	FX.DIR!FX.NOM!FX.PHY
	FX.DIR!FX.NOM!FX.PHY
	1,,4
	-1
	BLOCK	.FXLEN-<.-DEFFIL>

FILTYO:	SOSLE	FILCNT			;COUNT CHARACTERS
	IDPB	T1,FILPTR		;DEPOSIT
	POPJ	P,			;RETURN
SUBTTL	Common commands -- HELP

	EXP	0			;NO SPECIAL TYPEOUT ROUTINE FOR HELP
	EXP	[ASCIZ |This text|]	;HELP TEXT
	EXP	HD.COM			;FLAGS
.HELP:	JUMPG	C,CMDJNK		;SHOULDN'T HAVE AN ARGUMENT
	SKIPN	S.MODE			;IS OUR CURRENT MODE THE HELP MODE?
	POPJ	P,			;YES--THEN THIS COMMAND IS A NOOP
	MOVEI	P1,0			;OUR INDEX
	MOVE	T1,S.SCRO		;GET CURRENT SCROLL VALUE
	MOVEM	T1,OLDSCR		;SAVE
	SETZM	S.SCRO			;RESET SCROLLING
	EXCH	P1,S.MODE		;SET HELP AS THE NEW MODE
	MOVEM	P1,OLDMOD		;SAVE OLD MODE INDEX
	MOVEM	P1,HLPMOD		;SAVE FOR HELP
	JRST	HLPPRC			;ONWARD
SUBTTL	Common commands -- JOB


	EXP	JOB.H			;MODE TYPER FOR HELP
	EXP	[ASCIZ |Display IPCF activity for a given job|]
	EXP	HD.COM			;FLAGS
.JOB:	JUMPLE	C,JOB1			;DEFAULT IF NO ARGUMENTS
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.DECNW##		;GET A DECIMAL NUMBER
	CAMLE	N,JOBN			;REASONABLE NUMBER
	JRST	CMDJOB			;NOPE
	SKIPA	T1,N			;GET LINES TO SCROLL
JOB1:	MOVNI	T1,1			;DEFAULT TO ALL JOBS
	MOVEM	T1,S.JOB		;SET
	POPJ	P,			;AND RETURN

JOB.H:	SKIPGE	T1,S.JOB		;GET TARGET
	JRST	JOB.H1			;DEFAULT
	MOVE	T2,[" ",,3]		;PAD CHARACTER IS SPACE, 3 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	JRST	JOB.H2			;FINISH UP
JOB.H1:	MOVEI	T1,[ASCIZ |All|]	;DEFAULT TO ALL JOBS
	PUSHJ	P,.TSTRG##		;TYPE IT
JOB.H2:	MOVEI	T1,[ASCIZ |    |]	;MUST SPACE OUT
	PJRST	.TSTRG##		;TYPE AND RETURN
SUBTTL	Common commands -- MODE


	EXP	MODE.H			;MODE TYPER FOR HELP
	EXP	[ASCIZ |Change display mode|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.MODE:	JUMPLE	C,CMDNEA		;HAVE AN ARGUMENT?
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.SIXSW##		;GET A KEYWORD
	JUMPE	N,CMDNEA		;HAVE A KEYWORD?
	JUMPG	C,CMDJNK		;BETTER BE EOL
	MOVE	T2,N			;GET KEYWORD
	MOVE	T1,[IOWD MODNUM,MODNAM]	;POINT TO KEYWORD TABLE
	PUSHJ	P,.LKNAM##		;FIND IT
	  JRST	CMDKEY			;CAN'T
	SUBI	T1,MODNAM		;GET INDEX
	SKIPE	S.MODE			;IS OUR CURRENT MODE THE HELP MODE?
	JRST	MODE.1			;NO
	MOVEM	T1,HLPMOD		;SAVE NEW MODE FOR HELP
	POPJ	P,			;RETURN

MODE.1:	CAIN	T1,MODEIPCF		;GENERIC?
	MOVEI	T1,MODEJOB		;YES
	EXCH	T1,S.MODE		;SAVE IT AND GET OLD MODE
	CAME	T1,S.MODE		;NEW MODE SAME AS OLD ONE?
	MOVEM	T1,OLDMOD		;SAVE OLD MODE SO WE CAN RETURN TO IT
	SETZM	ATOFLG			;RESET AUTO SCROLL STUFF
	SETZM	S.SCRO			;AND THE CURRENT SCROLL COUNTER
	POPJ	P,			;RETURN


; Type mode for HELP
;
MODE.H:	MOVE	T1,HLPMOD		;GET MODE INDEX USED BY HELP
	MOVE	T1,MODNAM(T1)		;GET MODE NAME
	PUSHJ	P,SIXOUT		;TYPE IT
	PJRST	.TSPAC##		;FILL WITH A SPACE AND RETURN
SUBTTL	Common commands -- MONITOR


	EXP	0			;NO SPECIAL HELP
	EXP	[ASCIZ |Examine the running monitor|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.MONIT:	JUMPG	C,CMDJNK		;CHECK FOR CRUFT ON LINE
	PJRST	MAPMON			;GO MAP THE MONITOR
SUBTTL	Common commands -- ORIGIN


	EXP	S.ORIG			;SPECIAL ROUTINE FOR HELP
	EXP	[ASCIZ |Display origin of data|]
	EXP	HD.COM!HD.TOG		;FLAGS
.ORIGI:	MOVEI	T1,S.ORIG		;GET SWITCH STORAGE ADDRESS
	PJRST	TOGGLE			;TOGGLE THE VALUE AND RETURN
SUBTTL	Common commands -- PERFORMANCE


	EXP	S.PERF			;SPECIAL ROUTINE FOR HELP
	EXP	[ASCIZ |Display mapped page performance data|]
	EXP	HD.COM!HD.TOG		;FLAGS
.PERFO:	MOVEI	T1,S.PERF		;GET SWITCH STORAGE ADDRESS
	PJRST	TOGGLE			;TOGGLE THE VALUE AND RETURN
SUBTTL	Common commands -- REFRESH


	EXP	0			;NO SPECIAL TYPEOUT FOR HELP
	EXP	[ASCIZ |Refresh the screen|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.REFRE:	PJRST	TTYREF			;LET TERMINAL SERVICE DO IT
SUBTTL	Common commands -- RETURN


	EXP	0			;NO SPECIAL TYPEOUT FOR HELP
	EXP	[ASCIZ |Return to command level|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.RETUR:	PUSHJ	P,DPBOT			;POSITION TO BOTTOM OF SCREEN
	PJRST	TOPLVL			;BACK TO TOP LEVEL
SUBTTL	Common commands -- SCROLL


	EXP	SCRO.H			;SCROLL LINES TYPER FOR HELP
	EXP	[ASCIZ |Scroll the screen|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.SCROL:	JUMPLE	C,SCRO.1		;DEFAULT IF NO ARGUMENTS
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.DECNW##		;GET A DECIMAL NUMBER
	SKIPN	T1,N			;GET LINES TO SCROLL
SCRO.1:	MOVEI	T1,1			;DEAFAULT TO ONE
	JUMPG	T1,SCRO.2		;POSITIVE?
	JUMPL	T1,SCRO.3		;NEGATIVE?
	POPJ	P,			;NO-OP IF ZERO
SCRO.2:	SKIPGE	S.SCRO			;SET YET?
	SETZM	S.SCRO			;NO
	ADDM	T1,S.SCRO		;SAVE
	POPJ	P,			;AND RETURN
SCRO.3:	ADDB	T1,S.SCRO		;ADJUST
	SKIPGE	T1			;REASONABLE?
	SETZM	S.SCRO			;NO--RESET
	POPJ	P,			;AND RETURN


; Type scroll lines for HELP
;
SCRO.H:	SKIPGE	T1,S.SCRO		;GET LINES SCROLLED
	MOVEI	T1,0			;NOT SET YET
	MOVE	T2,[" ",,2]		;PAD CHARACTER IS SPACE, 2 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	MOVEI	T1,[ASCIZ |     |]	;MUST SPACE OUT
	PJRST	.TSTRG##		; TO END OF FIELD
SUBTTL	Common commands -- SLEEP


	EXP	SLEE.H			;SLEEP TIME TYPER
	EXP	[ASCIZ |Set sleep time|] ;HELP TEXT
	EXP	HD.COM			;FLAGS
.SLEEP:	JUMPLE	C,SLEE.1		;DEFAULT IF EOL OR EOF
	CAIE	C,":"			;END WITH COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
	PUSHJ	P,.DECNW##		;GET A DECIMAL NUMBER
	SKIPA	T1,N			;GET SLEEP TIME

SLEE.1:	MOVEI	T1,SLPDEF		;DEFAULT IT
	CAIL	T1,0			;RANGE CHECK SLEEP
	CAILE	T1,SLPMAX		; TIME FROM 0 TO SLPMAX
	JRST	CMDVOR			;VALUE OUT OF RANGE
	MOVEM	T1,S.SLEE		;SAVE IT
	POPJ	P,			;RETURN


; Type sleep time for HELP
;
SLEE.H:	SKIPG	T1,S.SLEE		;GET SLEEP TIME
	MOVEI	T1,SLPDEF		;USE DEFAULT IF NOT SET YET
	MOVE	T2,[" ",,2]		;PAD CHARACTER IS SPACE, 2 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	MOVEI	T1,[ASCIZ | Sec.|]	;GET SUFFIX
	PJRST	.TSTRG##		;TYPE IT AND RETURN
SUBTTL	Common commands -- Toggle settings and special help typeout


; Toggle a setting
; Call:		MOVE	T1, switch storage address
;	PUSHJ	P,TOGGLE
;
TOGGLE:	SKIPGE	T2,(T1)			;GET VALUE
	TDZA	T2,T2			;NOT SPECIFIED - ASSUME OFF
	ANDI	T2,1			;STRIP OFF ANY JUNK
	TRC	T2,1			;TOGGLE THE VALUE
	MOVEM	T2,(T1)			;UPDATE THE SWITCH VALUE
	POPJ	P,			;AND RETURN


; Type on/off setting
; Call:	MOVE	T1, switch storage address
;	PUSHJ	P,ONOFF
;
ONOFF:	MOVE	T1,(T1)			;GET VALUE
	MOVE	T1,ONOFFT(T1)		;AND ASSOCIATED TEXT
	PJRST	.TSTRG##		;TYPE SETTING AND RETURN

	EXP	[ASCIZ |Default|]
ONOFFT:	EXP	[ASCIZ |Off    |]
	EXP	[ASCIZ |On     |]
SUBTTL	JOB mode commands -- SELECT


	EXP	0			;SELECT TYPER FOR HELP
	EXP	[ASCIZ |Select columns to display|] ;HELP TEXT
	EXP	0			;FLAGS
.SELEC:	JUMPLE	C,SELEC6		;DEFAULT IF NO ARGUMENTS
	CAIE	C,":"			;END WITH A COLON?
	CAIN	C," "			;OR A SPACE?
	SKIPA				;EITHER IS OK
	JRST	CMDJNK			;ELSE ERROR
SELEC0:	PUSHJ	P,.SIXSW##		;GET A KEYWORD
	JUMPN	N,SELEC1		;HAVE A KEYWORD?
	JUMPL	C,SELEC2		;MAYBE JUST EOL?
	JRST	SELEC2			;MIGHT BE JUNK
SELEC1:	CAMN	N,['NONE  ']		;NONE?
	JRST	SELEC3			;YES
	CAMN	N,['ALL   ']		;OR ALL?
	JRST	SELEC4			;YES
	MOVE	T2,N			;GET KEYWORD
	MOVE	T1,[IOWD IJB.L,IJB.T]	;POINT TO TABLE
	PUSHJ	P,.LKNAM##		;SCAN THE TABLE FOR A MATCH
	  SKIPA				;MAYBE IT WAS NOXYZ
	JRST	SELEC2			;ONWARD
	JUMPG	T1,CMDKEY		;AMBIGUOUS IF MORE THAN ONE
	MOVE	T2,N			;COPY ARGUMENT
	TLC	T2,'NO '		;SEE IF /NOXYZ
	TLNE	T2,(7777B11)		; ..
	JRST	SELEC8			;NO--ERROR
	TLC	T2,'NO '		;RESTORE WORD
	LSH	T2,^D12			;STRIP "NO"
	MOVE	T1,[IOWD IJB.L,IJB.T]	;POINT TO TABLE AGAIN
	PUSHJ	P,.LKNAM##		;SEARCH IT
	  JRST	SELEC8			;ERROR
	HRROS	T1			;LH=-1 TO INDICATE NOXYZ

SELEC2:	PUSHJ	P,SCNSKP		;SKIP TABS AND SPACES
	CAIE	C,","			;COMMAS ARE ALLOWED
	JUMPG	C,CMDJNK		;JUNK ON LINE
	SUBI	T1,IJB.T-1		;GET INDEX INTO TABLE
	MOVE	N,T1			;COPY INDEX
	JRST	SELEC5			;FINISH UP
SELEC3:	SKIPA	N,[-1,,0]		;NONE
SELEC4:	MOVEI	N,-1			;ALL
SELEC5:	MOVE	T1,S.MODE		;GET MODE INDEX
	MOVEI	T1,S.INCL(T1)		;POINT TO STORAGE
	PUSHJ	P,SLKEY			;SET OR CLEAR BIT AS NECESSARY
	  JFCL
	MOVE	T1,S.MODE		;GET MODE INDEX AGAIN
	MOVE	I,S.INCL(T1)		;UPDATE
	JRST	SELEC7			;FINISH UP
SELEC6:	MOVE	T1,S.MODE		;GET THE MODE INDEX
	MOVEI	T1,S.INCL(T1)		;POINT TO THE APPROPRIATE MASK
	MOVE	I,[IJBDEF]		;GET DEFAULT MASK
	MOVEM	I,(T1)			;SET
SELEC7:	CAIN	C,","			;MORE TO COME?
	JRST	SELEC0			;GO BACK FOR MORE
	POPJ	P,			;RETURN

SELEC8:	MOVE	T2,N			;GET ORIGINAL ARGUMENT
	PJRST	CMDKEY			;COMMAND ERROR
SUBTTL	HELP mode -- Loop


HLPPRC:	MOVE	P1,HLPMOD		;GET A MODE INDEX
	SKIPG	S.DPY			;DISPLAY?
	SKIPA	T2,MAXC##		;YES - GET SCREEN WIDTH FROM DPYPAK
	MOVEI	T2,^D72			;ELSE ASSUME 72
	SUBI	T2,^D20			;ALLOW 25 CHARACTERS FOR US
	LSH	T2,-1			;DIVIDE BY 2
	PUSHJ	P,.TSPAC##		;TYPE A SPACE
	SOJG	T2,.-1			;LOOP UNTILL THE MID SCREEN
	MOVEI	T1,[ASCIZ |Help for |]	;INTRODUCTION
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,MODNAM(P1)		;GET MODE NAME
	PUSHJ	P,.TSIXN##		;TYPE IT
	MOVEI	T1,[ASCIZ | mode|]	;GET TERMINATING TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVEI	T1,[ASCIZ \
  Command  Setting  Description
------------------------------------------------------------------------
\]
	PUSHJ	P,.TSTRG##		;TYPE IT
HLPPR0:	MOVE	P2,MODCMD(P1)		;GET AOBJN POINTER TO COMMANDS
	MOVE	S,S.SCRO		;GET SCROLLING VALUE

HLPPR1:	SOJGE	S,HLPPR5		;TIME TO DISPLAY?
	HRRZ	T1,MODCMD(P1)		;GET BASE ADDRESS OF TABLE -1
	HRRZ	T2,P2			;GET CURRENT INDEX INTO COMMAND TABLE
	SUBI	T2,(T1)			;COMPUTE INDEX INTO CMD DISPATCH TABLE
	MOVE	T1,MODDSP(P1)		;GET BASE ADDRESS OF CMD DISPATCH TABLE
	ADDI	T1,(T2)			;INDEX INTO THE TABLE
	MOVE	P3,(T1)			;GET DISPATCH ADDRESS

HLPPR2:	MOVEI	T1,[ASCIZ |* |]		;GET FLAG
	MOVX	T2,HD.COM		;GET A BIT
;	TDNN	T2,.HDFLG(P3)		;IS THIS COMMAND COMMON TO ALL MODES?
	MOVEI	T1,[ASCIZ |  |]		;NO
	PUSHJ	P,.TSTRG##		;TYPE POSSIBE FLAG
	MOVE	T1,1(P2)		;GET A COMMAND NAME
	PUSHJ	P,SIXOUT		;TYPE IT
	MOVEI	T1,[ASCIZ |   |]	;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT

HLPPR3:	MOVEI	T1,[ASCIZ |       |]	;GET FILLER TEXT INCASE NO SUBR
	SKIPE	T2,.HDVAL(P3)		;HAVE A VALUE TYPEOUT ROUTINE?
	SKIPA	T1,.HDVAL(P3)		;YES - MAYBE THIS IS A STORAGE ADDR
	MOVEI	T2,.TSTRG##		;NO - GET FILLER TEXT TYPER
	MOVX	T3,HD.TOG		;GET TOGGLE ON/OFF BIT
	TDNE	T3,.HDFLG(P3)		;THIS COMMAND US THE ONOFF ROUTINE?
	MOVEI	T2,ONOFF		;YES
	PUSHJ	P,(T2)			;TYPE CURRENT VALUE FOR THIS COMMAND
	MOVEI	T1,[ASCIZ |  |]		;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT

HLPPR4:	MOVE	T1,.HDTXT(P3)		;GET HELP TEXT FOR THIS COMMAND
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,.TCRLF##		;NEW LINE

HLPPR5:	AOBJN	P2,HLPPR1		;LOOP FOR ALL COMMANDS
	MOVE	P2,[-HLPMAX,,HLPTAB]	;AOBJN POINTER

HLPPR6:	SOJGE	S,HLPPR7		;TIME TO DISPLAY?
	SKIPE	T1,(P2)			;GET A LINE OF TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,.TCRLF##		;APPEND A CRLF
HLPPR7:	AOBJN	P2,HLPPR6		;LOOP THROUGH TABLE
	POPJ	P,			;AND RETURN

HLPTAB:	EXP	0
;	[ASCIZ	|* Commands common to all modes|]
;	EXP	0
	[ASCIZ	|Type CONTINUE to resume viewing the previous display|]
HLPMAX==.-HLPTAB
SUBTTL	HELP mode -- CONTINUE command


	EXP	[ASCIZ |Continue previous display|]
.CONTI:	JUMPG	C,CMDJNK		;CHECK FOR JUNK IN COMMAND
	MOVE	T1,OLDMOD		;GET THE OLD MODE
	MOVEM	T1,S.MODE		;SET IT AS THE CURRENT ONE
	MOVE	T1,OLDSCR		;GET OLD SETTING
	MOVEM	T1,S.SCRO		;MAKE IT THE CURRENT ONE
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Loop



JOBPRC:	MOVE	T1,S.MODE		;GET OUR MODE INDEX
	MOVN	J,MODTTL(T1)		;GET -NUMBER OF TITLE LINES
	MOVN	PID,PIDCNT		;GET -NUMBER OF PID BLOCKS
	HRL	PID,PIDBLK+1		;GET ADDRESS OF FIRST PID BLOCK
	MOVSS	PID			;MAKE AN AOBJN POINTER
	MOVE	S,S.SCRO		;GET NUMBER OF LINES TO SCROLL
JOBPR1:	PUSHJ	P,CHKJOB		;OK TO DISPLAY THIS JOB?
	  JUMPGE J,JOBPRX		;NO
JOBPR2:	SKIPL	J			;TITLE LINES ARE ALWAYS DISPLAYED
	SOJGE	S,JOBPR4		;TIME TO DISPLAY?
	PUSHJ	P,JOBNUM		;OUTPUT JOB NUMBER
	PUSHJ	P,JOBUNM		;OUTPUT NAME
	PUSHJ	P,JOBPPN		;OUTPUT PPN
	PUSHJ	P,JOBPRG		;OUTPUT PROGRAM
	PUSHJ	P,JOBQTA		;OUTPUT QUOTAS
	PUSHJ	P,JOBTSR		;OUTPUT TOTAL SENDS AND RECEIVES
	PUSHJ	P,JOBOSR		;OUTPUT OUTSTANDING SENDS AND RECEIVES
	PUSHJ	P,JOBCAP		;OUTPUT IPCF CAPABILITIES
	PUSHJ	P,JOBPID		;OUTPUT A PID
	PUSHJ	P,JOBSPR		;OUTPUT SYSTEM PROCESS NAME
	PUSHJ	P,JOBINF		;OUTPUT LOCAL [SYSTEM]INFO
	PUSHJ	P,JOBPNM		;OUTPUT PID NAME
	SKIPN	JOBTYO			;ANYTHING TYPEOUT FOR THIS JOB?
	JRST	JOBPR3			;NO
	PUSHJ	P,.TCRLF##		;YES - ADD A CRLF
	SETZM	JOBTYO			;CLEAR FLAG
JOBPR3:	JUMPL	J,JOBPRX		;IGNORE HEADER PASSES
JOBPR4:	PUSHJ	P,CHKPID		;CHECK NEXT PID
	  JRST	JOBPRX			;NO MORE FOR THIS JOB
	JRST	JOBPR2			;JOB HAS ANOTHER PID
JOBPRX:	CAMGE	J,JOBN			;DONE ALL JOBS?
	AOJA	J,JOBPR1		;NO - BACK FOR MORE
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Check job and PID


JNA==40000

; HERE TO SEE IF WE SHOULD DISPLAY THIS JOB'S IPCF INFORMATION
;
CHKJOB:	SKIPL	S.JOB			;WANT A SPECIFIC JOB?
	CAMN	J,S.JOB			;YES--IS THIS THE ONE?
	SKIPA				;PROCESS THIS ONE
	POPJ	P,			;ELSE RETURN
	JUMPL	J,.POPJ##		;IGNORE HEADER PASSES
	JUMPE	J,CHKJ.1		;SEE IF THE MONITOR HAS ANY PIDS
	HRLZ	T1,J			;LOAD JOB NUMBER AS INDEX
	HRRI	T1,.GTSTS		;JOB STATUS TABLE
	PUSHJ	P,.MAPG##		;READ IT
	  SETZ	T1,			;CAN'T
	TLNN	T1,JNA			;JOB NUMBER ASSIGNED?
	POPJ	P,			;NO - RETURN
CHKJ.1:	PUSHJ	P,CHKP.1		;ANY PIDS FOR THIS JOB?
	  SKIPA				;NO
	AOS	(P)			;YES
	POPJ	P,			;RETURN


; CHECK FOR PID BELONGING TO CURRENT JOB
;
CHKPID:	SKIPN	PIDFLG			;HAVE A PID FOR THIS JOB?
	POPJ	P,			;NO - THEN THERE CAN'T BE ANYMORE
	AOBJP	PID,.POPJ##		;POINT TO NEXT ENTRY
	ADDI	PID,.PBLEN-1		;POINT TO NEXT PID BLOCK
CHKP.1:	SETZM	PIDFLG			;INDICATE NO PID FOUND YET
	HRRZ	T1,.PBJOB(PID)		;GET JOB NUMBER
	CAMN	T1,J			;THIS JOB?
	JRST	CHKP.3			;YES - NOW CHECK FOR A SPECIAL PID
	CAMLE	T1,J			;BEYOND THIS JOB?
	POPJ	P,			;YES--RETURN
CHKP.2:	AOBJP	PID,.POPJ##		;RETURN IF DONE
	ADDI	PID,.PBLEN-1		;POINT TO NEXT PID BLOCK
	JRST	CHKP.1			;LOOP BACK

CHKP.3:	AOS	PIDFLG			;REMEMBER WE FOUND A PID FOR THIS JOB
	JRST	.POPJ1##		;RETURN
SUBTTL	JOB mode -- Column headers


JOBHDR:	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVEI	T2,3(J)			;GET POSITIVE INDEX INTO HEADER TABLE
	ADD	T2,T1			;OFFSET INTO TABLE
	MOVE	T1,(T2)			;GET TEXT ADDRESS
	PUSHJ	P,.TSTRG##		;TYPE IT
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN


JOBSPA:	PUSH	P,T1			;SAVE T1
	SKIPE	COLUMN			;OUTPUT ANYTHING YET?
	PUSHJ	P,.TSPAC##		;YES
	POP	P,T1			;RESTORE T1
	POPJ	P,			;AND RETURN
SUBTTL	JOB mode -- Job number


HDRNUM:	[ASCIZ	|   |]			;LINE 1
	[ASCIZ	|Job|]			;LINE 2
	[ASCIZ	|---|]			;LINE 3

JOBNUM:	TXNN	I,IJBJOB		;JOBS?
	POPJ	P,			;NO
	MOVEI	T1,HDRNUM		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVE	T1,J			;GET JOB NUMBER
	MOVE	T2,[" ",,3]		;PAD CHARACTER RIGHT JUSTIFIED
	PUSHJ	P,DECOUT		;TYPE IT
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- User name


HDRUNM:	[ASCIZ	|            |]		;LINE 1
	[ASCIZ	| User  Name |]		;LINE 2
	[ASCIZ	|------------|]		;LINE 3

JOBUNM:	TXNN	I,IJBUSE		;NAME?
	POPJ	P,			;NO
	MOVEI	T1,HDRUNM		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	JUMPE	J,JOBN.1		;CHECK FOR JOB 0
	MOVE	T1,.PBUNM+0(PID)	;GET USER NAME (WORD 1)
	PUSHJ	P,SIXOUT		;TYPE IT
	MOVE	T1,.PBUNM+1(PID)	;GET USER NAME (WORD 2)
	PUSHJ	P,SIXOUT		;TYPE IT
	JRST	JOBN.2			;FINISH UP
JOBN.1:	MOVEI	T1,[ASCIZ |Exec process|]
	PUSHJ	P,.TSTRG##		;MAKE NAME STAND OUT FROM OTHERS
JOBN.2:	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- PPN


HDRPPN:	[ASCIZ	|             |]	;LINE 1
	[ASCIZ	|     PPN     |]	;LINE 2
	[ASCIZ	|-------------|]	;LINE 3

JOBPPN:	TXNN	I,IJBPPN		;PPNS?
	POPJ	P,			;NO
	MOVEI	T1,HDRPPN		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	JUMPE	J,JOBP.1		;CHECK FOR JOB 0
	MOVE	T1,.PBPPN(PID)		;GET THE PPN
	PUSH	P,T1			;SAVE IT
	HLRZS	T1			;GET PROJECT NUMBER
	MOVE	T2,[" ",,6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;TYPE COMMA
	POP	P,T1			;RESTORE PPN
	HRRZS	T1			;GET PROGRAMMER NUMBER
	MOVE	T2,[" ",,-6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	JRST	JOBP.2			;SKIP JOB 0 STUFF
JOBP.1:	MOVEI	T1,[ASCIZ |             |] ;A FEW SPACES
	PUSHJ	P,.TSTRG##		;TYPE THEM
JOBP.2:	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Program name


HDRPRG:	[ASCIZ	|      |]		;LINE 1
	[ASCIZ	| Prog |]		;LINE 2
	[ASCIZ	|------|]		;LINE 3

JOBPRG:	TXNN	I,IJBPRO		;PROGRAMS?
	POPJ	P,			;NO
	MOVEI	T1,HDRPRG		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVE	T1,.PBPRG(PID)		;GET THE PROGRAM NAME
	SKIPN	J			;CHECK FOR JOB 0
	MOVE	T1,['TOPS10']		;SET PROGRAM NAME TO 'TOPS10'
	PUSHJ	P,SIXOUT		;TYPE IT
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Quotas


HDRQTA:	[ASCIZ	|  Quotas   |]		;LINE 1
	[ASCIZ	|Sts Snd Rcv|]		;LINE 2
	[ASCIZ	|-----------|]		;LINE 3

JOBQTA:	TXNN	I,IJBQUO		;QUOTAS?
	POPJ	P,			;NO
	MOVEI	T1,HDRQTA		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVEI	T1,[ASCIZ |On  |]	;ASSUME ENABLED
	LDB	T2,[POINTR (.PBQTA(PID),IP.CQX)] ;GET DISABLED BIT
	SKIPE	T2			;IS IT
	MOVEI	T1,[ASCIZ |Off |]	;YES
	PUSHJ	P,.TSTRG##		;TYPE IT
	LDB	T2,[POINTR (.PBQTA(PID),IP.CQQ)] ;GET QUOTA SET BIT
	JUMPE	T2,JOBQ.1		;SET FOR THIS JOB?
	LDB	T1,[POINTR (.PBQTA(PID),IP.CQS)] ;GET SEND QUOTA
	MOVE	T2,[" ",,3]		;PAD CHARACTER IS SPACE, 3 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	PUSHJ	P,.TSPAC##		;SPACE
	LDB	T1,[POINTR (.PBQTA(PID),IP.CQR)] ;GET RECEIVE QUOTA
	MOVE	T2,[" ",,3]		;PAD CHARACTER IS SPACE, 3 COLUMNS
	PUSHJ	P,DECOUT		;TYPE IT
	JRST	JOBQ.2			;ALMOST DONE
JOBQ.1:	MOVEI	T1,[ASCIZ |not set|]	;GET OBVIOUS MESSAGE
	PUSHJ	P,.TSTRG##		;TYPE IT
JOBQ.2:	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Total sends and receives


HDRTSR:	[ASCIZ	|    Total    |]	;LINE 1
	[ASCIZ	| Snds   Rcvs |]	;LINE 2
	[ASCIZ	|-------------|]	;LINE 3

JOBTSR:	TXNN	I,IJBTOT		;TOTALS?
	POPJ	P,			;NO
	MOVEI	T1,HDRTSR		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	LDB	T1,[POINTR (.PBTSR(PID),IP.CQD)] ;GET TOTAL SENDS
	MOVE	T2,[" ",,6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,DECOUT		;TYPE SENDS
	PUSHJ	P,.TSPAC##		;SPACE
	LDB	T1,[POINTR (.PBTSR(PID),IP.CQC)] ;GET TOTAL RECEIVES
	MOVE	T2,[" ",,6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,DECOUT		;TYPE RECEIVES
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Outstanding sends and receives


HDROSR:	[ASCIZ	|Outstanding|]		;LINE 1
	[ASCIZ	|Sends Recvs|]		;LINE 2
	[ASCIZ	|-----------|]		;LINE 3

JOBOSR:	TXNN	I,IJBOUT		;OUTSTANDING?
	POPJ	P,			;NO
	MOVEI	T1,HDROSR		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	LDB	T1,[POINTR (.PBOSR(PID),IP.CQP)] ;GET OUTSTANDING SENDS
	MOVE	T2,[" ",,5]		;PAD CHARACTER IS SPACE, 5 COLUMNS
	PUSHJ	P,DECOUT		;TYPE SENDS
	PUSHJ	P,.TSPAC##		;SPACE
	LDB	T1,[POINTR (.PBOSR(PID),IP.CQO)] ;GET OUTSTANDING RECEIVES
	MOVE	T2,[" ",,5]		;PAD CHARACTER IS SPACE, 5 COLUMNS
	PUSHJ	P,DECOUT		;TYPE RECEIVES
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Capabilities


JACCT==1
JLOG==4
JS.XO==20000

HDRCAP:	[ASCIZ	|      |]		;LINE 1
	[ASCIZ	|Capabi|]		;LINE 2
	[ASCIZ	|------|]		;LINE 3

JOBCAP:	TXNN	I,IJBCAP		;CAPABILITIES?
	POPJ	P,			;NO
	MOVEI	T1,HDRCAP		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	SKIPE	J			;CHECK FOR JOB 0
	SKIPA	T1,.PBCAP(PID)		;GET CAPABILITIES
	SETZ	T1,			;FOR JOB 0
	PUSHJ	P,SIXOUT		;TYPE THEM
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- PID


HDRPID:	[ASCIZ	|            |]		;LINE 1
	[ASCIZ	|     PID    |]		;LINE 2
	[ASCIZ	|------------|]		;LINE 3

JOBPID:	TXNN	I,IJBPID		;WANT PID DISPLAY?
	POPJ	P,			;NO
	MOVEI	T1,HDRPID		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	SKIPN	PIDFLG			;HAVE A PID?
	POPJ	P,			;NO
	SKIPGE	T1,.PBSID(PID)		;GET SPECIAL PID
	MOVE	T1,.PBPID(PID)		;USE REGULAR PID
	PUSHJ	P,TYPPID		;TYPE PID
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- System process


HDRSPR:	[ASCIZ	|                  |]	;LINE 1
	[ASCIZ	| System Processes |]	;LINE 2
	[ASCIZ	|------------------|]	;LINE 3

JOBSPR:	TXNN	I,IJBSYS		;SYSTEM PROCESSES?
	POPJ	P,			;NO
	MOVEI	T1,HDRSPR		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVE	T1,.PBSNM(PID)		;GET ADDRESS OF SPECIAL PID NAME
	PUSHJ	P,.TSTRG##		;TYPE IT
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- Job's [SYSTEM]INFO


HDRINF:	[ASCIZ	|   Job's    |]		;LINE 1
	[ASCIZ	|[SYSTEM]INFO|]		;LINE 2
	[ASCIZ	|------------|]		;LINE 3

JOBINF:	TXNN	I,IJBLOCAL		;INFO?
	POPJ	P,			;NO
	MOVEI	T1,HDRINF		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVE	T1,.PBINF(PID)		;GET LOCAL [SYSTEM]INFO PID
	PUSHJ	P,TYPPID		;TYPE PID
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	JOB mode -- PID name


HDRPNM:	[ASCIZ	|                             |]
	[ASCIZ	|          PID  name          |]
	[ASCIZ	|-----------------------------|]

JOBPNM:	TXNN	I,IJBNAM		;PID NAMES?
	POPJ	P,			;NO
	MOVEI	T1,HDRPNM		;GET ADDRESS OF HEADERS
	JUMPL	J,JOBHDR		;TYPE A COLUMN HEADER
	PUSHJ	P,JOBSPA		;SEE IF A LEADING SPACE IS NECESSARY
	MOVEI	T1,.PBNAM(PID)		;POINT TO NAME TEXT
	SKIPN	(T1)			;HAVE A NAME HERE?
	POPJ	P,			;NO
	PUSHJ	P,.TSTRG##		;TYPE PID NAME
	AOS	JOBTYO			;INDICATE OUTPUT
	POPJ	P,			;RETURN
SUBTTL	PACKET mode -- Loop


PKTPRC:	MOVEI	J,0			;START WITH JOB 0 (MONITOR PROCESSES)

PKTPR1:	PUSHJ	P,PDBJOB		;TYPE PDB/JOB INFORMATION
	CAMGE	J,JOBN			;DONE ALL JOBS?
	AOJA	J,PKTPR1		;LOOP FOR ALL JOBS
	POPJ	P,			;YES
SUBTTL	PACKET mode -- Display packets for a job


PDBJOB:	SETZM	PDBCNT			;CLEAR PDB COUNTER FOR THIS JOB
	MOVE	S,S.SCRO		;GET SCROLL VALUE

PDBJO1:	PUSHJ	P,PDBCPY		;TRY TO COPY A PDB FROM THE MONITOR
	  POPJ	P,			;END OF CHAIN
	SKIPL	S.JOB			;WANT A SPECIFIC JOB?
	CAMN	J,S.JOB			;YES--IS THIS THE ONE?
	SKIPA				;PROCESS THIS ONE
	POPJ	P,			;ELSE RETURN
	SOJGE	S,PDBJO2		;TIME TO DISPLAY?
	PUSHJ	P,PDBHDR		;TYPE PDB HEADER
	PUSHJ	P,PDBWD0		;TYPE PDB WORD 0
	PUSHJ	P,PDBWD1		;TYPE PDB WORD 1
	PUSHJ	P,PDBWD2		;TYPE PDB WORD 2
	PUSHJ	P,PDBWD3		;TYPE PDB WORD 3
	PUSHJ	P,PDBWD4		;TYPE PDB WORD 4
	PUSHJ	P,PDBWD5		;TYPE PDB WORD 5
	PUSHJ	P,.TCRLF##		;NEW LINE
PDBJO2:	AOS	PDBCNT			;COUNT
	JRST	PDBJO1			;LOOP FOR ANOTHER BLOCK
; Copy a Packet Descriptor Block from the monitor into
; our address space
;
PDBCPY:	MOVE	T1,PDBBLK+.IPCFL	;GET LINK WORD
	SKIPE	PDBCNT			;FIRST TIME THROUGH?
	JRST	PDBC.1			;NO
	HRLZ	T1,J			;GET JOB NUMBER
	HRRI	T1,.GTIPP		;GETTAB TABLE
	PUSHJ	P,.MAPG##		;GET THE JOB'S IPCF POINTERS
	  POPJ	P,			;CAN'T

PDBC.1:	HLRZM	T1,PDBADR		;SAVE MONITOR ADDRESS
	SKIPN	PDBADR			;END OF CHAIN?
	POPJ	P,			;YES
	SETZ	T2,			;CLEAR A COUNTER

PDBC.2:	MOVE	T1,PDBADR		;GET EXEC ADDRESS
	ADDI	T1,(T2)			;OFFSET INTO BLOCK
	PUSHJ	P,.MAPE##		;EXAMINE THAT ADDRESS
	  POPJ	P,			;CAN'T
	MOVEM	T1,PDBBLK(T2)		;SAVE IT
	CAIGE	T2,5			;DONE ALL WORDS YET?
	AOJA	T2,PDBC.2		;LOOP
	JRST	.POPJ1##		;RETURN
SUBTTL	PACKET mode -- Header display


PDBHDR:	PUSHJ	P,.TCRLF##		;NEW LINE
	MOVEI	P1,PDBBLK		;POINT TO OUR COPY OF THE BLOCK
	MOVEI	T1,[ASCIZ |Job |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,J			;GET JOB NUMBER
	MOVE	T2,[" ",,-3]		;PAD CHARACTER IS SPACE, 3 COLUMNS
	PUSHJ	P,DECOUT		;TYPE JOB NUMBER
	MOVEI	T1,[ASCIZ |  +----------------+  Block #|]
	PUSHJ	P,.TSTRG##		;TYPE TOP LINE
	MOVE	T1,PDBCNT		;GET BLOCK NUMBER
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ |, Exec address = |]
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	T1,PDBADR		;GET PDB ADDRESS
	PUSHJ	P,.TOCTW##		;TYPE IT
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	PACKET mode -- .IPCFL word display


PDBWD0:	MOVEI	T1,[ASCIZ /Link:    | /]
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFL(P1)		;GET LINK TO NEXT PDB
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFL(P1)		;GET RANDOM FLAGS AND FIELDS
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBFLG		;TYPE FLAGS
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN


PDBFLG:	MOVE	P2,.IPCFL(P1)		;GET FLAG WORD
	MOVEI	T1,[ASCIZ |  Priv'd|]
	TXNE	P2,IP.CFP		;SENDER INVOKING PRIVS?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |  VM|]
	TXNE	P2,IP.CFV		;VM PAGE TRANSFER MODE?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |  No data|]
	TXNE	P2,IP.CFZ		;ZERO LENGTH PACKET?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |  ACK|]
	TXNE	P2,IP.CFA		;ACK REQUESTED?
	PUSHJ	P,.TSTRG##		;TYPE IT
	POPJ	P,			;RETURN


; Packet Descriptor Block error codes
;
PDBERR:	MOVEI	T1,[ASCIZ |  Error = |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	LDB	T1,[POINTR (.IPCFL(P1),IP.CFE)] ;GET ERROR CODE
	MOVE	T2,[-IPCELN,,IPCETB]	;GET AOBJN POINTER
	PJRST	TBLTYP			;TYPE TEXT FROM TABLE AND RETURN


; System sender code
;
PDBSND:	MOVEI	T1,[ASCIZ |  System sender = |]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	LDB	T1,[POINTR (.IPCFL(P1),IP.CFC)] ;GET SYSTEM SENDER CODE
	MOVE	T2,[-SSCLEN,,SSCTAB]	;GET AOBJN POINTER
	PJRST	TBLTYP			;TYPE TEXT FROM TABLE AND RETURN


; Return codes
;
PDBRET:	LDB	T1,[POINTR (.IPCFL(P1),IP.CFM)] ;GET RETURN CODE
	MOVE	T2,[-RETLEN,,RETTAB]	;GET AOBJN POINTER
	PJRST	TBLTYP			;TYPE TEXT FROM TABLE AND RETURN
SUBTTL	PACKET mode -- .IPCFS word display


PDBWD1:	MOVEI	T1,[ASCIZ /Sender:  | /] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFS(P1)		;GET LH OF PID
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFS(P1)		;GET RH OF PID
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBERR		;TYPE PDB ERROR CODE (IF ANY)
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	PACKET mode -- .IPCFR word display


PDBWD2:	MOVEI	T1,[ASCIZ /Receiver:| /] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFR(P1)		;GET LH OF PID
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFR(P1)		;GET RH OF PID
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBSND		;TYPE SYSTEM SENDER CODE (IF ANY)
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	PACKET mode -- .IPCFP word display


PDBWD3:	MOVEI	T1,[ASCIZ /Packet:  | /] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFP(P1)		;GET LENGTH
	MOVE	T2,[" ",,6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFP(P1)		;GET ADDRESS
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBPKT		;TYPE PACKET INFO
	PJRST	.TCRLF##		;TYPE NEW LINE AND RETURN

; Packet info
;
PDBPKT:	MOVX	T1,IP.CFV		;GET VM BIT
	TDNE	T1,.IPCFL(P1)		;PACKET OR PAGE MODE?
	JRST	PDBP.1			;VM
	HLRZ	T2,.IPCFP(P1)		;GET LENGTH
	MOVEI	T1,[ASCIZ |  Long packet|] ;ASSUME A PRIV'ED USER
	CAMG	T2,PKTLEN		;A NORMAL PACKET LENGTH?
	MOVEI	T1,[ASCIZ |  Normal packet|] ;SAY SO
	SKIPN	T2			;NON-ZERO LENGTH?
	MOVEI	T1,[ASCIZ |  Zero length message|]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	HLRZ	T2,.IPCFP(P1)		;GET LENGTH AGAIN
	JUMPE	T2,.POPJ##		;RETURN IF ZERO
	MOVEI	T1,[ASCIZ | (|]		;INTRODUCTION
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFP(P1)		;GET LENGTH ONE MORE TIME
	PUSHJ	P,.TDECW##		;TYPE IT
	MOVEI	T1,[ASCIZ | words)|]	;ALMOST DONE
	PJRST	.TSTRG##		;TYPE TEXT AND RETURN

PDBP.1:	MOVEI	T1,[ASCIZ |  Page is on disk|] ;ASSUME THE USUAL
	MOVEI	T2,400000		;BIT 18 MEANS PAGE ON DISK
	TDNN	T2,.IPCFP(P1)		;CHECK IT
	MOVEI	T1,[ASCIZ |  Page is in core|] ;BAD GUESS
	PJRST	.TSTRG##		;TYPE TEXT AND RETURN
SUBTTL	PACKET mode -- .IPCFU word display


PDBWD4:	MOVEI	T1,[ASCIZ /Snd PPN: | /] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFU(P1)		;GET PROJECT NUMBER
	MOVE	T2,[" ",,6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFU(P1)		;GET PROGRAMMER NUMBER
	MOVE	T2,[" ",,-6]		;PAD CHARACTER IS SPACE, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBCAP		;TYPE CAPABILITIES
	PJRST	.TCRLF##		;TYPE A NEW LINE AND RETURN
SUBTTL	PACKET mode -- .IPCFC word display


PDBWD5:	MOVEI	T1,[ASCIZ /Capabil: | /] ;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	HLRZ	T1,.IPCFC(P1)		;GET LH OF WORD
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	PUSHJ	P,.TCOMA##		;A COMMA
	PUSHJ	P,.TCOMA##		;ANOTHER COMMA
	HRRZ	T1,.IPCFC(P1)		;GET RH OF WORD
	MOVE	T2,["0",,6]		;PAD CHARACTER IS ZERO, 6 COLUMNS
	PUSHJ	P,OCTOUT		;TYPE IT
	MOVEI	T1,[ASCIZ / |/]		;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	PUSHJ	P,PDBSJB		;TYPE SENDER'S JOB NUMBER
	PUSHJ	P,.TCRLF##		;TYPE A NEW LINE
	MOVEI	T1,[ASCIZ |         +----------------+|]
	PJRST	.TSTRG##		;TYPE BOTTOM LINE AND RETURN


; Capabilities
;
PDBCAP:	MOVEI	T1,[ASCIZ |  Privs = |]	;GET TEXT
	PUSHJ	P,.TSTRG##		;TYPE IT
	MOVE	P2,.IPCFC(P1)		;GET CAPABILITIES WORD
	MOVEI	T1,[ASCIZ |JAC  |]
	TXNE	P2,IP.JAC		;JACCT SET?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |LGN  |]
	TXNE	P2,IP.JLG		;JOB LOGGED IN?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |EXO  |]
	TXNE	P2,IP.SXO		;EXECUTE-ONLY?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |POK  |]
	TXNE	P2,IP.POK		;POKE PRIVS?
	PUSHJ	P,.TSTRG##		;YES
	MOVEI	T1,[ASCIZ |IPC  |]
	TXNE	P2,IP.IPC		;IPCF PRIVS?
	PUSHJ	P,.TSTRG##		;YES
	POPJ	P,			;RETURN


; Sender's job number
;
PDBSJB:	MOVEI	T1,[ASCIZ |  Sender's job = |]
	PUSHJ	P,.TSTRG##		;TYPE TEXT
	LDB	T1,[POINTR (.IPCFC(P1),IP.SJN)] ;GET JOB NUMBER
	PJRST	.TDECW##		;TYPE IT AND RETURN
SUBTTL	PACKET mode -- IPCF Error code and text table


; Table of IPCF error codes and messages
;
IPCETB:	     0,,[ASCIZ |(none)|]
	IPCAC%,,[ASCIZ |Address check|]
	IPCNL%,,[ASCIZ |Not long enough|]
	IPCNP%,,[ASCIZ |No packet in receive queue|]
	IPCIU%,,[ASCIZ |Page in use (locked)|]
	IPCTL%,,[ASCIZ |Data too long|]
	IPCDU%,,[ASCIZ |Unknown receiver's PID|]
	IPCDD%,,[ASCIZ |Destination disabled|]
	IPCRS%,,[ASCIZ |No room in sender's quota|]
	IPCRR%,,[ASCIZ |No room in receiver's quota|]
	IPCRY%,,[ASCIZ |No room in system storage|]
	IPCUP%,,[ASCIZ |Unknown/duplicate page|]
	IPCIS%,,[ASCIZ |Invalid send PID|]
	IPCPI%,,[ASCIZ |Priv insufficient|]
	IPCUF%,,[ASCIZ |Unknown function|]
	IPCBJ%,,[ASCIZ |Bad job number|]
	IPCPF%,,[ASCIZ |PID table full|]
	IPCPR%,,[ASCIZ |Page requested|]
	IPCIE%,,[ASCIZ |Paging I/O error|]
	IPCBI%,,[ASCIZ |Bad index for system PID table|]
	IPCUI%,,[ASCIZ |Undefined id in system PID table|]
	IPCRU%,,[ASCIZ |PID unknown|]
	IPCFU%,,[ASCIZ |[SYSTEM]INFO internal error|]
	IPCCF%,,[ASCIZ |[SYSTEM]IPCC request from [SYSTEM]INFO failed|]
	IPCFF%,,[ASCIZ |[SYSTEM]INFO failed to complete an assign|]
	IPCQP%,,[ASCIZ |PID quota exceeded|]
	IPCBP%,,[ASCIZ |Bad (unknown) PID|]
	IPCDN%,,[ASCIZ |Duplicate name|]
	IPCNN%,,[ASCIZ |No such name|]
	IPCBN%,,[ASCIZ |Name has illegal characters|]
IPCELN==.-IPCETB-1
SUBTTL	PACKET mode -- System sender codes and text table


; Table of system senders codes and messages
;
SSCTAB:	     0,,[ASCIZ |(none)|]
	.IPCCC,,[ASCIZ |[SYSTEM]IPCC|]
	.IPCCF,,[ASCIZ |System-wide [SYSTEM]INFO|]
	.IPCCP,,[ASCIZ |Receiver's [SYSTEM]INFO|]
	.IPCCG,,[ASCIZ |[SYSTEM]GOPHER|]
SSCLEN==.-SSCTAB-1
SUBTTL	PACKET mode -- Return codes and text table


; Table of return codes and messages
;
RETTAB:	     0,,[ASCIZ |(none)|]
	.IPCFN,,[ASCIZ |Non-existant PID|]
RETLEN==.-RETTAB-1
SUBTTL	PACKET mode -- Text table searching and typeout


; This routine will take a code and a pointer and search
; a table for text to typeout.
; Call:	MOVE	T1, octal code
;	MOVE	T2, AOBJN pointer to table
;	PUSHJ	P,TBLTYP
;
; If no entry is found, 'nnn (unknown)' will be typed
;
TBLTYP:	HLRZ	T3,(T2)			;GET A CODE
	CAMN	T1,T3			;FOUND THE ONE WE WANT?
	JRST	TBLT.1			;YES
	AOBJN	T2,TBLTYP		;LOOP THROUGH TABLE
	PUSHJ	P,.TOCTW##		;TYPE UNKNOWN CODE
	SKIPA	T2,[[ASCIZ | (unknown)|]] ;DON'T KNOW THIS CODE

TBLT.1:	HRRZ	T2,(T2)			;GET ADDRESS OF TEXT
	PUSH	P,T2			;SAVE ADDRESS
	PUSHJ	P,.TOCTW##		;TYPE CODE IN OCTAL
	MOVEI	T1,[ASCIZ |; |]		;GET SEPARATOR
	PUSHJ	P,.TSTRG##		;TYPE IT
	POP	P,T1			;GET TEXT ADDRESS BACK
	PJRST	.TSTRG##		;TYPE IT AND RETURN
	[ASCIZ	|                  |]
SIDNAM:	[ASCIZ	|[SYSTEM]IPCC      |]
	[ASCIZ	|[SYSTEM]INFO      |]
	[ASCIZ	|[SYSTEM]QUASAR    |]
	[ASCIZ	|[SYSTEM]MDA       |]
	[ASCIZ	|Tape labeler      |]
	[ASCIZ	|File daemon       |]
	[ASCIZ	|Tape AVR          |]
	[ASCIZ	|[SYSTEM]ACCOUNTING|]
	[ASCIZ	|Operator Control  |]
	[ASCIZ	|[SYSTEM]ERROR     |]
	[ASCIZ	|Disk AVR          |]
	[ASCIZ	|MOS mem Controller|]
	[ASCIZ	|DECnet manager    |]
	[ASCIZ	|[SYSTEM]GOPHER    |]
SUBTTL	Special typeout routines -- PID


TYPPID:	MOVE	T2,T1			;PUT IN A BETTER PLACE
	MOVEI	T3,^D12			;12 DIGITS
	SETZ	T4,			;CLEAR A FLAG
TYPP.1:	LSHC	T1,3			;GET A DIGIT
	ANDI	T1,7			;STRIP OFF JUNK
	JUMPN	T4,TYPP.2		;ALREADY FOUND A DIGIT?
	SKIPE	T1			;NON-ZERO?
	AOSA	T4			;YES
	SKIPA	T1,[" "]		;NO - TYPE A SPACE
TYPP.2:	ADDI	T1,"0"			;CONVERT TO ASCII
	PUSHJ	P,.TCHAR##		;TYPE IT
	SOJG	T3,TYPP.1		;LOOP
	POPJ	P,			
SUBTTL	Special typeout routines -- Justified sixbit word


SIXOUT:	MOVE	T2,T1			;GET WORD
	MOVEI	T3,6			;SET UP COUNTER
SIXO.1:	LSHC	T1,6			;SHIFT IN 6 BITS
	ANDI	T1,77			;STRIP OFF JUNK
	ADDI	T1," "			;MAKE IT ASCII
	PUSHJ	P,.TCHAR##		;TYPE IT
	SOJG	T3,SIXO.1		;LOOP
	POPJ	P,			;RETURN
SUBTTL	Special typeout routines -- Justified numeric word


DECOUT:	SKIPA	T3,[12]			;RADIX 10
OCTOUT:	MOVEI	T3,10			;RADIX 8
	HLRZM	T2,PADCHR		;STORE PAD CHARACTER
	HRRES	T2			;GET PAD COUNT
	MOVMM	T2,PADCNT		;STORE PAD COUNT
	JUMPGE	T2,NUMR			;CHECK FOR RIGHT JUSTIFICATION
	PUSHJ	P,NUML			;OUTPUT LEFT JUSTIFIED NUMBER
NUMPAD:	SOSGE	PADCNT			;DONE?
	POPJ	P,			;YES
	MOVE	T1,PADCHR		;GET PAD CHARACTER
	PUSHJ	P,.TCHAR##		;TYPE IT
	JRST	NUMPAD			;LOOP

NUMR:	IDIVI	T1,(T3)			;DIVIDE BY RADIX
	HRLM	T2,(P)			;STORE REMAINDER
	SOS	PADCNT			;COUNT CHARACTERS
	SKIPE	T1			;DONE?
	PUSHJ	P,NUMR			;NO - RECURSE
NUMR.1:	SOSGE	PADCNT			;COUNT COLUMNS TO PAD
	JRST	NUMR.2			;DONE
	MOVE	T1,PADCHR		;GET PAD CHARACTER
	PUSHJ	P,.TCHAR##		;TYPE IT
	JRST	NUMR.1			;LOOP
NUMR.2:	HLRZ	T1,(P)			;GET A DIGIT
	ADDI	T1,"0"			;MAKE IT ASCII
	PJRST	.TCHAR##		;TYPE IT AND RETURN

NUML:	IDIVI	T1,(T3)			;DIVIDE BY RADIX
	HRLM	T2,(P)			;STORE REMAINDER
	SOS	PADCNT			;COUNT CHARACTERS
	SKIPE	T1			;DONE?
	PUSHJ	P,NUML			;NO - RECURSE
	HLRZ	T1,(P)			;GET A DIGIT
	ADDI	T1,"0"			;MAKE IT ASCII
	PJRST	.TCHAR##		;TYPE IT AND RETURN
SUBTTL	Special typeout routines -- Time


TIMOUT:	IDIV	T1,[^D24*^D60*^D60]	;T1:= DAYS
	IDIVI	T2,^D60*^D60		;T2:= HOURS
	IDIVI	T3,^D60			;T3:= MINUTES, T4:= SECONDS
	PUSH	P,T4			;SAVE SECONDS
	PUSH	P,T3			;SAVE MINUTES
	PUSH	P,T2			;SAVE HOURS
	JUMPE	T1,TIMO.1		;UP FOR DAYS?
	PUSHJ	P,.TDECW##		;YES
	MOVEI	T1,[ASCIZ |d+|]		;GET DELIMITER
	PUSHJ	P,.TSTRG##		;TYPE IT

TIMO.1:	POP	P,T1			;GET HOURS
	MOVEI	T2,"0"			;GET FILLER
	PUSHJ	P,.TDEC2##		;TYPE IT
	PUSHJ	P,.TCOLN##		;TYPE COLON
	POP	P,T1			;GET MINUTES
	MOVEI	T2,"0"			;GET FILLER
	PUSHJ	P,.TDEC2##		;TYPE IT
	PUSHJ	P,.TCOLN##		;TYPE COLON
	POP	P,T1			;GET SECONDS
	MOVEI	T2,"0"			;GET FILLER
	PJRST	.TDEC2##		;TYPE IT AND RETURN
SUBTTL	Special typeout routines -- High precision time output


; Call:	MOVE	T1, time in 10-microsecond units
;	PUSHJ	P,HPTOUT
;
HPTOUT:	IDIVI	T1,^D100		;CONVERT TO MILLISECONDS
	IDIVI	T1,^D1000		;GET MILLISECONDS
	PUSH	P,T2			;SAVE IT
	IDIVI	T1,^D60			;GET SECONDS
	PUSH	P,T2			;SAVE IT
	IDIVI	T1,^D60			;GET HOURS
	PUSH	P,T2			;SAVE MINUTES
	JUMPN	T1,HPTO.1		;HAVE HOURS?
	JUMPN	T2,HPTO.2		;HAVE MINUTES?
	JRST	HPTO.3			;THEN TYPE SECONDS AND FRACTION

HPTO.1:	SETZ	T2,			;NO PADDING
	PUSHJ	P,.TDEC2##		;TYPE HOURS
	PUSHJ	P,.TCOLN##		;TYPE A COLON
	SKIPA	T2,["0"]		;PAD MINUTES WITH A ZERO

HPTO.2:	SETZ	T2,			;NO PADDING
	MOVE	T1,(P)			;GET MINUTES
	PUSHJ	P,.TDEC2##		;TYPE MINUTES
	PUSHJ	P,.TCOLN##		;TYPE A COLON
	SETZ	T4,			;WE DON'T WANT FRACTIONS TYPED
	SKIPA	T2,["0"]		;PAD SECONDS WITH A ZERO

HPTO.3:	SETZ	T2,			;NO PADDING
	MOVE	T1,-1(P)		;GET SECONDS
	PUSHJ	P,.TDEC2##		;TYPE SECONDS
	POP	P,(P)			;PRUNE
	POP	P,(P)			; STACK
	PUSHJ	P,DOT			;TYPE A PERIOD
	POP	P,T1			;GET MILLISECONDS
	IDIVI	T1,^D10			;STRIP OFF LOW ORDER DIGIT
	CAIL	T2,5			;NEED TO ROUND UP?
	ADDI	T1,1			;YES
	MOVEI	T2,"0"			;PAD WITH A ZERO
	PJRST	.TDEC2##		;TYPE FRACTION AND RETURN
SUBTTL	Special typeout routines -- Miscellaneous


DASH:	SKIPA	T1,["-"]
DOT:	MOVEI	T1,"."
	PJRST	.TCHAR##
.HELPR::POPJ	P,
SUBTTL	Core allocation


; Get core
; Call:	MOVE	T1, number of words
;	PUSHJ	P,GETCOR
;
; On return, T2:= address
;
GETCOR:	MOVE	T2,.JBFF		;GET FIRST FREE
	MOVE	T3,T2			;COPY IT
	ADDI	T3,(T1)			;PLUS THE NUMBER OF WORDS NEEDED
	MOVEM	T3,.JBFF		;UPDATE FIRST FREE
	CAMG	T3,.JBREL		;ALREADY HAVE CORE?
	POPJ	P,			;YES
	CORE	T3,			;CORE UP
	  HALT	.			;CAN'T
	POPJ	P,			;RETURN
SUBTTL	DPYPAK interface -- Initialization


DPINI:	SKIPG	S.DPY			;USER SPECIFY /DPY?
	POPJ	P,			;NO
	SETZM	S.DPY			;ASSUME NOT DISPLAY
	PUSHJ	P,DP.SAC
	MOVE	T1,[ASCIZ | |]		;DON'T DEFAULT TTY TYPE
	MOVEM	T1,DP.TRM		;TELL DPYPAK
	MOVEI	16,[-2,,0
		       [7]
		       DP.TRM]+1
	PUSHJ	P,DPYINI##
	CAMN	0,[-1]			;DISPLAY INITIALIZATION FAIL?
	POPJ	P,			;YES - JUST RETURN
	AOS	S.DPY			;INDICATE DISPLAY
	PUSHJ	P,DPYZAP##
	PUSHJ	P,DP.RAC
	MOVE	T1,[POINT 7,DP.BUF]
	MOVEM	T1,DP.PTR
	SETZM	DP.LIN
	SETZM	DP.OLN
	SETZM	DP.LLN
	POPJ	P,
SUBTTL	DPYPAK interface -- Commands



BONOFF:	MOVEI	T1,[ASCIZ |Off    |]
	MOVE	T3,S.MODE
	TDNE	T2,S.INCL(T3)
	MOVEI	T1,[ASCIZ |On     |]
	PJRST	.TSTRG##
SUBTTL	DPYPAK interface -- User exit


DPXIT:	SKIPG	S.DPY			;DISPLAY?
	  POPJ	P,			;NO
	PUSHJ	P,DP.SAC	;SAVE THE AC'S
	SETO	T1,
DPBOT:	SKIPG	S.DPY
	  POPJ	P,
	PUSHJ	P,DP.SAC
	SETZ	T1,

DPXXX:	PUSH	P,T1
	OUTCHR	[.CHCRT]	;<CR> TO RESET SCNSER'S CHAR POSITION
	MOVEI	16,[-4,,0
			[^D1]
			MAXL##
			[^D80]
			MAXL##]+1
	PUSHJ	P,DPYCSC##		;CLEAR SECTION
	MOVE	T1,MAXL##	;GET MAX LINE
	SUBI	T1,1		;A LITTLE LESS (EXIT 1, DOES CRLF)
	MOVEM	T1,DP.ARG
	MOVEI	16,[-3,,0
			[-1]
		 	[^D1]
			DP.ARG]+1
	PUSHJ	P,DPYCHR##
	POP	P,T1
	SKIPE	T1
	PUSHJ	P,DPYXIT##	;RESET TERMINAL PARAMETERS
	PJRST	DP.RAC		;RESTORE AC'S AND RETURN

DPCON::	SKIPG	S.DPY			;DISPLAY?
	 POPJ	P,
	PUSHJ	P,DP.SAC
	PUSHJ	P,DPYTTY##
	PJRST	DP.RAC
SUBTTL	DPYPAK interface -- Initialize display cycle output


DPLIN:	SKIPG	S.DPY			;DISPLAY?
	 POPJ	P,			;NO--JUST RETURN
	SETZM	DP.LIN			;START WITH LINE 0
	SETZM	DP.OLN			;AND NO LINES OUTPUT
	POPJ	P,			;RETURN
SUBTTL	DPYPAK interface -- Clean up at end of display cycle


DPCLR:	SKIPG	S.DPY			;DISPLAY?
	 POPJ	P,			;NO--RETURN
	MOVE	T1,DP.OLN		;GET LINES OUTPUT THIS PASS
	PUSH	P,T1			;SAVE IT
	CAMGE	T1,DP.LLN		;MORE THAN LAST?
	  PUSHJ	P,LINCLR		;NO--CLEAR THE REST
	POP	P,DP.LLN		;AND SAVE FOR NEXT PASS
	POPJ	P,			;AND RETURN

LINCLR:	PUSHJ	P,DP.SAC		;SAVE THE ACS
LINC.1:	AOS	T1,DP.OLN		;COUNT LINES
	CAMLE	T1,DP.LLN		;ALL LINES CLEAR?
	  PJRST	DP.RAC			;YES--RESTORES ACS AND CONTINUE
	MOVEI	16,[-4,,0
			[^D1]
			DP.OLN
			[^D80]
			DP.OLN]+1
	PUSHJ	P,DPYCSC##		;CLEAR SECTION
	JRST	LINC.1			;AND LOOP
SUBTTL	DPYPAK interface -- Output a character


DPCHR::	CAIN	T1,.CHCRT		;<CR>?
	  POPJ	P,			;YES
	CAIN	T1,.CHLFD		;<LF>?
	  JRST	DP.CH1			;YES
	IDPB	T1,DP.PTR		;STORE CHAR
	POPJ	P,			;AND RETURN

DP.CH1:	SKIPLE	S.AUTO			;DOING AUTOMATIC SCROLLING?
	AOS	ATOFLG			;YES--INDICATE SOMTHING OUTPUT
	AOS	T1,DP.LIN		;GET CURRENT LINE
	CAILE	T1,0			;SEE IF OUT OF RANGE
	 CAMLE	T1,MAXL##		;..
	  JRST	DP.CH2			;YES--JUST ZAP BUFFER
	AOS	DP.OLN			;COUNT LINES OUTPUT
	PUSHJ	P,DP.SAC
	MOVEI	16,[-5,,0
			DP.BUF
			[1]
			DP.OLN
			[^D80]
			DP.OLN]+1
	PUSHJ	P,DPYRSC##
	PUSHJ	P,DP.RAC
DP.CH2:	MOVE	T1,[POINT 7,DP.BUF]
	MOVEM	T1,DP.PTR
	SETZM	DP.BUF
	MOVE	T1,[DP.BUF,,DP.BUF+1]
	BLT	T1,DP.BUF+^D20
	POPJ	P,
SUBTTL	DPYPAK interface -- Save and restore the ACs


DP.SAC:	MOVEM	0,DP.AC
	MOVE	0,[1,,DP.AC+1]
	BLT	0,DP.AC+16
	POPJ	P,

DP.RAC:	MOVE	0,[DP.AC+1,,1]
	BLT	0,16
	MOVE	0,DP.AC
	POPJ	P,
SUBTTL	Literals


	LIT
SUBTTL	Data storage


	RELOC	0

ZBEG:!					;START OF DATA TO ZERO AT STARTUP

PDL:	BLOCK	PDLSIZ			;PUSH DOWN LIST
INTBLK:	BLOCK	4			;INTERRUPT BLOCK
ERRTYO:	BLOCK	1			;OLD CHARACTER PUTTER DURING ERRORS
ERRCNT:	BLOCK	1			;ERROR BUFFER BYTE COUNT
ERRPTR:	BLOCK	1			;ERROR BUFFER BYTE POINTER
ERRBUF:	BLOCK	<ERRSIZ/5>+1		;ERROR BUFFER
OFFSET:	BLOCK	1			;CCL ENTRY OFFSET
COMIDX:	BLOCK	1			;INVOKING COMMAND (MODE) INDEX
OPTNAM:	BLOCK	2			;OPTION NAMES
MAPPTR:	BLOCK	1			;PERFORMANCE DATA BLOCK ADDRESS

JOBN:	BLOCK	1			;NUMBER OF JOBS
JIFFIE:	BLOCK	1			;JIFFIE VALUE
PIDN:	BLOCK	1			;NUMBER OF PIDS
PIDTAB:	BLOCK	1			;ADDRESS OF PIDTAB
PIDBLK:	BLOCK	2			;WORD COUNT, ADDRESS OF PID BLOCKS
PIDCNT:	BLOCK	1			;COUNT OF PID BLOCKS IN USE
PBTEMP:	BLOCK	.PBLEN			;TEMPORARY PID BLOCK
SIDTAB:	BLOCK	SIDMAX			;SPECIAL PID TABLE
ATOFLG:	BLOCK	1			;AUTO SCROLL FLAG
ATOINC:	BLOCK	1			;COMPUTED AUTO SCROLL INCREMENT
COLUMN:	BLOCK	1			;COLUMN COUNT
JOBTYO:	BLOCK	1			;FLAG NON-ZERO IF ANYTHING DISPLAYED
PIDFLG:	BLOCK	1			;NON-ZERO IF A PID FOR CURRENT JOB
PDBCNT:	BLOCK	1			;PACKET DESCRIPTOR BLOCK COUNT
PDBADR:	BLOCK	1			;PACKET DESCRIPTOR BLOCK MONITOR ADDR
PDBBLK:	BLOCK	6			;PACKET DESCRIPTOR BLOCK FROM MONITOR
CPYBLK:	BLOCK	3			;MAPPER COPY BLOCK
PADCHR:	BLOCK	1			;PAD CHARACTER
PADCNT:	BLOCK	1			;PAD COUNT
SCNBLK:	BLOCK	.FXLEN			;SCAN BLOCK
FILCNT:	BLOCK	1			;CHARACTER COUNT
FILPTR:	BLOCK	1			;BYTE POINTER TO ASCIZ FILESPEC

PDB:	BLOCK	PDBLEN			;PACKET DESCRIPTOR BLOCK
PMB:	BLOCK	PMBLEN			;PACKET MESSAGE BLOCK
NAM:	BLOCK	NAMLEN			;NAME TO ASSIGN TO PID
ACK:	BLOCK	1			;ACK CODE
OURPID:	BLOCK	1			;OUR PID
NAMPTR:	BLOCK	1			;BYTE POINTER TO NAME

MONFIL:	BLOCK	.FXLEN			;MONITOR BOOTSTRAP FILE
CONFIG:	BLOCK	5			;SYSTAM NAME
LOCYER:	BLOCK	1			;LOCAL YEAR
LOCMON:	BLOCK	1			;LOCAL MONTH
LOCDAY:	BLOCK	1			;LOCAL DAY
LOCHOR:	BLOCK	1			;LOCAL HOUR
LOCMIN:	BLOCK	1			;LOCAL MINUTE
LOCSEC:	BLOCK	1			;LOCAL SECOND
UPTIME:	BLOCK	1			;SYSTEM UPTIME
UDT:	BLOCK	1			;UNIVERSAL DATE/TIME
STOPCD:	BLOCK	1			;LAST STOPCODE

PKTLEN:	BLOCK	1			;MAXIMUM PACKET LENGTH
DEFQTA:	BLOCK	1			;DEFAULT QUOTAS
PKTSNT:	BLOCK	1			;TOTAL PACKETS SENT
PKTOUT:	BLOCK	1			;TOTAL PACKETS OUTSTANDING
PIDMSK:	BLOCK	1			;PID MASK
PIDNUM:	BLOCK	1			;NUMBER OF PIDS DEFINED
PIDSRL:	BLOCK	1			;TOTAL PIDS DEFINED SINCE RELOAD
PICNUM:	BLOCK	1			;IPCF PAGES IN CORE
IPCCNT:	BLOCK	1			;IPCF PAGES SWAPPED
TWTNUM:	BLOCK	1			;TOTAL WORDS TRANSFERED
TPTNUM:	BLOCK	1			;TOTAL PAGES TRANSFERED

OLDMOD:	BLOCK	1			;PREVIOUS MODE
OLDSCR:	BLOCK	1			;OLD SCROLL VALUE
HLPMOD:	BLOCK	1			;OLD MODE (FOR HELP)

SBEG:!					;START OF SWITCH STORAGE

S.AUTO:	BLOCK	1			;AUTO-SCROLL
S.CTX:	BLOCK	1			;CONTEXT NUMBER
S.DPY:	BLOCK	1			;DISPLAY
S.FILE:	BLOCK	<FILSIZ/5>+1		;ASCIZ FILESPEC
S.INCL:	BLOCK	MODNUM			;INCLUDED COLUMN BITS
S.JOB:	BLOCK	1			;JOB NUMBER
S.MODE:	BLOCK	1			;MODE
S.ORIG:	BLOCK	1			;ORIGIN OF DISPLAY (MONITOR OR FILE)
S.PERF:	BLOCK	1			;PERFORMANCE
S.SCRO:	BLOCK	1			;SCROLL VALUE
S.SLEE:	BLOCK	1			;SLEEP TIME

SEND:!					;END OF SWITCH STORAGE

DP.PTR:	BLOCK	1
DP.LIN:	BLOCK	1
DP.LLN:	BLOCK	1
DP.OLN:	BLOCK	1
DP.BUF:	BLOCK	^D20+1
DP.AC:	BLOCK	20
DP.TRM:	BLOCK	1
DP.ARG:	BLOCK	1

ZEND:!					;END OF DATA TO ZERO AT STARTUP


	END	IPCF			;A GOOD PLACE TO BEGIN