Google
 

Trailing-Edge - PDP-10 Archives - bb-d549g-sb - sysdpy.mac
There are 31 other files named sysdpy.mac in the archive. Click here to see a list.
SUBTTL	SYSDPY %434(562) DYNAMIC SYSTAT FOR DISPLAYS
SUBTTL /PMW/RDH 25-MAY-79

	COMMENT	\

Copyright (C) 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979
Digital Equipment Corporation, Maynard, Massachusetts, U.S.A.

This software is furnished under a license and may be used and copyed 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 transferred.

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.

\
	SUBTTL	VERSION INFORMATION

SEARCH	SYSDPU			;SYSDPY'S CHEAP COPIES OF MONITOR'S SYMBOLS
SEARCH	JOBDAT,MACTEN,UUOSYM	;SYMBOL DEFINITIONS

;UNTIL THE GALAXY GROUP GETS THEIR ACT TOGETHER . . .
;IN PARTICULAR, THE SYMBOL "NETSTS" IN QSRMAC RIPS OFF SYSDPY
;SEARCH	GLXMAC,QSRMAC,ORNMAC	;FOR QUEUES SYMBOLS

;GALAXY SYMBOLS
	ARG.DA==1
	ARG.HD==0
	LIQALL==766B8
	WT.MOR==1B1
	.LSQUE==0
	.OARGC==4
	.OFLAG==3
	.OHDRS==5
	.ORDSP==105
	.QOLIS==10
;END GALAXY SYMBOLS



SALL				;PRETTIER LISTINGS
.DIREC	FLBLST			;PRETTIER LISTINGS



;THE VERSION NUMBERS

MAJVER==434	;MAJOR (RELEASE) VERSION
MINVER==0	;MINOR (MAINTENANCE) LEVEL
EDTVER==562	;EDIT LEVEL
CSTVER==0	;CUSTOMER EDIT LEVEL

LOC	.JBVER
BYTE	(3)CSTVER(9)MAJVER(6)MINVER(18)EDTVER
RELOC
	SUBTTL	EDIT HISTORY

;EDIT LEVEL 471 TO 472

;EDIT 1  SYSVBX DID NOT RUN WITHOUT A CORE ARGUMENT ,AS  CORE
;	  EXPANSION WAS DONE AFTER A LOCK UUO

;EDIT 2 ASSIGN AND INIT VALUES WERE NO LONGER PRINTED BY VERSION471
;	 FOR DEVICES

;EDIT LEVEL 472 TO 474

;EDIT 3 UNMARKED ADD SUPPORT FOR VM SYSTEMS

;EDIT 4 ALWAYS USE REFRESH MODE FOR VM DISPLAY

;EDIT 5 USE IMGIN FOR SIZE OF LOW SEGMENTS ON VM SYSTEMS

;EDIT 6 FOR NONSHARABLE SEGMENTS ON VM SYSTEMS USE RIGHT HAND
;	9 BITS OF LEFT HALF WORD OF JBTSWP ENTRY

;EDIT 7 UPDATE HELP TEXT FOR M COMMAND AND ADD HELP TEXT
;	FOR USERS WITHOUT SPY OR PEEK PRIV. USINF F COMMAND

;EDIT 8 UPDATE SECOND LINE OF VM DISPLAY 

;EDIT 9  DISPLAY WARNINGS ONLY ONCE
;	 TO THE NORMAL DISPLAY
;	ENTRY IN THE N DISPLAY

;EDIT 10 REPORT K OR P IN SWAP STATISTICS

;EDIT 11 THE AMOUNT OF SWAPPING SPACE USED IS COMPUTED WRONLY
;	 FOR KI SYSTEMS

;EDIT 12 THE SWAP ERROR COUNT IS COMPUTED IN THE WRONG WAY
;	 THIS MAY GIVE UNREASONABLY HIGH NUMBER OF ERRORS

;EDIT 13 INCREASE THE SLEEP TIME OF SYSDPY FROM 5 TO 10 SECONDS

;EDIT 14 SINCE VERSION 50665 MSK4KS IS 13 BITS

;EDIT 15 UNPRIVILIGED USERS DID NOT GET AN AUTOMATIC SCREEN REFRESH
;	 AFTER A WARNING

;EDIT 16 NEW VM DATA IN JOBVRT INTEGRATED

;EDIT 17 SINCE 678 LOAD JBT VRT IS OKAY SO UPDATE PGDATA LOGIC
;EDIT LEVEL 505 TO 506

;EDIT 18 CORRECT PRINTOUT OF VM DATA FOR INDIVIDUAL JOBS
;	 AND UPDATE SOME COMMENTS

;EDIT 19 PRINT CORRECT SWAPPING RATIO CORRECT EDIT 11
;	 AND USE RIGHT ACCU

;EDIT 20 LINE NUMBER OF JOBS IS WRONG FOR MONITORS OLDER
;	 THAN 503 NOT HAVING THE GETTAB ENTRY FOR DDBLDB

;EDIT 21 CORRECT CODE PRINTING LIMIT VALUES FOR SYSTEM
;	 AND USER PAGING RATES.NOTE: THIS EDIT IS NOT MARKED IN THE
;	 SOURCE

;EDIT 22 PRINT CORRECT SYSTEM PAGING RATE
;	 NOTE: EDIT NOT MARKED IN LISTING

;EDIT 507 VTO5-B DOES NOT WORK ON DC72 AT 2400 BAUD AS FILL CHARACTER
;	  0 DISAPPEARS THIS IS DUE TO THE DC72 BEING ASSEMBLED 
;	  FEATURE SWITCH FTTOFN .NEQ. 0
;	  THIS EDIT IS ONLY FOR DOCUMENTATION

;EDIT 510 GIVE STRANGE OPERATING SYSTEMS AND UNPRIVILIGED USERS A CHANCE
;	  TO SEE LINE NUMBERS BY USING THE TRMNO. AND DEVNAM UUO

;EDIT 511 ADAPT TO NEW NUMTAB FORMAT USE LOAD 721 AS THE TRANSACTION
;	  NUMTAB CONTAINS ENTRY TYPE VALUE

;EDIT 512 BELIEVE IN NEW DEVJOB ENTRY IN DDB'S

;EDIT 513 MAKE F DISPLAY PAGEABLE

;EDIT 514 CORRECT DEVICE LOGIC FOR 602 

;EDIT 515 CLEAN UP CHARACTER INPUT LOGIC

;EDIT 516 MAKE C FILE A UNIVERSAL

;EDIT 517 CLEAN UP ERRORS IN PAGED F DISPLAY

;EDIT 520 WAIT A LITTLE BETWEEN DISPLAYS SO ONE CAN
;	   READ THE DISPLAY

;EDIT 521 REFRESH THE SREEN WHEN CHANGING THE DISPLAY PROGRAM

;EDIT 522 FIX THE DISAPEARING M DISPLAY

;EDIT 523 FIX REFRESH PROBLEM

;EDIT 524	ONLY ESCAPE COULD ESCAPE FROM A FROZEN SCREEN ALLOW ANY
;		CHARACTER
;EDIT 525	USE HRRZ FOR GETTING MONVER

;EDIT 526	PEEK FACILITY WAS NOT RECOGNIZED

;EDIT 527	DONOT DISPLAY AN EMPTY F DISPLAY SCREEN

;EDIT 530	ADAPT TO CHANGED JUMPPT MACRO

;EDIT 531	UNPRIVILIGED JOBS GET DATA FOR CPU1 ON A SINGLE
;		CPU SYSTEM

;EDIT 532	ADD HISEG SIZE TO MONITOR SIZE

;edit 533	search universal jobdat file for jobdat symbols

;edit 534	jobs locked into core cannot refresh the screen

;edit	535	too many " dev by how headers" are printed when
;		display ends at bottom of a column

;edit 536	d display hangs for unpriviliged users

;edit 537	d display contains extra right paren between w column
;		and swap ratio column
;edit 540	add vt61 support
;edit	541	add vt50 supprot
;edit	542	add vt52 support
;edit	543	add network topology "wt" display
;edit	544	add network statistics display
;edit	545	add individual print line for one job on normal display
;edit	546	add control R and A for VT61 support
;edit	547	make edits 540 thru 547 work
;edit	550	make edit 542 work
;edit	551	Fix averages of edit 544
;edit	552	Fix DEVJOB so owner of device is correct
;EDIT	553	VT50 CANNOT (IN GENERAL) CURSOR ADDRESS; NTAVG VALUE FOR
;		"\" DISPLAY WRONG (MONITOR INFORMATION STILL ALMOST
;		USELESS HOWEVER); "T" HISTOGRAM POWERS OF 2 OFF BY ONE;
;		"DEVICE BY HOW" FIELD TOO SMALL FOR "HOW" FOR 5 & 6 CHAR
;		DEVICE NAMES (IF 72-COLUMN TERMINAL ONLY 2 COLUMNS CAN
;		NOW FIT ON SCREEN); DON'T SHOW HISEG STUFF ON VT50 SINCE
;		IT CONFLICTS WITH DEV BY HOW FIELD (AND NEITHER WORKS AS
;		A RESULT); ALLOW FOR 3-DIGIT NODE NUMBERS IN "T" DIS-
;		PLAY; IMPLEMENT "O" COMMAND TO TOGGLE SUPPRESSION OF
;		[OPR] JOBS ON "N" AND "M" DISPLAYS

;EDIT	554	FIX ^A AND ^R COMMANDS - ALSO, IF REVERSE VIDEO MODE
;		AND REFRESHING, REFRESH SCREEN IN NORMAL MODE THEN GO
;		BACK TO REVERSE VIDEO FOR UPDATING; ON EXIT CLEAR BOTH.
;EDIT	555	GETTAB THE PJOBN INFO (7.01) IF POSSIBLE; DON'T SHOW THE
;		DUMMY DDB'S USED FOR TAPE LABELING; SHOW TTY DDB'S NOT
;		CONTROLLING A JOB (I.E., IN USE AS AN I/O DEVICE)

;EDIT	556	USE .GTNDB TABLE IF EXTANT FOR NDB POINTERS. CLEANUP.

;EDIT	557	DON'T PRINT INCREMENTAL SYSTEM UPTIMES
;		CALL VERSION 434

;EDIT	560	PRINT TRUE USER MEMORY AVAILABLE. ADD "L" COMMAND
;		TO LOG THE SCREEN IN LPT:SYSDPY.LOG[-].

;EDIT	561	ADD "Q" COMMAND TO LIST THE QUEUES, COMPRESS "T"
;		DISPLAY TO ALLOW FOR MORE NEIGHBORS. ADD (KL ONLY)
;		RH20 AND PI USAGE DISPLAYS TO "N" DISPLAY.

;EDIT	562	ADD "N+" AND "N-" COMMANDS. SHOW SECOND UNIT OF DUAL-
;		PORTED DISKS IN "F" DISPLAY. (NOTE THAT THIS DEPENDS ON
;		DSKCHR RETURNING THE SECOND PORT INFORMATION, WHICH
;		IT DOESN'T IN EARLY 7.00 MONITORS. DATE PRINTED WRONG.
;		SHOW CACHE SWEEPS ON KS-10 ALSO. "J" DISPLAY DIDN'T DO
;		INCREMENTAL RUNTIMES CORRECTLY. NEW VALUES FOR GALAXY
;		SYMBOLS. LOG TO DSK:SYSDPY.LOG INSTEAD. CLEAR BOTTOM OF
;		SCREEN ON EXIT (GENERAL VOTE SEEMS TO PREFER THIS OVER
;		CLEARING ENTIRE SCREEN AND POSITIONING TO HOME).
	SUBTTL	AC ASSIGNMENTS
;
;NOTE THAT HELP PROGRAM USES ACS 0-6 IN UNUSUAL WAY

M=0
A=1
B=2
C=3
D=4
J=5
JS=<XCUR==6>
R=<YCUR==7>
N=10
N1=11
F=12
BP=13
T1=14
T2=15
CH=16
P=17

.XCREF	M,A,B,C,D,J,JS,R,N,N1,BP,T1,T2,CH,P  ;SAVE SOME PAPER

;I/O CHANNELS
TTY==1		;NORMAL DISPLAY OUTPUT (CHARACTER TERMINAL)
DIS==1		;VIDEO DISPLAY
HLP==3		;HELP FILE CHANNEL
LOG==4		;SCREEN LOGGING CHANNEL
	SUBTTL	DISPLAY PARAMETERS

V.DVT6==0	;DIGITAL VT06
V.DV5A==1	;DIGITAL VT05A
V.DV5B==2	;DIGITAL VT05B
V.DVBX==3	;DIGITAL VB10C
V.DV61==4	;DIGITAL VT61 DISPLAY
V.DV50==5	;DIGITAL VT50 DISPLAY
V.DV52==6	;DIGITAL VT52 DISPLAY
V.DHZL==20	;HAZELTINE 2000
V.DDLT==21	;DELTA DATA TELTERM
;RECOMMEND CUSTOMERS ASSIGN NEGATIVE VALUES

ND	V.DISP,V.DV52		;DEFAULT TO DIGITAL VT52
IFE V.DISP-V.DVT6,<
	TITLE	SYSDPY -- SYSTEM DISPLAY FOR DIGITAL VT06 DISPLAY TERMINAL

	XSIZE==^D72		;WIDTH OF SCREEN
	YSIZE==^D25		;HEIGHT OF SCREEN

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D100		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CFILL==177		;FILLER CODE
	CDOWN==12		;CURSOR DOWN
	CUP==32			;CURSOR UP
	CLEFT==31		;CURSOR LEFT
	CRIGHT==30		;CURSOR RIGHT
	HOMEUP==35		;CURSOR TO HOME
	ERASE==37		;ERASE TO END OF SCREEN
	EREOL==36		;ERASE TO END OF LINE
>;	END OF	IFE V.DISP-V.DVT6
IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>,<
IFE V.DISP-V.DV5A,<
	TITLE	SYSDPA -- SYSTEM DISPLAY FOR DIGITAL VT05A DISPLAY TERMINAL>
IFE V.DISP-V.DV5B,<
	TITLE	SYSDPB -- SYSTEM DISPLAY FOR DIGITAL VT05B DISPLAY TERMINAL>

	XSIZE==^D72
	YSIZE==^D20

ND	UPDNJB,^D15		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D1000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CFILL==0
	CDOWN==12
	CUP==32
	CLEFT==31
	CRIGHT==30
	HOMEUP==35
	ERASE==37
	EREOL==36
>;	END OF IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>
IFE V.DISP-V.DVBX, <
	TITLE	SYSVBX -- SYSTEM DISPLAY FOR DIGITAL VB10C INCREMENTAL PRECISION DISPLAY

	XSIZE==^D72
	YSIZE==^D25

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CDOWN==12
	CUP==32
	CLEFT==31
	CRIGHT==30
	HOMEUP==35
	ERASE==37
	EREOL==36
>;	END OF	IFE V.DISP-V.DVBX
IFE V.DISP-V.DV50,<
	TITLE	SYSV50 -- SYSTEM DISPLAY FOR DIGITAL VT50 DECSCOPE

	XSIZE==^D80
	YSIZE==^D12

ND	UPDNJB,^D8		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CUP=="A"_^D9 + .CHESC
;	CDOWN=="B"_^D9 + .CHESC
	CDOWN==12
	CRIGHT=="C"_^D9 + .CHESC
;	CLEFT=="D"_^D9 + .CHESC
	CLEFT==010
	HOMEUP=="H"_^D9 + .CHESC
	ERASE=="J"_^D9 + .CHESC
	EREOL=="K"_^D9 + .CHESC
>;	END V.DISP-V.DV50
IFE V.DISP-V.DV52,<
	TITLE	SYSV52 -- SYSTEM DISPLAY FOR DIGITAL VT52 DECSCOPE

	XSIZE==^D80
	YSIZE==^D24

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CUP=="A"_^D9 + .CHESC
	CDOWN=="B"_^D9 + .CHESC
	CRIGHT=="C"_^D9 + .CHESC
	CLEFT=="D"_^D9 + .CHESC
	HOMEUP=="H"_^D9 + .CHESC
	ERASE=="J"_^D9 + .CHESC
	EREOL=="K"_^D9 + .CHESC
>;	END V.DISP-V.DV52
IFE V.DISP-V.DV61,<
	TITLE	SYSV61 -- SYSTEM DISPLAY FOR DIGITAL VT61 DECSCOPE

	XSIZE==^D80
	YSIZE==^D24

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CUP=="A"_^D9 + .CHESC
	CDOWN=="B"_^D9 + .CHESC
	CRIGHT=="C"_^D9 + .CHESC
	CLEFT=="D"_^D9 + .CHESC
	HOMEUP=="H"_^D9 + .CHESC
	ERASE=="J"_^D9 + .CHESC
	EREOL=="K"_^D9 + .CHESC
>;	END V.DISP-V.DV61
IFE V.DISP-V.DHZL, <
	TITLE	SYSHZL -- SYSTEM DISPLAY FOR HAZELTINE 2000 DISPLAY TERMINAL

	XSIZE==^D74
	YSIZE==^D27

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CDOWN==12
	CUP==32
	CLEFT==31
	CRIGHT==30
	HOMEUP==35
	ERASE==37
	EREOL==36
>;	END OF	IFE V.DISP-V.DHZL
IFE V.DISP-V.DDLT, <
	TITLE	SYSDLT -- SYSTEM DISPLAY FOR DELTA DATA TELTERM DISPLAY TERMINAL

	XSIZE==^D80
	YSIZE==^D27

ND	UPDNJB,^D20		;NUMBER OF JOBS TO +-
ND	NSYSYS,1		;LINE TO START SYSTEM DISPLAY IN "N"
ND	REPRAT,^D10000		;NUMBER OF PASSES BEFORE REFRESH FORCED

	CDOWN==12
	CUP==32
	CLEFT==31
	CRIGHT==30
	HOMEUP==35
	ERASE==37
	EREOL==36
>;	END OF	IFE V.DISP-V.DDLT
	SUBTTL	ASSEMBLY PARAMETERS

ND	FTNET,-1	;DEFAULT NETWORK DISPLAY ON

ND	PDLEN,^D20	;PUSH DOWN STACK LENGTH
ND	JIFSEC,^D60	;LINE FREQ IF NO GETTAB
ND	INTVAL,^D10	;NUMBER OF SECONDS BETWEEN UPDATES
ND	RELOCK,^D1000	;# PASSES BEFORE CANCELLING /V
ND	DSKBKL,20	;LENGTH OF DSKCHR BLOCK
ND	XDBLEN,^D64	;SCRATCH DATA BLOCK LENGTH
ND	IPCPAG,377	;IPCF PAGE TO USE
HSIZE==^D39
SUBTTL PARAMETERS AND DEFINITIONS

;FLAGS (LH OF F)

FL.SUP==1	;SUPPRESS OUTPUT
FL.DEV==2	;DEVICE HEADER OUTPUT
FL.GOD==4	;I AM [1,N]
FL.FLS==10	;TOGGLE FOR FLASHING LINES
FL.INC==20	;TOGGLE DISPLAY OF INCREMENTAL STATISTICS
FL.DOR==40	;DORMANT SEG TABLE BEING PRINTED
FL.SCN==100	;NEW SCANNER SERVICE (FOR TTYTAB LAYOUT)
FL.SPY==200	;SPY UUO DONE SUCCESSFULLY
FL.EOL==400	;SYNC FOR CLEAR EOL IN OUTPUT
FL.LOG==1000	;LOGGING EACH SCREEN
FL.REF==2000	;ONE FOR FULL REFRESH PASS, 0 FOR PARTIAL
FL.PDOR==4000	;FIRST OR SECOND HISEG PASS
FL.NBK==10000	;NON-BLANK LINE
FL.HLP==20000	;LAST TYPEIN WAS JUNK--FLASH HELP
FL.PEK==40000	;PEEK UUO DONE SUCCESSFULLY
FL.NHED==100000	;NO HEADING ON 2ND COLUMN
FL.LOCK==200000	;JOB IS LOCKED INTO CORE
FL.CRF==400000	;GIVE A FREE CRLF AT RIGHT MARGIN IF NEEDED

;FLAGS (RH OF F)

FR.JOB==1B18	;JOBS ONLY (MULTI-COLUMN) IN "N" DISPLAY
FR.SJB==1B19	;EXPANDED JOB (72 CHARS WIDE), NO SYSTEM STUFF
FR.ALT==1B20	;SINGLE PASS ALTMODE
;FR.SKP==1B21	;***UNUSED****
FR.DIS==1B22	;DISPLAY INITIALIZED
FR.KIX==1B23	;RUNNING ON A KI-10
FR.KIP==1B24	;CORE ALLOCATION IS IN PAGES
FR.PDB==1B25	;FLAG FOR SPY TABLE INITILIZATION
FR.VMM=1B26	;FLAG THAT THERE IS VM DISPLAY
FR.VMO=1B27	;MONITOR HAS VM OPTION
FR.NRM==1B28	;DISPLAY NORMAL PROGRAM AGAIN
FR.RVD==1B29	;REVERSE VIDEO
FR.RVR==1B30	;REVERSE VIDEO REFRESH RESET
FR.ALR==1B31	;ALARM MODE

	;STATUS BITS TO INITIALIZE

	;STATUS BITS TO PRESERVE
FX.MSK==FL.GOD!FL.FLS!FL.INC!FL.SCN!FL.SPY!FL.LOG!FL.REF!FL.HLP!FL.PEK!FL.LOCK,,FR.SJB!FR.ALT!FR.DIS!FR.KIX!FR.KIP!FR.VMO!FR.RVD!FR.RVR!FR.ALR
OPDEF	CALL	[PUSHJ	P,]
OPDEF	RETURN	[POPJ	P,]

DEFINE	SET	(LT,RT,TOP,BOT,NEXT,TABS)<
	PUSHJ	P,SETUP
	XX=10
	RADIX	10
	BYTE	(7)LT-1(7)RT-LT(5)TOP-1,BOT-1(2)NEXT(10)TABS-TAB0
	RADIX	XX
>

DEFINE	TABSET	(TABS)<
	PUSHJ	P,TSETUP
	EXP	TABS-TAB0
>

DEFINE	CHANGE	(LT,RT,TOP,BOT,NEXT,TABS)<
	FIN
	SET	LT,RT,TOP,BOT,NEXT,TABS
>

DEFINE FIN <
	TLO	F,FL.NHED	;SET TO SUPPRESS SECOND HEADING
	PUSHJ	P,CRLF		;CLEAR ALL REMAINING SPACE
	SKIPL	LINE
	JRST	.-2
	TLZ	F,FL.NHED
>

DEFINE	HEADER(TEXT,%L) <
	CALL	SETHDR		;REMEMBER HEADER CODE
	JRST	%L		;SKIP HEADER
	PUSH	P,M		;;SAVE M
	TEXT
	POP	P,M		;;GET REGISTER BACK
	RETURN
%L:
>
	SUBTTL	PSEUDO OPERATIONS

;THE FOLLOWING MACROS ALLOW THE DEFINITION OF PSEUDO OPCODES

;OPCODES

.OPTXT==0		;TEXT TO BE PRINTED
.OPGTD==1		;PRINT GETTAB X,Y IN DECIMAL
.OPNWL==2		;A NEW LINE
.OPSTP==3		;END OF PSEUDO PROGRAM
.OPPLD==4		;PRINT LEFT HALF IN DECIMAL
.OPPRD==5		;PRINT RIGHT HALF IN DECIMAL
.OPGTB==6		;GETTAB VALUE
.OPPFS==7		;PRINT A FLOAT SCALED
.OPTAB==10		;PRINT ATAB CHARACTER
.OPLPA==11		;PRINT A LEFT PAREN
.OPRPA==12		;PRINT A RIGHT PAREN
.OPPER==13		;PRINT A PERIOD
.OPPLS==14		;PRINT A PLUS SIGN
.OPPRP==15		;PRINT RIGHT DECIMAL PADDED

.OPMAX==15		;LAST ONE
	DEFINE	.TXT(TEXT)
<	BYTE	(9).OPTXT(9)0(18)[ASCIZ \TEXT\]
>
	DEFINE	.PGTBD(X,Y)
<	BYTE	(9).OPGTD(9)X(9)0(9)Y
>
	DEFINE	.NWLIN
<	BYTE	(9).OPNWL(27)0
>
	DEFINE	.END
<	BYTE	(9).OPSTP(27)0
>
	OPDEF	.PLD[4B8]
	OPDEF	.PRD[5B8]
	DEFINE	.GTB(X,Y,WHERE)
<	BYTE	(9).OPGTB(9)X(18)Y
	Z	WHERE
>
	OPDEF	..PRDP[15B8]

	DEFINE	.PRDP(WHERE,FACTOR)
<	..PRDP	WHERE
	EXP	FACTOR
>

	OPDEF	..PFLS[7B8]
	DEFINE	.PFLS(WHERE,SCALE)
<	..PFLS	WHERE
	EXP	SCALE
>
	DEFINE	.INL(%L)
<	MOVEI	A,.+2		;;GET PSEUDO PC
	JRST	PSEUDO		;;AND START PSEUDO INTERPRETATION
>
	DEFINE	.TAB
<	BYTE	(9).OPTAB(27)0
>
	DEFINE	.LPA
<	BYTE	(9).OPLPA(27)0
>
	DEFINE	.RPA
<	BYTE	(9).OPRPA(27)0
>
	DEFINE	.PER
<	BYTE	(9).OPPER(27)0
>
	DEFINE	.PLS
<	BYTE	(9).OPPLS(27)0
>
SUBTTL TOP LEVEL PROGRAM
;START HERE

SYSDPY:	JFCL			;ALLOW FOR CCL ENTRY
	HLRZ	1,.JBSA		;GET INITIAL .JBFF
	CAME	1,.JBFF		;COMPARE AGAINST CURRENT VALUE
	JRST	SYSDP1		;DIFFERENT--MUST BE RESTART
	JUMPE	.SGDEV,SYSDPG	;MUST BE FROM LOADER ITSELF(AC1 NOT -1)
	MOVSI	1,'SAV'		;MAKE .SAV FILE
	MOVE	3,.SGPPN	;GET DIRECTORY
	SETZB	10,12		;PREPARE OPEN
	OPEN	.SGDEV-1	;OPEN FILE
	  JRST	SYSDP1		;GIVE UP IF CAN'T FIND IT
	LOOKUP	.SGNAM		;LOOKUP NAME OF THIS PROG
	  JRST	SYSDP0		;NOT THERE
	LSH	2,-33		;POSITION PROTECTION
	HRLI	2,.ACWRI	;CHECK WRITE ACCESS
	HRROI	4,.GTPPN	;GET MY PPN
	GETTAB	4,		;FROM THE MONITOR
	  JRST	SYSDP0		;NONE--GIVE UP
	SKIPN	3,.SGPPN	;GET FILE DIRECTORY
	MOVE	3,4		; DEFAULT TO SELF
	MOVEI	1,2		;POINT TO ARGS
	CHKACC	1,		;CHECK FILE ACCESS
	  JRST	SYSDP0		;GIVE UP
SYSDPG:	SETCAM	1,GODLY		;SAVE FLAG NE 0 IF GOD
SYSDP0:	RELEAS			;CANCEL OPEN
SYSDP1:	SETZM	GODLY		;NO FALSE GODS THERE EXIST ENOUGH
	AOS	.JBFF		;FLAG THAT DONE

;HERE TO ACTUALLY START INITIALIZATION
	SETZB	0,ZER		;CLEAR OUT SCRATCH
	MOVE	A,[ZER,,ZER+1]
	BLT	A,LZER
	MOVEI	17,1		;CLEAR
	BLT	17,16		; ACS
	MOVE	P,[IOWD PDLEN,PDLST]  ;INITIALIZE PDL POINTER
	SETZ	F,		;NO FLAGS
	SETOM	.FRAJR		;AUTOMATIC ROLL FEATURE
	JUMPPT	A,,KA10		;SEE IF KI-10
	TRO	F,FR.KIX!FR.KIP	;YES--SET FLAG
KA10:	MOVE	A,[%CNVER]	;GET MONITOR VERSION
	GETTAB	A,		;GET MONITOR VERSION VIA UUO!!
	 SETZM	A		;VERY OLD!!
	MOVEM	A,MONVER	;  TESTS
	MOVX	A,%CNDJB	;ASK MONITOR FOR
	GETTAB	A,		;PJOBN/DEVJOB INFORMATION
	 MOVE	A,[POINT 9,20,35]  ;6-SERIES MONITORS
	HRRM	A,PJOBNO	;SAVE DEVJOB INDEX
	HLLM	A,PJOBNP	;AND POINTER TO JOB NUMBER IN SAME
SYSD00:	MOVX	A,%CNPGS	;GET "PAGE" SIZE
	PUSHJ	P,GETZ		;FROM MONITOR
	JFFO	A,.+1		;COUNT BITS
	MOVN	B,B		;NEGATIVE LEADING ZEROS
	ADDI	B,^D35		;POSITIVE TRAILING ZEROS
	MOVEM	B,P2WLSH	;SO CAN LSH @P2WLSH
	MOVN	B,B		;NEGATIVE
	HRRZM	B,W2PLSH	;SO CAN LSH @W2PLSH
	SETZM	DUAL		;ASSUME ONE CPU
	MOVE	A,[%CNSTS]	;GET STATUS WORD
	PUSHJ	P,GETA		;IN A
	TLNE	A,(ST%DUL)	;A DUAL PROCESSOR SYSTEM
	SETOM	DUAL		;YES FLAG IT
	MOVE	A,[%CNTIC]	;NO OF TICKS PER SECOND
	PUSHJ	P,GET		;GETTAB PRESENT?
	  MOVEI	A,JIFSEC	;NO, PRESET JIFFY CLOCK
	MOVEM	A,TCKSEC
	MOVEI	A,NORMAL	;SET NORMAL PROGRAM ON ENTRY
	MOVEM	A,PROGRM	;SAVE DISPLAY PROGRAM ADDRESS
	RESET			;RESET THE WORLD
	AOS	.JBFF		;SET FLAG THAT WE ARE STARTED
	HRROI	A,.GTPRV	;GET OUR PRIVS
	PUSHJ	P,GETZ		; FROM MONITOR
	TXNE	A,JP.SPM	;SEE IF CAN SPY ON MONITOR
	TLO	F,FL.GOD	;YES--SET GOD FLAG
	PUSHJ	P,OPNTTY	;OPEN THE TTY CHANNEL
	MOVE	A,XGETTS	;GETTAB SELF TABLE
	PUSHJ	P,GETZ		;GET IT
	JUMPE	A,START		;OK?
	MOVEM	A,GTTSLF	;SAVE SELF POINTER
	MOVE	A,XPDBPT	;PTR TO PTR TO PDB'S
	PUSHJ	P,GETZ		;GET PTR TO PDB'S
	SKIPLE	A		;SKIP IF ABSENT
	TDO	A,[XWD N1,400000];SET BIT FOR SPYING
	SKIPL	A		;SEE IF SWAPPING PDBS
	JRST	NSWPDB		;NO--CONTINUE
	TRNE	F,FR.KIX	;SEE IF KI-10
	MOVEI	A,0		;KI SWAP PDB--CLEAR POINTER
NSWPDB:	MOVEM	A,PDBPTR	;AND SAVE FOR SPYING
	MOVE	A,XSYSSZ	;HOW MUCH TO ASK FOR IN SPY
	PUSHJ	P,GETA
	MOVEI	A,-1(A)
	SPY	A,		;ASK FOR IT
	SKIPA			;CAN'T HAVE IT
	TLO	F,FL.SPY	;GOT IT. REMEMBER IT
	HRRZ	A,GTTSLF	;GET A NON ZERO LOCATION
	PUSHJ	P,MPEEK		;PEEK OR SPY
	SKIPE	A		;  0, PEEK FAILED
	TLO	F,FL.PEK	;  ELSE SHOW PEEK WORKS

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

START:	TXZ	F,FR.VMO	;ASSUME NO VIRTUAL MONITOR
	MOVE	A,[%CNST2]	;GET FEATURE WORD
	CALL	GETZ		;GET IT OR A ZERO
	TXNE	A,ST%VMS	;VM??
	TXO	F,FR.VMO	;(YES) REMEMBER IT
	PUSHJ	P,IJBDAT	;READ SYSTEM PARAMETERS
	SKIPN	TTYFLG		;CAN WE GET TTY DATA
	TLNE	F,FL.PEK!FL.SPY	;SPYING OR PEEKING POSSIBLE?
	JRST	START0		;YES THEN NO SURPRISES
	MOVEI	A,NOSPPK	;NO SPY OR PEEK WARNING
	MOVEM	A,PROGRM	;SET THE PROGROM WORD
START0:	MOVEI	A,CCINT		;SETUP ^C INTERCEPT
	MOVEM	A,.JBINT	; TO RELEASE /V MODE
	SETZM	CCIOPC		;  CLEAR OLD PC ON RESTART
;(START OF EDIT 1 PART 1)
	IFE	V.DISP-V.DVBX,<
	MOVEI	A,1		;PREPARE TO LOCK LOW SEGMENT
	LOCK	A,		;TRY TO LOCK
	JRST	[OUTSTR	[ASCIZ	/?LOCK FAILED
/]
		EXIT]
>	;END OF IFE V.DISP-V.DVBX	(END OF EDIT 1 PART1)
;	LOOP HERE TO REFRESH ENTIRE SCREEN

SYSTT0:	TLNN	F,FL.GOD	;SEE IF GOD
	TRNE	F,FR.NRM	;DO NOT GO TO ALTMOD WHEN
	SKIPA			;EITHER GODLY OR GETTING NORMAL
	TRO	F,FR.ALT	;NO--TIME TO STOP AUTO UPDATES
SYSTT1:	TLO	F,FL.REF	;SHOW FULL-REFRESH PASS
	MOVE	A,[XWD 240240,240240]
	MOVEM	A,DBUF
	MOVE	A,[XWD DBUF,DBUF+1]
	BLT	A,DBFEND
	PUSHJ	P,CLEAR		;CLEAR SCREEN AT FIRST
	MOVNI	A,REPRAT
	MOVEM	A,REPS
IFN	V.DISP-V.DVBX,<
	PUSHJ	P,HOME
	PUSHJ	P,FRCOUT	;FORCE OUTPUT
> ;END OF IFN V.DISP-V.DVBX
IFE	V.DISP-V.DHZL, <
	PUSHJ	P,HOME		;PUT OUT A SECOND HOME FOR HAZELTINE
> ;END OF IFE V.DISP-V.DHZL

;	LOOP HERE TO UPDATE SCREEN

REENT:	IFN	V.DISP-V.DVBX,<
	PUSHJ	P,HOME
	PUSHJ	P,FRCOUT	;FORCE OUTPUT
> ;END OF IFN V.DISP-V.DVBX
	TDZ	F,[-1-FX.MSK]	;CLEAR MOST FLAGS
IFE	V.DISP-V.DV61,<		;IF SYSV61
	TLNN	F,FL.REF	;REFRESH PASS?
	TRZN	F,FR.RVR	;NO - TIME TO RETURN TO REVERSE VIDEO?
	CAIA			;LEAVE VIDEO ALONE
	PUSHJ	P,RVIDEO	;NEED TO RESTORE REVERSE VIDEO AFTER REFRESH
> ;END OF IFE V.DISP-V.DV61
REENT0:	SETOM	NLTYPD		;FLAG SOMETHING TYPED
	CALL	@PROGRM		;GO TO CURRENT DISPLAY PROGRAM
	SKIPN	NLTYPD		;ANYTHING TYPED
	JRST	REENT0		;NO GET NEXT PAGE

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;HERE AT END OF SCREEN CONSTRUCTION TO OUTPUT SCREEN AND DO OVERHEAD

FINIS:	FIN			;COMPLETE SCREEN
	TLCN	F,FL.FLS	;COMPLEMENT FLASHER
	TLNN	F,FL.HLP	;SEE IF HELP ADVISED
	JRST	FINISH		;NO-SKIP ADVISORY
	SET	55,XSIZE+1,YSIZE,YSIZE+1,0,TAB0
	MOVEI	M,[ASCIZ / Type H for Help/]
	PUSHJ	P,MSG
FINISH:	TLNE	F,FL.LOG	;LOGGING SCREENS?
	PUSHJ	P,LISCR		;YES, LIST THIS SCREEN

IFE	<V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV52>,<
	TLNN	F,FL.REF	;SEE IF REFRESH CYCLE
	JRST	FINISQ		;NO--USE DIRECT CURSOR ADDRESSING
				;YES--DO IT THE LONG WAY
> ;END OF IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV52>
IFE	<V.DISP-V.DVT6>*<V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>,<
;	BUFFER DUMP ROUTINE FOR INCREMENTAL POSITIONING DISPLAYS (VT06)

	MOVE	BP,[POINT 9,DBUF]
	PUSHJ	P,HOME
	SETZB	C,D		;CURRENT CURSOR POS
	SETZM	LINE
FIN5:	SETZM	COL
	TLZ	F,FL.EOL

FIN4:	PUSHJ	P,GETCH
	CAIN	T2,400!" "	;TEST FOR BLANK CHANGED TO BLANK
	MOVEI	T2," "		;  YES, CONVERT TO NORMAL BLANK
	TRNE	T2,400		;TEST FOR *SOMETHING* CHANGE TO BLANK
	MOVEI	T2,200!" "	;  YES, SHOW IT AS SUCH
	MOVE	CH,T2
	TRZN	CH,200		;NEW?
	TLNE	F,FL.EOL	;OR CONSIDERING BLANK LINE?
	PUSHJ	P,FINR		;YES
	AOS	T1,COL		;COUNT COLUMNS
	CAIGE	T1,XSIZE	;DONE LINE?
	JRST	FIN4

FIN3B:	TLNN	F,FL.EOL	;CLEAR LINE IN ORDER?
	JRST	FIN6		;NO
	MOVEI	CH,EREOL	;END OF LINE
	PUSHJ	P,DPYOUT
IFE	<V.DISP-V.DV5B>*<V.DISP-V.DVT6>,<
	PUSHJ	P,FILLIT	;ADD FILLERS
> ;END OF IFE <V.DISP-V.DV5B>*<V.DISP-V.DVT6>

FIN6:	AOS	T1,LINE
	CAIGE	T1,YSIZE	;DONE WITH LAST LINE?
	JRST	FIN5		;NO
	JRST	FINSLP
>;	END OF	IFE V.DISP-V.DVT6/DV51/DV5B/DV61/DV50/DV52
IFE	<V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV52>*<V.DISP-V.DHZL>*<V.DISP-V.DDLT>,<
;
;	BUFFER DUMP ROUTINE FOR ABSOLUTE POSITIONING DISPLAYS
;		(HAZELTINE 2000, DELTA DATA TELTERM, VT05)

FINISQ:	SETZB	XCUR,YCUR
	MOVSI	J,-<XSIZE*YSIZE-1> ;GET # OF CHARACTERS, -1
	MOVE	BP,[POINT 9,DBUF]
FINIS0:	ILDB	T2,BP
	CAIN	T2,400!" "	;TEST FOR BLANK CHANGED TO BLANK
	JRST	[MOVEI CH," "	;  YES, GET 'NORMAL' BLANK
		 DPB   CH,BP	;CLEAR BIT IN CHAR BUFFER
		 JRST  FINIS1]	;  & CONTINUE
	TRNE	T2,400		;TEST FOR *SOMETHING* CHANGED TO BLANK
	MOVEI	T2,200!" "	;  YES, CONVERT TO CHANGED BLANK
	TRZN	T2,200
FINIS1:	AOBJN	J,FINIS0
	JUMPGE	J,FINSLP
	DPB	T2,BP
	HRRZ	C,J
	IDIVI	C,XSIZE
	EXCH	C,D
IFE	V.DISP-V.DDLT, <
	CAIN	T2," "		;TEST FOR DELTA-DATA BLANK
	PUSHJ	P,DPYSPC	;  YES, GO LOOK FOR SPECIAL HANDLING
> ;END OF IFE V.DISP-V.DDLT
	CAIE	D,(YCUR)
	PUSHJ	P,DPYPOS
	CAIE	C,(XCUR)
	PUSHJ	P,DPYX
	MOVEI	CH,(T2)
	PUSHJ	P,DPYOUT
IFE V.DISP-V.DDLT, <
	CAIE	T2,23		;TEST FOR DELTA-DATA "CLEAR LINE"
	JRST	FINIS2		;  NO, JUMP
	SOS	XCUR		;BACK UP X-POSITION FOR NO-UPDATE
	MOVE	D,LASTCR(YCUR)	;GET LAST CHARACTER WRITTEN ON SCREEN
	MOVEM	XCUR,LASTCR(YCUR) ;  & UPDATE TO NEW POSITION
	SUB	D,XCUR		;  MINUS WHERE LAST CHARACTER WILL BE
	MOVMS	D		;GET MAGNITUDE OF CURSOR MOVEMENT
	ASH	D,-1		;  DIVIDE BY 2
	PUSHJ	P,DPYFIL	;PUT OUT A FILL CHARACTER
	SOJG	D,.-1		;REPEAT AS NECESSARY
FINIS2:	CAIGE	XCUR,XSIZE-1	;TEST FOR END OF DELTA-DATA LINE
	AOJA	XCUR,FINIS3	;  NO, UPDATE X-POSITION & JUMP
	MOVEM	XCUR,LASTCR(YCUR) ;SHOW CURRENT LAST-CHARACTER
	SETZ	XCUR,		;SHOW AT LEFT SIDE OF NEXT LINE
	AOJA	YCUR,FINIS1	;  NO, UPDATE Y-POSITION & REPEAT
FINIS3:	CAMLE	XCUR,LASTCR(YCUR) ;TEST FOR HIGHER VALUE
	MOVEM	XCUR,LASTCR(YCUR) ;  YES, UPDATE L/C POSITION
	JRST	FINIS1			;  & REPEAT
>;	END OF	IFE V.DISP-V.DDLT
IFN V.DISP-V.DDLT, <
	AOJA	XCUR,FINIS1	;UPDATE POSITION & REPEAT
>;	END OF	IFN V.DISP-V.DDLT
>;	END OF  <V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DHZL>*<V.DISP-V.DDLT>
IFE V.DISP-V.DVBX, <
	MOVE	A,[353535,,353535]
	MOVE	B,DISBES	;CLOBBER OLD JUMP
	MOVEM	A,(B)
	MOVEM	A,1(B)
	MOVE	A,[POINT 9,DBUF]	;POINT AT TEMP AREA
	MOVE	B,[POINT 6,DISBUF]	;POINT AT DISPLAY BUFFER
	MOVEI	J,YSIZE		;LINE COUNTER
DLP1:	MOVEI	JS,XSIZE	;COL. COUNTER
DLP2:	ILDB	CH,A		;GET NEXT CHARACTER
	TRZE	CH,400		;CLEAR BLANK CODE
	MOVEI	CH," "		;CONVERT TO SPACE
	ANDI	CH,177		;MASK TO ASCII
	CAIGE	CH,40		;SEE IF CONTROL
	JRST	DCNTRL		;YES--GO HANDLE
	CAIGE	CH,100		;SEE IF ALPHA
	JRST	DOK		;NO--MUST BE OK
	CAILE	CH,132		;SEE IF ALPHA
	JRST	DCNTRL		;NO--HANDLE
	SUBI	CH,100		;YES--CONVERT TO DISPLAY CODE
DOK:	PUSHJ	P,DSTORE	;STORE IN DISPLAY VECTOR
	SOJG	JS,DLP2		;LOOP ACROSS LINE
	MOVEI	CH,34		;STORE NEW-LINE
	PUSHJ	P,DSTORE	;  SEQUENCE
	MOVEI	CH,33		;  ..
	PUSHJ	P,DSTORE	;  ..
	SOJG	J,DLP1		;LOOP FOR ALL LINES
	MOVEI	CH,40		;GET A BLANK
DLP3:	HLRZ	C,B		;SEE IF AT MIDDLE OF WORD
	CAIN	C,300600	; ..
	JRST	DDONE		;YES--PROCEED
	IDPB	CH,B		;NO--STUFF A BLANK
	JRST	DLP3		;LOOP UNTIL DONE
DDONE:	MOVEI	CH,37		;STORE ESCAPE
	IDPB	CH,B		;  CODE
	MOVEI	CH,160000	;ESCAPE TO MODE 7
	HRRM	CH,(B)		; ..
	MOVEI	CH,DISPLA	;JUMP TO START
	MOVEM	CH,1(B)		; ..
	HRRZM	B,DISBES	;STORE NEW END LOCATION
	HRLI	B,2(B)		;START DOWN TWO
	MOVE	A,[353535,,353535]
	MOVEM	A,2(B)		;CLEAR REST OF BUFFER
	ADDI	B,3		;COMPLETE BLT POINTER
	BLT	B,DISBEN-1	;CLEAR REST OF BUFFER
	TRON	F,FR.DIS	;SEE IF INITIALIZED YET
	OUTPUT	DIS,[DISPLA
		     0]
	JRST	FINSLP		;AND PROCEED
;HERE ON SPECIAL CHARACTER
DCNTRL:	CAIL	CH,140		;SEE IF LOWER
	CAILE	CH,172		;  CASE ALPHA
	JRST	NOTLC		;NO--TRY AGAIN
	SUBI	CH,140		;CONVERT TO DISPLAY CODE
SIO:	PUSH	P,CH		;SAVE CHARACTER
	MOVEI	CH,36		;YES--SWITCH TO L.C.
	PUSHJ	P,DSTORE	; ..
	POP	P,CH		;RESTORE CHARACTER
	PUSHJ	P,DSTORE	;STORE IT
	MOVEI	CH,35		;BACK TO U.C.
	JRST	DOK		;AND STORE THAT
NOTLC:	CAIN	CH,133
	JRST	OBRAK
	CAIN	CH,135
	JRST	CBRAK
	CAIN	CH,136
	JRST	UPARRO
	MOVEI	CH,0		;ELSE GIVE UP
	JRST	DOK		;PRINT INDIRECT
OBRAK:	MOVEI	CH,53		;GET CHAR
	JRST	SIO		;GO STORE AND SHIFT BACK
CBRAK:	MOVEI	CH,54		;GET CHAR
	JRST	SIO		;GO STORE AND SHIFT BACK
UPARRO:	MOVEI	CH,46		;GET CHAR
	JRST	SIO		;GO STORE AND SHIFT BACK

;ROUTINE TO STORE IF ROOM
DSTORE:	HRRZ	T1,B		;GET ADDRESS
	CAIGE	T1,DISBEN-5	;SEE IF NEAR END
	IDPB	CH,B		;NO--STORE
				; AND FALL INTO POPJ P,

HOME:				;ROUTINE TO HOME UP THE SCREEN
CLEAR:				;ROUTINE TO CLEAR THE SCREEN
HOMDWN:				;ROUTINE TO POSITION TO BOTTOM OF SCREEN

	POPJ	P,		;JUST RETURN
>;	END OF IFE V.DISP-V.DVBX
FINSLP:
IFN V.DISP-V.DVBX,<
	PUSHJ	P,HOME		;RETURN TO HOME POSITION
	PUSHJ	P,FRCOUT	;FORCE OUTPUT
	TLZE	F,FL.REF	;TEST FOR REFRESH PASS
	JRST	HIBER0		;GO RIGHT NOW
>;	END OF IFN V.DISP-V.DVBX
	TLNN	F,FL.LOCK	;SEE IF /V MODE
	JRST	FINSL0		;NOT V MODE
	AOSL	RELCKC		;COUNT TO AUTO UNLOCK
	CALL	UNLOCK		;UNLOCK JOB
FINSL0:	CALL	GETOPR		;GET DATA FROM OPR
	SKIPA			;NO DATA THERE
	PJRST	FINX		;PROCESS OPERATOR REQUEST
	SKIPG	J,HIBTIM	;GET WAIT TIME
	MOVEI	J,INTVAL*^D1000	;NONE, USE DEFAULT
	TLO	J,(HB.RTL!HB.RTC)  ;WAKE UP ON TTY ACTIVITY
	HIBER	J,
	 PUSHJ	P,[ANDI	J,-1	;HIBER FAILED, MS TO SLEEP
		IDIVI	J,^D1000;SECONDS TO SLEEP
		SLEEP	J,	;SLEEP
		POPJ	P,]	;DO NORMAL STUFF
HIBER0:	MOVEI	J,"N"		;NORMAL TO GO NOW?
	TRNE	F,FR.NRM	;IF SO DESIRED
	JRST	FINX		;DO AS IF N WAS TYPED
	PJRST	FINOPR		;FINISH ANY REQUESTS
;FINOPR IS USED TO PROCES ALL THE OPERATOR CHARACTERS
;THIS CODE EXITS TO REENT OR SYSTT0

FINOPR:	CALL	GETOPR		;SEE IF ANY INPUT
	SKIPA			;(NO) DO EXIT LOGIC
	JRST	FINX		;PROCESS CHARACTER
	TRNN	F,FR.ALT	;STARTING TO WAIT
	JRST	FINOP0		;NOPE STILL BUSY
FREEZE:	INCHRW	J		;WAIT FOR INPUT
	JRST	FINX		;HERE TO GO AFTER WE GOT CHAR
FINOP0:	TLNE	F,FL.REF	;REFRESH WISHED
	JRST	SYSTT1		;YES DO IT
	TLNE	F,FL.GOD	;SEE IF GOD
	TLNN	F,FL.LOCK	;SEE IF LOCKED
	AOSGE	REPS
	JRST	REENT
	JRST	SYSTT0

;FINX IS ENTERED WITH A COMMAND CHARACTER IN J

FINX:	TRZ	F,FR.ALT	;UNFREEZE THE SCREEN
	CAIL	J,"A"+40	;SEE IF LOWER CASE
	CAILE	J,"Z"+40	; ALPHABETIC
	SKIPA			;NO LEAVE ALONE
	SUBI	J,40		;YES--CONVERT TO UPPER CASE
	MOVSI	A,-CHRN		;SEARCH CONTROL CHARACTER TABLE
FINXCL:	HLRZ	B,CHRTAB(A)	;GET NEXT CANDIDATE
	CAIE	B,(J)		;SEE IF MATCH
	CAIN	B,PRGFLG(J)	;OR MATCH ON PROGRAM
	JRST	FINXCX		;YES--GO HANDLE
	AOBJN	A,FINXCL	;NO--TRY NEXT
				;NOT IN TABLE--

;HERE FOR SPECIAL PROCESSING OF A DIGIT

	CAIL	J,"0"		;CHECK THE RANGE
	CAILE	J,"9"		; 0-9
	JRST	FINXC1		;NO
	SUBI	J,"0"		;CONVERT TO DECADE DIGIT
	EXCH	J,NUMBER	;GET ACCUMULATED NUMBER SO FAR
	IMULI	J,^D10		;SHIFT OVER A DECADE
	ADDB	J,NUMBER	;MAKE NEW NUMBER
	AOS	NUMFLG		;NOTE EXPLICIT NUMBER TYPED IN
	JRST	FINOPR		;KEEP GOING
FINXC1:	CAIL	J,40		;SKIP IF NOT CONTROL
	TLO	F,FL.HLP	;NOT FOUND--SET HELP MESSAGE FLAG
	JRST	FINOPR		;AND TRY NEXT ONE
FINXCX:	TLZ	F,FL.HLP	;CLEAR HELP NEEDED FLAG
	SKIPGE	B,CHRTAB(A)	;GET PROGRAM ADDRESS OR SUBROUTINE
	JRST	FINXC0		;ONLY SET DISPLAY ADDRESS
	CALL	(B)		;DO ACTION CODE 
	SETZM	NUMBER		;RESET COMMAND NUMBER PREFIX
	SETZM	NUMFLG		;AND NUMBER TYPED FLAG
	PJRST	FINOPR		;GET ANOTHER COMMAND
FINXC0:	PUSHJ	P,REFRSH	;GET A FRESH SCREEN
	SETZM	FIRJOB		;ALWAYS START AT THE END
FINXC9:	HRRM	B,PROGRM	;STORE FINAL DISPLAY ADDRESS
	JRST	FINOPR		;AND SEE WHAT MORE IN STORE

;GETOPR GET A CHARACTER IN J IF THERE IS ANY TYPED
;BY THE OPERATOR. RETURN A CONTROL C CHARACTER
;IF CCIOPC IS .NEQ. 0

GETOPR:	SKIPN	CCIOPC		;DO NOT LOSE CHARACTER
LOSER:	INCHRS	J		;GET ONE IF ANY
	SKIPE	CCIOPC		;NO CHARACTER AND NO ^C
SETCNC:	AOSA	(P)		;PREPARE THE SKIP RETURN
	RETURN			;NORMAL RETURN NOTHING THERE
	SKIPE	CCIOPC		;A NORMAL CHARACTER?
	MOVEI	J,.CHCNC	;NO GET CONTROL C
	RETURN


;NDECW  --  INPUT A DECIMAL NUMBER FROM OPERATOR
;
;RETURNS NUMBER IN AC N; COUNT OF DIGITS TYPED IN AC N1

NDECW:	SETZB	N,N1		;INITIALIZE COUNTS
NDECW0:	INCHWL	CH		;READ IN A CHARACTER
	CAIL	CH,"0"		;VALID DECIMAL DIGIT?
	CAILE	CH,"9"		;. . .
	 POPJ	P,		;NOPE, ALL DONE
	IMULI	N,^D10		;YES, NEXT DECADE
	ADDI	N,-"0"(CH)	;ADD IN THIS DECADE
	AOJA	N1,NDECW0	;AND COUNT DIGITS
;TABLE FOR ACTION CHARACTER DISPATCH

PRGFLG==400000		;SIGN BIT FLAGS THIS IS A DISPLAY PROGRAM

	DEFINE	DISPLAY(A,B)<
	PRGFLG+A,,B>

CHRTAB:	XWD	" ",CPOPJ	;UPDATE SCREEN IMMEDIATELY
	XWD	"-",DWNJOB	;BACK UP JOBS BY 20.
	XWD	"+",UPJOB	;MOVE UP JOBS BY 20.
	XWD	"#",TGLTTY	;TOGGLE TTY OUTPUT FLAG
	XWD	"O",TGLOPR	;TOGGLE [OPR] SUPPRESSION
	XWD	.CHCNC,ALLDON	;IF ^C, GO EXIT
	XWD	.CHCNZ,ALLDON	;IF ^Z, GO EXIT
	XWD	.CHESC,ALTMOD	;ALTMOD, FREEZE THE SCREEN
	XWD	"V",STLOCK	;TOGGLE LOCK/UNLOCK HPQ 0/1 STATUS
	XWD	"R",REFRSH	;IMMEDIATE REFRESH ON THE SCREEN
	XWD	"W",WAITIM	;READ WAIT TIME
	XWD	"I",TGLINC	;TOGGLE INCREMENTAL STATISTICS
	XWD	"A",ALTJOB	;AUTO ROLL JOBS
	XWD	"L",LOGSCR	;SCREEN LOGGING
	XWD	"%",TGLPCT	;TOGGLE RUNTIME OR PERCENTAGE
	XWD	"S",TGLSJB	;TOGGLE SYSTEM OR EXPANDED JOBS IN "N"
IFE <V.DISP-V.DV61>,<
	XWD	.CHCNR,RVIDEO
	XWD	.CHCNA,ALARM
>
IF2,<
IFNDEF DEVPRG,<DEVPRG=FILPRG>
IFNDEF MEMPRG,<MEMPRG=NORMAL>
>

;TABLE FOR SCREEN SELECTOR
	DISPLAY	"N",NORMAL	;NORMAL DISPLAY
	DISPLAY	"F",FILPRG	;FILE SYSTEM DISPLAY
	DISPLAY	"D",DEVPRG	;DEVICES DISPLAY
	DISPLAY	"J",JOBPRG	;JOBS
	DISPLAY	"M",MEMPRG	;MEMORY AND SWAPPER
	DISPLAY	"H",HELP	;HELP TEXT
IFN FTNET,<
	DISPLAY "T",NETPRG	;DISPLAY THE NETWORK TOPOLOGY
	DISPLAY	"\",NETSTS	;DISPLAY THE NETWORK STATISTICS
>
	DISPLAY	"Q",QUEPRG	;DISPLAY THE QUEUES
CHRN==.-CHRTAB
;HERE WHEN USER TYPES +, TO ADVANCE JOBS BY 20.

UPJOB:	SKIPG	A,NUMBER	;USER GIVE EXPLICIT SKIP VALUE?
	MOVEI	A,UPDNJB	;NO, USE DEFAULT INCREMENT
	TRNE	F,FR.VMM	;VM TYPE OF DISPLAY
	SUBI	A,2		;IN THAT CASE 2 LINES ARE LOST
	ADDM	A,FIRJOB	;ADVANCE
	JRST	MOVJOB		;GO TO COMMON ROUTINE

;HERE WHEN USER TYPES -, TO BACK UP JOBS BY 20.

DWNJOB:	SKIPG	A,NUMBER	;USER GIVE EXPLICIT SKIP VALUE?
	MOVEI	A,UPDNJB	;NO, USE DEFAULT INCREMENT
	MOVN	A,A		;AND MAKE IT A DECREMENT
	TRNE	F,FR.VMM	;VM DISPLAY ON
	ADDI	A,2		;THEN TWO LESS
	ADDM	A,FIRJOB	;RETARD
	SKIPGE	FIRJOB		;SEE IF TOO FAR
	SETZM	FIRJOB		;YES--SET TO START
MOVJOB:	SETZM	.FRAJR		;CLEAR AUTO ROLL FEATURE
	HRRZ	A,PROGRM	;GET DISPLAY PROGRAM
	CAIL	A,MEMPRG	;IF DISPLAY IS
	CAILE	A,NORMAL	;NOT J/M/N
	POPJ	P,		;THEN NO JOB LIMIT CHECK (E.G., H DISPLAY)
	MOVE	A,XHGHJB	;GET GETTAB PARM FOR HIGHEST ACTIVE JOB
	PUSHJ	P,GETZ		;GO TRY TO READ IT FROM SYSTEM
	SKIPN	A		;  GOT IT, SKIP
	MOVE	A,JOBN		;  ERROR, GET HIGHEST JOB NUMBER
	SUB	A,FIRJOB	;MINUS FIRST JOB TO BE DISPLAYED
	SUBI	A,UPDNJB-1	;MINUS # OF JOBS DISPLAYED, MINUS 1
	SKIPGE	A		;SKIP IF JOBS FOR ENTIRE SCREEN
	ADDM	A,FIRJOB	;  ELSE BACK FIRST JOB # DOWN
	SKIPGE	FIRJOB		;TEST FOR TOO FAR BACK
	SETZM	FIRJOB		;  YES, LEAVE IT AT ZERO
	RETURN
;HERE WHEN A TYPED TO FLAG FOR AUTO JOB ROLL
;EACH PASS WILL ADVANCE TO NEXT PAGE OF JOBS UNTIL DONE
;THEN START OVER WITH 1.  STOP MODE WITH A, +, -.

ALTJOB:	SETCMM	.FRAJR		;TOGGLE ROLL FLAG
	RETURN

;HERE WHEN USER TYPES #, TO TOGGLE FLAG WHICH DETERMINES
;WHETHER TTYS DISPLAY FOR OPERATORS OR FOR CLEMENTS

TGLTTY:	SETCMM	REALTT		;TOGGLE FLAG
	RETURN

;TOGGLE SUPPRESSION OF [OPR] JOBS

TGLOPR:	SETCMM	SUPOPR		;TOGGLE [OPR] SUPPRESSION FLAG
	POPJ	P,		;RETURN

;TOGGLE WHETHER J/M/N DISPLAY RUNTIME OR PERCENTAGE

TGLPCT:	SETCMM	PCTFLG		;TOGGLE PERCENTAGE FLAG
	POPJ	P,		;THAT'S THAT.

;TOGGLE WHETHER EXPANDED JOB (USER NAME, DISK READS/WRITES) OR
;USUAL SYSTEM DISPLAY IN "N" DISPLAY

TGLSJB:	TRC	F,FR.SJB	;TOGGLE SYSTEM/JOB FLAG
	PJRST	REFRSH		;AND MARK A REFRESH NEEDED
;HERE WHEN ^C INTERCEPT

CCTYPD:	PUSH	P,A		;SAVE AN AC
	HRRZ	A,CCIOPC	;GET PC IN QUESTION
	CAIE	A,LOSER		;GOING TO LOOSE A CHARACTER
	CAIN	A,FREEZE	;SEE IF HUNG ON AN ALTMODE
CCTYPC:	MOVEI	A,FINX		;YES--GO LOOK AT INPUT
	HRRM	A,CCIOPC	;SAVE NEW OR OLD PC
	POP	P,A		;RESTORE THE AC
	JRSTF	@CCIOPC		;JUST RETURN AND CATCH IN MAIN
				;LOOP.  DON'T CLEAR IN CASE OF LOOP.

;HERE WHEN USER TYPES ^C OR ^Z, TO EXIT TO MONITOR

ALLDON:	IFE	V.DISP-V.DV61,<	;IF VT61
	TRNE	F,FR.RVD	;IN REVERSE VIDEO?
	PUSHJ	P,RVIDEO	;YES, CLEAR IT (EXIT WITH NORMAL VIDEO)
	TRNE	F,FR.ALR	;IN "ALARM"ING MODE?
	PUSHJ	P,ALARM		;YES, CLEAR IT
> ;END OF IFE V.DISP-V.DV61
	PUSHJ	P,HOMDWN	;HOME DOWN SCREEN
	TLNE	F,FL.LOG	;LOGGING SCREENS?
	CLOSE	LOG,		;YES, CLOSE OFF FILE
	TLNE	F,FL.LOG	;LOGGING SCREENS?
	RELEAS	LOG,		;YES, LEGGO OF LOG DEVICE
	RESET			;  & RESET EVERYTHING ELSE, TOO
	AOS	.JBFF		;FLAG INITIALIZED
ALLDNE:	MOVN	J,MYJOB		;GET NEGATIVE OF CURRENT JOB #
	JOBSTS	J,		;FIND OUT ABOUT ME
	  MOVEI	J,0		;  ERROR, SET FLAGS TO ZERO
	TXNE	J,JB.ULI	;TEST FOR LOGGED IN
	JRST	DOEXIT		;  YES, GO EXIT
	SKIPE	J		;(SKIP MSG IF NO JOBSTS UUO)
	OUTSTR	KJMSG		;GIVE A 'KJOB' & A LOGOUT
	LOGOUT			;  DITTO
KJMSG:	ASCII	/.KJOB/		;MESSAGE FOR END OF PROGRAM
	BYTE	(7) 15, 12, ".", 0, 0 ;  DITTO
DOEXIT:	EXIT	1,		;RETURN TO MONITOR, WITH .CONT PRIVILEGES
	TLZ	F,FL.LOCK	;CLEAR LOCK (RESET DID IT)
	PUSHJ	P,OPNTTY	;RE-OPEN TTY CHANNEL
	JRST	START		;     NOW START FROM THE TOP
ALTMOD:	TRC	F,FR.ALT	;YES--SET FLAG
	RETURN			;FLAG JUST CLEARED OR SET

STLOCK:	HRRZI	J,1		;SET LOCK/UNLOCK PARAMETER FOR LOW-SEG ONLY
	TLNE	F,FL.LOCK	;TEST FOR LOCKED NOW
	JRST	UNLOCK		;  YES, GO RESET & UNLOCK
IFN V.DISP-V.DVBX,<
	LOCK	J,		;ATTEMPT TO LOCK US
	  JFCL			;  FAILED
>;	END OF IFN V.DISP-V.DVBX
	TLO	F,FL.LOCK	;  WORKED, SHOW LOCKED NOW
	HRROI	A,.GTRTD	;REAL TIME WORD
	PUSHJ	P,GETZ		;GO GET IT
	LDB	A,[POINTR A,JR$HPC]  ;USER LEVEL SET HPQ COMMAND
	MOVEM	A,HPQCMD	;REMEMBER IT
	MOVEI	A,1		;GET FLAGS FOR HPQ #1
	SKIPN	HPQCMD		;IN NOT ALREADY IN HPQ,
	HPQ	A,		;GET IN A HPQ (MAYBE)
	  JFCL			;       & IGNORE FAILURES
	MOVNI	A,RELOCK	;SET FOR AUTO UNLOCK
	MOVEM	A,RELCKC	; IN CASE OPER FORGETS
	SKIPN	A,HIBTIW	;GET OPERATOR-SPECIFIED WAIT TIME
	MOVEI	A,^D1000	;NONE, USE DEFAULT (SHORT)
	MOVEM	A,HIBTIM	;SET WAIT TIME
	RETURN
UNLOCK:
IFN V.DISP-V.DVBX,<
	UNLOK.	J,		;ATTEMPT TO UNLOCK MYSELF
	  JRST	SYSDPY		;  FAILED, DO IT VIA 'RESET'
>;	END OF IFN V.DISP-V.DVBX
	TLZ	F,FL.LOCK	;SHOW WE ARE NO LONGER LOCKED
	MOVEI	A,0		;GET FLAGS FOR HPQ #0
	SKIPN	HPQCMD		;IF NOT SET HPQ COMMAND
	HPQ	A,		;REQUEST NORMAL CPU PRIORITY
	  JFCL			;  IGNORE ERROR RETURN
	MOVE	A,HIBTIW	;GET OPERATOR-SPECIFIED WAIT TIME
	MOVEM	A,HIBTIM	;AND RESET WAIT TIME
	RETURN

TGLINC:	TLC	F,FL.INC	;TOGGLE INCREMENTAL FLAG
	POPJ	P,		;THAT'S THAT
REFRSH:	TLO	F,FL.REF	;FORCE A REFRESH
IFN	V.DISP-V.DV61,<POPJ P,>	;IF NOT VT61 JUST RETURN, ELSE
IFE	V.DISP-V.DV61,<		;CHECK FOR REVERSE VIDEO
	TRNN	F,FR.RVD	;IN REVERSE VIDEO?
	POPJ	P,		;NO, JUST RETURN TO REFRESH
	TRO	F,FR.RVR	;YES, RESTORE IT LATER
	JRST	RVIDEO		;AND CANCEL IT FOR REFRESH
> ;END OF IFE V.DISP-V.DV61


;WAITIM  --  SET WAIT TIME BETWEEN SCREEN UPDATES

WAITIM:	MOVE	N,NUMBER	;PICK UP COMMAND ARGUMENT
	CAILE	N,^D60		;MAX OF (APPROX) ONE MINUTE
	MOVEI	N,^D60		;SET MAX
	IMULI	N,^D1000	;CONVERT TO MILLISECONDS
	CAIG	N,0		;IF USER TYPED EXPLICIT 0
	MOVEI	N,1		;THEN MAKE INTO ONE TICK (NOT INFINITY)
	SKIPN	NUMFLG		;BY THE WAY, AN EXPLICIT NUMBER WAS TYPED?
	SETZ	N,		;NO, RETURN TO DEFAULT
	MOVEM	N,HIBTIM	;SET WAIT TIME
	MOVEM	N,HIBTIW	;AND REMEMBER OPERATOR GAVE IT
	POPJ	P,		;RETURN WITH NEW WAIT TIME SET
;SCREEN LOGGING COMMAND AND SUPPORT

LOGSCR:	TLNE	F,FL.LOG	;ALREADY LOGGING?
	POPJ	P,		;YES, NOOP
	MOVE	A,[LOGFLP,,FLPBLK]  ;MAKE A COPY OF THE PROTOTYPE
	BLT	A,FLPBLK+FLPLEN-1   ;LOG FILE FILOP. BLOCK
	MOVE	A,[LOGLKE,,LKEBLK]  ;MAKE A COPY OF THE PROTOTYPE
	BLT	A,LKEBLK+LKELEN-1   ;LOG FILE ENTER BLOCK
	MOVE	A,[FLPLEN,,FLPBLK]  ;FILOP. ARG POINTER
	FILOP.	A,		;APPEND SCREEN LOG
	 JRST	NOLOGS		;ERROR, FORGET IT
	TLO	F,FL.LOG	;GOT IT, NOTE WE ARE NOW LOGGING
;	SETOM	LOGSCT		;SUPPRESS LEADING <FF>
	POPJ	P,		;RETURN READY AND WILLING

LOGFLP:	400000+LOG,,.FOAPP	;CHANNEL,,APPEND
	.IOASL			;ASCII MODE
	'DSK   '		;ON DEVICE DSK:
	LOGOHD,,0		;OUTPUT RING HEADER
	0,,0			;DEFAULT NUMBER OF BUFFERS
	0,,LKEBLK		;ADDRESS OF ENTER BLOCK

	FLPLEN==.-LOGFLP

LOGLKE:	3			;LENGTH OF BLOCK
	0			;PATH [-]
	'SYSDPY'		;FILENAME SYSDPY
	'LOG   '		;EXTENSION .LOG

	LKELEN==.-LOGLKE
LISCR:	MOVEI	T2,.CHFFD	;FORMFEED
	PUSHJ	P,LISCH		;TO START THINGS OFF
	SETZB	A,COL		;START AT COLUMN 0
	SETZM	LINE		;IN LINE 0
	MOVEI	B," "		;FOR SPACE FILL

LISCR2:	PUSHJ	P,GETCH		;GET NEXT SCREEN CHARACTER
	TRNE	T2,400		;*SOMETHING* BLANKED OUT?
	MOVEI	T2," "		;YES, LIST AS BLANK THEN
	ANDI	T2,177		;JUST THE CHARACTER
	CAIN	T2," "		;A BLANK?
	AOJA	A,LISCR5	;YES, COUNT UP (MAYBE SUPPRESS)
	JUMPE	A,LISCR4	;OUTPUT CHAR UNLESS SAVED BLANKS
	EXCH	T2,B		;IN WHICH CASE
	PUSHJ	P,LISCH		;LIST BLANKS INSTEAD
	SOJG	A,.-1		;UNTIL CAUGHT UP WITH WHERE SHOULD BE
	EXCH	B,T2		;RETREIVE REAL CHARACTER
LISCR4:	PUSHJ	P,LISCH		;OUTPUT CHARACTER
LISCR5:	AOS	T1,COL		;ADVANCE COLUMN COUNTER
	CAIGE	T1,XSIZE	;UNTIL THIS LINE FINISHED
	JRST	LISCR2		;MORE OF THIS LINE TO GO
	MOVEI	T2,.CHCRT	;A <CR>
	PUSHJ	P,LISCH		;TO END THIS LISTING LINE
	MOVEI	T2,.CHLFD	;AND A <LF>
	PUSHJ	P,LISCH		;TO END THE <CR><LF>
	SETZB	A,COL		;NO BLANKS, START OF LINE
	AOS	T1,LINE		;ADVANCE TO NEXT LINE
	CAIGE	T1,YSIZE	;DONE YET?
	JRST	LISCR2		;NOPE, DO ANOTHER LINE
	POPJ	P,		;YES - SCREEN OUTPUT


LISCH:	SOSGE	LOGOHD+2	;ROOM FOR ANOTHER CHARACTER?
	JRST	LISCH2		;NO, ASK MONITOR FOR NEXT BUFFER
	IDPB	T2,LOGOHD+1	;STUFF THIS CHARACTER
	POPJ	P,		;DONE

LISCH2:	OUTPUT	LOG,		;ASK FOR NEXT BUFFER
	JRST	LISCH		;ASSUME GOT ONE . . .
	SUBTTL	VARIOUS "ERROR" MESSAGES

;SPY OR PEEK PRIVILEGES ARE REQUIRED FOR CERTAIN FUNCTIONS

NOPRIV:
NOSPPK:	SET	1,XSIZE,1,YSIZE,0,TAB4
	MOVEI	M,NOSPTX	;WARNING
	CALL	MSG		;SET UP THE MESSAGE
	JRST	ADVICE		;TELL COMMON EXIT

NOSPTX:	ASCIZ	\You do not have either PEEK or SPY privileges.
\


;"M" COMMAND WITHOUT VM OPTION

NONVM:	SET	1,XSIZE,1,YSIZE,0,TAB4
	MOVEI	M,NOVMTX	;EXPLANATION
	CALL	MSG		;STORE THE TEXT
	PJRST	ADVICE		;COMMON EXIT CODE

NOVMTX:	ASCIZ	\This monitor does not support virtual memory.
\


;"\" COMMAND BUT FTCMSR TURNED OFF IN MONITOR

NOCMSR:	SET	1,XSIZE,1,YSIZE,0,TAB4	;STANDARD (FULL) SCREEN
	MOVEI	M,NOCMTX	;SAY WHY IT FAILS
	PUSHJ	P,MSG		;TELL USER
	PJRST	ADVICE		;COMMON EXIT

NOCMTX:	ASCIZ	\This monitor does not support network statistics.
\
;"L" COMMAND CAN'T ENTER/APPEND "LOG" FILE

NOLOGS:	SET	1,XSIZE,1,YSIZE,0,TAB4
	MOVEI	M,NOLOTX	;ERROR TEXT
	PUSHJ	P,MSG		;SHOW ON SCREEN
	PJRST	ADVICE		;AND CAP OFF

NOLOTX:	ASCIZ\? Can't create/append log file DSK:SYSDPY.LOG[-]
\



;COMMON ADVICE PRINTER

ADVICE:	MOVEI	M,ADVTXT	;GET ADVICE TEXT ADDRESS
	CALL	MSG		;AND PRINT IT
	TRO	F,FR.NRM	;AND RETURN TO NORMAL
	TRZ	F,FR.ALT	;DO NOT GET STUCK BY $ MODE
	TLZ	F,FL.REF	;WAIT A SECOND
	RETURN

ADVTXT:	ASCIZ	\
This display will be automatically replaced by the normal display.
Type any command to effect immediate replacement.
\
	SUBTTL	"H" -- DISPLAY HELP MESSAGE

HELP:	PUSHJ	P,THISIS	;GIVE HEADER LINE
	PUSHJ	P,CRLF		;BLANK LINE FOR NEATNESS
	TABSET	TAB7		;NORMAL TAB STOPS
	MOVE	A,FIRJOB	;COUNT OF "JOBS" TO SKIP
	MOVEM	A,EATCNT	;SET FOR EMSG
	SKIPN	HLPADR		;ALREADY GOT HELP TEXT?
	JRST	HELP0		;NO, LOOK FOR IT ON DISK
	MOVE	M,HLPADR	;GET HELP TEXT INTO M
	JRST	HELP7		;AND GO TYPE IT OUT

HELP0:	MOVEI	A,.IODMP	;NO, PREPARE TO READ IT IN
	MOVSI	B,'HLP'		;FROM HLP:
	SETZ	C,		;(IN DUMP MODE)
	OPEN	HLP,A		;OPEN HELP DEVICE
	 JRST	HELP6		;HMMMMM . . .

;NOTICE THAT AT THIS POINT PECULIAR AC USEAGE APPEARS
;AC'S 0 TO 6 ARE USED BUT NOT AS M/A/B/C/D/J/JS . . .

	MOVEI	.RBCNT,.RBSIZ	;LENGTH OF LOOKUP BLOCK
	SETZ	.RBPPN,		;DEFAULT PATH
	MOVE	.RBNAM,['SYSDPY']  ;NAME OF HELP FILE
	MOVSI	.RBEXT,'HLP'	;AND ITS EXTENSION
	LOOKUP	HLP,.RBCNT	;SEE IF HLP:SYSDPY.HLP EXISTS
	 JRST	[HRRZ	N,.RBEXT;ERROR CODE
		CAIN	N,ERFNF%;FILE NOT FOUND?
		JRST	HELP6	;YES, USE OUR TEXT
		MOVEI	M,[ASCIZ\? LOOKUP error (\] ;MESSAGE
		PUSHJ	P,MSGOCT;TELL USER OF WOES
		MOVEI	M,[ASCIZ\) for help file HLP:SYSDPY.HLP\]
		JRST	HELP7]	;CAP OFF ERROR
	MOVE	A,.RBSIZ	;GET SIZE OF FILE

;NOW WE RETURN TO MORE RATIONAL AC USAGE . . .

	MOVN	C,A		;FOR IOWD
	MOVE	B,.JBFF		;ADDRESS FOR HELP TEXT
	ADDB	A,.JBFF		;ALLOCATE SPACE
	ADDI	A,1		;GUARANTEE TRAILING <NUL>
	CAMG	A,.JBREL	;HAVE WE ROOM?
	JRST	HELP1		;YES
	CORE	A,		;NO, ASK FOR SOME MORE
	 JRST	[MOVEI	M,[ASCIZ\? Insufficient memory for reading help file text!
\]				;TELL USER OF WOES
		JRST	HELP7]	;GO DISPLAY TEXT
	MOVN	A,C		;RESTORE AC A FROM CORE UUO

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

HELP1:	MOVS	C,C		;START IOWD
	HRRI	C,-1(B)		;FINISH IOWD
	SETZ	D,		;FINISH COMMAND LIST
	IN	HLP,C		;READ HELP FILE
	SKIPA			;GOT IT
	 JRST	[MOVEI	M,[ASCIZ\? I/O error reading HLP:SYSDPY.HLP
\]				;MORE WOES
		JRST	HELP7]	;GO TELL USER
	MOVEM	B,HLPADR	;SAVE ADDRESS OF HELP TEXT
	RELEAS	HLP,		;DITCH I/O CHANNEL
	SUB	A,B		;GET BACK LENGTH
	SUBI	A,1		;REAL FILE LENGTH
	IMULI	A,5		;COUNT OF 7-BIT ASCII BYTES
	TLO	B,(POINT 7,)	;MAKE INTO BYTE POINTER
	MOVE	C,B		;COPY FOR RE-WRITTING
HELP2:	ILDB	CH,B		;GET CHARACTER
	JUMPE	CH,HELP3	;SKIP OVER NULLS
	IDPB	CH,C		;OK CHARACTER, STORE IT
HELP3:	SOJG	A,HELP2		;LOOP BACK FOR REST OF MESSAGE
	MOVEI	CH,0		;NOW WE WANT A <NUL>
	IDPB	CH,C		;TO TERMINATE HELP TEXT
	MOVE	M,HLPADR	;ADDRESS OF HELP TEXT
	JRST	HELP7		;GO SET TO TYPE IT OUT

HELP6:	MOVEI	M,HLPTXT	;USE OUR OWN MINI-HELP TEXT
HELP7:	PUSHJ	P,EMSG		;LIST ASCIZ TEXT
	PUSHJ	P,CHKDON	;SEE HOW SCREEN FARED
	JRST	HELP		;NOT SO GOOD, TRY AGAIN
	POPJ	P,		;REASONABLY WELL, GO SHOW IT
;AND OUR VERY OWN HELP TEXT

HLPTXT:	ASCIZ	n+	Advance screen by "n" or approximately one screen-full
n-	Retreat screen by "n" or approximately one screen-full
A	Toggle Auto roll of all jobs
F	List file system statistics
H	List this text
I	List incremental statistics (where applicable)
J	List only jobs (in multiple columns)
L	Log screens into file DSK:SYSDPY.LOG[-] (Close on ^Z)
M	List virtual memory data
N	List normal (some of everything) status
O	Toggle suppression of [OPR] jobs in "N" & "M" display
Q	List the system queues
R	Refresh entire screen immediately 
S	Toggle System or expanded job statistics in "N" display
T	Topology for network display
V	Toggle cpu and core priority
nW	Set wait time to "n" decimal seconds
\	Display network statistics
#	Toggle PTY number or controlling job number
%	Toggle runtime or percentage of cpu
^A	Toggle alarm (flashing) mode (if applicable)
^C	Terminate SYSDPY execution
^R	Toggle reverse video updating (if applicable)
^Z	Terminate SYSDPY execution
<ESC>	Freeze screen as is (any subsequent command will thaw)
SPACE	Update screen display immediately

	SUBTTL	"N" DISPLAY, SOME OF EVERYTHING

;MEMPRG IS THE START OF THE DISPLAY PROGRAM FOR A VM SYSTEM
;NORMAL IS THE START FOR THE CLASSIC SYSTEM DISPLAY
;THE CONTROL FLOW IS REGULATED BY THE FLAG FR.VMM
;ONCE THIS FLAG HAS BEEN SET BY MEMPRG THEN NORMAL
;CAN DO THE JOB. NOTE: THAT IF THE SYSTEM DOES NOT 
;SUPPORT VM THAT THE VM DISPLAY AND NORMAL DISPLAY ARE
;IDENTICAL.

MEMPRG:	TRNN	F,FR.VMO	;IS VM OPTION THERE
	JRST	NONVM		;NO TELL HIM THE FACT
	TROA	F,FR.VMM	;THEN TURN THE FLAG ON
				;AND SKIP INTO NORMAL
JOBPRG:	TRO	F,FR.JOB	;FLAG JOBS ONLY
				;AND FALL INTO NORMAL
NORMAL:	PUSHJ	P,STROLL	;START DISPLAY VARIABLES
	SETOM	NLTYPD		;MARK THAT LINES HAVE BEEN TYPED
	TRZ	F,FR.NRM	;ONLY WHEN NORMAL FORGET FLAG
	PUSHJ	P,WNDJOB	;SET JOB WINDOW
	SETZM	JBUBZR		;CLEAR FIRST JOB USAGE WORD
	MOVE	A,[JBUBZR,,JBUBZR+1]  ;BLT POINTER TO
	BLT	A,JBUEZR	;CLEAR ALL JOB USAGE FIGURES
	PUSHJ	P,GUPTIM	;GET SYSTEM UPTIME
	SUB	A,UPTIME	;A:= INCREMENTAL UPTIME
	ADDM	A,UPTIME	;UPDATE TOTAL UPTIME
	TLNN	F,FL.INC	;WANT INCREMENTAL OR TOTAL?
	MOVE	A,UPTIME	;TOTAL
	MOVEM	A,UPTINC	;SAVE INCREMENTAL UPTIME FOR OTHERS
	MOVE	A,[%NSHJB]	;HIGHEST JOB NUMBER IN USE
	PUSHJ	P,GET		;READ FROM MONITOR
	 MOVE	A,JOBN		;???
	MOVEM	A,JBNMAX	;REMEMBER IT
	PUSHJ	P,GJBDAT	;READ ALL THE JOB DATA
	MOVN	J,JBNMAX	;GET MAX JOB IN USE
	HRLZ	J,J		;MAKE "IOWD" INDEX POINTER
	HRRI	J,1		;START WITH JOB 1
	SUBTTL	"N" DISPLAY -- JOBS

NORML0:	TLOE	F,FL.NHED	;GOT HEADER YET?
	JRST	NORML2		;YES
	TRNE	F,FR.VMM	;DOING VM DISPLAY?
	PUSHJ	P,PAGSYS	;YES, TYPE SOME LEADING INFORMATION
	MOVEI	M,[ASCIZ /Job  Who  Where What/]
	CALL	MSG		;PRINT PART OF MESSAGE
	TRNE	F,FR.VMM	;IS VIRTUAL M THERE
	JRST	NORML1		;YES THEN ALL SET
	MOVEI	M,[ASCIZ /  #/]
	CALL	MSG		;PRINT MESSAGE
	CALL	KAYPAG		;KAYS OR PAGES
NORML1:	MOVEI	M,[ASCIZ /  Virtual     Physical      PGR  /]
	TRNE	F,FR.VMM	;DOING MEMORY DISPLAY?
	PUSHJ	P,MSG		;YES
	MOVEI	M,[ASCIZ / State Runtime/]
	CALL	MSG		;PRINT THE END OF THE LINE
	MOVEI	M,[ASCIZ\     Reads   Writes    User\]
	TRNN	F,FR.JOB!FR.VMM	;IN "J" OR "M" DISPLAY?
	TRNN	F,FR.SJB	;NO, "N" DISPLAY, IN EXPANDED JOBS?
	CAIA			;NO, THEN NO DISK READS/WRITES/ETC.
	PUSHJ	P,MSG		;YES, EXTRA HEADER
	PUSHJ	P,CRLF		;CAP OFF HEADER LINE
NORML2:	MOVE	JS,@JBSTS
	TXNN	JS,JS$JNA
	JRST	NORMNJ

NORML3:	AOS	JBNUSE		;COUNT JOBS IN USE
	TXNE	JS,JS$LOG	;JOB LOGGED IN?
	AOS	JBNLOG		;YES, COUNT LOGGED-IN JOBS
	HRRZM	J,CLINE		;WE ARE AT THIS LINE
	PUSHJ	P,SETVIS	;DETERMINE VISIBLITY
	HRRZ	N,J		;GET THE JOB NUMBER
	SKIPE	VISIBL		;NEXT SCREEN DISPLAY CAN SHOW IT
	CAMGE	N,FIRJOB
	TLO	F,FL.SUP	;NO, SUPPRESS THIS JOB
	SKIPN	SUPOPR		;WANT TO SUPPRESS [OPR] JOBS?
	JRST	NORML4		;NO, ALWAYS SHOW
	MOVE	A,@JBPPN	;YES, GET JOB'S PPN
	CAMN	A,OPRPPN	;IS THIS AN [OPR] JOB?
	TLOA	F,FL.SUP	;YES, SUPPRESS THIS JOB

NORML4:	TLNE	F,FL.SUP	;WANT TO SUPPRESS THIS JOB?
	JRST	SYSL0E		;YES, JUST GATHER FIGURES
	PUSHJ	P,DECPRT	;PRINT THE JOB NUMBER
	PUSHJ	P,TAB		;AND TERMINATE WITH A <TAB>
	MOVE	A,@JBPPN	;GET THE JOB'S PPN
;[561]	CAMN	A,LOGPPN	;TEST FOR [2,5]
;[561]	JRST	[PUSHJ P,STRWHO	;  YES, PRINT **,** CAUSE WE DON'T KNOW
;[561]		 JRST  SYSL0D]
	CAMN	A,OPRPPN	;TEST FOR [1,2]
	JRST	[MOVE  A,[SIXBIT/[OPR]/] ;YES, PRINT [OPR]
		 PUSHJ P,SIXBP
		 JRST  SYSL0D]
	CAMN	A,ME		;TEST FOR MY PPN
	JRST	[MOVE  A,[SIXBIT/[SELF]/] ;YES, PRINT [SELF]
		 PUSHJ P,SIXBP
		 JRST  SYSL0D]
	PUSHJ	P,PNTPPN	;PRINT PRJ-PRG #
SYSL0D:	PUSHJ	P,TAB
SYSL0E:	SKIPN	A,TTYFLG	;DO WE DECIDE HE IS DETACHED?
	JRST	SYS3LD		;YES HE LOSES
	JUMPL	A,SYS2LD	;JUMP IF PRIVILEGED TOPS10 STYLE
	HRRZ	A,J		;GET JOB NUMBER
	TRMNO.	A,		;GET LINE UDX
	JRST	SYS3LD		;CAN ONLY BE DETACHED
	CAME	A,CTYNDX	;IS IT CTY
	JRST	SYS1LD		;NO GO ON
	MOVSI	A,(SIXBIT .CTY.);SAY CTY
	JRST	SYS3LD		;THAT'S ALL
SYS1LD:	DEVNAM	A,		;GET THE DEVICE NAME
	SETZM	A		;ZAP NAME ON FAILURE
	JRST	SYS3LD		;PRINT IT
SYS2LD:	MOVE	A,@TTLDB
SYS3LD:	PUSHJ	P,PTYCTL	;CHANGE TO CONTROLLING JOB IF PTY
	TLNN	A,-1		;ATTACHED TO A TTY?
	AOS	JBNDET		;COUNT DETACHED JOBS
	TLNE	F,FL.SUP	;OUTPUT FOR THIS JOB?
	JRST	SYSL2		;NO
	TLNN	A,-1
	TLO	A,'DET'
	HLRZ	CH,A		;COPY L.H. OF NAME AS R.H. OF AC
	CAIN	CH,'TTY'	;TEST FOR 'TTYNN'
	HRLZ	A,A		;  YES, CONVERT TO 'NN   '
	TRNN	A,-1
	JRST	SYSL1G
	HRRZ	CH,A
	LSH	A,-14
	HRR	A,CH
	LSH	A,14
	TRNE	A,-1
	SOS	COL		;BACK UP ONE IF NO ROOM
SYSL1G:	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	MOVE	A,@JBPRG	;GET THE PROGRAM NAME
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
SYSL2:	TRNN	F,FR.VMO	;HAS SYSTEM VMSER ACTIVE?
	JRST	SYS2LG		;(NO) USE OLD LOGIC
	PUSHJ	P,VMHILO	;GET PHY AND VIRT LOW AND HIGH SIZES
	HRRZ	N,JOBPHY	;LOW SEG PHYSICAL SIZE
	HLRZ	A,JOBPHY	;HIGH SEG PHYSICAL SIZE
	ADD	N,A		;TOTAL USER PROGRAM PHYSICAL SIZE
	ADD	N,JOBPPG	;PLUS PER-PROCESS PAGES
	HRRZ	N1,JOBVIR	;LOW SEG VIRTUAL SIZE
	HLRZ	A,JOBVIR	;HIGH SEG VIRTUAL SIZE
	ADD	N1,A		;TOTAL USER PROGRAM VIRTUAL SIZE
	ADD	N1,JOBPPG	;PLUS PER-PROCESS PAGES
	JRST	NORM3A		;COUNT 'EM UP

SYS2LG:	SETZ	N1,		;NO VIRTUAL SIZE
	MOVS	N,@JBADR		
	JUMPE	N,SYSL1I
	TXNN	JS,JS$SWP
	JRST	NORM3
SYSL1I:	MOVE	N,@JBSWP
	ANDI	N,777
	JUMPN	N,NORM3A
	HLRZ	N,@JBADR	;IN PROCESS--USE IN CORE VALUE
NORM3:	ADDI	N,1
	LSH	N,@W2PLSH	;GET "PAGE" COUNT
	ANDI	N,777
NORM3A:	ADDM	N,PHYUSE	;COUNT TOTAL PHYSICAL IN USE
	ADDM	N1,VIRUSE	;COUNT TOTAL VIRTUAL IN USE
	PUSHJ	P,INACTC	;TEST FOR ACTIVE PROGRAM
	  ADDM	N,ACTUSE	;  YES, ADD CORE SIZE IN
	TLNN	F,FL.SUP	;SEE IF SUPPRESSED
	CALL	PGDATA		;TYPE PAGING DATA
TSTATE:	MOVSI	A,'^W '		;"COMMAND WAIT"
	TXNE	JS,JS$RUN	;RUN BIT ON?
	MOVSI	A,'CW '		;YES, CHANGE INDICATION
	TXNE	JS,JS$CMW	;JOB IN COMMAND WAIT?
	JRST	TSTAT9		;YES. SAY SO REGARDLESS OF STATE
	MOVSI	A,'OW '		;"OPERATOR WAIT FOR DEVICE"
	TXNE	JS,JS$OWD	;JOB IN DEVICE ERROR WAIT?
	JRST	TSTAT9		;YES, SAY SO
	MOVSI	A,'^D '		;"DAEMON (.DCORE) WAIT"
	TXNE	JS,JS$JDC	;JOB WAITING FOR DAEMON?
	JRST	TSTAT9		;YES, TELL USER THAT
	MOVSI	A,'^C '		;"CONTROL-C (HALT) STATE"
	JUMPGE	JS,TSTAT9	;IF JOB IS NOT RUNNING SAY HALTED
	MOVSI	A,'RU '		;"RUN/GET[SEG]/MERGE COMMAND/UUO"
	MOVX	N,J2$IGS	;THE "IN GETSEG" BIT
	TXNN	JS,JS$RUU	;IN A RUN UUO OR COMMAND?
	TDNE	N,@JBST2	;OR IN A GETSEG (MERGE) UUO OR COMMAND?
	JRST	TSTAT8		;YES, SAY THAT THEN (AND COUNT ACTIVE)
	LDB	B,[POINTR JS,JS$WST]  ;GET JOB WAIT STATE QUEUE
	IDIVI	B,3		;THREE QUEUE NAMES PER WORD
	IMULI	C,^D12		;EQUALS 12 BITS PER WORD
	MOVE	A,QTAB(B)	;WORD HOLDING QUEUE CODES
	LSH	A,(C)		;LEFT JUSTIFY QUEUE CODE NAME
	AND	A,[7777B11]	;MASK OFF ANY OTHER CODES
	MOVS	B,A		;PUT IN RH(B) FOR EASE OF CHECKING
	CAIE	B,'SL '		;IN SLEEP QUEUE?
	JRST	TSTAT0		;NO, CHECK FOR TI
	MOVX	N,J2$HIB	;THE "IN A HIBER" BIT
	TDNN	N,@JBST2	;PROGRAM IN A HIBER OR A SLEEP?
	JRST	TSTAT8		;IN A SLEEP, COUNT SLEEPY JOB
	MOVSI	A,'HB '		;IN A HIBER, INDICATE ACCORDINGLY
	TXNE	JS,JS$CLK	;ALSO GOT A CLOCK REQUEST PENDING?
	MOVSI	A,'HS '		;YES, "HIBER WITH A SLEEP TIME"
	JRST	TSTAT8		;COUNT UP A SLEEPY JOB
TSTAT0:
;	CAIE	B,'TI '		;IN TERMINAL I/O WAIT?
;	JRST	TSTAT2		;NO, SEE IF RN (OR HPQ) STATE
;	SKIPN	B,@TTIOS	;YES--SEE IF I/O SETUP
;	JRST	TSTAT2		;NO--LEAVE ALONE
;	TLNN	F,FL.SCN	;SEE IF NEW SCANNER SERVICE
;	MOVNS	B		;NO--INVERT SIGN
;	SKIPGE	B		;SEE IF OUTPUT ACTIVE
;	MOVSI	A,'TO '		;YES--SET TO TTY OUTPUT
;	JRST	TSTAT8		;AND COUNT LEAST ACTIVE JOBS
	CAIE	B,'DI '		;IN DISK I/O WAIT?
	CAIN	B,'IO '		;OR RANDOM I/O WAIT?
	JRST	TSTAT1		;YES, SEE WHICH DIRECTION
	CAIE	B,'TI '		;IN TERMINAL I/O WAIT?
	JRST	TSTAT2		;NO, CHECK FOR OTHER STATES
;TTY'S MUST BE HANDLED SPECIAL SINCE FOR THEM IO$OUT IS IGNORED
	MOVE	B,['TWTITO']	;YES
	PUSHJ	P,IOWTT		;CHECK IF TTY IS IN OR OUT BLOCKED
	MOVS	B,A		;GET STATE BACK INTO B AGAIN
	CAIE	B,'TI '		;IN TERMINAL INPUT STATE?
	JRST	TSTAT7		;NO, COUNT COUNT I/O BLOCKED
	JRST	TSTAT8		;YES, COUNT AS SLEEPY JOB

TSTAT1:	CAIN	B,'DI '		;IN DISK I/O WAIT?
	MOVE	B,['DWDIDO']	;YES
	CAIN	B,'IO '		;RANDOM I/O WAIT?
	MOVE	B,['IOINOU']	;YES
;	CAIN	B,'TI '		;IN TERMINAL I/O WAIT?
;	MOVE	B,['TWTITO']	;YES
	PUSHJ	P,IOWCK		;PICK APPROPRIATE STATE
;	MOVS	B,A		;GET STATE BACK AGAIN
;	CAIE	B,'TI '		;TERMINAL INPUT WAIT?
	JRST	TSTAT7		;NO, COUNT I/O BLOCK JOBS
;	JRST	TSTAT8		;YES, COUNT SLEEPY JOBS
TSTAT2:	CAIE	B,'RN '		;IN THE RN QUEUE(S)?
	JRST	TSTAT3		;NO--GO ON
	LDB	B,[POINTR @JBRTD,JR$HPQ]  ;YES, GET HPQ (IF ANY)
	JUMPE	B,TSTAT6	;NOT IN HPQ
	TRZN	B,10		;HPQ .GE. 10?
	TROA	B,' H0'		;NO, PRINT AS HN
	ADDI	B,' 00'		;YES, PRINT AS NN
	LSHC	A,^D36+^D24	;LEFT JUSTIFY SIXBIT IN A
	JRST	TSTAT6		;COUNT RN JOBS

TSTAT3:	CAIE	B,'EW '		;EVENT WAIT?
	JRST	TSTAT7		;EVERYTHING ELSE COUNTS AS ACTIVE
				; BUT "BLOCKED" (EVEN NA)
	LDB	B,[POINTR @JBST2,J2$WEW]  ;ESLEEP (EVENT WAIT) CODE
	CAIN	B,EW$TKW	;MAGTAPE KONTROLLER WAIT?
	MOVSI	A,'EK '		;YES, "EVENT KONTROLLER WAIT"
	CAIN	B,EW$REW	;MAGTAPE REWIND?
	MOVSI	A,'ER '		;YES, "EVENT REWIND WAIT"
	CAIN	B,EW$LBL	;LABEL PROCESSING WAIT?
	MOVSI	A,'EL '		;YES, "EVENT LABEL WAIT"
	CAIN	B,EW$NET	;NETWORK WAIT?
	MOVSI	A,'EN '		;YES, "EVENT NETWORK WAIT"
	CAIE	B,EW$FEI	;FRONT END INPUT WAIT?
	CAIN	B,EW$FEO	;OR FRONT END OUTPUT WAIT?
	MOVSI	A,'EF '		;YES, "EVENT FRONT-END WAIT"
	CAIN	B,EW$D60	;DN60 WAIT?
	MOVSI	A,'E6 '		;YES, "EVENT DN60 WAIT"
	MOVX	N,J2$EWS	;EVENT WAIT SATISFIED BIT
	TDNN	N,@JBST2	;JOB READY TO WAKE UP?
	JRST	TSTAT8		;NO, COUNT AS A SLEEPY JOB
	MOVSI	A,'ES '		;YES, CALL "EVENT WAIT SATISFIED"
	JRST	TSTAT7		;COUNT AS ACTIVE, BUT NOT IN RN QUEUE(S)
TSTAT6:	AOS	JRNRN		;JOBS IN ACTIVE RN STATE
TSTAT7:	AOS	JRNIO		;JOBS ACTIVE OR IO BLOCKED
TSTAT8:	AOS	JRNSL		;JOBS ACTIVE BUT SLEEPING
TSTAT9:	TLNE	F,FL.SUP	;SUPPRESSING OUTPUT?
	JRST	TSTATL		;YES, NO OUTPUT
	PUSHJ	P,SIXBP
	TXNN	JS,JS$LCK	;SEE IF LOCKED
	JRST	TSTATL		;NO--PROCEED
	MOVEI	CH,"&"		;INDICATE LOCKED
	PUSHJ	P,TYO		;OUTPUT IT
	SKIPN	@JBSGN	;SEE IF HI-SEG LOGIC
	JRST	SYSL1E		;NO--FINISH UP
TSTATL:	SKIPN	A,@JBSGN	;JOB HAVE A HISEG?
	JRST	[PUSHJ	P,SPACE
		JRST	SYSL1E]
	JUMPL	A,SYSL1S	;JUMP IF SPYING
	PUSH	P,J		;SAVE J
	MOVE	J,A
	SKIPE	B,@JBPRG	;AN OBSOLETED SEGMENT?
	JRST	SYSL1A		;NO-CHECK IF IT'S A NON CUSP HISEG
	MOVEI	CH,"@"
	MOVE	B,@JBSTS
	TXNE	B,JS$SHR	;IS IT SHARABLE?
	JRST	SYSL1B		;YES-FLAG JOB WITH @
	JRST	SYSL1F		;NO-MUST BE PRIVATE
SYSL1S:	MOVEI	CH,"+"		;GET A "+"
	PUSHJ	P,TYO		;OUTPUT IT TO SHOW SPYING
	JRST	SYSL1E		;  CONTINUE ON
SYSL1A:	MOVE	B,@JBPPN	;GET HISEG OWNER
	MOVEI	CH,"#"		;PREPARE TO FLAG JOB WITH #
	CAMN	B,OLDPPN
	MOVEI	CH,"O"
	CAMN	B,NEWPPN
	MOVEI	CH,"N"
	CAMN	B,SYSPPN	;CUSP?
SYSL1F:	MOVEI	CH," "		;PRINT A SPACE
SYSL1B:	PUSHJ	P,TYO		;PRINT @ OR #
	POP	P,J		;RESTORE J & A
	SUB	A,JOBN
	AOS	@SGCNT		;INCREMENT HISEG USE COUNT
SYSL1E:	SETZB	CH,A		;ZAP BOTH V AND SW WORD
	TRNN	F,FR.VMO	;IS VM OPTION IN SYSTEM
	JRST	SYSL2E		;NO SKIP THE V FLAG
;[561]	HLRZ	N,@JBPGR	;GET VIRTUAL FLAG
;[561]	JUMPE	N,SYSL2E	;NOT VIRTUAL
	MOVE	N,JOBPHY	;JOB'S PHYSICAL MEMORY SIZE(S)
	CAME	N,JOBVIR	;SAME AS VIRTUAL SIZE(S)?
	MOVEI	CH,"V"		;NO, FLAG JOB AS VIRTUAL
SYSL2E:	PUSHJ	P,LOPSWP	;PRINT STATE AND "SW"/"SF" IF SWAPPED/& FRAGMENTED
	MOVE	A,@JBTIM
	SUB	A,@JTTIM	;A := INCREMENTAL RUN TIME
	ADDM	A,@JTTIM	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTALS?
	MOVE	A,@JTTIM	;TOTALS
	SKIPN	PCTFLG		;RUNTIME OR PERCENTAGE?
	JRST	SYSL2T		;RUNTIME, JUST TYPE IT
	MOVE	B,UPTINC	;PERCENTAGE, GET UPTIME
	MOVEM	B,TEMP		;AND STORE FOR CMPDNA
	PUSHJ	P,CMPDNA	;PRINT OUT PERCENTAGE OF CPU
	PUSHJ	P,PERCNT	;WITH A PERCENT SIGN FOR CUTENESS
	CAIA			;DON'T BOTHER PRINTING TIME NOW
SYSL2T:	PUSHJ	P,TCKTIM	;JUST PRINT THE RUNTIME
	TRNN	F,FR.SJB	;EXPANDED JOB DISPLAY?
	JRST	SYSL5		;NO

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;PRINT DISK READS AND WRITES

	PUSHJ	P,TAB		;YES, TAB OVER TO DISK READS COLUMN
	MOVE	N,@JBRCT	;PICK UP DISK READS
	ANDX	N,RC.TTL	;REDUCE TO JOB TOTAL
	SUB	N,@JTRCT	;N := INCREMENTAL DISK READS
	ADDM	N,@JTRCT	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTALS?
	MOVE	N,@JTRCT	;TOTALS
	PUSHJ	P,DECB8		;PRINT DISK READS
	PUSHJ	P,TAB		;TAB OVER TO NEXT COLUMN
	MOVE	N,@JBWCT	;DISK WRITES
	ANDX	N,WC.TTL	;REDUCE TO JOB TOTAL
	SUB	N,@JTWCT	;N := INCREMENTAL DISK WRITES
	ADDM	N,@JTWCT	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTALS?
	MOVE	N,@JTWCT	;TOTALS
	PUSHJ	P,DECB8		;PRINT DISK WRITES

;PRINT USER NAME NOW

	PUSHJ	P,TAB		;TAB OVER TO USER NAME COLUMN
	MOVE	A,@JBNM1	;FIRST HALF OF THE USER NAME
	PUSHJ	P,SIXB6		;TYPE IT OUT
	SKIPE	A,@JBNM2	;SECOND HALF OF THE USER NAME
	PUSHJ	P,SIXBP		;TYPE IT OUT IF NON-BLANK

;END OF JOBS DISPLAY

SYSL5:	PUSHJ	P,CRLF		;CAP OFF THIS JOB'S DISPLAY LINE
NORMNJ:	TLZ	F,FL.SUP	;CLEAR DISPLAY SUPPRESS FOR NEXT JOB
	AOBJN	J,NORML0	;LOOP FOR ALL JOBS
	CALL	SETEND		;SET SLINE VARIABLE TO ADAPT TO EMPTY SCREEN
	TRNE	F,FR.JOB!FR.SJB!FR.VMM  ;JOBS ONLY?
	POPJ	P,		;YES, THEN ALL DONE

;FALL INTO HIGH SEGMENT SUMMARY STUFF AND DO SYSTEM DISPLAY
;CONTINUED FROM PREVIOUS PAGE

HIGH:	TLO	F,FL.SUP	;NO OUTPUT, JUST GET THE NUMBERS
	SETZM	JOBPPG		;DON'T MISLEAD HIPSWP
;[560]	JRST	HIGH0		;SKIP SETUP
;[560]
;[560]	THE CODE IS LEFT IN IN CASE SOMEONE LATER [RE-] IMPLEMENTS A
;[560]	HIGH SEG DISPLAY. IN THE "N" SCREEN THERE IS SIMPLY NOT ENOUGH
;[560]	ROOM TO DO A REASONABLE HIGH SEG DISPLAY, AND STILL DISPLAY
;[560]	SOME OF THE OTHER [MORE] INTERESTING FIGURES - LIKE DISK 
;[560]	STRUCTURES, ET AL.
;[560]
;[560]	TRNE	F,FR.VMM	;IF VM DISPLAY THEN
;[560]	JRST	[TLO	F,FL.SUP;SUPPRESS OUTPUT
;[560]		JRST	HIGH0]	;BUT UPDATE MEMORY COUNTERS
;[560]	CALL	WNDHSG		;SET WINDOW FOR HIGH SEGMENT
;[560]	MOVEI	M,[ASCIZ /HiSeg  #/]
;[560]	CALL	MSG		;PRINT FIRST PART
;[560]	CALL	KAYPAG		;NEXT K OR P
;[560]	MOVEI	M,[ASCIZ / SW #U
;[560]/]
;[560]	CALL	MSG		;PRINT THE LAST PART

HIGH0:	MOVE	J,SEGPTR
HIGH00:	MOVE	JS,@JBSTS
;[560]	TXNN	JS,JS$SNA
;[560]	JRST	DORMNT
;[560]	TLZ	F,FL.DOR
;[560]DOR1:	TLNE	F,FL.PDOR
;[560]	JRST	HIGH2A
;[560]	TLNN	F,FL.DOR
;[560]	PUSHJ	P,HIGH01
;[560]	JRST	DUNHGH
;[560]HIGH2A:	TLNE	F,FL.DOR
	TXNE	JS,JS$SNA	;SEGMENT NOT ACTIVE?
	PUSHJ	P,HIGH01
DUNHGH:	AOBJN	J,HIGH00	;ARE THERE ANY MORE HI SEGS.?
;[560]	MOVE	J,SEGPTR
;[560]	TLON	F,FL.PDOR
;[560]	JRST	HIGH00
	TLZ	F,FL.SUP	;CLEAR ANY SUPPRESSION
	JRST	NODORM


;[560]DORMNT:	LDB	N,IMGOUT	;SWAPPED OUT SIZE
;[560]	SKIPN	@JBADR		;SEGMENT IN CORE?
;[560]	CAIE	N,0		;NO - ON DISK?
;[560]	TLOA	F,FL.DOR
;[560]	JRST	DUNHGH		;NOT IN USE
;[560]	JRST	DOR1
HIGH01:
;[560]	TLNE	F,FL.SUP	;SUPPRESSING OUTPUT
;[560]	JRST	HIGH02		;YES, SAVE SOME CPU CYCLES
;[560]	SKIPN	A,@JBPRG
;[560]	JRST	[MOVE	A,[SIXBIT /(PRIV)/]
;[560]		TXNE	JS,JS$SHR
;[560]		MOVE	A,[SIXBIT /(OBS)/]
;[560]		JRST	.+1]
;[560]	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
;[560]	MOVEI	CH,0
;[560]	MOVE	N,@JBPPN
;[560]	CAMN	N,OLDPPN
;[560]	MOVEI	CH,"O"
;[560]	CAMN	N,NEWPPN
;[560]	MOVEI	CH,"N"
;[560]	JUMPN	CH,[SKIPLE LINE
;[560]		    SKIPG  COL
;[560]		    JRST   .+1
;[560]		    SOS    COL
;[560]		    PUSHJ  P,TYO
;[560]		    JRST   .+1]

HIGH02:	TXNN	JS,JS$SHR	;A SHARABLE SEGMENT
	TLNN	F,FR.VMO	;(NO) A VM OPTION IN SYSTEM
	JRST	HIGH07		;(YES) OR (NO) RESPECTIVELY
	MOVS	N,@JBSWP	;GET JBTSWP ENTRY
	JRST	HIGH04		;AND PROCESS IT
HIGH07:	MOVS	N,@JBADR
	JUMPN	N,HIGH03
	MOVE	N,@JBSWP	;IF NOTHING IN JBTADR - MUST BE SWAPPED
	JRST	HIGH04
HIGH03:	ADDI	N,1
	LSH	N,@W2PLSH	;GET "PAGE" COUNT
HIGH04:	ANDI	N,777
	TLNE	F,FL.DOR
	JRST	HIGH4A
;[561]	ADDM	N,CORUSE
	MOVE	B,N		;SAVE CORE SIZE FOR LATER
	PUSHJ	P,SEGSCN	;FIND FIRST USER OF THIS HIGH SEG
	  JRST	NOALOW		;NO USERS
	JRST	FSALOW		;SEE IF ACTIVE
NXALOW:	ADD	J,JBSGN		;RESTORE PTR TO SEGMENT TABLE
	EXCH	J,B		;RESTORE ORIGINAL J AND B
	PUSHJ	P,HIGH6A	;FIND NEXT USER OF THIS HIGH SEG
	  JRST	NOALOW		;NO MORE USERS
FSALOW:	EXCH	J,B		;J=PTR TO USER IN SEGMENT TABLE
	SUB	J,JBSGN		;J=JOB NUMBER OF USER
	PUSHJ	P,INACTC	;SKIP IF INACTIVE
	  SKIPA	J,B		;ACTIVE, COUNT THIS HIGH SEGMENT
	JRST	NXALOW		;INACTIVE, CHECK OTHER USERS
	ADDM	N,ACTUSE	;COUNT VIRTUAL CORE FOR ACTIVE SEGMENTS
NOALOW:	PUSH	P,N		;END OF ACTIVE-SEGMENT SEARCH
HIGH4A:	PUSHJ	P,DECPRT
	PUSHJ	P,TAB
	SETZB	A,CH		;ZAP PRINT WORDS
	PUSHJ	P,HIPSWP
	TLNE	F,FL.DOR
	JRST	[MOVEI	M,[ASCIZ /D
/]
	  PUSHJ	P,MSG
	  JRST	HIGH4B]
	MOVEI	A,(J)
	SUB	A,JOBN
	SOS	N,@SGCNT
	IMULM	N,(P)
	AOS	N,@SGCNT
	POP	P,A
	SKIPLE	A		;DON'T ADD TO CORSAV IF 0 OR -VE
	ADDM	A,SHRSAV	;COUNT MEMORY SAVED BY SHARING
	TLNE	F,FL.SUP	;TOSSING OUT OUTPUT?
	POPJ	P,		;YES, ALL USAGE COUNTERS UPDATED
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF
HIGH4B:	MOVE	A,@JBPPN
	JUMPN	A,HIGH05
	TLNE	F,FL.DOR
	JRST	HIGH5X
	PUSHJ	P,SEGSCN	;LOOK FOR JOB WITH THIS SEGMENT NO.
	  MOVEI	B,0		;NONE FOUND!!
HIGH05:	SKIPGE	B		;PRIVATE HISEG?
	JUMPE	A,[MOVEI M,[ASCIZ / Owner:Job /]	;YES-COMPUTE JOB NO.
		SUB	B,JBSGN
		HRRZ	N,B
		PUSHJ	P,MSGDEC	;AND PRINT IT
		JRST	CRLF]

HIGH5X:	CAMN	A,SYSPPN	;CUSP HISEG?
	JRST	CPOPJ		;YES-DON'T PRINT IT
	CAME	A,OLDPPN
	CAMN	A,NEWPPN
	POPJ	P,
	MOVEI	M,[ASCIZ / Owner:/]
	PUSHJ	P,MSG
	JUMPLE	A,[PUSHJ	P,SIXBP	;OWNER MUST BE A DEVICE
		   JRST		CRLF]
	PUSHJ	P,PNTPPN	;PRINT OWNER
	JRST	CRLF
;SUBROUTINE TO CONVERT TTY NUMBER TO CONTROLLING JOB NUMBER
;IF CONTROLLED OVER A PTY (5.03 AND MORE RECENT ONLY)
;CALL:	MOVE	A,'TTYNN'
;	PUSHJ	P,PTYCTL
;	RETURN WITH TTYNN OR JOBNN
;USES B,C,D,R

PTYCTL:	TLNN	A,-1		;SEE IF DETACHED
	POPJ	P,		;YES--LEAVE ALONE
	HRLZ	C,A		;GET TTY NUMBER (0 IF CTY)
	MOVEI	B,0		;CLEAR ACCUMULATOR
	LSH	C,3		;CONVERT TO
	LSHC	B,3		; BINARY FROM
	JUMPN	C,.-2		; SIXBIT
	CAML	B,PTYOFS	;SEE IF PTY
	CAML	B,PTYMAX	; DRIVEN
	POPJ	P,		;NO--RETURN
	SUB	B,PTYOFS	;YES--GET PTY NUMBER
	MOVEI	R,10		;CONVERT TO OCTAL
	PUSHJ	P,MAKSIX	; SIXBIT
	HRLI	B,'PTY'		;CHANGE TO DEVICE NAME
	SKIPE	REALTT		;TEST FOR PTY DISPLAY
	JRST	PTYXIT		;  YES, JUMP
	DEVTYP	B,1B19		;PHYSICAL DEVICE--GET JOB OWNER
	  POPJ	P,		;ERROR RETURN IF PRE 5.03
	LSH	B,-11		;GET JOB NUMBER
	ANDI	B,777		;REMOVE JUNK
	JUMPE	B,CPOPJ		;IF NOT CONNECTED, GIVE UP
	MOVEI	R,12		;CONVERT TO DECIMAL
	PUSHJ	P,MAKSIX	; SIXBIT
	HRLI	B,'JOB'		;ADD JOB PREFIX
PTYXIT:	MOVE	A,B		;CHANGE ANSWER
	POPJ	P,		;RETURN

;SUBROUTINE TO CONVERT BINARY TO SIXBIT IN ARBITRARY RADIX
;ARG/ANSWER IN B (0-777)
;USES C,D  RADIX IN R

MAKSIX:	MOVE	D,[POINT 6,B,17]	;PRESET POINTER
MAKSX1:	IDIVI	B,(R)		;OLD FASHIONED WAY
	HRLM	C,(P)
	SKIPE	B
	PUSHJ	P,MAKSX1
	HLRZ	C,(P)
	ADDI	C,'0'
	IDPB	C,D
	POPJ	P,
;SUBROUTINE TO FIND 1ST. JOB USING A SEGMENT
;CALL	MOVE	J,SEGMENT NO.
;	PUSHJ	P,SEGSCN
;	NONE FOUND RETURN
;	FOUND
;AC'S B & C DESTROYED
;AC J IS RESPECTED

SEGSCN:	MOVN	B,JOBN
	HRLZS	B
	HRR	B,JBSGN		;PREPARE AOBJN PTR. FOR SCANNING JBTSGN
HIGH06:	HRRZ	C,(B)		;GET SEGMENT NO.
	CAIE	C,(J)		;DOES IT MATCH WITH CURRENT ONE?
HIGH6A:	AOBJN	B,HIGH06	;NO-DO AGAIN
	SKIPGE	B		;WE HAVE A MATCH?
CPOPJ1:	AOS	(P)		;YES - SKIP RETURN
	POPJ	P,		;NO-NONE FOUND RETURN

;SUBROUTINE TO CHECK IF A SEGMENT IS INACTIVE
;INACTIVE IS DEFINED AS RUN BIT OFF OR SL/HB/TI/EW STATE
;ARGS	J=SEGMENT NUMBER IN RH
;NON-SKIP RETURN IF ACTIVE, SKIP RETURN IF INACTIVE

INACTC:	SKIPL	D,@JBSTS	;SKIP IF RUN BIT ON
	JRST	CPOPJ1		;OFF, INACTIVE
	LDB	D,[POINT 5,D,14]	;GET WAIT STATE CODE
	CAME	D,SLQ		;IN "SL" STATE?
	CAMN	C,HBQ		;OR "HB" STATE?
	JRST	CPOPJ1		;YES, ONE MATCHES, INACTIVE
	CAME	D,TIQ		;IN "TI" STATE?
	CAMN	D,EWQ		;OR "EW" STATE?
	AOS	(P)		;YES, MATCHES, INACTIVE
	POPJ	P,		;NO, MUST BE ACTIVE
;VMHILO COMPUTE PHYSICAL AND VIRTUAL HIGH AND LOW DATA
;THIS SHOULD BE COMPATIBLE WITH THE CORE COMMAND OUTPUT
;
;RETURNS:
;
;	JOBPHY		LOW,,HIGH PHYSICAL SEGMENT SIZES
;	JOBVIR		LOW,,HIGH VIRTUAL SEGMENT SIZES
;	JOBPPG		MONITOR PER-PROCESS PAGES FOR THIS JOB

VMHILO:	SETZ	N1,		;ASSUME NO HIGH SEG
	MOVE	N,@JBSWP	;GET LOW SEGSIZE
	MOVE	A,@JBSGN	;GET JBTSGN ENTRY
	JUMPLE	A,VMHIL1	;SPYING OR NO HIGH SEG
	TXNN	A,JS$SHR	;SHARABLE??
	JRST	VMHIL0		;NOPE OTHER ARITHMETIC

	ADD	A,JBSWP		;GET JBTSWP ENTRY
	HRRZ	N1,(A)		;AND GET HISEG SIZE
	JRST	VMHIL1		;ALLSET
VMHIL0:	ADD	A,JBSWP		;GET JBTSWP POINTER
	HLRZ	N1,(A)		;AND GET HISEG SIZE
	SUB	N,N1		;(NO) REDUCE LOW SEG SIZE
VMHIL1:	HRL	N1,N		;MAKE LOW,,HIGH PHYSICAL SIZES
	AND	N1,[777,,777]	;NO NOISE
	MOVEM	N1,JOBPHY	;REMEMBER PHYSICAL SIZES
	HRRZ	N,@JBPGR	;GET VIRTUAL SEGMENT SIZES
	LDB	N1,[POINT 9,N,18+8]  ;HIGH SEG SIZE
	HRL	N1,N		;MAKE LOW,,HIGH VIRTUAL SIZES
	AND	N1,[777,,777]	;NO NOISE
	MOVEM	N1,JOBVIR	;REMEMBER VIRTUAL ALSO
	LDB	N1,[POINTR @JBPDB,JP$PPP]  ;JOB'S PER-PROCESS PAGES
	CAIG	N1,0		;ZERO?
	MOVEI	N1,1		;UPMP COUNTS FOR AT LEAST ONE
	MOVEM	N1,JOBPPG	;REMEMBER OVERHEAD PAGES
	POPJ	P,		;RETURN WITH MEMORY SIZES
;IOWCK  --  DETERMINE IF I/O WAIT JOB IS IN OR OUT BLOCKED
;CALL IS:
;
;	MOVX	B,SIXBIT/XXYYZZ/
;	PUSHJ	P,IOWCK
;	RETURN
;
;WHERE 'XX' IS THE INDETERMINATE (NO PEEK OR SPY) STATE, 'YY' IS THE
;INPUT STATE, AND 'ZZ' IS THE OUTPUT STATE.

IOWCK:	HLRZ	A,@JBPC		;ADDRESS OF I/O BLOCKED DDB
	ADDI	A,$DVIOS	;OFFSET INTO DEVIOS WORD
	PUSHJ	P,MPEEK		;READ THE DEVICE I/O STATUS WORD
	JUMPE	A,IOWCK5	;IF 0 THEN NO PRIVS
	TXNE	A,IO$OUT	;DOING INPUT OR OUTPUT?
	LSH	B,^D12		;OUTPUT
	LSH	B,^D12		;INPUT
IOWCK5:	HLLZ	A,B		;GET I/O CODE IN A
	TLZ	A,77		;AND ONLY 2 CHARS WORTH
	POPJ	P,		;RETURN WITH STATE IN A

;SPECIAL KROCK IOWCK FOR TTY'S SINCE THEY WORK DIFFERENTLY

IOWTT:	HLRZ	A,@JBPC		;ADDRESS OF I/O BLOCKED TTY DDB
	ADDI	A,$DVIOS	;OFFSET INTO DEVIOS WORD
	PUSHJ	P,MPEEK		;READ THE DEVICE I/O STATUS WORD
	JUMPE	A,IOWTT5	;IF 0 THEN NO PRIVS
	SKIPGE	A		;DOING INPUT OR OUTPUT?
	LSH	B,^D12		;OUTPUT
	LSH	B,^D12		;INPUT
IOWTT5:	HLLZ	A,B		;GET I/O CODE IN A
	TLZ	A,77		;AND ONLY 2 CHARS WORTH
	POPJ	P,		;RETURN WITH TTY STATE IN A
;SUBROUTINE TO PRINT A MSG. FOLLOWED "SW" IF SEGMENT SWAPPED & NOT FRAGMENTED
; OR "SF" IF SWAPPED & FRAGMENTED, OR "FR" IF JUST FRAGMENTED & A HISEG
; OR NOTHING IF IN CORE & NOT FRAGMENTED
;CALL	MOVE	JS,JOB/HISEG STATUS
;	SETZ	A,		;ZERO F SF OR SW PRINT WORD
;	MOVEI	CH,CHAR	;VALUE TO BE APPENDED
;	PUSHJ	P,LOPSWP/HIPSWP
;	ALWAYS GOOD RETURN
;AC'S A,BP,CH ARE DESTROYED
;AC JS IS RESPECTED  *******MSG TO BE PRINTED MUSTN'T EXCEED 4 CHS.********

HIPSWP:	TXNE	JS,JS$SWP	;IS HI SEG SWAPPED?
	JRST	LOPSW1		;YES - GO PRINT "S" OR "SF"
	SKIPL	@JBSWP		;CORE IMAGE FRAGMENTED ON DISK?
	JRST	LOPCO3		;NO
	MOVSI	A,'F  '		;YES - PRESUME HISEG IN CORE
	JRST	LOPCO2		;BUT INDICATE FRAGMENTED ON DISK

LOPSWP:	TXNN	JS,JS$SWP	;IS SEG SWAPPED?
	JRST	LOPCO3		;NO - PRINT MSG & EXIT
LOPSW1:	MOVSI	A,'S  '		;PREPARE TO PRINT "S"
	SKIPGE	@JBSWP		;IS SEG FRAGMENTED?
	MOVSI	A,'SF '		;YES - INDICATE SWAPPED & FRAGMENTED
LOPSW2:	PUSH	P,CH		;SAVE APPENDENDUM
	PUSHJ	P,SIXBP		;PRINT "S" OR "SF"
	POP	P,CH		;GET APPENDUM BACK
LOPSW3:	SKIPE	CH		;ANYTHING TO PRINT?
	CALL	TYO		;(YES) DO IT
	LDB	N,IMGOUT	;GET CORE SIZE ON DISK
	ADD	N,JOBPPG	;PLUS OVERHEAD (LOW SEG ONLY)
	ADDM	N,DSKUSE	;ADD TO TOTAL SPACE USED ON SWAPPING SPACE
	JRST	TAB		;PRINT TAB & EXIT

LOPCO2:	PUSH	P,CH		;SAVE APPENDENDUM
	PUSHJ	P,SIXBP		;PRINT "F"
	POP	P,CH		;GET APPENDUM BACK
LOPCO3:	SKIPE	CH		;ANYTHING TO PRINT?
	CALL	TYO		;(YES) DO IT
	PJRST	TAB		;PRINT TAB & EXIT
	SUBTTL	"N" DISPLAY  --  GENERAL SYSTEM STATISTICS

NODORM:	CALL	WNDSYS		;WINDOW FOR SYSTEM DATA
NODOR0:	PUSHJ	P,CONFIG	;SHORT FORM OF "THISIS"
	CALL	CRLF		;START A NEW LINE
	PUSHJ	P,PDATIM
	MOVEI	M,[ASCIZ/ UP:/]	;IDENTIFY DATA
	PUSHJ	P,MSG		;TYPE OUT TEXT
	MOVE	A,UPTIME	;ALWAYS PRINT TOTAL UPTIME
	PUSHJ	P,TCKTIM	;TYPE OUT UPTIME
	PUSHJ	P,CRLF		;END LINE
	SUBTTL	"N" DISPLAY -- CPU USAGE STATISTICS

CPULP:	MOVE	A,[%CNCPU]	;MAX CPU'S MONITOR BUILT FOR
	PUSHJ	P,GET		;FIND OUT
	 JRST	[MOVEI	A,1	;ASSUME 1
		SKIPE	DUAL	;UNLESS 1077/1088/1099
		MOVEI	A,2	;IN WHICH CASE IS 2 CPU'S
		JRST	.+1]	;CONTINUE
	MOVEM	A,CPMAX		;SAVE FOR LOOP EXIT
	SUBI	A,1		;FLAG, .GT. 0 IF MULTI-CPU
	MOVEM	A,CPMNY		;REMEMBER FOR DOORBELL ETC.
	MOVE	A,[%CNBCP]	;FIND OUT BOOT CPU
	PUSHJ	P,GETZ		;ON GENERAL PRINCIPLES
	MOVEM	A,CPBTS		;AND REMEMBER IT
	MOVE	A,[%CCTYP]	;FIND OUT CPU TYPE FOR CPU0
	PUSHJ	P,GETZ		;READ IT
	CAIE	A,.CCKLX	;ON A KL-10?
	CAIN	A,.CCKSX	;OR A KS-10?
	SETOM	CPCSH		;YES, WATCH CACHE FLUSHES
	MOVEI	M,[ASCIZ/ (+)/]	;INDICATE "INCREMENTAL" NUMBERS
	TLNE	F,FL.INC	;INCREMENTAL OR TOTAL?
	PUSHJ	P,MSG		;INCREMENTAL, TELL USER
	MOVEI	M,[ASCIZ/	ID	OV	LS	 UPTIME	CTX	UUO/]
	PUSHJ	P,MSG		;LABEL COLUMNS
	MOVEI	M,[ASCIZ/	DBL/]  ;DOORBELLS/SEC
	SKIPLE	CPMNY		;MULTI-CPU?
	PUSHJ	P,MSG		;YES, ADD COLUMN FOR DOORBELLS/SEC
	MOVEI	M,[ASCIZ/	CSH/]  ;CACHE SWEEP COUNT
	SKIPE	CPCSH		;WATCHING CACHE FLUSHES?
	PUSHJ	P,MSG		;YES, ADD COLUMN
	PUSHJ	P,CRLF		;END HEADER LINE
	SETOM	CPU		;START WITH CPU-1

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

CPULP0:	AOS	J,CPU		;ADVANCE TO NEXT CPU
	CAML	J,CPMAX		;EXCEEDED SYSTEM MAX?
	JRST	CPULP9		;END CPU STUFF
	ASH	J,1		;INDEX INTO %CCXXX/%CVXXX TABLES
	MOVE	A,[%CCLOG]	;CPU LOGICAL NAME
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GET		;GET THIS CPU'S NAME
	 MOVE	A,['CPU?  ']	;FAILED?
	MOVEM	A,CPNAM(J)	;SAVE IT
	PUSHJ	P,SIXBP		;AND TYPE IT OUT

;MAKE SURE CPU IS RUNNING, ABORT DISPLAY IF NOT

	SETZ	M,		;ASSUME CPU IS OK
	MOVE	A,[%CVRUN]	;CPU RUN/SCHEDULING WORD
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;SEE WHAT MONITOR THINKS
	TXNE	A,CV%RUN	;"NOT RUNNING JOBS"?
	MOVEI	M,[ASCIZ/	(Not Scheduling)/]  ;NO
	MOVE	A,[%CCOKP]	;CPU "OK" WORD
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	CAILE	A,0		;CPU RUNNING OK IF .LE. 0
	MOVEI	M,[ASCIZ/	(Not Running)/]  ;SAY NOT RUNNING
CPULP1:	MOVEM	M,CPOKF(J)	;SAVE GOODNESS FOR OTHERS ALSO
	JUMPE	M,CPULP2	;IF NO ERROR PROCEDE WITH CPU STUFF
	PUSHJ	P,MSG		;TELL USER OF WOES
	JRST	CPULP7		;THAT'S IT FOR THIS CPU

;CPU IS RUNNING, SET UPTIME FOR CALCULATING INCREMENTAL VALUES

CPULP2:	MOVE	A,[%CVUPT]	;CPU UPTIME
	ADD	A,J		;OFFSET FOR CURRENT CPU
	PUSHJ	P,GETZ		;GET WHAT'S THERE
	SUB	A,CPUPT(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPUPT(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPUPT(J)	;WANT TOTALS
	MOVEM	A,TEMP		;SAVE IT

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;SHOW CPU IDLE (NO JOBS TO RUN) TIME

	PUSHJ	P,TAB		;TAB OVER TO THE COLUMN
	MOVE	A,[%CVNUL]	;CPU NULL (IDLE) TIME
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPNUL(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPNUL(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPNUL(J)	;WANT TOTALS
	PUSHJ	P,CALCNA	;CALCULATE PERCENT IDLE TIME
	PUSHJ	P,DECB2		;PRINT PERCENT IDLE TIME

;SHOW CPU OVERHEAD (INTERRUPT LEVEL, SCHEDULER, ETC.) TIME

	PUSHJ	P,TAB		;TAB OVER TO THE COLUMN
	MOVE	A,[%CVOHT]	;CPU OVERHEAD TIME
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPOHT(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPOHT(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPOHT(J)	;WANT TOTALS
	PUSHJ	P,CALCNA	;CALCULATE PERCENT OVERHEAD TIME
	PUSHJ	P,DECB2		;PRINT PERCENT OVERHEAD TIME

;SHOW CPU LOST (JOBS RUNNABLE, BUT COULDN'T) TIME

	PUSHJ	P,TAB		;TAB OVER TO THE COLUMN
	MOVE	A,[%CVLST]	;CPU LOST TIME
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPLST(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPLST(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPLST(J)	;WANT TOTALS
	PUSHJ	P,CALCNA	;CALCULATE PERCENT LOST TIME
	PUSHJ	P,DECB2		;PRINT PERCENT LOST TIME

;SHOW CPU UPTIME

	PUSHJ	P,TAB		;SPACE OVER FOR UPTIME
	MOVE	A,TEMP		;GET THIS CPU UPTIME
	PUSHJ	P,TCKTIM	;PRINT UPTIME

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;SHOW CPU CONTEXT SWITCHES PER SECOND

	PUSHJ	P,TAB		;TAB OVER TO CONTEXT SWITCHS
	MOVE	A,[%CVTJC]	;CONTEXT SWITCH COUNT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPTJC(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPTJC(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPTJC(J)	;WANT TOTALS
	PUSHJ	P,CALCPT	;CALCULATE CONTEXT SWITCHES PER SECOND
	PUSHJ	P,DECB3		;PRINT CONTEXT SWITCHES PER SECOND

;SHOW CPU MONITOR CALLS ("UUO'S") PER SECOND

	PUSHJ	P,TAB		;TAB OVER TO UUOS
	MOVE	A,[%CVTUC]	;UUO COUNT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPTUC(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPTUC(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPTUC(J)	;WANT TOTALS
	PUSHJ	P,CALCPT	;CALCULATE UUOS PER SECOND
	PUSHJ	P,DECB3		;PRINT UUOS PER SECOND

;SHOW INTER-CPU DOORBELLS PER SECOND (IF APPLICABLE)

	SKIPN	CPMNY		;ON A MULTI-CPU SYSTEM?
	JRST	CPULP5		;NO
	PUSHJ	P,TAB		;YES, TAB OVER TO DOORBELLS COLUMN
	MOVE	A,[%CVNDB]	;NUMBER OF TIMES DOORBELL RUNG
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPNDB(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPNDB(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPNDB(J)	;WANT TOTALS
	PUSHJ	P,CALCPT	;CALCULATE DOORBELLS PER SECOND
	PUSHJ	P,DECB3		;PRINT DOORBELLS PER SECOND

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;SHOW CPU CACHE SWEEPS PER SECOND (IF APPLICABLE)

CPULP5:	SKIPN	CPCSH		;WATCHING CACHE FLUSHES?
	JRST	CPULP7		;NO, NO CACHE SWEEPS THEN
	PUSHJ	P,TAB		;YES, TAB OVER
	MOVE	A,[%CVCSN]	;CACHE SWEEPS SINCE RELOAD
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	SUB	A,CPCSN(J)	;A := INCREMENTAL VALUE
	ADDM	A,CPCSN(J)	;UPDATE TOTALS TABLE
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,CPCSN(J)	;WANT TOTALS
	PUSHJ	P,CALCPT	;CALCULATE CACHE SWEEPS PER SECOND
	PUSHJ	P,DECB3		;PRINT CACHE SWEEPS PER SECOND

;CALCULATE CPU CLOCK RATE IN CASE BPA STUFF TURNED ON

	MOVE	A,[%CCEBS]	;EBOX TICKS PER SECOND
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ IT
	IDIV	A,[^D500000]	;CONVERT TO MHZ FOR BPA STUFF
	CAIGE	A,0		;JUST TO MAKE SURE
	SETZ	A,		;. . .
	MOVEM	A,CPMHZ(J)	;SAVE CPU CLOCK RATE

CPULP7:	PUSHJ	P,CRLF		;END OF THIS LINE

	JRST	CPULP0		;CHECK OUT ANY MORE CPU'S

CPULP9:!
	SUBTTL	"N" DISPLAY  --  FILE AND SWAPPING I/O COUNTS

CPUIO:	TABSET	TAB1IO		;SET NEAT TABS FOR I/O
	MOVEI	M,[ASCIZ\	DSKI	DSKO	SWPI	SWPO
\]				;COLUMN HEADER
	PUSHJ	P,MSG		;LABEL COLUMNS
	SETOM	CPU		;START WITH CPU -1

CPUIO0:	AOS	J,CPU		;NEXT CPU
	CAML	J,CPMAX		;REACHED END YET?
	JRST	CPUIO9		;YES, EXIT THIS STUFF
	ASH	J,1		;DOUBLE WORD INDEX
	SKIPE	CPOKF(J)	;IS CPU RUNNING OK?
	JRST	CPUIO0		;CPU KNOWN NOT RUNNING
	MOVE	A,CPNAM(J)	;GET THIS CPU'S NAME
	PUSHJ	P,SIXTAB	;AND TYPE IT OUT

;LIST FILE BLOCKS PER SECOND INPUT

	MOVE	A,[%CVFBI]	;FILE BLOCKS INPUT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,CPFBI(J)	;A := INCREMENTAL
	ADDM	A,CPFBI(J)	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL MODE?
	MOVE	A,CPFBI(J)	;TOTAL
	PUSHJ	P,CALCTT	;CALCULATE PER-SECOND FIGURE
	PUSHJ	P,DECB4		;PRINT PER-SECOND FILE READS

;LIST FILE BLOCKS PER SECOND OUTPUT

	PUSHJ	P,TAB		;SPACE OVER
	MOVE	A,[%CVFBO]	;FILE BLOCKS OUTPUT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,CPFBO(J)	;A := INCREMENTAL
	ADDM	A,CPFBO(J)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,CPFBO(J)	;TOTALS
	PUSHJ	P,CALCTT	;CALCULATE PER-SECOND FILE WRITES
	PUSHJ	P,DECB4		;PRINT PER-SECOND FILE WRITES

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;LIST SWAP BLOCKS PER SECOND INPUT

	PUSHJ	P,TAB		;SPACE OVER
	MOVE	A,[%CVSBI]	;SWAP BLOCKS INPUT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,CPSBI(J)	;A := INCREMENTAL
	ADDM	A,CPSBI(J)	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,CPSBI(J)	;TOTAL
	PUSHJ	P,CALCTT	;CALCULATE PER-SECOND SWAP READS
	PUSHJ	P,DECB4		;PRINT PER-SECOND SWAP READS

;LIST SWAP BLOCKS PER SECOND OUTPUT

	PUSHJ	P,TAB		;SPACE OVER
	MOVE	A,[%CVSBO]	;SWAP BLOCKS OUTPUT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,CPSBO(J)	;A := INCREMENTAL
	ADDM	A,CPSBO(J)	;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,CPSBO(J)	;TOTALS
	PUSHJ	P,CALCTT	;CALCULATE PER-SECOND SWAP WRITES
	PUSHJ	P,DECB4		;PRINT PER-SECOND SWAP WRITES

;CAP OFF THIS CPU DISK I/O STATISTICS

	PUSHJ	P,CRLF		;END OF LINE
	JRST	CPUIO0		;LOOP FOR NEXT CPU

CPUIO9:!			;END OF CPU DISK I/O
	SUBTTL	"N" DISPLAY  --  KL-10 RH20 CHANNEL USAGE

;IT SHOULD BE NOTED (LEST CONFUSION ARISE) THAT THE PERCENTAGES CAL-
;CULATED HERE ARE NOT RH20 USAGE, BUT RATHER RH20 TO MBOX USAGE, AND
;AS SUCH CAN VARY WIDELY (COMME, PAR EXAMPLE, A FACTOR OF TEN) FROM WHAT
;ONE MIGHT INTUITIVELY EXPECT THE NUMBERS TO BE. TYPICALLY THE MORE THE
;SYSTEM IS BEAT UPON (CHANNELS ACTIVE, SWEEPING CACHE, ETC.) THE HIGHER
;THE CHANNEL PERCENTAGES WILL BE FOR THE SAME (!) AMOUNT OF THROUGHPUT.

CPUCH:	TABSET	TAB1CP		;SET NEAT TABS
	MOVEI	M,[ASCIZ\	CH0	CH1	CH2	CH3	CH4	CH5	CH6	CH7
\]				;COLUMN HEADER
	MOVEM	M,CPHDR		;SAVE FOR FIRST OCCURENCE
	SETOM	CPU		;START WITH CPU -1

;LOOP OVER EACH CPU IN SYSTEM

CPUCH0:	AOS	J,CPU		;NEXT CPU
	CAML	J,CPMAX		;DONE LAST ONE YET?
	JRST	CPUCH9		;YES, EXIT CHANNEL PERCENTAGES
	ASH	J,1		;%CCXXX/%CVXXX DOUBLE WORD INDEX
	SKIPE	CPOKF(J)	;IS CPU RUNNING OK?
	JRST	CPUCH0		;CPU KNOWN NOT RUNNING
	MOVE	A,[%CVBPF]	;SEE IF PERF ANAL COUNTS BEING KEPT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;AND READ MONITOR'S COUNTER FLAG
	JUMPGE	A,CPUCH0	;SKIP THIS CPU IF NOT COUNTING
	MOVE	A,[%CCBPA]	;PERF ANAL COUNT SUBTABLE POINTER
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM CDB
	JUMPE	A,CPUCH0	;NONE FOR THIS CPU
	TXNN	A,777B8		;GOT A LENGTH?
	JRST	CPUCH0		;NO, SKIP THIS CPU
	HRLZM	A,CPRLX		;SAVE REL OFFSET INTO CDB
	SKIPE	M,CPHDR		;GIVEN COLUMN HEADER YET?
	PUSHJ	P,MSG		;NO, LABEL THE COLUMNS
	SETZM	CPHDR		;NOTE COLUMNS HAVE BEEN IDENTIFIED
	MOVE	A,CPNAM(J)	;NOW GET THIS CPU'S NAME
	PUSHJ	P,SIXBP		;TYPE IT OUT
	MOVE	JS,[-10,,%CVCH0];PRESET JS INDEX FOR RH20 CHANNELS
	PUSHJ	P,CPLQR		;DO ALL THE WORK
	JRST	CPUCH0		;TRY FOR ANOTHER CPU

CPUCH9:!			;END OF KL-10 CHANNEL USAGE
	SUBTTL	"N" DISPLAY -- KL-10 PI CHANNEL USAGE

CPUPI:	TABSET	TAB1CP		;SET NEAT TABS
	MOVEI	M,[ASCIZ\	PI0	PI1	PI2	PI3	PI4	PI5	PI6	PI7
\]				;COLUMN HEADER
	MOVEM	M,CPHDR		;SAVE FOR FIRST OCCURENCE
	SETOM	CPU		;START WITH CPU -1

;LOOP OVER EACH CPU IN SYSTEM

CPUPI0:	AOS	J,CPU		;NEXT CPU
	CAML	J,CPMAX		;DONE LAST ONE YET?
	JRST	CPUPI9		;YES, EXIT PI PERCENTAGES
	ASH	J,1		;%CCXXX/%CVXXX DOUBLE WORD INDEX
	SKIPE	CPOKF(J)	;IS CPU RUNNING OK?
	JRST	CPUPI0		;CPU KNOWN NOT RUNNING
	MOVE	A,[%CVBPF]	;SEE IF PERF ANAL COUNTS BEING KEPT
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;AND READ MONITOR'S COUNTER FLAG
	JUMPGE	A,CPUPI0	;SKIP THIS CPU IF NOT COUNTING
	MOVE	A,[%CCBPA]	;PERF ANAL COUNT SUBTABLE POINTER
	ADD	A,J		;OFFSET FOR THIS CPU
	PUSHJ	P,GETZ		;READ FROM CDB
	JUMPE	A,CPUPI0	;NONE FOR THIS CPU
	TXNN	A,777B8		;GOT A LENGTH?
	JRST	CPUPI0		;NO, SKIP THIS CPU
	HRLZM	A,CPRLX		;SAVE REL OFFSET INTO CDB
	SKIPE	M,CPHDR		;GIVEN COLUMN HEADER YET?
	PUSHJ	P,MSG		;NO, LABEL THE COLUMNS
	SETZM	CPHDR		;NOTE COLUMNS HAVE BEEN IDENTIFIED
	MOVE	A,CPNAM(J)	;NOW GET THIS CPU'S NAME
	PUSHJ	P,SIXBP		;TYPE IT OUT
	MOVE	JS,[-10,,%CVPI0];PRESET JS INDEX FOR PI CHANNELS
	PUSHJ	P,CPLQR		;DO ALL THE WORK
	JRST	CPUPI0		;TRY FOR ANOTHER CPU

CPUPI9:	JRST	NETLP		;END OF KL-10 PI USAGE
;STUFF FOR CPU STATISTICS ABOVE

;CPLQR  --  LOOP THROUGH KL10 PERF ANAL SUBTABLE PRINTING PERCENTAGES

CPLQR0:	ADDI	JS,3		;SUBTABLE IS IN 4 WORD BLOCKS
CPLQR:	HRLZI	A,(JS)		;SUBTABLE ITEM
	ADD	A,CPRLX		;RELOCATE INTO %CVXXX TABLE
	HRRI	A,.GTC0V(J)	;RELOCATE INTO CDB (GETTAB)
	PUSHJ	P,GET4		;READ 4 WORDS
	 PJRST	CRLF		;IT'S ALL OVER
	ASHC	A,-^D12		;A'B := TOTAL ELAPSED TIME IN USEC
	ASHC	C,-^D12		;C'D := CPU CYCLES / 2
	DMOVE	N,A		;HOLD ELAPSED TIME
	DSUB	A,@CIELT(J)	;A'B := INCREMENTAL ELAPSED TIME
	DMOVEM	N,@CIELT(J)	;SET NEW TOTAL ELAPSED TIME
	TLNE	F,FL.INC	;INCREMENTAL OR TOTAL?
	DMOVE	N,A		;N'N1 := ELAPSED TIME (USEC)
	DMOVE	A,C		;TEMP COPY
	DSUB	A,@CIELC(J)	;A'B := INCREMENTAL PERF COUNT
	DMOVEM	C,@CIELC(J)	;SET NEW TOTAL PERF COUNT
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	DMOVE	A,C		;A'B := PERF COUNT
	DMUL	A,[EXP 0,^D20000]  ;PERCENTAGE FIGURE
				; (CPU CYCLES * ^D100 * ^D100)
	DDIV	A,CPMHD(J)	;DIVIDE BY CLOCK RATE (IN MHZ)
	DMOVE	C,A		;DDIV WANTS QUAD WORD
	SETZB	A,B		;A'B'C'D := PERF USEC COUNT * ^D10000
	DDIV	A,N		;A'B := PERCENTAGE (HUNDREDTHS)
	ASHC	C,1		;ROUND UP
	DSUB	C,N		;(DON'T HAVE DCAM??)
	CAILE	C,0		;HALFWAY TO NEXT POINT?
	ADDI	B,1		;YES
	MOVE	N,B		;PUT WHERE DECOUT CAN FIND IT
	PUSHJ	P,TAB		;SEPARATE COLUMNS
	PUSHJ	P,CPCPT		;TYPE OUT PERCENTAGE
	AOBJN	JS,CPLQR0	;LOOP FOR REST OF LINE
	PJRST	CRLF		;CAP OFF LINE
;CDB SUBTABLE INDEX POINTERS

CIELT:	Z	CP0PAV(JS)	;CPU0 PERF ITEMS (ELAPSED)
CIELC:	Z	CP0PAV+2(JS)	;CPU0 PERF ITEMS (COUNT)
	Z	CP1PAV(JS)	;CPU1 PERF ITEMS (ELAPSED)
	Z	CP1PAV+2(JS)	;CPU1 PERF ITEMS (COUNT)
	Z	CP2PAV(JS)	;CPU2 PERF ITEMS (ELAPSED)
	Z	CP2PAV+2(JS)	;CPU2 PERF ITEMS (COUNT)
	Z	CP3PAV(JS)	;CPU3 PERF ITEMS (ELAPSED)
	Z	CP3PAV+2(JS)	;CPU3 PERF ITEMS (COUNT)
	Z	CP4PAV(JS)	;CPU4 PERF ITEMS (ELAPSED)
	Z	CP4PAV+2(JS)	;CPU4 PERF ITEMS (COUNT)
	Z	CP5PAV(JS)	;CPU5 PERF ITEMS (ELAPSED)
	Z	CP5PAV+2(JS)	;CPU5 PERF ITEMS (COUNT)
	SUBTTL	"N" DISPLAY -- NETWORK BYTE I/O STATISTICS

NETLP:	TABSET	TAB1NT		;SET TO NET I/O TABS
	MOVEI	M,[ASCIZ\NET In:\] ;SHOW NET STATISTICS
	PUSHJ	P,MSG		;PREFIX INPUT COUNTS

;INPUT BYTES PER SECOND PROCESSED

	MOVE	A,[%NTBYI]	;TOTAL INPUT BYTES PROCESSED
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,NTBYI		;A := INCREMENTAL
	ADDM	A,NTBYI		;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,NTBYI		;TOTALS
	PUSHJ	P,CMPCTT	;BYTES PER SECOND

;OUTPUT BYTES PROCESSED PER SECOND

	MOVEI	M,[ASCIZ\	Out:\] ;PREFIX OUT
	PUSHJ	P,MSG		;TELL USER
	MOVE	A,[%NTBYO]	;TOTAL OUTPUT BYTES PROCESSED
	PUSHJ	P,GETZ		;READ FROM MONITOR
	SUB	A,NTBYO		;A := INCREMENTAL
	ADDM	A,NTBYO		;UPDATE TOTALS
	TLNN	F,FL.INC	;INCREMENTAL OR TOTALS?
	MOVE	A,NTBYO		;TOTALS
	PUSHJ	P,CMPCTT	;BYTES PER SECOND

;MONITOR FREE CORE USED

	MOVEI	M,[ASCIZ\	Cor:\] ;PREFIX MSG
	MOVE	A,[%NTCOR]	;NETWORK CORE IN USE
	PUSHJ	P,GETZ		;READ FROM MONITOR
	MOVE	N,A		;POSITION FOR DECPRT
	PUSHJ	P,MSGDEC	;TYPE OUT PREFIX AND MESSAGE

;CAP OFF LINE

	PUSHJ	P,CRLF		;END OF NET I/O STATISTICS

;FALL INTO TTYLP
	SUBTTL	"N" DISPLAY -- TTY CHARACTER I/O STATISTICS

TTYLP:	TABSET	TAB1TT		;CHANGE TAB STOPS FOR TTY STATS
	MOVEI	M,[ASCIZ/TTY In:/] ;SHOW TTY STATISTICS
	PUSHJ	P,MSG		;PREPARE USER

;INPUT CHARACTERS RECEIVED

	MOVE	A,[%SCNRI]	;TOTAL RECEIVED CHARACTERS
	PUSHJ	P,GETZ		;READ IT
	SUB	A,SCNRI		;A := INCREMENTAL VALUE
	ADDM	A,SCNRI		;UPDATE TOTALS
	TLNN	F,FL.INC	;WANT INCREMENTALS OR TOTALS
	MOVE	A,SCNRI		;TOTALS
	PUSHJ	P,CMPCTT	;RECEIVED CHARACTERS PER SECOND

;OUTPUT CHARACTERS TRANSMITTED

	MOVEI	M,[ASCIZ/	Out:/]  ;SHOW OUTPUT
	PUSHJ	P,MSG		;PREPARE USER
	MOVE	A,[%SCNXI]	;TOTAL CHARACTERS SENT
	PUSHJ	P,GETZ		;READ IT
	SUB	A,SCNXI		;A := INCREMENTAL
	ADDM	A,SCNXI		;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTALS OR TOTALS?
	MOVE	A,SCNXI		;TOTALS
	PUSHJ	P,CMPCTT	;TRANSMITTED CHARACTERS PER SECOND

;CHUNKS IN USE (PERCENTAGE)

	MOVE	A,[%CNTTC]	;TOTAL CHUNKS COUNT
	PUSHJ	P,GETZ		;READ IT
	HLREM	A,TEMP		;SAVE TOTAL FOR PERCENTAGE CALC
	MOVE	A,[%CNTTN]	;TOTAL NUMBER OF FREE CHUNKS
	PUSHJ	P,GETZ		;READ IT
	MOVN	A,A		;ACTUALLY WANT CHUNKS USED
	ADD	A,TEMP		;A := CHUNKS USED
	MOVEI	M,[ASCIZ/	Cnk:/]  ;LABEL IT
	PUSHJ	P,CMPCNA	;TYPE OUT PERCENTAGE CHUNKS USED
	MOVEI	CH,"%"		;TELL USER THAT NUMBER
	PUSHJ	P,TYO		;IS A PERCENTAGE

	PUSHJ	P,CRLF		;END OF TTY STATISTICS

;FALL INTO MEMORY UTILIZATION STATISTICS
	SUBTTL	"N" DISPLAY -- MEMORY AVAILABILITY AND JOB LOADING STATISTICS

MEMLP:	MOVX	A,%NSCMX	;GET CORMAX VALUE
	PUSHJ	P,GETA		;FROM MONITOR
	MOVEM	A,CORMAX	;SAVE FOR MOMENT
	MOVEM	A,N		;HOLD HERE ALSO
	MOVX	A,%NSMXM	;GET MAX USER MEMORY SPACE
	PUSHJ	P,GETA		;FROM MONITOR
	MOVEM	A,MAXMAX	;SAVE FOR MOMENT
	MOVX	A,%CNNWC	;TOTAL (MAX) WORDS OF MEMORY
	PUSHJ	P,GETA		;READ FROM MONITOR
	MOVE	B,A		;HOLD ONTO IT FOR A MOMENT
	MOVX	A,%CNSIZ	;GET SIZE OF MONITOR LOW SEG
	PUSHJ	P,GETA		;FROM MONITOR
	SUB	B,A		;SUBTRACT FROM TOTAL
	MOVX	A,%CNMXF	;GET FINAL VIRTUAL ADDRESS
	PUSHJ	P,GETZ		;OF MONITOR HIGHSEG
	JUMPE	A,MEMLP1	;IF PRE-7.01335 USE OLD VALUE
	SUB	B,A		;REMOVE FROM PHYSICAL MEM AVAILABLE
	MOVX	A,%CNVSH	;GET FIRST VIRTUAL ADDRESS
	PUSHJ	P,GET		;OF MONITOR HIGH SEGMENT
	 MOVEI	A,453000	;DEFAULT
	ADD	B,A		;ALLOW FOR MONITOR HIGH SEGMENT
	JRST	MEMLP2		;B := MAX POSSIBLE MAXMAX
MEMLP1:	MOVX	A,%CNHSL	;OLD (PRE-HIGHSEG-LDB DAYS) LENGTH
	PUSHJ	P,GETA		;OF MONITOR HIGH SEG
	SUB	B,A		;B := MAX POSSIBLE MAXMAX
MEMLP2:	MOVEM	B,PHYMAX	;REMEMBER IT

;CORMAX := MAXIMUM SINGLE USER PHYSICAL MEMORY AVAILABLE
;MAXMAX := MAXIMUM TOTAL USER PHYSICAL MEMORY AVAILABLE (INCL LOCKED)
;PHYMAX := MAXIMUM PHYSICAL MEMORY AVAILABLE AFTER MONITOR
;
;CORMAX .LE. MAXMAX .LE. PHYMAX (MAXMAX .LT. PHYMAX MEANS SOMEONE HAS
;PUT SOME MEMORY OFFLINE - I.E., THERE IS A HOLE IN MEMORY SOMEWHERE)

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;PRINT THE VARIOUS PHYSICAL MEMORY VALUES

	MOVEI	M,[ASCIZ /Mem:/]
	LSH	N,@W2PLSH	;MAXIMUM SINGLE USER SIZE
	PUSHJ	P,MSGDEC	;ISSUE
	MOVE	A,MAXMAX	;MAXIMUM USER SPACE AVAILABLE
	CAMN	A,CORMAX	;CORMAX SAME AS MAXMAX
	CAME	A,B		;AS WELL AS PHYMAX?
	CAIA			;NO
	JRST	MEMLP4		;ALL THREE THE SAME
	MOVEI	M,[ASCIZ \/\]
	MOVE	N,A		;GET CORMAX WHERE DECOUT WANTS IT
	LSH	N,@W2PLSH	;CONVERT TO PAGE COUNT
	CAMN	A,CORMAX	;CORMAX AND MAXMAX THE SAME?
	PUSHJ	P,MSG		;YES, THEN PHYMAX DIFFERENT
	CAME	A,CORMAX	;CORMAX AND MAXMAX THE SAME?
	PUSHJ	P,MSGDEC	;NO, LIST MAXMAX AS WELL
	MOVE	N,B		;GET PHYMAX FOR DECOUT
	LSH	N,@W2PLSH	;AND MAKE INTO PAGE COUNT
	MOVEI	M,[ASCIZ\/\]	;SEPARATOR
	CAME	A,B		;MAXMAX AND PHYMAX THE SAME?
	PUSHJ	P,MSGDEC	;NO, LIST PHYMAX AS WELL THEN

;NOW LIST MEMORY SPACE SAVED BY SHARING PAGES (HIGHSEGS)

MEMLP4:	MOVEI	M,[ASCIZ / Shr:/]
	MOVE	N,SHRSAV	;MEMORY SAVED BY SHARING
	PUSHJ	P,MSGDEC	;PRINT MEM SAVED BY SHARING

;DISPLAY ACTIVE JOB LOADING

	MOVEI	M,[ASCIZ\ JRN:\]  ;JOBS RUNNING
	MOVE	N,JRNRN		;JOBS IN RN STATE
	PUSHJ	P,MSGDEC	;LIST THEM
	MOVEI	M,[ASCIZ\/\]	;SEPARATE FROM
	MOVE	N,JRNIO		;JOBS RUNNING OR IO BLOCKED
	PUSHJ	P,MSGDEC	;LIST THEM
	MOVEI	M,[ASCIZ\/\]	;SEPARATE FROM
	MOVE	N,JRNSL		;JOBS NOT ^C'ED
	PUSHJ	P,MSGDEC	;LIST THEM

	PUSHJ	P,CRLF		;START A NEW LINE FOR SWAPPING

;CONTINUED ON NEXT PAGE
	SUBTTL	"N" DISPLAY -- SWAPPING AND VIRTUAL MEMORY USAGE

SWPLP:	MOVEI	M,[ASCIZ/Use:/]
	MOVE	N,PHYUSE	;PHYSICAL (WORKING SET) MEMORY
	PUSHJ	P,MSGDEC	;TELL USER
	MOVEI	M,[ASCIZ\/\]	;SEPARATE WITH A "/"
	MOVE	N,VIRUSE	;TOTAL VIRTUAL PROGRAM SIZES
	CAME	N,PHYUSE	;SAME AS PHYSICAL TOTALS?
	PUSHJ	P,MSGDEC	;NO, TYPE VIRTUAL USE ALSO
	MOVEI	M,[ASCIZ/ Swp:/]
	MOVE	N,VIRUSE	;TOTAL VIRTUAL PROGRAM SIZE
	SUB	N,PHYUSE	;LESS THAT PHYSICALLY USED
	ADD	N,DSKUSE	;PLUS PHYSICAL STUFF SWAPPED
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ \/\]
	MOVE	A,XK4SWP
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,MSGDEC
	MOVE	N,MAXMAX	;TOTAL USER MEMORY SPACE
	LSH	N,@W2PLSH	;CONVERT TO PAGES
	MOVEM	N,TEMP		;STORE FOR CMPDFA ROUT.
	MOVE	A,ACTUSE	;GET AMOUNT OF ACTIVE CORE (IN K)
	SUB	A,N		;GET AMOUNT MUST BE SWAPPED
	CAIGE	A,0		;IF ALL WILL FIT
	SETZ	A,		;(IT WILL) DON'T CONFUSE TYPEOUT
	MOVEI	M,[ASCIZ/ ASR:/]  ;GET MESSAGE FOR ACTIVE SWAPPING RATIO
	PUSHJ	P,CMPDFA	;PRINT INTEGER+FRACTION(TEMP)
	PUSHJ	P,CRLF		;NEW LINE

;CONTINUED ON NEXT PAGE
	SUBTTL	"N" DISPLAY -- SCHEDULE, KSYS, AND ERROR COUNTERS

;CONTINUED FROM PREVIOUS PAGE

ERRLP:	SETO	J,		;INITIALIZE COUNTER

;CHECK KSYS (SYSTEM SHUTDOWN) TIMER

	MOVX	A,%NSKTM	;KSYS TIMER
	PUSHJ	P,GETZ		;GET MINUTES TILL KSYS
	MOVEI	M,[ASCIZ/KSYS:/]  ;WARN USER
	SKIPE	N,A		;KSYS SET?
	PUSHJ	P,MSPDEC	;YES, GIVE KSYS TIMER

;CHECK FOR SYSTEM-WIDE HARDWARE ERRORS

	MOVX	A,%SYERR	;GET HARDWARE ERROR COUNT
	PUSHJ	P,GETZ		;  OR 0
	MOVEI	M,[ASCIZ/HDE:/]	;HARDWARE ERROR HEADER
	SKIPE	N,A		;MOVE TO AC
	PUSHJ	P,MSPDEC	;PRINT IF NON-ZERO

;CHECK FOR ANY JOB AND/OR DEBUG MONITOR STOPCD'S

	MOVX	A,%SYNDS	;GET SOFTWARE DEBUG STOPS
	PUSHJ	P,GETZ		;  OR 0
	MOVE	B,A		;SAVE AWAY
	MOVX	A,%SYNJS	;GET SOFTWARE JOB STOPS
	PUSHJ	P,GETZ		;  OR 0
	MOVEI	M,[ASCIZ/STP:/]	;SOFTWARE ERROR HEADER
	SKIPN	N,B		;MOVE TO AC
	SKIPE	A		; IF NON-ZERO
	PUSHJ	P,MSPDEC	;  PRINT
	MOVEI	M,[ASCIZ\/\]	;SEPARATE DEBUG AND JOB
	SKIPE	N,A		;GET DEBUG STOPCODES
	PUSHJ	P,MSPDEC	;PRINT IF ANY

;CHECK FOR SYSTEM MAIN MEMORY PARITY ERRORS

	MOVX	A,%NSTPE	;TOTAL SYSTEM MEMORY PARITY ERRORS
	PUSHJ	P,GETZ		;READ FROM MONITOR
	MOVEI	M,[ASCIZ/MPE:/]	;PARITY ERROR HEADER
	SKIPE	N,A		;ANY PARITY ERRORS?
	PUSHJ	P,MSPDEC	;YES, LIST THE COUNT

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;CHECK FOR FILE SYSTEM RETRIEVAL INFORMATION BLOCK ERRORS

	MOVX	A,%LDTOT	;TOTAL FILE SYSTEM RIB ERRORS
	PUSHJ	P,GETZ		;SEE HOW IT'S DOING
	MOVEI	M,[ASCIZ/RIB:/]	;RIB ERROR HEADER
	SKIPE	N,A		;IF ANY RIB ERRORS
	PUSHJ	P,MSPDEC	;TELL OPERATOR

;SHOW COUNT OF POKE.'S DONE TO MONITOR IF NON-ZERO

	MOVX	A,%CNPUC	;JOB,,COUNT OF POKE.'S
	PUSHJ	P,GETZ		;READ FROM MONITOR
	JUMPE	A,ERRLP2	;SKIP IF NO POKE.'S HAVE BEEN DONE
	MOVEI	M,[ASCIZ/POK:/]	;POKE COUNT HEADER
	HRRZ	N,A		;COUNT OF POKE.'S
	PUSHJ	P,MSPDEC	;PRINT OUT COUNT OF POKE.'S
	MOVEI	M,[ASCIZ\/\]	;SEPARATOR
	HLRZ	N,A		;JOB WHICH LAST POKE.'ED
	PUSHJ	P,MSGDEC	;TYPE THAT TOO
ERRLP2:

;SHOW CURRENT RUNNING SCHEDULE (STATES) IF NON-ZERO

	MOVX	A,%CNSTS	;GET SYSTEM STATES
	PUSHJ	P,GETZ		;FROM MONITOR
	ANDI	A,1777		;REDUCE TO SCHEDULING PARMS
	MOVEI	M,[ASCIZ/SCH:/]	;SHOW OPR SCHEDULING
	SKIPE	N,A		;IF NON-ZERO
	PUSHJ	P,MSPOCT	;SOME SORT OF SCHED SET

	CAIL	J,0		;IF NEGATIVE, NOTHING TYPED
	PUSHJ	P,CRLF		;END OF THIS LINE
;HERE TO PRINT RESPONSE MEASURES

REPEAT	0,<	;DON'T BOTHER, SINCE NO ONE SEEMS TO KNOW WHAT
		;THEY ARE, LET ALONE CARE.

	MOVEI	M,[ASCIZ /RSP:/];HEADER FOR RESPONSES
	SETZM	CPU		;SET FOR CPU0
;LOOP TO PRINT RESPONSE FOR EACH CPU
RSPLP1:	SKIPE	CPU		;IF FIRST CPU OR
	SKIPE	DUAL		;SEVERAL CPU'S THEN
	SKIPA			;PRINT
	JRST	RSP1C		;ELSE SKIP IT
	MOVEI	A,%CVRNX	;NO. OF RESPONSES SINCE STARTUP
	PUSHJ	P,GETRSP	;GET FROM MONITOR REL TABLE
	  JRST RSP1C		;NOT PRESENT FOR THIS CPU
	PUSH	P,A		;SAVE TOTAL NO. OF RESPONSES
	MOVEI	A,%CVRSX	;SUM OF RESPONSE TIMES IN JIFFIES
	PUSHJ	P,GETRSP	;GET FROM MONITOR REL TABLE
	  JRST	RSP1B		;NOT PRESENT FOR THIS CPU
	MOVE	N,A		;MOVE TO N FOR PNTSEC ROUTINE
	MUL	A,A		;GET SQUARE OF SUM OF RESPONSES
	PUSH	P,A		;SAVE FOR STANDARD DEV
	PUSH	P,B		; ..
	IDIV	N,-2(P)		;AVERAGE RSP=SUM/NUMBER(IN JIFFIES)
	PUSHJ	P,PNTSEC	;PRINT IN SECONDS + TENTHS
	POP	P,N1		;RESTORE SQUARE OF SUM
	POP	P,N		; ..
	MOVEI	M,[ASCIZ / /]	;SEPARATE AVER FROM STAND DEV
	MOVEI	A,%CVRLX	;SUM OF SQUARES OF RESPONSES
	PUSHJ	P,GETRSP	;GET FROM MONITOR REL TABLE
	  JRST	RSP1B		;NOT THERE
	MOVE	B,A		;POSITION
	MOVEI	A,%CVRHX	;ASK FOR HIGH SUM OF SQUARES
	PUSHJ	P,GETRSP	;FROM MONITOR
	  JRST	RSP1B		;(STRANGE!)
	MUL	B,(P)		;MULT BY NUMBER
	IMUL	A,(P)		; BOTH HALVES
	ADD	A,B		;INCLUDE CROSS CARRY
	MOVE	B,C		;POSITION LOW HALF
	SETCMM	N		;COMPLEMENT SQUARE OF SUM
	MOVNS	N1		; ..
	SKIPN	N1		;HANDLE CARRY
	ADDI	N,1		; YES
	TLZ	N1,(1B0)	;GOT (N,N1)=-SQ.SUM
	ADD	B,N1		;ADD TO N*SUM SQ.
	ADD	A,N		; ..
	TLZE	B,(1B0)		;SEE IF CARRY
	ADDI	A,1		;YES. GOT (A,B)=N*SUM SQ.-SQ.SUM
	PUSHJ	P,ISQRT		;COMPUTE N=SQRT((A,B))
	IDIV	N,(P)		;DIVIDE BY NUMBER; N=STD.DEV
	PUSHJ	P,PNTSEC	;PRINT AS SECONDS PLUS TENTHS
	POP	P,A		;REMOVE NO.
	MOVEI	M,[ASCIZ /+/]	;SEPARATE CPU0 AND CPU1 STUFF
	AOS	CPU		;STEP TO NEXT CPU
	JRST	RSPLP1		;GO SEE IF EXISTS	
;HERE WHEN PRINTED MEAN AND STANDARD DEV FOR ALL CPUS
RSP1B:	POP	P,A		;REMOVE NUMBER
RSP1C:	MOVEI	M,[ASCIZ " #/M:"]	;HEADER FOR NUMBER OF RESPONSES
	MOVE	T1,UPTIME	;UP TIME IN JIFFIES
	IDIV	T1,TCKSEC	;NO. OF SECONDS UP
	IDIVI	T1,^D60		;NO. OF MINUTES UP
	MOVEM	T1,TEMP		;STORE FOR CMPCNA
	SETZM	CPU		;START WITH CPU0
RSPLP2:	SKIPE	CPU		;IF FIRST CPU OR
	SKIPE	DUAL		;SEVERAL CPU'S
	SKIPA			;THEN PRINT
	JRST	RSP2		;ELSE SKIP
	MOVEI	A,%CVRNX	;NO. OF RESPONSES FOR THIS CPU
	PUSHJ	P,GETRSP	;GET FROM MONITOR TABLE
	  JRST	RSP2		;NOT THERE
	PUSHJ	P,CMPDFA	;PRINT NO. RESPONSES PER MIN
	MOVEI	M,[ASCIZ /+/]	;SEPARATE CPUS WITH +
	AOS	CPU		;STEP TO NEXT CPU
	JRST	RSPLP2		;TRY NEXT CPU

;HERE WHEN PRINTED FOR ALL CPUS
RSP2:	PUSHJ	P,CRLF

> ;END OF REPEAT 0 FROM PREVIOUS PAGE
	SUBTTL	"N" DISPLAY -- JOBS-IN-USE STATISTICS

PRJOB:	MOVEI	M,[ASCIZ /Jobs:/]
	MOVE	N,JBNUSE	;COUNT OF JOBS IN USE
	PUSHJ	P,MSGDEC	;TELL USER
	MOVEI	M,[ASCIZ \/\]	;SEPARATOR
	MOVE	N,JOBN		;NUMBER OF JOBS IN SYSTEM
	SUBI	N,1		;ALLOW FOR NULL JOB
	PUSHJ	P,MSGDEC	;PUT ON SCREEN
	MOVEI	M,[ASCIZ / Log'd in:/]
	MOVE	N,JBNLOG	;NUMBER OF JOBS LOGGED-IN
	PUSHJ	P,MSGDEC	;TELL USER
PRDET:	MOVEI	M,[ASCIZ / Det:/]
	MOVE	N,JBNDET	;NUMBER OF DETACHED JOBS
	PUSHJ	P,MSGDEC	;INFORM USER
	PUSHJ	P,CRLF		;START ON A NEW LINE

;FALL INTO STRUCTURE DISPLAY
	SUBTTL	"N" DISPLAY -- DISK STRUCTURES

STRCL==<XSIZE-^D40>/^D20	;NUMBER OF STR COLUMNS ON SCREEN

STRLP:	SKIPL	A,LINE		;OFF BOTTOM OF SCREEN?
	CAILE	A,YSIZE-2	;ROOM FOR AT LEAST ONE LINE OF STRS?
	JRST	STRLP9		;NO, NO STRUCTURES DISPLAY
	TABSET	TAB1ST		;SET UP STRUCTURE COLUMNS
	SETZM	CURFS		;INITIALIZE SYSSTR LOOP
	MOVEI	J,STRCL		;NUMBER OF COLUMNS
	MOVEI	M,[ASCIZ/Struc  Mnt  Free    /]  ;COLUMN HEADER
	PUSHJ	P,MSG		;LABEL COLUMN
	SOJG	J,.-2		;LABEL ALL COLUMNS

;LOOP FOR ALL STRUCTURES IN SYSTEM

STRLP1:	PUSHJ	P,CRLF		;START A FRESH LINE
	MOVEI	J,STRCL		;RESET COLUMN COUNTER
STRLP3:	MOVE	A,CURFS		;LAST STRUCTURE
	SYSSTR	A,		;SEE WHAT'S NEXT
	 JRST	STRLP8		;???
	JUMPE	A,STRLP8	;0 IS END
	MOVEM	A,CURFS		;SAVE FOR NEXT ITERATION
	MOVEM	A,DSKBLK	;SETUP FOR DSKCHR
	MOVE	B,[DSKBKL,,DSKBLK]  ;POINTER FOR DSKCHR TO
	DSKCHR	B,		;RETURN STRUCTURE INFORMATION
	 JRST	STRLP8		;??? CAN'T FAIL HERE
	PUSHJ	P,SIXTAB	;ISSUE STRUCTURE NAME, <TAB>
	MOVE	N,DSKBLK+.DCSMT	;STRUCTURE MOUNT COUNT
	PUSHJ	P,DECPRT	;TYPE IT OUT
	PUSHJ	P,TAB		;SPACE OVER
	MOVE	N,DSKBLK+.DCFCT	;FREE BLOCKS COUNT
	PUSHJ	P,DECPRT	;TYPE IT OUT ALSO
	SOJE	J,STRLP1	;END OF SCREEN?
	PUSHJ	P,TAB		;NO, ADVANCE TO NEXT COLUMN
	JRST	STRLP3		;AND DO ANOTHER STRUCTURE

STRLP8:	CAIE	J,STRCL		;AT START OF A LINE?
	PUSHJ	P,CRLF		;NO, CAP OFF CURRENT LINE

STRLP9:!			;END OF STRUCTURES DISPLAY
	SUBTTL	"N" DISPLAY -- DEVICES ASSIGNED OR IN USE

DEVCL==<XSIZE-^D40>/^D13	;NUMBER OF DEVICE COLUMNS

DEVLP:	SKIPL	A,LINE		;IF NOT OFF BOTTOM OF SCREEN
	CAILE	A,YSIZE-2	;THEN ROOM FOR AT LEAST ONE LINE OF DEV?
	JRST	DEVLP9		;NO, FORGET THE DEVICES DISPLAY
	TABSET	TAB1DV		;SET DEVICE COLUMNS
	MOVEI	J,DEVCL		;NUMBER OF DEVICE COLUMNS
	MOVEM	J,CPHDR		;MARK NO HEADER OUTPUT YET
	MOVE	A,XDVLST	;GET THE BASE OF THE DDB CHAIN
	CALL	GET		;GET THE VALUE
	JRST	DEVLP9		;END OF DEVICES DISPLAY
DEVLP1:	TLNN	A,-1		;IS THIS THE END OF THE DDB LIST
	JRST	DEVLP8		;END OF DEVICES DISPLAY
	HLRZ	D,A		;GET THE DDB ADDRESS
	MOVEI	A,$DVMOD(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVE	B,A		;(EDIT 2) REMEMBER THE DEVMOD ENTRY
	TXNE	A,DV$ASC!DV$ASP	;IN USE BY ANYONE?
	TXNE	A,DV$TTA!DV$DSK	;SHOW TTY'S NOT CONTROLLING JOBS
	JRST	DEVLP6		;LOOK AT NEXT DEVICE
	MOVEI	A,@PJOBNO	;GET ADDRESS OF DEVJOB WORD
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVE	C,A		;GET A COPY OF THE RESULT
	MOVEI	A,$DVNAM(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	HLRZ	BP,A
	CAIN	BP,'PTY'
	JRST	DEVLP6		;LOOK AT NEXT DEVICE
	TRZ	BP,77		;ONLY FIRST TWO CHARACTERS
	CAIN	BP,'''L '	;TAPE LABEL PROCESSOR DUMMY DDB?
	JRST	DEVLP6		;YES, DON'T CLUTTER UP SCREEN
	SKIPN	CPHDR		;PRINTED COLUMN HEADER YET?
	JRST	DEVLP2		;YES, JUST PRINT DEVICE
	MOVEI	M,[ASCIZ /Dev   By How	/]  ;DEVICE HEADER
	PUSHJ	P,MSG		;LABEL COLUMN
	SOJG	J,.-2		;LABEL ALL COLUMNS
	PUSHJ	P,CRLF		;END COLUMN HEADERS
	EXCH	J,CPHDR		;MARK HEADER AS HAVING BEEN PRINTED

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

DEVLP2:	PUSHJ	P,SIXTAB	;PRINT SIXBIT DEVICE NAME FOLLOWED BY TAB
	LDB	N,PJOBNP	;GET JOB NUMBER OWNING DDB
	JUMPE	N,[MOVEI M,[ASCIZ/Det	/] ;IF "ASSIGNED" TO JOB 0
		PUSHJ	P,MSG	;SAY DEVICE IS DETACHED
		JRST	DEVLP3]	;CAP OFF
	PUSHJ	P,DECPRT	;SHOW OWNER JOB NUMBER
	PUSHJ	P,TAB		;TAB OVER TO "HOW" COLUMN
	MOVEI	CH,"A"		;IN CASE "A"SSIGNED
	TXNE	B,DV$ASC	;IS DEVICE ASSIGNED BY CONSOLE COMMAND?
	PUSHJ	P,TYO		;YES (OR REASSI CALLI)
	MOVEI	CH,"I"		;IN CASE "I"NITED OR OPENED
	TXNE	B,DV$ASP	;IS DEVICE IN USE FOR I/O?
	PUSHJ	P,TYO		;YES
DEVLP3:	SOJG	J,DEVLP4	;UNLESS STILL ROOM ON SCREEN
	PUSHJ	P,CRLF		;END THIS LINE
	TROA	J,DEVCL		;AND RESET COLUMN COUNT
DEVLP4:	PUSHJ	P,TAB		;JUST TAB OVER TO NEXT COLUMN
DEVLP6:	MOVEI	A,$DVSER(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	JRST	DEVLP1

DEVLP8:	CAIE	J,DEVCL		;IN MIDDLE OF A LINE?
	PUSHJ	P,CRLF		;YES, CAP IT OFF

DEVLP9:!			;END OF DEVICES DISPLAY

	POPJ	P,		;END OF "N" DISPLAY
	SUBTTL	"F" -- FILE SYSTEM DISPLAY PROGRAM

FILPRG:	TLNN	F,FL.SPY!FL.PEK	;TEST FOR ENOUGH PRIVILEGES
	JRST	NOPRIV		; NO EXPLAIN IT
	CALL	STROLL		;START THE ROLL CALL
	PUSHJ	P,THISIS	;OUTPUT HEADER
	TABSET	TAB4		;FILE SYSTEM TABS
	SETZM	CURFS
	PUSHJ	P,SETVIS	;DETERMINE INITIAL SCREEN VISIBILITY
	HEADER	<	MOVEI	M,[ASCIZ .Unit or F/S	Free	BR	BW	DR	DW	MR	MW	Seeks.]
	CALL	IMSG		;PRINT HEADER
	CALL	ICRLF		;AND A NEW LINE
>
FLFSL:	MOVE	A,CURFS
	SYSSTR	A,
	  JFCL
	JUMPE	A,FILEXI	;NONE OR ALL DONE
	MOVEM	A,CURFS
	MOVEI	M,[ASCIZ /Structure /]
	CALL	IMSG		;PRINT IF VISIBLE
	PUSHJ	P,ISIXBP	;TYPE STRUCTURE NAME
	MOVEI	M,[ASCIZ / Free:/]
	CALL	IMSG		;PRINT IF VISIBLE
	MOVE	A,CURFS
	MOVEM	A,DSKBLK
	MOVE	A,[XWD DSKBKL,DSKBLK]	;SET FOR DISK CHARACTERISTICS UUO
	DSKCHR	A,		;FOR THE STRUCTURE FIRST
	 JRST	FILEXI		;SHOULDN'T FAIL
	MOVE	N,DSKBLK+.DCFCT	;GET BLOCKS LEFT
	PUSHJ	P,IDECPR	;ON STR
	MOVEI	M,[ASCIZ / Mount:/]
	CALL	IMSG		;PRINT IF VISIBLE
	MOVE	N,DSKBLK+.DCSMT	;GET MOUNT COUNT
	CALL	IDECPR		;PRINT IF VISIBLE
	CALL	ICRLF		;END OF STRUCTURE
;UNIT STUFF HERE

	MOVE	A,DSKBLK+.DCULN	;GET LOGICAL UNIT NAME
	MOVEM	A,CURUN		;CURRENT UNIT LOGICAL NAME
	MOVEI	B,77		;FIND LOW CHARACTER
FLFSL2:	TDNE	B,A
	JRST	FLFS1
	LSH	B,6
	JUMPN	B,FLFSL2
FLFS1:	AND	B,[010101010101]
	MOVEM	B,CUINC		;INCREMENT UNIT NAME

FLUNL:	MOVE	A,CURUN		;NAME OF CURRENT UNIT
FLUNL0:	MOVEM	A,DSKBLK	;SET FOR DSKCHR
	MOVE	A,[XWD DSKBKL,DSKBLK]  ;ARG POINTER FOR DSKCHR TO
	DSKCHR	A,		;READ LOGICAL UNIT INFORMATION
	 JRST	FLFSN		;SHOULD NEVER HAPPEN
	MOVEM	A,DSKBLK	;SAVE BITS
	SKIPE	D,CURUN2	;LOOKING AT SECOND PORT TO DISK UNIT?
	JRST	FLUN3		;YES, ALREADY HAVE ADDRESS OF UDB
	MOVE	A,XSYSUN	;GET SYSTEM UNIT BLK LIST
	PUSHJ	P,GETA
	HLRZ	D,A
FLUNL2:	MOVEI	A,UNILOG(D)
	PUSHJ	P,MPEEK		;GET NAME OF UNIT
	CAMN	A,CURUN		;SAME AS CURRENT?
	JRST	FLUN3		;YES
	MOVEI	A,UNISYS(D)	;NO. LOOK ON
	PUSHJ	P,MPEEK
	HLRZ	D,A
	JUMPN	D,FLUNL2
	JRST	FLUNN		;NOT FOUND. STRANGE.
FLUN3:	MOVEM	D,UNIBLK	;SAVE UNIT DATA BLOCK ADDR
	MOVE	A,DSKBLK+.DCUPN	;UNIT PHYSICAL NAME
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /(/]	;PREPARE FOR UNIT LOGICAL NAME
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	A,UNIHID(D)	;ADDRESS OF UNIT ID
	SKIPE	CURUN2		;LOOKING AT SECOND PORT?
	SKIPA	A,['..... ']	;YES, THEN SO INDICATE
	PUSHJ	P,MPEEK		;NO, READ STRUCTURE UNIT NAME
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /)	/]
	CALL	IMSG		;PRINT IF VISIBLE
	MOVE	N,DSKBLK+.DCUNT	;UNIT FREE BLOCKS
	SKIPN	CURUN2		;IF LOOKING AT ALTERNATE PORT NO FREE
	CALL	IDECPR		;MAIN PORT, PRINT IF VISIBLE
	SETZM	CURUN2		;DONE WITH THIS FLAG
	MOVSI	C,-UDTBL
FLUNL3:	HRRZ	A,UDTAB(C)
	PUSHJ	P,GETUDB
	HLRE	A,UDTAB(C)
	JUMPE	A,FLUNLA
	JUMPL	A,FLDIFF
	ADD	A,UNIBLK
	PUSHJ	P,MPEEK		;SPY OR PEEK
	ADD	N,A
	JRST	FLUNLA

FLDIFF:	MOVNS	A
	ADD	A,UNIBLK
	PUSHJ	P,MPEEK		;SPY OR PEEK
	SUB	N,A
FLUNLA:	CALL	ITAB		;PRINT A TAB IF VISIBLE
	CALL	IDECPR		;PRINT IF VISIBLE
	AOBJN	C,FLUNL3
	CALL	ICRLF		;NEW LINE IF VISIBLE
	TLZ	F,FL.NBK+FL.DEV
	HLLZ	A,DSKBLK
	TLZ	A,BITMSK
	JUMPE	A,FLUN4
	MOVSI	C,-BITTL
FLBTL:	SKIPGE	A
	PUSHJ	P,PRTBIT
	LSH	A,1
	AOBJN	C,FLBTL
FLUN4:	LDB	C,DSKLEV	;DISK LEVEL NO.
	CAIG	C,1		;5.01, 5.02 OR EARLIER?
	 HALT	.		;HA!

;HERE TO DO 5.03 OR LATER UNIT ERROR INFO

FLUN5:	MOVSI	C,-UER2TL
FLUNL5:	HLRZ	A,UER2T1(C)
	PUSHJ	P,GETUDB
	HRRZ	M,UER2T1(C)
	XCT	UER2T2(C)
	TLO	F,FL.CRF	;ADVANCE TO NEW LINE IF NEEDED
	PUSHJ	P,@UER2T3(C)
	TLZ	F,FL.CRF	;CLEAR FREE CRLF FLAG
	AOBJN	C,FLUNL5
	TLZE	F,FL.NBK+FL.DEV	;HAVE WE TYPED ANYTHING ON THIS LINE?
	PUSHJ	P,ICRLF		;YES, WE NEED A NEW LINE IF VISIBLE

;NOTE THAT THIS CODE IS DEPENDENT ON MONITOR CONDITIONALS FOR THE VALUE
;OF UNI2ND. THIS MECHANISM WILL SOON BE REPLACED BY AN EXPANDED DSKCHR.

	MOVEI	A,UNI2ND(D)	;ADDRESS OF SECOND PORT UDB
	PUSHJ	P,MPEEK		;READ IT
	JUMPE	A,FLUNN		;NO SUCH ANIMAL
	TLNE	A,1		;MAIN OR ALTERNATE?
	JRST	FLUNN		;MAIN (THIS IS ALTERNATE WE JUST DID)
	MOVEM	A,CURUN2	;ALTERNATE, REMEMBER IT (AND SET FLAG)
	PUSHJ	P,MPEEK		;GET UNIT PHYSICAL NAME
	JUMPN	A,FLUNL0	;AND GO TYPE UNIT STUFF FOR IT TOO
	SETZM	CURUN2		;DUH?

FLUNN:	MOVE	A,CURUN
	ADD	A,CUINC
	MOVEM	A,CURUN
	JRST	FLUNL

FLFSN:	SETZM	CURUN2		;DON'T TYPE "....." FOR VALID STR
	JRST	FLFSL		;LOOP FOR NEXT STRUCTURE
FILEXI:	HEADER	<	MOVEI	M,[ASCIZ /Swap Unit	R	W	Used(/]
	CALL	MSG		;AND PRINT IT
	CALL	KAYPAG		;PRINT K OR P
	MOVEI	M,[ASCIZ /)/]	;RIGHT BRACKET
	CALL	IMSG		;FINISH IT NICELY
	CALL	ICRLF		;PRINT NEW LINE
>
	MOVE	A,XSWPUN
	PUSHJ	P,GETA
	HLRZ	D,A
SWLP1:	MOVEI	A,UNINAM(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
SWLP2:	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /(/]	;GET LEFT-PAREN MESSAGE
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	A,UNIHID(D)	;GET ADDR OF PHYSICAL UNIT ID
	SKIPE	CURUN2		;LOOKING AT ALTERNATE PORT?
	SKIPA	A,['..... ']	;YES, SO INDICATE
	PUSHJ	P,MPEEK		;NO, GET UNIT ID FROM MONITOR
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /)	/] ;GET RIGHT-PAREN & TAB MESSAGE
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	A,UNIICT(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVE	N,A
	CALL	IDECTAB		;PRINT IF VISIBLE
	MOVEI	A,UNIOCT(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVE	N,A
	MOVEI	M,[ASCIZ/	/] ;PRECEDE BY A TAB
	PUSHJ	P,IDECPRT
	SKIPE	CURUN2		;LOOKING AT MAIN OR ALTERNATE
	JRST	SWLP4		;ALTERNATE, HAS JUNK NUMBERS
	MOVEI	A,UNIFKS(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVEM	A,N
	MOVEI	A,UNIK4S(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	ANDI	A,MSKK4S
	TRNE	F,FR.KIP
	LSH	A,1
	MOVEM	A,TEMP
	SUBB	A,N
	CALL	IPRPCNT		;PRINT PERCENTAGE
SWLP4:	CALL	ICRLF		;END THE LINE NICELY

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;CHECK FOR SECOND PORT ACCESS TO THIS SWAPPING UNIT

	MOVEI	A,UNI2ND(D)	;ADDRESS OF SECOND PORT UDB
	PUSHJ	P,MPEEK		;READ IT
	JUMPE	A,SWLP7		;NO SUCH ANIMAL
	TLNE	A,1		;MAIN OR ALTERNATE?
	JRST	SWLP6		;MAIN (THIS IS ALTERNATE WE JUST DID)
	MOVEM	D,CURUN2	;ALTERNATE, REMEMBER MAIN
	HRRZS	D,A		;PUT UDB ADDRESS IN D
	PUSHJ	P,MPEEK		;GET UNIT PHYSICAL NAME
	JUMPN	A,SWLP2		;AND GO TYPE UNIT STUFF FOR IT TOO
SWLP6:	MOVE	D,CURUN2	;RESTORE MAIN UDB
SWLP7:	SETZM	CURUN2		;AND CLEAR FLAG
	MOVEI	A,UNISWP(D)
	PUSHJ	P,MPEEK		;SPY OR PEEK
	HLRZ	D,A
	JUMPN	D,SWLP1
	CALL	ICRLF		;PRINT NEW LINE
;HERE TO CHECK FOR SWAP READ ERRORS
	MOVE	A,XSWPER
	PUSHJ	P,GETZ
	JUMPE	A,SWFIN
	MOVE	D,A
	CALL	ICRLF		;PRINT NEW LINE
	MOVEI	M,[ASCIZ /Swap errors: /]
	CALL	IMSG		;PRINT IF VISIBLE
	HLRZ	N,D
	CALL	IDECTAB		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ / CHK/]
	TXZE	D,IO$IMP
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ / DEV/]
	TXZE	D,IO$DER
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ / DAT/]
	TXZE	D,IO$DTE
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /   Lost: /]
	HRRZ	N,D
	TRZ	N,070000	;ZAP TWO MORE ERROR BITS
	SKIPGE	VISIBLE		;CAN WE SEE IT?
	PUSHJ	P,MSGDEC
	CALL	ICRLF		;PRINT NEW LINE
SWFIN:	RETURN			;END OF DISPLAY PROGRAM

;OFFSET IN A GETS CONTENTS INTO N

GETUDB:	ADD	A,UNIBLK
	PUSHJ	P,MPEEK		;SPY OR PEEK
	MOVE	N,A
	POPJ	P,
PRTBIT:	MOVEI	M,BITTAB(C)
	SKIPN	@M		;THIS BIT MEAN ANYTHING?
	POPJ	P,		;NO, NO TYPEOUT THEN
	PUSHJ	P,ISPACE	;WANT LEADING SPACE SEPAATOR
	PUSHJ	P,IMSG		;PRINT IF VISIBLE
	TLO	F,FL.NBK	;NOTE SOMETHING OUTPUT
	POPJ	P,		;RETURN HAVING PRINTED FLAG

PRTUED:	JUMPE	N,CPOPJ
	TLO	F,FL.NBK	;NOTE SOMETHING OUTPUT
	PUSH	P,M
	MOVE	M,RTEND		;GET RIGHT-HAND MARGIN
	SUB	M,COL		;M := SPACES LEFT ON SCREEN
	CAIGE	M,^D11		;REASONABLE AMOUNT LEFT?
	PUSHJ	P,IFRCL		;NO, FORCE NEW (INDENTED) LINE
	MOVEI	M,[ASCIZ / Errors:/]
	TLON	F,FL.DEV
	PUSHJ	P,IMSG		;PRINT IF VISIBLE
	POP	P,M
	PUSHJ	P,ISPACE	;GET LEADING SPACE
	PUSHJ	P,IMSG		;PRINT IF VISIBLE
	PJRST	IDECPR		;PRINT IF VISIBLE

PRTUEO:	JUMPE	N,CPOPJ
	TLO	F,FL.NBK	;NOTE SOMETHING OUTPUT
	PUSH	P,M
	MOVE	M,RTEND		;GET RIGHT-HAND MARGIN
	SUB	M,COL		;M := SPACES LEFT ON SCREEN
	CAIGE	M,^D18		;REASONABLE AMOUNT LEFT?
	PUSHJ	P,IFRCL		;NO, FORCE NEW (INDENTED) LINE
	MOVEI	M,[ASCIZ / Errors:/]
	TLON	F,FL.DEV
	PUSHJ	P,IMSG		;PRINT IF VISIBLE
	POP	P,M
	PUSHJ	P,ISPACE	;LEADING SPACE SEPARATOR
	PUSHJ	P,IMSG		;PRINT IF VISIBLE
	SKIPGE	VISIBL		;CAN WE SEE IT?
	PJRST	OCTPRT
	POPJ	P,
BITTAB:	ASCIZ	/RHB/		;REREAD HOME BLOCKS
	ASCIZ	/OFL/		;UNIT IS OFFLINE
	ASCIZ	/HWP/		;HARDWARE WRITE PROTECT
	ASCIZ	/SWP/		;SOFTWARE WRITE PROTECT
	ASCIZ	/SAF/		;SINGLE-ACCESS FILE STRUCTURE
	Z			;ZERO MOUNT COUNT
	ASCIZ	/PRF/		;PRIVATE FILE STRUCTURE
	Z			;FIRST HALF OF DC.STS FIELD
	Z			;SECOND HALF OF DC.STS FIELD
	Z			;MULTIPLE SAT BLOCKS
	ASCIZ	/NNA/		;NO NEW ACCESSES
	ASCIZ	/AWL/		;WRITE-LOCKED FOR ALL JOBS
	Z			;NOT ASSIGNED
	Z			;NOT ASSIGNED
	ASCIZ	/2PT/		;DUAL-PORTED UNIT
BITTL==.-BITTAB

BITMSK=77	;CLEAR, LEAVING BITS IN 777700,,0

UDTAB:	XWD	0,UNIBRC
	XWD	0,UNIBWC
	XWD	0,UNIDRC
	XWD	0,UNIDWC
	XWD	-UNIICT,UNIMRC
	XWD	-UNIOCT,UNIMWC
	XWD	UNIMSC,UNIUSC
UDTBL==.-UDTAB
;5.03 AND LATER MONITORS ERROR INFO TABLES

UER2T1:	XWD	UNIHCT,[ASCIZ /HDEV:/]
	XWD	UNIHCT,[ASCIZ /HDAT:/]
	XWD	UNISCT,[ASCIZ /SDEV:/]
	XWD	UNISCT,[ASCIZ /SDAT:/]
	XWD	UNIECT,[ASCIZ /RETRIES:/]
	XWD	UNIMCT,[ASCIZ /SER:/]
	XWD	UNIMCT,[ASCIZ /RER:/]
	XWD	UNIMCT,[ASCIZ /CER:/]
	XWD	UNIHNG,[ASCIZ /PHUNG:/]
	XWD	UNIHNG,[ASCIZ /THUNG:/]
	XWD	UNIHNG,[ASCIZ /NTHUNG:/]
	XWD	UNIHNG,[ASCIZ /SHUNG:/]
	XWD	UNIHBN,[ASCIZ /LBN:/]
	XWD	UNISOF,[ASCIZ /1CONI:/]
	XWD	UNIERR,[ASCIZ /2CONI:/]
	XWD	UNISDI,[ASCIZ /1DATAI:/]
	XWD	UNIHDI,[ASCIZ /2DATAI:/]
UER2TL==.-UER2T1

UER2T2:	HLRZS	N
	HRRZS	N
	HLRZS	N
	HRRZS	N
	HRRZ	N,N
	LDB	N,[POINT 12,N,11]
	LDB	N,[POINT 12,N,23]
	ANDI	N,7777
	LDB	N,[POINT 9,N,26]
	LDB	N,[POINT 9,N,17]
	LDB	N,[POINT 9,N,8]
	LDB	N,[POINT 9,N,35]
	JFCL
	JFCL
	JFCL
	JFCL
	JFCL
UER2T3:	PRTUED			;HDEV
	PRTUED			;HDAT
	PRTUED			;SDEV
	PRTUED			;SDAT
	PRTUED			;RETRIES
	PRTUED			;SER
	PRTUED			;RER
	PRTUED			;CER
	PRTUED			;PHUNG
	PRTUED			;THUNG
	PRTUED			;NTHUNG
	PRTUED			;SHUNG
	PRTUED			;LBN
	PRTUEO			;1CONI
	PRTUEO			;2CONI
	PRTUEO			;1DATAI
	PRTUEO			;2DATAI
SUBTTL "\" NETWORK STATISTICS DISPLAY PROGRAM

IFN	FTNET,<

X2SIZE==XSIZE/2

NETSTS:	MOVE	A,[<F%CMSR&777000000>+.GTFET]  ;GET FTCMSR
	PUSHJ	P,GETZ		;FROM MONITOR
	TRNN	A,<F%CMSR&777777>  ;IS FTCMSR TURNED ON?
	JRST	NOCMSR		;NO, THIS DISPLAY USELESS

;LINE 1

	PUSHJ	P,THISIS	;GIVE STANDARD HEADER LINE
	TABSET	TAB7		;NETWORK TABS

;LINE 2

	MOVEI	M,[ASCIZ /NTCOR=	/]
	PUSHJ	P,MSG
	MOVE	A,[%NTCOR]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /NTMAX=	/]
	PUSHJ	P,MSG
	MOVE	A,[%NTMAX]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /NTBAD=	/]
	PUSHJ	P,MSG
	MOVE	A,[%NTBAD]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECPRT
NETST4:	PUSHJ	P,CRLF

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;UN-NUMBERED CONTROL WINDOW

	SET	1,X2SIZE-1,3,12,0,TAB9A
	SETZM	NTRTL		;INITIALIZE RECEIVED TOTAL
	SETZM	NTXTL		;INITIALIZE TRANSMITTED TOTAL
	MOVEI	M,[ASCIZ /Unnumbered CTL	XMIT'ed	RECV'ed
/]
	PUSHJ	P,MSG
	MOVSI	J,-^D7			;MAX ENTRIES
UNPRT1:	MOVE	M,[[ASCIZ \0 DAP/DATA	\]
		[ASCIZ	/1 ACK	/]
		[ASCIZ	/2 NAK	/]
		[ASCIZ	/3 REP	/]
		[ASCIZ	/4 START	/]
		[ASCIZ	/5 STACK	/]
		[ASCIZ	/6 NODE ID	/]](J)
	PUSHJ	P,MSG
	MOVE	A,[%NTXTP]	;RECEVICE TABLE
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTXTP(J)	;A := INCREMENTAL
	ADDM	A,NTXTP(J)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	SKIPA	N,NTXTP(J)	;TOTAL
	MOVE	N,A
	ADDM	N,NTXTL		;ACCUMULATE TOTAL SENT
	TRNN	J,-1		;DAP/DATA MESSAGES?
	MOVNM	N,NTXTH		;YES, REMEMBER FOR HISTOGRAM
	PUSHJ	P,DECTAB
	MOVE	A,[%NTRTP]
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTRTP(J)	;A := INCREMENTAL
	ADDM	A,NTRTP(J)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	SKIPA	N,NTRTP(J)	;TOTAL
	MOVE	N,A
	ADDM	N,NTRTL		;ACCUMULATE TOTAL RECEIVED
	TRNN	J,-1		;DAT/DATA MESSAGES?
	MOVNM	N,NTRTH		;YES, REMEMBER FOR HISTOGRAM
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF
	AOBJN	J,UNPRT1

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;NUMBERED MESSAGE WINDOW

	SET	X2SIZE,XSIZE,3,12,0,TAB9B
	MOVEI	M,[ASCIZ /Numbered CTL	XMIT'ed	RECV'ed
/]
	PUSHJ	P,MSG
	MOVSI	J,-^D7
	HRRI	J,1
NUPRT1:	MOVE	M,[[ASCIZ /0	 /]
		[ASCIZ /1 CONNECT	/]
		[ASCIZ /2 DISCONNECT	/]
		[ASCIZ /3 NEIGHBORS	/]
		[ASCIZ /4 REQ CONFIG	/]
		[ASCIZ /5 CONFIG	/]
		[ASCIZ /6 DATA REQUEST	/]
		[ASCIZ /7 STATION CTL	/]](J)
	PUSHJ	P,MSG
	MOVE	A,[%NTXMT]	;RECEVICE TABLE
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTXMT(J)	;A := INCREMENTAL
	ADDM	A,NTXMT(J)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	SKIPA	N,NTXMT(J)	;TOTAL
	MOVE	N,A
	ADDM	N,NTXTH		;ACCUMULATE TOTAL DATA SENT
	PUSHJ	P,DECTAB
	MOVE	A,[%NTRMT]
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTRMT(J)	;A := INCREMENTAL
	ADDM	A,NTRMT(J)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	SKIPA	N,NTRMT(J)	;TOTAL
	MOVE	N,A
	ADDM	N,NTRTH		;ACCUMULATE TOTAL DATA RECEIVED
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF
	AOBJN	J,NUPRT1

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;HERE TO DO A HISTOGRAM OF MESSAGE LENGTHS

	SET	1,X2SIZE-1,11,YSIZE,0,TAB7
	MOVEI	M,[ASCIZ /XMIT'ed=/]
	PUSHJ	P,MSG
	MOVE	N,NTXTL		;TOTAL MESSAGES SENT
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /Average=/]
	PUSHJ	P,MSG
	MOVE	N,NTXTL		;GET TOTAL SENT AGAIN
	MOVE	A,UPTINC	;UPTIME
	IDIV	A,TCKSEC
	IDIV	N,A
	PUSH	P,N+1
	PUSHJ	P,DECPRT
	MOVEI	CH,"."
	PUSHJ	P,TYO
	POP	P,N
	IMULI	N,^D100		;- SCALE REMAINDER
	IDIV	N,A		;
	PUSHJ	P,DECPRT
	MOVEI	M,[ASCIZ \/sec\]
	PUSHJ	P,MSG
	PUSHJ	P,CRLF

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

IFGE	<YSIZE-20>,<		;DON'T BOTHER FOR VT50'S, ETC.

;PRINT THE ACTUAL HISTOGRAM

	MOVEI	M,[ASCIZ / 2**N	0%   20%  40%  60%  80%  99%
/]
	PUSHJ	P,MSG
	MOVE	A,[%NTXDL]
	PUSHJ	P,GETA
	LDB	J,[POINT 9,A,8]	;NUMBER OF ENTRIES
	MOVNS	J
	MOVSI	J,(J)		;AOBJN POINTER
	HRRI	J,(A)		;TABLE INDEX
	SETZB	N,JS		;SETUP COUNT/INDEX
	MOVMS	NTXTH		;POSITIFY TOTAL DATA SENT
LEN2:	HRLI	A,1(J)		;OFF BY ONE
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTXDL(JS)	;A := INCREMENTAL
	ADDM	A,NTXDL(JS)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,NTXDL(JS)	;TOTAL
	IMULI	A,^D100
	IDIV	A,NTXTH		;SCALE BY TOTAL DATA SENT
	HRRI	N,1(JS)		;SIZE (LOG 2)
	PUSHJ	P,DECPRT
	PUSHJ	P,SPACE
	MOVE	N,A
	MOVEI	CH,"0"		;LEADING 0
	CAIGE	N,^D10		;PERCENTAGE ONLY ONE DIGIT?
	PUSHJ	P,TYO		;YES, MAKE TWO FOR NEATNESS
	PUSHJ	P,DECPRT
	MOVEI	CH,"%"
	PUSHJ	P,TYO
	JUMPE	A,LEN3
	PUSHJ	P,TAB
	ADDI	A,3		;ROUNDING
	ASH	A,-2
	MOVEI	CH,"*"
	PUSHJ	P,TYO
	SOJG	A,.-1
LEN3:	PUSHJ	P,CRLF
	ADDI	JS,1		;INDEX TO INTERNAL TABLE
	AOBJN	J,LEN2

> ;END IFGE <YSIZE-20>

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;HERE TO DO THE HISTOGRAM OF RECEIVED MESSAGES

	SET	X2SIZE,XSIZE,11,YSIZE,0,TAB8
	MOVEI	M,[ASCIZ /RECV'ed=/]
	PUSHJ	P,MSG
	MOVE	N,NTRTL		;GET TOTAL RECEIVED
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ/Average=/]
	PUSHJ	P,MSG
	MOVE	N,NTRTL		;TOTAL RECEIVED AGAIN
	MOVE	A,UPTINC	;UPTIME
	IDIV	A,TCKSEC
	IDIV	N,A
	PUSH	P,N+1
	PUSHJ	P,DECPRT
	MOVEI	CH,"."
	PUSHJ	P,TYO
	POP	P,N
	IMULI	N,^D100		;- SCALE REMAINDER
	IDIV	N,A		;
	PUSHJ	P,DECPRT
	MOVEI	M,[ASCIZ \/sec\]
	PUSHJ	P,MSG
	PUSHJ	P,CRLF

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

IFGE	<YSIZE-20>,<		;DON'T BOTHER IF VT50'S, ETC.

	MOVEI	M,[ASCIZ / 2**N	0%   20%  40%  60%  80%  99%
/]
	PUSHJ	P,MSG
	MOVE	A,[%NTRDL]
	PUSHJ	P,GETA
	LDB	J,[POINT 9,A,8]	;NUMBER OF ENTRIES
	MOVNS	J
	MOVSI	J,(J)		;AOBJN POINTER
	HRRI	J,(A)		;TABLE INDEX
	SETZB	N,JS		;INITIALIZE COUNT/INDEX
	MOVMS	NTRTH		;POSITIFY TOTAL DATA RECEIVED
LEN5:	HRLI	A,1(J)		;OFF BY ONE
	HRRI	A,.GTNTP
	PUSHJ	P,GETA
	SUB	A,NTRDL(JS)	;A := INCREMENTAL VALUE
	ADDM	A,NTRDL(JS)	;UPDATE TOTAL
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,NTRDL(JS)	;TOTAL
	IMULI	A,^D100
	IDIV	A,NTRTH		;SCALE BY TOTAL DATA RECEIVED
	HRRI	N,1(JS)		;GET SIZE (LOG 2)
	PUSHJ	P,DECPRT
	PUSHJ	P,SPACE
	MOVE	N,A
	MOVEI	CH,"0"		;LEADING 0
	CAIGE	N,^D10		;PERCENTAGE ONLY ONE DIGIT?
	PUSHJ	P,TYO		;YES, MAKE TWO FOR NEATNESS
	PUSHJ	P,DECPRT
	MOVEI	CH,"%"
	PUSHJ	P,TYO
	JUMPE	A,LEN6
	PUSHJ	P,TAB
	ADDI	A,3		;ROUNDING
	ASH	A,-2
	MOVEI	CH,"*"
	PUSHJ	P,TYO
	SOJG	A,.-1
LEN6:	PUSHJ	P,CRLF
	ADDI	JS,1		;OFFSET FOR INTERNAL TABLE
	AOBJN	J,LEN5

> ;END IFGE <YSIZE-20>

	POPJ	P,
SUBTTL "T" NETWORK DISPLAY OF THE TOPOLOGY

NETPRG:	PUSHJ	P,THISIS	;GIVE STANDARD HEADER LINE
	TABSET	TAB7		;SET STANDARD TABS

NETPI0:	MOVE	A,[%CNNDB]	;GET THE GETTAB POINTER TO THE NDB'S
	PUSHJ	P,GET		;GET IT
	  CAIA
	JUMPN	A,NETPI2	;OK THERE IS A NETWORK
	SET	1,XSIZE,2,YSIZE,0,TAB4
	MOVEI	M,[ASCIZ \The T command can only be executed if:
1.The requester has SPY or PEEK privileges.
2. And the monitor was built for network support =603
\]
	CALL	MSG
	JRST	ADVICE

NETPI2:	TLNN	F,FL.SPY!FL.PEK	;IS THE USER PRIVILEGED
	JRST	NOPRIV		;NO
	PUSH	P,A		;SAVE FIRST NDB
	MOVSI	B,-NDBTLN	;NDB POINTERS TABLE LENGTH
NETPI4:	MOVE	A,NDBGTB(B)	;NEXT POINTER GETTAB TABLE INDEX
	GETTAB	A,		;(MUST GETTAB SINCE IN HIGH SEG)
	 JRST	NETPI5		;MUST BE PRE-7.01
	TLZ	A,37		;CLEAR INDEX AND INDIRECT BITS
	TRNE	B,-1		;FIRST ENTRY?
	ADDI	A,XDBBLK	;NO (NOT LENGTH) RELOCATE POINTER
	MOVEM	A,NDBPTB(B)	;SAVE IN NDB POINTER TABLE
	AOBJN	B,NETPI4	;LOOP
	MOVEI	A,N		;ADDRESS OF NEIGHBORS INFO
	HRRM	A,NDBNGN	;SET UP BYTE POINTER
NETPI5:	POP	P,A		;GET BACK FIRST NDB
	DPB	A,NDBNXT	;SAVE THE FIRST NDB POINTER
	SKIPG	N,FIRJOB	;ANY "+" COMMANDS SEEN?
	JRST	NETPI8		;NO
NETPI6:	PUSHJ	P,NXTNDB	;YES, SKIP THAT MANY NDB'S
	 JRST	[PUSHJ	P,DWNJOB  ;TOO MANY, BACKUP SOME
		 JRST	NETPI0]	;TRY AGAIN
	SOJG	N,NETPI6	;SKIP NODES
NETPI8:	CALL	STROLL
	SETOM	NLTYPD		;YES, WE TYPED

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

	SKIPG	NETMNY		;LOTS OF NEIGHBORS SOMEWHERE?
	JRST	NETPR0		;NO, NORMAL DISPLAY
	SET	1,XSIZE,2,YSIZE,0,TAB6X  ;YES, COMPRESS SCREEN
	JRST	NETPR1		;AND BUILD DISPLAY
NETPR0:	SET	1,XSIZE,2,YSIZE,0,TAB6  ;NORMAL TOPOLOGY DISPLAY
NETPR1:	MOVEI	M,[ASCIZ \ Node	Neighbors	OPR	CTL	LAR	LAP	LMS	LMA	LMR	LMP
\]
	CALL	MSG
NETPR2:	SKIPGE	LINE		;FILLED SCREEN YET?
	 POPJ	P,		;YEAH, QUIT NOW
	PUSHJ	P,NXTNDB	;NO, ADVANCE TO NEXT NODE
	  JRST	[PUSHJ	P,CHKDON;SCREEN NICELY FILLED UP YET?
		JRST	NETPRG	;NO, TRY AGAIN
		POPJ	P,]	;YES, SCREEN OK TO SHOW
	LDB	A,NDBSNM	;GET THE NODE NAME ADDRESS
	PUSHJ	P,MPEEK		;GET NODE NAME
	PUSHJ	P,SIXBP
	MOVEI	CH,"("
	PUSHJ	P,TYO
	LDB	N,NDBNNM	;GET THE NODE NUMBER
	PUSHJ	P,OCTPRT
	MOVEI	M,[ASCIZ \)\]
	CALL	MSG
	PUSHJ	P,TAB
	SETZ	A,		;COUNT THE NEIGHBORS
	SKIPA	C,NDBNGH	;GET THE TOPOLOGY POINTER
NETPR4:	IBP	C		;ADVANCE TOPOLOGY POINTER
	LDB	N,C		;GET A NEIGHBOR ENTRY
	LDB	N,NDBNGN	;GET NODE NUMBER OF NEIGHBOR
	SKIPE	N
	PUSHJ	P,[TRNN N,700	;FULL THREE DIGITS?
		PUSHJ	P,SPACE	;NO MORE THAN TWO
		TRNN	N,770	;HOW MAY DIGITS
		PUSHJ	P,SPACE	;ONLY ONE
		PUSHJ	P,OCTPRT;PRINT OCTAL NODE NUMBER
		AOJA	A,COMMA];COUNT NEIGHBORS AND SEPARATE
	CAME	C,NDBNGL	;LAST NEIGHBOR?
	JRST	NETPR4		;NOT YET, KEEP GOING
	SUBI	A,<<XSIZE-40>/7>;SEE IF LOTS OF NEIGHBORS
	MOVEM	A,NETMNY	;(COMPRESS SCREEN IF .GT. 0)
	PUSHJ	P,TAB
	LDB	A,NDBOPR	;GET THE OPR ENTRY
	JUMPE	A,NETPR5	;NO OPR TERMINAL
	ADDI	A,16		;YES, POINT THE LDBDCH ENTRY IN THE LDB
	PUSHJ	P,MPEEK		;READ IT
	ANDI	A,777		;ONLY NINE BITS
	MOVEI	N,(A)		;COPY
	PUSHJ	P,OCTPRT

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

NETPR5:	PUSHJ	P,TAB
	LDB	N,NDBCTJ	;IS STATION CONTROL BUSY
	SKIPE	N
	PUSHJ	P,DECPRT	;YES, PRINT THE JOB NUMBER
	PUSHJ	P,TAB
	LDB	N,NDBLAR	;LAR
	PUSHJ	P,DECTAB
	LDB	N,NDBLAP	;LAP
	PUSHJ	P,DECTAB
	LDB	N,NDBLMS
	PUSHJ	P,DECTAB
	LDB	N,NDBLMA	;LMA
	PUSHJ	P,DECTAB
	LDB	N,NDBLMR	;LMR
	PUSHJ	P,DECTAB
	LDB	N,NDBLMP	;LMP
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF		;END OF LINE 1
	JRST	NETPR2		;DO NEXT NODE IN NETWORK



NXTNDB:	LDB	B,NDBNXT	;ADDRESS OF NEXT NDB
	JUMPE	B,CPOPJ		;0 TERMINATES LIST
	MOVE	C,NDBLEN	;LENGTH OF NDB
	CAILE	C,XDBLEN	;SMALL ENOUGH FOR US?
	 MOVEI	C,XDBLEN	;ONLY READ IN FIRST PART
	MOVN	C,C		;NEGATIVE LENGTH
	ASH	C,^D18		;AOBJN POINTER
NXTND1:	MOVE	A,B		;ADDRESS OF NDB WORD
	PUSHJ	P,MPEEK		;GET A WORD
	MOVEM	A,XDBBLK(C)	;STORE
	AOBJP	C,CPOPJ1	;EXIT IF LAST WORD
	AOJA	B,NXTND1	;GET NEXT WORD
SUBTTL LOCAL STORAGE FOR "T" DISPLAY

;LIST OF BYTE POINTERS TO BE GETTAB'ED FROM MONITOR (MATCHES NDBPTB)

NDBGTB:	%NDLEN			;LENGTH OF NDB
	%NDNXT			;ADDRESS OF NEXT NDB
	%NDNNM			;NODE NUMBER
	%NDSNM			;ADDRESS OF STATION NAME
	%NDNGH			;FIRST NEIGHBOR POINTER
	%NDNGL			;LAST NEIGHBOR POINTER
	%NDNGN			;NODE NUMBER IN %NDNGH
	%NDOPR			;ADDRESS OF OPR LDB IF ANY
	%NDCTJ			;STATION CONTROL JOB NUMBER
	%NDLAR			;LAST ACK RECEIVED
	%NDLAP			;LAST MESSAGE ACK'ED
	%NDLMS			;LAST MESSAGE SENT
	%NDLMA			;LAST MESSAGE ASSIGNED
	%NDLMR			;LAST MESSAGE RECEIVED
	%NDLMP			;LAST MESSAGE PROCESSED

	NDBTLN==.-NDBGTB

>;END FTNET
	SUBTTL	"Q" DISPLAY OF THE SYSTEM QUEUES

QUEPRG:	PUSHJ	P,THISIS	;IDENTIFY US
	PUSHJ	P,CRLF		;BLANK LINE FOR NEATNESS
	TABSET	TAB7		;SET NORMAL TAB STOPS
	MOVE	A,FIRJOB	;COUNT OF "JOBS" TO SKIP
	MOVEM	A,EATCNT	;SET FOR EMSG

;ASK [SYSTEM] QUASAR FOR A LISTING OF THE QUEUES

	MOVE	A,[1000,,IPCPAG];PAGE POINTER TO USE
	PUSHJ	P,RSTIPC	;CLEAR OUT ANY SPURIOUS IPCF PACKETS
	SKIPN	B,QSRPID	;PID FOR [SYSTEM] QUASAR
	JRST	QUEERR		;NO PID THEN NO QUEUES
	PUSHJ	P,CREPAG	;CREATE PAGE TO SEND TO QUASAR
	 JRST	QUEERR		;NO PAGE, NO QUEUES
	MOVX	N,LIQALL	;LIST ALL QUEUES
	MOVEM	N,QSRFLG	;SET IN FLAG WORD TO QUASAR
	MOVE	N,[QSRMSG,,<IPCPAG*1000>]  ;BLT POINTER TO
	BLT	N,<IPCPAG*1000>+QSRLEN-1  ;COPY QUASAR REQUEST MESSAGE
	PUSHJ	P,SNDIPC	;SEND REQUEST TO QUASAR
	 JRST	QUEERR		;QUE ERROR

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

;NOW RECEIVE IPCF REPLY PACKET(S)

QUELOP:	PUSHJ	P,RECIPC	;GET ANSWER PACKET
	 JRST	QUEERR		;DOESN'T WORK
	CAME	B,IPCBLK+.IPCFS	;THIS PACKET FROM [SYSTEM]QUASAR?
	JRST	QUELOP		;NO, EAT IT
	MOVEI	C,<IPCPAG*1000>+.OHDRS  ;FIRST ARGUMENT ADDRESS

;LOOP OVER ARGUMENT BLOCKS WITHIN IPCF MESSAGE

QUELO1:
;MACRO %53A(1072) AND MACTEN %2(26) BLOW THE POINTR FORM:
;	LDB	D,[POINTR ARG.HD(C),AR.LEN]  ;LENGTH OF THIS ARGUMENT BLOCK
;	LDB	N,[POINTR ARG.HD(C),AR.TYP]  ;TYPE OF THIS ARGUMENT BLOCK
	HLRZ	D,ARG.HD(C)	;LENGTH OF ARG BLOCK
	HRRZ	N,ARG.HD(C)	;TYPE OF ARG BLOCK
	CAIN	N,.ORDSP	;OPR DISPLAY ARGUMENT?
	JRST	QUELO6		;YES, JUST EAT IT
	MOVEI	M,ARG.DA(C)	;START OF TEXT (ASCIZ) STRING
	HRLI	M,(POINT 7,)	;MAKE ASCII BYTE POINTER
	MOVE	N,EATCNT	;GET EAT COUNTER
	CAME	N,FIRJOB	;STARTED DISPLAY YET?
	JRST	QUELO4		;YES, PASS TEXT VERBATIM
QUELO3:	MOVE	N,M		;COPY OF BYTE POINTER
	ILDB	CH,N		;GET A CHARACTER
	CAIE	CH,.CHCRT	;A <CR>?
	JRST	QUELO4		;NO, REAL TEXT, DISPLAY IT
	IBP	M		;YES, EAT IT
	IBP	M		;AND ASSUMED <LF> FOLLOWING
	JRST	QUELO3		;CHECK FOR MORE BLANK LINES
QUELO4:	PUSHJ	P,EMSG		;NO - GO DISPLAY THE TEXT
QUELO6:	SOSG	<IPCPAG*1000>+.OARGC  ;MORE ARGUMENT BLOCKS?
	JRST	QUELOS		;NO, SEE IF MORE IPCF PACKETS
	ADD	C,D		;POINT TO NEXT ARGUMENT BLOCK
	JRST	QUELO1		;BACK TO TYPE IT

;LOOP OVER ALL IPCF PACKETS COMPRISING ANSWER FROM [SYSTEM]QUASAR

QUELOS:	MOVE	N,<IPCPAG*1000>+.OFLAG  ;QUASAR FLAGS
	TXNE	N,WT.MOR	;MORE TO COME?
	JRST	QUELOP		;YES, GO READ IT
	PUSHJ	P,CHKDON	;NO, SEE HOW THIS SCREEN FARED
	JRST	QUEPRG		;NOT SO GOOD
	POPJ	P,		;OK

QUEERR:	MOVEI	M,[ASCIZ\? Queues cannot be listed
\]				;HORRIBLE ERROR MESSAGE
	PJRST	MSG		;GO LIST IT ON SCREEN
	SUBTTL	PAGE CREATE/DESTROY SUBROUTINES

;CREPAG  --  CREATE A PAGE
;CALL IS:
;
;	MOVX	A,<PAGE>
;	PUSHJ	P,CREPAG
;	 ERROR
;	NORMAL
;
;WHERE <PAGE> IS THE DESIRED PAGE NUMBER.
;
;ON ERROR THE PAGE COULD NOT BE CREATED (ERROR CODE IN M)
;
;ON NORMAL RETURN THE DESIRED PAGE IS CREATED AND ADDRESSABLE.
;
;USES M, N, N1

CREPAG:	HRRZ	N1,A		;DESIRED PAGE NUMBER
	MOVEI	N,1		;ONLY ONE ARGUMENT
	MOVE	M,[.PAGCD,,N]	;PAGE. ARGUMENT BLOCK TO
	PAGE.	M,		;CREATE A NEW PAGE
	 CAIN	M,PAGCE%	;ERROR UNLESS PAGE ALREADY EXISTED
	AOS	(P)		;SUCCESSFUL RETURN
	POPJ	P,		;RETURN AS APPROPRIATE



;DESPAG  --  DESTROY PAGE
;CALL IS:
;
;	MOVX	A,<PAGE>
;	PUSHJ	P,DESPAG
;	 ERROR
;	NORMAL
;
;WHERE <PAGE> IS THE DESIRED PAGE TO BE DESTROYED.
;
;ON ERROR THE PAGE COULD NOT BE MADE NON-EXISTANT
;
;ON NORMAL RETURN THE PAGE DOES NOT EXIST
;
;USES M, N, N1

DESPAG:	HRRZ	N1,A		;DESIRED PAGE NUMBER
	TXO	N1,PA.GAF	; (WANT TO DESTROY)
	MOVEI	N,1		;ONLY ONE ARGUMENT
	MOVE	M,[.PAGCD,,N]	;PAGE. ARGUMENT BLOCK TO
	PAGE.	M,		;DESTROY THE PAGE
	 CAIN	M,PAGME%	;ERROR ONLY IF PAGE ALREADY NON-EXTANT
	AOS	(P)		;SKIP RETURN
	POPJ	P,		;RETURN AS APPROPRIATE
	SUBTTL	IPCF SEND/RECEIVE ROUTINES

;RSTIPC  --  RESET IPCF (CLEAR ANY "BOGUS" PAGES)
;CALL IS:
;
;	MOVX	A,<PAGE>
;	PUSHJ	P,RSTIPC
;	RETURN
;
;WHERE <PAGE> IS A SCRATCH PAGE AVAILABLE TO RECEIVE ANY STRAY
;IPCF PAGES.
;
;ON RETURN THERE ARE NO IPCF PAGES WAITING TO BE RECEIVED BY THIS
;JOB.
;
;USES M, N, N1

RSTIPC:	PUSHJ	P,DESPAG	;MAKE SURE PAGE AVAILABLE TO RECEIVE
	 POPJ	P,		;DUH?
	MOVX	N,IP.CFB!IP.CFV	;NON-BLOCKING RECEIVE
	MOVEM	N,IPCBLK+.IPCFL	;SET FLAGS WORD
	SETZM	IPCBLK+.IPCFS	;CLEAR SENDERS PID
	SETZM	IPCBLK+.IPCFR	;CLEAR RECEIVERS PID
	MOVEM	A,IPCBLK+.IPCFP	;SET WHERE TO RECEIVE PAGE
	MOVE	N,[.IPCFP+1,,IPCBLK]  ;IPCFR. ARGUMENT BLOCK TO
	IPCFR.	N,		;RECEIVE ANY PAGE (NON-BLOCKING)
	 POPJ	P,		;GOOD ENOUGH
	JRST	RSTIPC		;AH HA! MAKE SURE NO MORE PAGES LEFT
;RECIPC  --  RECEIVE IPCF PAGE, BLOCKING
;CALL IS:
;
;	MOVX	A,<PAGE>
;	PUSHJ	P,RECIPC
;	 ERROR
;	NORMAL
;
;WHERE <PAGE> IS THE DESIRED PAGE NUMBER TO RECEIVE THE IPCF
;MESSAGE PACKET.
;
;ON ERROR RETURN EITHER THE PAGE COULD NOT BE MADE AVAILABLE
;(DESTROYED) FOR RECEIVING OR AN IPCF FAILURE OCCURED
;
;ON NORMAL RETURN THE IPCF MESSAGE PACKET IS IN <PAGE> AND N
;CONTAINS THE IPCF "ASSOCIATED VARIABLE"
;
;USES M, N, N1

RECIPC:	PUSHJ	P,DESPAG	;MAKE SURE PAGE AVAILABLE
	 POPJ	P,		;IS NOT, ERROR
	MOVX	N,IP.CFV	;PAGE MODE (BLOCKING)
	MOVEM	N,IPCBLK+.IPCFL	;SET IPCF FLAGS
	SETZM	IPCBLK+.IPCFS	;CLEAR SENDERS PID
	SETZM	IPCBLK+.IPCFR	;CLEAR RECEIVERS PID
	MOVEM	A,IPCBLK+.IPCFP	;SET RECEIVE POINTER
	MOVE	N,[.IPCFP+1,,IPCBLK]  ;IPCFR. ARGUMENT POINTER TO
	IPCFR.	N,		;RECEIVE A PAGE
	 POPJ	P,		;ERROR
	JRST	CPOPJ1		;SUCCESS, MESSAGE IN PAGE <PAGE>
;SNDIPC  --  SEND AN IPCF MESSAGE PAGE
;CALL IS:
;
;	MOVX	A,<PAGE>
;	MOVX	B,<PID>
;	PUSHJ	P,SNDIPC
;	 ERROR
;	NORMAL
;
;WHERE <PAGE> IS THE PAGE NUMBER OF THE MESSAGE PAGE TO BE SENT,
;AND <PID> IS THE IPCF PID TO WHOM THE MESSAGE IS TO BE SENT.
;
;ON ERROR THE MESSAGE COULD NOT BE SENT (ERROR OTHER THAN RECEIVER
;OR SYSTEM FULL)
;
;ON NORMAL THE IPCF MESSAGE PAGE HAS BEEN SENT.
;
;USES M, N, N1

SNDIPC:	MOVX	N,IP.CFV	;PAGE MODE
	MOVEM	N,IPCBLK+.IPCFL	;SET FLAGS WORD
	SETZM	IPCBLK+.IPCFS	;CLEAR SENDERS PID
	MOVEM	B,IPCBLK+.IPCFR	;SET RECEIVERS PID
	MOVEM	A,IPCBLK+.IPCFP	;SET MESSAGE POINTER
SNDIPD:	MOVE	N,[.IPCFP+1,,IPCBLK]  ;IPCFS. ARGUMENT POINTER TO
	IPCFS.	N,		;SEND THE IPCF MESSAGE PAGE
	 CAIA			;MAYHAPS AN ERROR
	JRST	CPOPJ1		;PACKET SENT
	CAIE	N,IPCRR%	;RECEIVER FULL?
	CAIN	N,IPCRY%	;OR SYSTEM FULL?
	CAIA			;YES, NOT REALLY AN ERROR
	POPJ	P,		;ERROR
	MOVEI	N,1		;ONE SECOND
	SLEEP	N,		;TO WAIT FOR THINGS TO IMPROVE
	JRST	SNDIPD		;TRY ANOTHER SEND
SUBTTL SUBROUTINES FOR STATUS COMPUTATION

;SUBROUTINE TO READ JOB DATA AND VARIOUS PARAMETERS

IJBDAT:	MOVE	A,[%CNSTS]	;GET FEATURES
	CALL	GETZ		;IF ANY THERE
	MOVEI	B,^D50		;50 HERTZ??
	TXNN	A,ST%CYC	;IF 60 HERTZ THEN
	MOVEI	B,^D60		;CHANGE THE VALUE
	MOVEM	B,FREAK		;REMEMBER FREQUENCY
	MOVE	A,XDDBLD	;GET DDBLDB VALUE FROM THE SYSTEM
	PUSHJ	P,GETZ		;SEE IF GETTAB IMPLEMENTED
	MOVEM	A,VDDLDB	;REMEMBER THE VALUE
	PUSHJ	P,GUPTIM	;GET SYSTEM UPTIME
	MOVEM	A,UPTIME	;FOR INCREMENTAL DISPLAYS
	SETZM	TTYTAB		;FIND ADDRESS OF TTYTAB
	MOVEI	A,10		;TABLE INDEX FOR GETTAB UUO
	PUSHJ	P,GET0		;TRY TO GET THE SPY ADDRESS
	JRST	IJBDA1		;LOOK UP INDIVIDUALLY
	JRST	IJBDA1		;PEEK NEEDED
	MOVEM	N1,TTYTAB	;FOR LATER
IJBDA1:	PJOB	A,
	MOVEM	A,MYJOB		;GET JOB NUMBER
	SETOM	TTYFLG		;SUPPOSE TOPS10
	MOVE	A,[%CNMNT]	;TRY TO GET MONITOR TYPE
	CALL	GETZ		;GET IT OR A ZERO
	LDB	A,[POINT 6,A,23];GET MONITOR TYPE
	CAIE	A,1		;TOPS-10?
	JRST	IJBDA2		;NO TRY UUO'S
	TLNE	F,FL.PEK	;CLAIRVOYANT?
	JRST	IJBDA3		;YES THEN ALL SET
IJBDA2:	SETZM	TTYFLG		;ASSUME DETACHED
	MOVE	A,MYJOB		;GET LINE NUMBER OF MY JOB
	TRMNO.	A,		;TRY TO GET INDEX
	JRST	IJBDA3		;I CANNOT HELP YOU
	AOS	TTYFLG		;MAKE FLAG >0 
	MOVSI	A,(SIXBIT /CTY/);GET INDEX OF CTY
	IONDX.	A,		;AND GET ITS INDEX
	SETOM	A		;ERROR NEVER MATCH
	MOVEM	A,CTYNDX	;REMEBER CTY INDEX

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

IJBDA3:	MOVE	A,XOPPN		;GET GETTAB PARAMETER
	PUSHJ	P,GETZ		;GO READ OPERATOR PPN
	SKIPE	A		;  SKIP IF ERROR
	MOVEM	A,OPRPPN	;ELSE STORE AWAY
	HRROI	A,.GTSTS	;MY STATUS
	PUSHJ	P,GETA
	HRROI	B,.GTPPN	;MY PPN
	GETTAB	B,
	  TLOA	B,-1		;NON DISK SYSTEM-FLAG AS UNGODLY
	CAMN	B,OPRPPN	;SEE IF OPERATOR
	TXNN	A,JS$LOG	;YES-LOGGED IN?
	SKIPE	GODLY		;SEE IF DEBUGGING
	TLO	F,FL.GOD	;WE'RE GOD
	MOVEM	B,ME
	MOVE	A,XOPR
	PUSHJ	P,GETA		;FIND OUT WHO'S OPERATOR
	MOVEM	A,OPR
	MOVE	A,XSPPN		;WHERE IS SYS
	PUSHJ	P,GETZ
	SKIPE	A
	MOVEM	A,SYSPPN	;IF NONE, DONT STORE
	MOVX	A,%LDOLD
	PUSHJ	P,GETZ
	MOVEM	A,OLDPPN
	MOVX	A,%LDNEW
	PUSHJ	P,GETZ
	MOVEM	A,NEWPPN
	MOVE	A,XLPPN		;GET GETTAB PARAMETER
	PUSHJ	P,GETZ		;GO READ LOGIN PPN
	SKIPE	A		;  SKIP IF ERROR
	MOVEM	A,LOGPPN	;ELSE STORE AWAY

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

	MOVSI	B,LQTAB
	SETZ	C,		;CLEAR WORK AREA
QTLP:	MOVEI	A,.GTWSN	;GET Q TABLE FROM MONITOR
	HRL	A,B
	PUSHJ	P,GETZ
	JUMPE	A,QTLP1		;ZERO WHEN RUN OUT
	MOVEM	A,QTAB(B)	;STORE QUEUE SIXBIT
	MOVE	D,[POINT 12,QTAB(B)] ;GET BYTE-POINTER FOR QUEUE NAMES
	HRLI	C,-3		;GET AOBJN WORD FOR 3 ENTRIES / DATA ITEM
QTLP2:	ILDB	A,D		;GET NEXT QUEUE ENTRY
	CAIN	A,'SL'		;"SL" STATE?
	HRRZM	C,SLQ		;YES, REMEMBER Q CODE
	CAIN	A,'HB'		;"HB" STATE?
	HRRZM	C,HBQ		;YES, REMEMBER Q CODE
	CAIN	A,'TI'		;"TI" STATE?
	HRRZM	C,TIQ		;YES, REMEMBER Q CODE
	CAIN	A,'EW'		;"EW" STATE?
	HRRZM	C,EWQ		;YES, REMEMBER Q CODE
	AOBJN	C,QTLP2		;LOOP OVER 3 ENTRIES PER WORD
	AOBJN	B,QTLP
QTLP1:
	MOVE	A,XSTATS
	PUSHJ	P,GETZ
	MOVEM	A,STATES
	JUMPE	A,DNTSTO	;DONT OVERRIDE TCKSEC IF GETTAB UUO UNDEFINED
	MOVEI	B,^D60
	TLNE	A,4000
	MOVEI	B,^D50
	MOVEM	B,TCKSEC
	TLNE	A,100		;NEW SCANNER SERVICE?
	TLO	F,FL.SCN	;YES. REMEMBER IT.
	TLNN	A,(6B9)		;SEE IF 5.03
	JRST	DNTSTO		;NO--SKIP PTY
	MOVE	A,XPTYCN	;YES--GET PTY RANGE
	PUSHJ	P,GETZ
	HLRZM	A,PTYOFS
	ADD	A,PTYOFS
	HRRZM	A,PTYMAX
DNTSTO:	MOVX	A,%SIQSR	;GETTAB ARGUMENT TO
	PUSHJ	P,GETZ		;GET THE PID FOR [SYSTEM]QUASAR
	MOVEM	A,QSRPID	;SAVE IT FOR QUEPRG
	MOVE	A,XSEGPT
	PUSHJ	P,GETA
	MOVEM	A,SEGPTR
	HLRE	B,A
	MOVNM	B,SEGN
	HRRZM	A,JOBN
	HRRZM	A,GT.JOB		;FOR 60722 LOAD AND ONWARDS
	ADD	A,SEGN
	HRRZM	A,BOTH
	HRRZM	A,GT.SEG		;FOR 60722 AND ONWARDS
	HRRZ	B,.JBFF
	MOVEM	B,ZERLOW
	SUBTTL CORE ALLOCATION

	MOVE	D,[-NTABLE,,TABLE]
GJB6:	LDB	A,PSPYTB	;SPYABLE TABLE (SPYTAB SET)?
	JUMPE	A,GJB4		;NO, INTERNAL SYSDPY TABLE
	LDB	A,PTABLE	;YES, GET THE GETTAB TABLE INDEX
	TRZ	F,FR.PDB	;PREVENT OLD DATA TO CLOBBER US
	TLNE	F,FL.SPY	;CAN WE SPY
	PUSHJ	P,GET0		;TRY IT
	JRST	GJB4		;NO CANNOT SPY
	JRST	GJB4		;NO SPY THERE
	TRZE	F,FR.PDB	;PDB DATA
	JRST	GJB4		;YES ALLOCATE CORE
	HRR	B,(D)		;GET THE TABLE POINTER
	HRRM	N1,(B)		;AND STORE THE SPY ADDRESS
	MOVEI	B,1		;GET SPY FLAG
	JRST	GJB5		;SKIP CORE STUUF
GJB4:	MOVE	A,.JBFF		;START ALLOCATING CORE
	HRRZ	B,(D)		;GET TABLE ADDRESS POINTER
	HRRM	A,(B)		;STORE THE ADDRESS
	LDB	B,PSIZE		;GET INDEX IN TABLE SIZE TABLE
	MOVE	B,TSIZE(B)	;GET THE SIZE
	ADD	B,A		;GET NEW FREE ADDRESS
	MOVEM	B,.JBFF		;AND ACCOUNT IT
	CAMG	B,.JBREL	;DO WE HAVE ENOUGH CORE
	JRST	GJB7		;YES ALL IS THERE
	CORE	B,		;GET IT IF NOT THERE THEN
	JRST	NOCOR		;THAT'S THE END
GJB7:	SETZ	B,		;NO SPYING
GJB5:	DPB	B,PSPY		;SET THE SPY FLAG
	AOBJN	D,GJB6		;PROCESS ALL TABLES
	HRRZ	A,SGCNT		;ADDRESS OF SEGMENT COUNT
	ADD	A,SEGN		;AND COMPUTE LAST ADDRESS FOR
	SOS	A		;FOR A BLT
	MOVEM	A,.SEGLS	;IN SET UP LOOP
;[560]	SETZM	@ZERLOW		;CLEAR CORE
;[560]	MOVE	A,ZERLOW
;[560]	HRLS	A
;[560]	ADDI	A,1
;[560] ABOVE 4 INSTRUCTIONS LEFT OVER??? OR NEXT INSTRUCTION LOST???
	POPJ	P,

NOCOR:	OUTSTR	[ASCIZ /?Need More Core
/]
	RESET
	AOS	.JBFF		;INDICATE INITIALIZED
	LOGOUT
GJBDAT:	MOVN	D,JOBN		;MINUS THE NUMBER OF JOBS
	HRLZS	D		;-JOBN,,0	FOR AOBJN
GJBL2:	SKIPN	B,TTYTAB	;CANN DATA BE SPIED?
	JRST	GJBL5		;NO GETTAB IT
	HLRZ	C,D		;GET JOB NUMBER
	ADD	B,D		;AND GET ADDRES
	MOVE	B,(B)		;ELSE DIRECTLY FROM SPY SEGMENT
	JRST	GJBL6		;SKIP GETTAB STUFF
GJBL5:	MOVS	B,D		;GET THE JOB NUMBER
	HRRI	B,10		;AND THE TABLE INDEX
	GETTAB	B,		;AND GET THE TTYTAB ENTRY
	JRST	GJB3
GJBL6:	LDB	J,TPCJOB	;IF OLD SCNSRF, GET JOB NO
	TLNE	F,FL.SCN	;NEW SCNSER?
	MOVEI	J,0(D)		;YES. DIFFERENT LAYOUT. GET JOB NO.
	SETZM	@TTLDB
	TLZ	B,-1
	JUMPE	B,GJBN2
	MOVEI	A,$DVNAM(B)	;GET TTY NAME
	PUSHJ	P,MPEEK		;GET THE WORD
	MOVEM	A,@TTLDB	;STORE IN TABLE
	MOVEI	A,$DVIOS(B)	;GET TTY DEVIOS
	PUSHJ	P,MPEEK		;GET THE WORD
	MOVEM	A,@TTIOS	;STORE
	TLNN	F,FL.SCN	;WHICH SCANNER LAYOUT?
	JRST	GJBN2		;OLD.
	MOVE	A,VDDLDB	;GET OFFSET
	ADDI	A,(B)		;AND GET ADDRESS
	PUSHJ	P,MPEEK		;GET THE VALUE
	TRNE	A,-1		;ANY LDB LINK?
	JRST	GJBN2		;YES. OK TO TYPE NAME.
	HRLM	A,@TTLDB
GJBN2:	AOBJN	D,GJBL2		;ALL JOBS

GJB3:	MOVE	J,MYJOB
	MOVE	A,@TTLDB
	CAME	A,[SIXBIT /CTY/]
	CAMN	A,OPR
	TLO	F,FL.GOD
	MOVE	D,[XWD -NTAB,TABPTR]
INIT0:	LDB	B,PSPY		;SPYABLE?
	JUMPN	B,INIT1		;THEN FORGET LOOKUP
	LDB	B,PSIZE		;GET THE TABLE SIZE
	MOVN	B,TSIZE(B)	;VIA INDEX
	MOVSS	B		;SWAP HALVES
	HRRZ	C,(D)		;GET POINTER TO TABLE POINTER
	HRR	B,(C)		;GET TABLE ADDRESS
INIT2:	LDB	J,PTABLE	;GET THE TABLE VALUE
INIT3:	MOVE	A,J		;GET GETTAB PARAMETER
	PUSHJ	P,GETZ		;GET THE VALUE
	MOVEM	A,(B)		;STORE THE RESULT
	ADD	J,[1,,0]	;NEXT JOB
	AOBJN	B,INIT3		;FOR ALL TABLE MEMBERS
INIT1:	AOBJN	D,INIT0
	MOVE	A,SGCNT
	HRLS	A
	SETZM	(A)
	ADDI	A,1
	BLT	A,@.SEGLS
	POPJ	P,0		;END OF GET JOB DATA ROUTINE
;PSEUDO OPCODES AREA INTERPRETED HERE

PSEUDO:	LDB	T1,[POINT 9,(A),8]	;GET THE OPCODE
	CAILE	T1,.OPMAX	;VALID??
	AOJA	A,PSEUDO	;SEE IF THIS HELPS
	PUSH	P,A		;SAVE PSEUDO PC
	CALL	@PSOPC(T1)	;DO THE OPERATION
	POP	P,A		;RESTORE THE PC
	AOJA	A,PSEUDO	;THERE IS ARETURN CODE

PSOPC:	.PRTXT			;PRINT TEXT
	.PRGTD			;PRINT GETTAB VALUE DECIMAL
	CRLF			;PRINT CRLF
	.STOP			;LAST INSTRUCTION
	PLD			;PRINT LEFT HALF IN DECIMAL
	PRD			;PRINT RIGHT HALF IN DECIMAL
	GTB			;DO GETTAB INTO CEL
	PFLS			;PRINT A FLOAT WITH SCALE FACTOR
	TAB			;PRINT A TAB
	PLPA			;PRINT LEFT PAREN
	PRPA			;PRINT RIGHT PAREN
	OPPER			;PRINT PERIOD
	OPPLS			;PRINT A PLUS
	PRDP			;PRINT RIGHT HALF DECIMAL PADDED


.PRTXT:	HRRZ	M,(A)		;GET THE ADDRESS
	PJRST	MSG		;RETURN VIA MSG

.PRGTD:	MOVE	A,(A)		;GET GETTAB CODE
	TLZ	A,777000	;ZAP THE OPCODE
	CALL	GETZ		;ZERO OR VALUE
	MOVE	N,A		;GET THE VALUE
	PJRST	DECPRT		;RETURN VIA DECIMAL PRINTER

.STOP:	POP	P,A		;POP OFF RETURN
	POP	P,A		;AND SAVED A
	JRST	1(A)		;BACK TO NORMAL CODE

PLD:	HLRZ	N,@(A)		;GET THE VALUE
	PJRST	DECPRT		;AND PRINT IT
PRDP:	AOS	-1(P)		;POINT TO FACTOR
	MOVE	N,@-1(P)	;LOAD THE FACTOR
PRDP0:	IDIVI	N,^D10		;GET REDUCED SCALE
	HRRZ	N1,@(A)		;AND GET THE DATA
	CAMG	N,N1		;PADDING NEEDED
	JRST	PRDP1		;NO TYPE IT
	MOVEI	CH,"0"		;GET A ZERO
	CALL	TYO		;PRINT THE PADDING CHAR
	JRST	PRDP0		;TRY IT AGAIN
PRDP1:	HRRZ	N,@(A)		;GET DATA
	JUMPN	N,DECPRT	;PRINT NON ZERO VALUES ONLY
	POPJ	P,

PRD:	HRRZ	N,@(A)		;GET THE VALUE
	PJRST	DECPRT		;AND PRINT IT

GTB:	MOVE	A,(A)		;GET CODE
	TLZ	A,777000	;AFTER MASKING OPCODE
	CALL	GETZ		;GET ZERO OR VALUE IN A!
	AOS	T1,-1(P)	;POINT TO TARGET ADDRESS
	MOVEM	A,@(T1)		;AND STORE THE VALUE
	RETURN

PFLS:	MOVE	N,@(A)		;GET THE FLOATING NUMBER
	AOS	-1(P)		;POINT TO SCALE FACTOR
	FLTR	N1,@-1(P)	;GET THE SCALE FLOATING
	FMPR	N,N1		;AND GET THE PART WE WANT TO SEE
	FIXR	N,N		;FIX THE RESULT
	IDIV	N,@-1(P)	;NOW USE IT AS AN INTEGER
	PUSH	P,N1		;SAVE FRACTION
	CALL	DECPRT		;PRINT IT DECIMAL
	MOVEI	CH,"."		;TAKE DIVIDING CHARACTER
	CALL	TYO		;AND PRINT THAT
	POP	P,N		;GET FRACTION
	PJRST	DECPRT		;AND PRINT THAT

PLPA:	MOVEI	CH,"("		;GET LEFT PAREN
	PJRST	TYO		;AND PRINT IT

OPPER:	MOVEI	CH,"."		;GET A PERIOD
	PJRST	TYO		;AND PRINT IT

OPPLS:	MOVEI	CH,"+"		;GET A PLUS
	PJRST	TYO		;AND PRINT IT

PRPA:	MOVEI	CH,")"		;GET RIGHT PAREN
	PJRST	TYO		;AND TYPE IT
SUBTTL SUBROUTINES FOR CHAR AND PAGE HANDLING

THISIS:	SET	1,XSIZE,1,YSIZE,0,TAB4
THISIZ:	PUSHJ	P,CONFIG	;TYPE SYSTEM NAME
	PUSHJ	P,SPACE		;SPACE OVER
	PUSHJ	P,PDATIM	;TYPE CURRENT DATE AND TIME
	PUSHJ	P,SPACE		;SPACE OVER
	PUSHJ	P,GUPTIM	;GET SYSTEM UPTIME
	SUB	A,UPTIME	;A:= INCREMENTAL UPTIME
	ADDM	A,UPTIME	;KEEP TOTAL UP TO DATE
	TLNN	F,FL.INC	;INCREMENTAL OR TOTAL?
	MOVE	A,UPTIME	;TOTAL
	MOVEM	A,UPTINC	;SAVE FOR LATER USE
	MOVEI	M,[ASCIZ/(+) /]	;IN CASE INCREMENTAL
	TLNE	F,FL.INC	;INCREMENTAL DISPLAY?
	PUSHJ	P,MSG		;YES, TELL USER
	PUSHJ	P,PUPTIM	;TYPE SYSTEM UPTIME
	PJRST	CRLF
IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>, <
;
;	DISPLAY SUBROUTINES FOR THE VT06 DISPLAY TERMINAL
;
FINR:	DPB	CH,T1		;STORE WITHOUT NEW BIT
;	TLNE	F,FL.2PT+FL.REF	;IN SECOND PART AND
	CAIE	CH," "		;SPACE?
	TLZA	F,FL.EOL	;NO.
	TLON	F,FL.EOL	;YES. SEE IF FIRST OR LATER
	JRST	FINR1		;OUTPUT NON-SPACE OR FIRST SPACE
	POPJ	P,0		;MULT SPACE. DONT OUTPUT

FINR1:	MOVE	A,COL		;DESTINATION IS IN COL, LINE
	MOVE	B,LINE		; ..
	MOVEM	C,COL		;STORE CURSOR, FOR GETCH
	MOVEM	D,LINE
IFE V.DISP-V.DVT6,<
	CAIE	B,0(D)		;NEED TO MOVE VERTICALLY?
	PUSHJ	P,FILLIT	;YES--ADD FILLERS
>;	END OF IFE V.DISP-V.DVT6
FINR4:	MOVEI	CH,CDOWN
	CAIN	B,0(D)		;ON RIGHT LINE NOW?
	JRST	FINR2		;YES. GO LOOK AT X DIRECTION
	CAIG	B,0(D)		;NO. NEED TO GO UP OR DOWN?
	SOSA	D,LINE		;UP
	AOSA	D,LINE		;DOWN
	MOVEI	CH,CUP		;UP
	PUSHJ	P,DPYOUT
IFE V.DISP-V.DV5B,<
	PUSHJ	P,FILLIT	;ADD FILLER AFTER CURSOR
>;	END OF IFE V.DISP-V.DV5B
	JRST	FINR4

FINR2:	CAIN	A,0(C)		;ALREADY AT RIGHT PLACE?
	JRST	FINR5		;YES
	CAIG	A,0(C)		;NO. LEFT OR RIGHT?
	JRST	FINR8		;LEFT
	PUSHJ	P,GETCH		;GET OLD CHAR AT THIS POS TO RE-SEND
	MOVE	CH,T2
	AOS	C,COL		;MOVE CURSOR PAST THIS CHAR
FINR6:	PUSHJ	P,DPYOUT	;OUTPUT
	JRST	FINR2		;SEE IF TO DEST YET
FINR5:	PUSHJ	P,GETCH		;GET NEW CHAR AT DEST
	MOVE	CH,T2		;TO RIGHT AC
	PUSHJ	P,DPYOUT	;SEND IT
	CAIGE	C,XSIZE-1		;AND UNLESS UP AGAINST STOP,
	MOVEI	C,1(C)		;COUNT THIS POSITION OF CURSOR
	POPJ	P,0		;RETURN

FINR8:	MOVEI	T1,0(C)		;DEST COLUMN
	SUBI	T1,0(A)		;DIST=DEST-CURRENT
	CAILE	T1,0(A)		;DIST .LE. DEST FROM LEFT?
	JRST	FINR7		;NO. BETTER TO CR
	SOS	C,COL		;MOVE CURSOR LEFT 1 PLACE
	MOVEI	CH,CLEFT	;PHYSICALLY, TOO
	JRST	FINR6		; ..

FINR7:	SETZB	C,COL		;DO A CR
	MOVEI	CH,15
	JRST	FINR6
>;	END IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>

IFE V.DISP-V.DVT6,<
;SUBROUTINE TO POSITION CURSOR TO BOTTOM LEFT
;HOMEDN CODE CAN NOT BE USED BECAUSE OF HIGH-SPEED OPERATION
;THEREFORE, SIMULATE IT WITH 25 CURSOR DOWNS AND <CR>

HOMDWN:	OUTSTR	[BYTE (7)CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,15,ERASE,CFILL,CFILL,CFILL,0]
	POPJ	P,

>;	END OF IFE V.DISP-V.DVT6
IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>, <
;
;	DISPLAY SUBROUTINES FOR THE DIGITAL VT05
;
DPYX:	CAILE	C,4(XCUR)
	JRST	DPYPOS
	MOVE	A,D
	IMULI	A,XSIZE
	ADDI	A,-1(XCUR)
	IDIVI	A,4
	ADD	A,BPTAB(B)
DPYX1:	ILDB	CH,A
	PUSHJ	P,DPYOUT
	ADDI	XCUR,1
	CAIE	C,(XCUR)
	JRST	DPYX1
	POPJ	P,

DPYPOS:	MOVEI	XCUR,(C)
	MOVEI	YCUR,(D)
	MOVEI	CH,16
	PUSHJ	P,DPYOUT
	MOVEI	CH," "(D)
	PUSHJ	P,DPYOUT
IFE V.DISP-V.DV5B,<
	PUSHJ	P,FILLIT	;FILLERS FOR 2400 BAUD
>;	END OF IFE V.DISP-V.DV5B
	MOVEI	CH," "(C)
	PJRST	DPYOUT		;OUTPUT ADDRESS AND RETURN

HOMDWN:	IONEOU	[16]		;START OF CURSOR POSITIONING
	IONEOU	[<" "+YSIZE-2>]	;JUMP DOWN THE SCREEN
	IONEOU	[CFILL]		;NEED
	IONEOU	[CFILL]		; LOTS
	IONEOU	[CFILL]		;  OF
	IONEOU	[CFILL]		;   FILLERS
	IONEOU	[" "]		;STAY AT LEFT MARGIN
	IONEOU	[ERASE]		;CLEAR TO END OF SCREEN
	IONEOU	[CFILL]		;SOME
	IONEOU	[CFILL]		; MORE
	IONEOU	[CFILL]		;  FILL
	IONEOU	[CFILL]		;   CHARACTERS
	POPJ	P,

>;	END OF	IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>
IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5A>*<V.DISP-V.DV5B>,<
;SUBROUTINE TO CLEAR THE SCREEN
CLEAR:	PUSHJ	P,HOME		;GET TO START OF SCREEN
	MOVX	CH,ERASE	;COMMAND TO CLEAR THE SCREEN
	PJRST	DPYOUT		;SEND TO TERMINAL

;SUBROUTINE TO HOME UP AND FILL
HOME:	MOVEI	CH,HOMEUP	;ISSUE HOME
	PUSHJ	P,DPYOUT	;TO DISPLAY
				;THEN FALL INTO FILLERS
>;	END IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5A>*<V.DISP-V.DV5B>
IFE V.DISP-V.DV5A,<
	POPJ	P,		;NO FILLERS ON VT05A
>;	END IFE V.DISP-V.DV5A
IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5B>,<

;SUBROUTINE TO EMIT ENOUGH FILLER CHARACTERS TO KEEP VT06 HAPPY
;EVEN AT 2400 BAUD IN 50 CYCLE COUNTRIES.
;CLOBBERS CH
FILLIT:	MOVEI	CH,CFILL	;GET FILLER CHARACTER
	REPEAT	3,<PUSHJ P,DPYOUT>
	JRST	DPYOUT
>;	END OF IFE <V.DISP-V.DVT6>*<V.DISP-V.DV5B>
IFE <V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>,<
;
;	DISPLAY SUBROUTINES FOR THE DIGITAL VT61
;
	ESC61==33
IFN	<V.DISP-V.DV50>,<	;NOT FOR VT50'S
DPYX:	CAILE	C,4(XCUR)
	JRST	DPYPOS
	MOVE	A,D
	IMULI	A,XSIZE
	ADDI	A,-1(XCUR)
	IDIVI	A,4
	ADD	A,BPTAB(B)
DPYX1:	ILDB	CH,A
	PUSHJ	P,DPYOUT
	ADDI	XCUR,1
	CAIE	C,(XCUR)
	JRST	DPYX1
	POPJ	P,

DPYPOS:	MOVEI	XCUR,(C)
	MOVEI	YCUR,(D)
	MOVEI	CH,ESC61	;ESC
	PUSHJ	P,DPYOUT
	MOVEI	CH,"Y"
	PUSHJ	P,DPYOUT
	MOVEI	CH," "(D)
	PUSHJ	P,DPYOUT
	MOVEI	CH," "(C)
	PJRST	DPYOUT		;OUTPUT ADDRESS AND RETURN

HOMDWN:	OUTSTR	[BYTE	(7)ESC61,"Y",<" "+YSIZE-2>," ",<ERASE&177>,<<ERASE_-^D9>&177>,0]
	POPJ	P,
> ;END OF NOT-VT50 CONDITIONAL

IFE	<V.DISP-V.DV50>,<	;VT50'S ARE STUPID
HOMDWN:	OUTSTR	[BYTE (7)CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,CDOWN,<ERASE&177>,<<ERASE_-^D9>&177>,0]
	POPJ	P,
> ;END OF VT50 CONDITIONAL
HOME:	MOVX	CH,HOMEUP	;POSITION-TO-HOME COMMAND
	JRST	DPYOUT

;SUBROUTINE TO CLEAR THE SCREEN
CLEAR:	PUSHJ	P,HOME		;POSITION TO START OF SCREEN
	MOVX	CH,ERASE	;CLEAR-TO-EOS COMMAND
	PJRST	DPYOUT

IFE	V.DISP-V.DV61,<
RVIDEO:	MOVEI	CH,ESC61
	PUSHJ	P,DPYOUT
	MOVEI	CH,"O"
	PUSHJ	P,DPYOUT
	MOVEI	CH,"J"
	TRCE	F,FR.RVD
	MOVEI	CH,"j"
	PUSHJ	P,DPYOUT
	JRST	FRCOUT

ALARM:	MOVEI	CH,ESC61
	PUSHJ	P,DPYOUT
	MOVEI	CH,"O"
	PUSHJ	P,DPYOUT
	MOVEI	CH,"G"
	TRCE	F,FR.ALR
	MOVEI	CH,"g"
	PUSHJ	P,DPYOUT
	JRST	FRCOUT
> ;	END OF IFE V.DISP-V.DV61
>;	END OF IFE <V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>
IFE V.DISP-V.DHZL, <
;
;	DISPLAY SUBROUTINES FOR THE HAZELTINE 2000
;
DPYX:	CAILE	C,4(XCUR)
	JRST	DPYPOS
	MOVE	A,D
	IMULI	A,XSIZE
	ADDI	A,-1(XCUR)
	IDIVI	A,4
	ADD	A,BPTAB(B)
DPYX1:	ILDB	CH,A
	PUSHJ	P,DPYOUT
	ADDI	XCUR,1
	CAIE	C,(XCUR)
	JRST	DPYX1
	POPJ	P,

DPYPOS:	PUSHJ	P,CURSOR
	MOVEI	CH,(C)
	PUSHJ	P,DPYOUT
	MOVEI	CH,(D)
	JRST	DPYOUT

CLEAR:	MOVEI	M,[BYTE (7) 176,34,177,177,177,0,0,0,0,0]
	MOVE	A,[XWD 040040,040040]
	MOVEM	A,DBUF
	MOVE	A,[XWD DBUF,DBUF+1]
	BLT	A,DBFEND
	JRST	DPYCHR

CURSOR:	MOVEI	XCUR,(C)
	MOVEI	YCUR,(D)
	MOVEI	M,[BYTE (7) 176,21,0,0,0]
	JRST	DPYCHR

HOME:	MOVEI	M,[BYTE (7) 176,22,0,0,0]

DPYCHR:	HRLI	M,(<POINT 7>)
DPYCH1:	ILDB	CH,M
	JUMPE	CH,CPOPJ
	PUSHJ	P,DPYOUT
	JRST	DPYCH1

HOMDWN:	OUTSTR	[BYTE (7)176,34,177,177,177,176,22,0]
	POPJ	P,
>;	END OF	IFE V.DISP-V.DHZL
IFE V.DISP-V.DDLT, <
;
;	DISPLAY SUBROUTINES FOR THE DELTA DATA TELTERM
;
DPYSPC:	MOVE	B,BP		;COPY BUFFER BYTE POINTER
	MOVEI	A,XSIZE		;GET # OF CHARS IN A LINE
	SUBI	A,1(C)		;GET # OF CHARS REMAINING IN THIS ONE
	JUMPLE	A,CPOPJ		;  NONE, RETURN
	SETZB	M,T1		;CLEAR CHARACTER COUNTERS
DPYSP1:	ILDB	CH,B		;GET NEXT CHARACTER FROM BUFFER
	CAIN	CH,400!" "	;TEST FOR BLANK CHANGED TO BLANK
	JRST	DPYSP3		;  YES, JUMP TO NEXT CHAR
	TRNE	CH,400		;TEST FOR SOMETHING CHANGED TO BLANK
	MOVEI	CH,200!" "	;  YES, CONVERT TO THAT FORMAT
	CAIN	CH,200!" "	;TEST FOR MODIFIED BLANK
	AOS	M		;  YES, COUNT IT
	ANDI	CH,177		;MASK OFF FOR 7 BITS ONLY
	CAIE	CH," "		;TEST FOR A SPACE
	AOS	T1		;  NO, COUNT NON-BLANKS
DPYSP3:	SOJG	A,DPYSP1	;DECR COUNT & REPEAT
	TLNE	F,FL.REF	;TEST FOR REFRESHING NOW
	JUMPN	T1,CPOPJ	;  YES, THEN DON'T CLEAR IF CHARS REMAIN
	SUBI	M,(T1)		;GET # OF MODIFIED BLANKS - # OF OTHER
	CAIG	M,(T1)		;TEST FOR MORE BLANKS THAN OTHER (YET)
	POPJ	P,		;  NO, RETURN
	MOVEI	A,0		;CLEAR REGISTER AS A FLAG
	CAIN	D,YSIZE-1	;TEST FOR LAST ROW ON CRT
	TLNN	F,FL.REF	;TEST FOR FULL REFRESH
	AOBJN	J,DPYSP2	;  NO TO EITHER, UPDATE & SKIP
	POPJ	P,		;  YES TO BOTH, RETURN
DPYSP2:	SKIPN	A		;TEST FOR POINTER ALREADY SAVED
	MOVE	T1,BP		;  ELSE SAVE BYTE POINTER
	ILDB	CH,BP		;GET CHARACTER FROM BUFFER
	TRNE	CH,400		;TEST FOR CHANGED TO A BLANK
	MOVEI	CH," "		;  YES, GET A BLANK
	ANDI	CH,177		;  & CLEAR MODIFY BIT
	CAIE	CH," "		;TEST FOR BLANK
	TRO	CH,200		;  NO, MUST OUTPUT THIS TIME
	DPB	CH,BP		;STORE PROPER CHARACTER BACK
	TRNE	CH,200		;TEST FOR NON-BLANK
	SKIPE	A		;TEST FOR FIRST NON-BLANK
	JRST	DPYSP4		;  NO, JUMP
	MOVE	A,J		;SAVE POSITION POINTER
	SUB	A,[1,,1]	;SUBTRACT ONE FROM EACH HALF!
	MOVE	M,T1		;  & SAVE BYTE POINTER
DPYSP4:	CAME	BP,B		;TEST FOR CAUGHT UP
	AOBJN	J,DPYSP2	;  NO, UPDATE POSITION & LOOP
	MOVEI	T2,23		;GET A CLEAR LINE CHARACTER
	JUMPE	A,CPOPJ		;TEST FOR BLANK LINE
	MOVE	J,A		;  NO, POINT AT NEXT CHARACTER TO OUTPUT
	MOVE	BP,M		;        DITTO
	POPJ	P,		;RETURN NOW
DPYX:				;ENTRY FOR X-POSITION CHANGING ONLY
DPYPOS:	MOVEI	B,(D)		;GET DESIRED Y POSITION
	SUBI	B,(YCUR)	;  MINUS CURRENT Y POSITION
	MOVMS	B		;GET DELTA-Y = ABS(DESIRED-CURRENT)
	MOVEI	A,(C)		;GET DESIRED COLUMN
	ADDI	A,(B)		;  PLUS DELTA-Y
	CAIGE	A,4		;TEST FOR .LT. LIMIT
	JRST	DPYCAR		;  YES, GO DO <CR>+INCREMENTAL
	MOVEI	A,(C)		;GET DESIRED COLUMN
	ADDI	A,(D)		;  PLUS DESIRED ROW
	CAIGE	A,4		;TEST FOR .LT. LIMIT
	JRST	DPYHOM		;  YES, GO DO <HOME>+INCREMENTAL
	MOVEI	A,(C)		;GET DESIRED X POSITION
	SUBI	A,(XCUR)	;  MINUS CURRENT X POSITION
	MOVMS	A		;GET DELTA-X = ABS(DESIRED-CURRENT)
	ADDI	A,(B)		;ADD DELTA-X & DELTA-Y
	CAIGE	A,5		;TEST FOR .LT. LIMIT
	JRST	DPYINC		;  YES, GO DO INCRMENTAL SHIFT
	CAMLE	C,LASTCR(D)	;TEST FOR FORMATTING POSITION RQST
	JRST	DPYFOR		;  YES, JUMP
	MOVEI	XCUR,(C)
	MOVEI	YCUR,(D)
	MOVEI	M,[BYTE (7) 20, 16, 0,0,0]
	PUSHJ	P,DPYCHR
	MOVEI	CH,(C)
	PUSHJ	P,DPYOUT
	MOVEI	CH,(D)
	PUSHJ	P,DPYOUT	;OUTPUT Y POSITION
	POPJ	P,		;RETURN TO CALLER

DPYCAR:	SETZ	XCUR,		;CLEAR CURRENT X POSITION
	MOVEI	CH,15		;GET A <CR> CHARACTER
	JRST	DPYCOM		;GO TO COMMON ROUTINE

DPYHOM:	SETZB	XCUR,YCUR	;CLEAR CURRENT X & Y POSITIONS
	MOVEI	CH,24		;GET A <HOME> CHARACTER
DPYCOM:	PUSHJ	P,DPYOUT	;OUTPUT CONTROL CHARACTER
	PUSHJ	P,DPYFIL	;PUT OUT A FILL CHARACTER
	ADDI	A,2		;  & REQUEST TWO MORE LATER

DPYINC:	MOVEI	CH,13		;ASSUME DOWN
	CAIN	D,(YCUR)	;TEST FOR CORRECT LINE
	JRST	DPYHOR		;  YES, JUMP
	CAIG	D,(YCUR)	;TEST FOR DIRECTION
	SOSA	YCUR		;  UP, DECR CURRENT Y & SKIP
	AOSA	YCUR		;  DOWN, INCR CURRENT Y & SKIP
	MOVEI	CH,32		;CHANGE TO UPWARD CHARACTER
	PUSHJ	P,DPYOUT	;OUTPUT VERTICAL CONTROL CHARACTER
	JRST	DPYINC		;REPEAT AS NECESSARY
DPYHOR:	MOVEI	CH,10		;ASSUME LEFT
	CAIN	C,(XCUR)	;TEST FOR CORRECT COLUMN
	POPJ	P,		;  YES, RETURN
	CAIG	C,(XCUR)	;TEST FOR DIRECTION
	SOJA	XCUR,DPYPUT	;  LEFT, DECR CURRENT X & JUMP
	AOS	XCUR		;  RIGHT, INCR CURRENT X
	MOVEI	CH,31		;CHANGE FOR RIGHTWARD DIRECTION
	CAMLE	XCUR,LASTCR(YCUR) ;TEST FOR UNFORMATTED AREA
	MOVEI	CH," "		;  YES, PUT OUT A GOOD OLD BLANK
DPYPUT:	PUSHJ	P,DPYOUT	;OUTPUT THE CHARACTER
	JRST	DPYHOR		;REPEAT AS NECESSARY

DPYFOR:	PUSH	P,C		;SAVE DESIRED X POSITION
	MOVE	C,LASTCR(D)	;GET LAST CHARACTER WRITTEN ON SAME LINE
	PUSHJ	P,DPYPOS	;  & GO POSITION THERE NOW
	MOVEI	A,(XCUR)	;SAVE CURRENT POSITION OF THE LINE
	POP	P,XCUR		;RESTORE DESIRED AS CURRENT POSITION NOW
	MOVEI	C,(XCUR)	;  DITTO
	CAMLE	XCUR,LASTCR(YCUR) ;TEST FOR EXCEEDING CURRENT POSITION
	MOVEM	XCUR,LASTCR(YCUR) ;  YES, SHOW AS LAST CHARACTER WRITTEN
	SUBM	XCUR,A		;GET NUMBER OF CHARACTERS TO SEND
DPYBLK:	JUMPLE	A,CPOPJ		;  NONE, RETURN
	MOVEI	CH," "		;GET A BLANK
	PUSHJ	P,DPYOUT	;  & OUTPUT IT
	SOJA	A,DPYBLK	;DECR COUNT & REPEAT

HOME:	MOVEI	CH,24		;GET A <HOME> CONTROL CHARACTER
	PJRST	DPYOUT		;  & OUTPUT IT

CLEAR:	MOVEI	M,[BYTE (7) 20, 22, 20, 05, 0]
	SETZM	LASTCR		;CLEAR LAST-CHARACTER POSITION ARRAY
	MOVE	A,[XWD LASTCR,LASTCR+1] ;  DITTO
	BLT	A,LASTCR+YSIZE-1 ;  DITTO

DPYCHR:	HRLI	M,(<POINT 7>)
DPYCH1:	ILDB	CH,M
	JUMPE	CH,CPOPJ
	PUSHJ	P,DPYOUT
	JRST	DPYCH1

DPYFIL:	MOVEI	CH,177		;GET A NICE FILL CHARACTER
	PJRST	DPYOUT		;GO OUTPUT IT & RETURN

HOMDWN:	OUTSTR	[BYTE	(7)20,22,20,05,24,0]
	POPJ	P,
>;	END OF	IFE V.DISP-V.DHZL
;MPEEK  --  READ WORD FROM MONITOR EXEC VIRTUAL ADDRESS SPACE
;CALL IS:
;
;	MOVX	A,<ADR>
;	MOVX	J,<JOB>
;	PUSHJ	P,MPEEK
;	RETURN
;
;WHERE <ADR> IS THE EXEC VIRTUAL ADDRESS TO BE READ. IF <ADR> IS IN THE
;"PER-PROCESS" RANGE THEN A JOBPEK WILL BE USED TO READ THE SPECIFIED
;JOB'S PER-PROCESS AREA. IF THE JOB IS SWAPPED, OR CURRENTLY RUNNING ON
;ANOTHER CPU (STUCK IN THE OTHER CPU'S CACHE) THEN 0 IS RETURNED.
;
;THE MONITOR WORD IS RETURNED IN AC A.
;
;USES N, N1

MPEEK:	CAIL	A,340000	;IS DESIRED ADDRESS IN PER-PROCESS AREA?
	CAILE	A,377777	; . . .
	JRST	MPEEK4		;NO, TRY PEEK/SPY
	HRLZ	N,J		;YES, GET JOB NUMBER
	TXO	N,JK.EVA!JK.AIO+1  ;READ ONE WORD FROM PER PROCESS AREA
	HRLZ	N1,A		;ADDRESS TO BE READ
	HRRI	N1,A		;WHERE TO READ CONTENTS INTO
	MOVEI	A,N		;A := ADDRESS OF ARG BLOCK TO
	JOBPEK	A,		;ASK MONITOR FOR FUNNY ADDRESS
	SETZ	A,		;CAN'T (SWAPPED OR NOT PRIVILEGED)
	POPJ	P,		;RETURN WITH WORD IN A

MPEEK4:	TLNE	F,FL.SPY	;CAN WE SPY?
	TRNE	A,400000	;YES, ADDRESS IN MONITOR HIGH SEG?
	CAIA			;ONE WAY OR THE OTHER WE MUST PEEK
	SKIPA	A,400000(A)	;SPY THE INFORMATION (FASTER)
	PEEK	A,		;PEEK THE INFORMATION (SLOWER)
	POPJ	P,0
;SUB TO GET MONITOR WORD - RETURN 0 IN A IF CANNOT GET
; AND PRINT "?" BECAUSE UNEXPECTED ERROR

GETA:	PUSHJ	P,GET
	  TDZA	A,A		;RETURN 0
	POPJ	P,		;OK
	MOVEI	CH,"?"		;PRINT QUESTION MARK
	PJRST	TYO		;PRINT

;SUBROUTINE TO GET MONITOR WORD - RETURN 0 IN A IF CANNOT
; NOT AN ERROR IF NOT THERE - USE 0 AS VALUE

GETZ:	PUSHJ	P,GET
	  MOVEI	A,0		;RETURN 0
	POPJ	P,

;SUBROUTINE TO GET MONITOR WORD - SKIP IF CAN, NO SKIP IF CANNOT

GET:	PUSHJ	P,GET0		;SEE WHERE THE WORD IS
	POPJ	P,		;WORD DOES NOT EXIST
	PJRST	GETPEK		;PEEK FOR IT
	MOVE	A,0(N1)		;GET THE WORD BY SPYING
	JRST	CPOPJ1		;WIN RETURN

;GET 4 CONSECUTIVE MONITOR WORDS

GET4:	PUSHJ	P,GET0		;SEE WHERE WORD IS
	POPJ	P,		;WORD DOES NOT EXIST
	PJRST	GETPK4		;GO GETTAB THEM
	DMOVE	A,0(N1)		;GOT THE WORD(S)
	DMOVE	C,2(N1)		;GOT THE OTHER WORDS TOO
	JRST	CPOPJ1		;SUCCESSFUL RETURN
;DO THE WORK FOR THE GET ROUTINES

GET0:	TLNN	F,FL.SPY	;SPYING??
	PJRST	CPOPJ1		;NO PEEKING IS REQUIRED
	LDB	BP,[POINT 9,GTTSLF,8]
	CAIGE	BP,0(A)		;TABLE OK?
	POPJ	P,		;NO THEN IT DOES NOT EXIST
	HRRZ	BP,GTTSLF	;YES. GET THE DESIRED TABLE BASE WORD
	ADDI	BP,400000(A)
	MOVE	BP,0(BP)	;READ MONITOR
	HLRZ	N1,A		;GET DESIRED ITEM IN TABLE
	SKIPGE	A		;WANT SELF?
	MOVE	N1,MYJOB	;YES.
	CALL	@SPYGET		;GET TABLE DATA
	JRST	GETSPR		;NO, REGULAR TABLE
	TRO	F,FR.PDB	;SET A FLAG FOR GETBLK CODE
	SKIPE	PDBPTR		;FAIL IF NO PDB POINTER
	CAML	N1,JOBN		;SKIP IF LEGAL JOB NUMBER
	JRST	CPOPJ1		;TRY PEEK BETTER POPJ ??
	SKIPGE	PDBPTR		;SEE IF SWAPPING PDBS
	JRST	[MOVNS N1	;YES--GET -N
		 ADD   N1,PDBPTR;INCLUDE OFFSET
		 MOVE  N1,(N1)	;GET JBTADR(-JOB)
		 TRNN  N1,-1	;SEE IF IN CORE
		 JRST  CPOPJ1	;NO--GO LET MONITOR TRY
		 JRST  GETSPP]	;YES--SPY ON IT
	ADD	BP,@PDBPTR	;ADD ADDR OF PDB FOR THIS JOB
	JRST	GETSPP		;GET ENTRY FROM PDB

GETSPR:	CAIGE	CH,0(N1)
	POPJ	P,		;DOES NOT EXIST
	TLNN	BP,(17B17)	;SEE IF INDEXED
GETSPP:	MOVEI	N1,0		;NO--KILL INDEX
	ADDI	N1,400000(BP)	;COMPUTE ADDRESS TO GET WORD
CPOPJ2:	AOS	0(P)		;WIN RETURN
	JRST	CPOPJ1		;DOUBLE SKIP
;HERE IF SPY FAILED - TRY GETTAB UUO

GETPEK:	GETTAB	A,
	  POPJ	P,		;ERROR GETTAB NOT THERE
	JRST	CPOPJ1		;OK, RETURN

GETPK4:	MOVE	B,A		;ADDRESS OF WORD PLUS ONE
	ADD	B,[1,,0]	;PLUS ONE
	DMOVE	C,A		;PLUS TWO MORE WORDS
	DADD	C,[EXP <2,,0>,<2,,0>]  ;LAST TWO WORD "ADDRESS"ES
	GETTAB	A,		;TRY FOR WORD 1
	 POPJ	P,		;NOPE
	GETTAB	B,		;TRY FOR WORD 2
	 POPJ	P,		;NOPE
	GETTAB	C,		;TRY FOR WORD 3
	 POPJ	P,		;NOPE
	GETTAB	D,		;TRY FOR WORD 4
	 POPJ	P,		;NOPE
	JRST	CPOPJ1		;GOT ALL FOUR!

RNG722:	LDB	CH,[POINT 3,BP,11]	;GET ENTRY TYPE
	MOVE	CH,LENTAB(CH)		;GET TABLE LENGTH
	JUMPGE	CH,CPOPJ		;GOT IT
	AOJE	CH,CPOPJ1		;PDB DATA
	LDB	CH,[POINT 9,BP,8]	;GET TABLE LENGTH
	RETURN
;LENTAB CONTAINS THE LENGTH CORRESPONDENCE BETWEEN ENTRY TYPE
;>0 YOU GOT THE LENTH
;=0 TABLE DOES NOT EXIST (NO ENTRIES)
;-1 PDB DATA
;-2 NUMTAB CONTAINS THE LENGTH

STRWHO:	MOVE	A,[SIXBIT /**,**/]
SIXBP:	MOVE	BP,[POINT 6,A]
SIXBP1:	ILDB	CH,BP
	JUMPE	CH,CPOPJ
	ADDI	CH,40
	PUSHJ	P,TYO
	TLNE	BP,770000
	JRST	SIXBP1
CPOPJ:	POPJ	P,0

SIXB6:	MOVE	BP,[POINT 6,A]
SIXB61:	ILDB	CH,BP
	ADDI	CH,40
	PUSHJ	P,TYO
	TLNE	BP,770000
	JRST	SIXB61
	POPJ	P,

CRLF:	MOVEI	M,[ASCIZ /
/]
MSG:	TLNN	M,777700	;UNLESS ALREADY HAVE BYTE POINTER
	HRLI	M,(<POINT 7>)	;MAKE ADDRESS INTO BYTE POINTER
MSG1:	ILDB	CH,M
	JUMPE	CH,CPOPJ
	PUSHJ	P,TYO
	JRST	MSG1

COLON:	MOVEI	CH,":"
	JRST	TYO
COMMA:	MOVEI	CH,","
	JRST	TYO
DOT:	MOVEI	CH,"."		;A DOT OR PERIOD CHARACTER
	PJRST	TYO		;TO BE TYPED OUT.
PERCNT:	MOVEI	CH,"%"		;A PERCENT SIGN
	PJRST	TYO		;TO BE TYPED OUT.

;PRINT PERCENT
PRPCNT:	MOVEM	N,TEMP1
	PUSHJ	P,MSGDEC
	MOVSI	A,(SIXBIT ./.)
	MOVE	N,TEMP
	PUSHJ	P,SIXDEC
	MOVEI	M,[ASCIZ / = /]
	MOVE	N,TEMP1
	PUSHJ	P,CMPCNT
	MOVEI	CH,"%"	;PRINT PERCENT
	PJRST	TYO
EMSG:	TLNN	M,777700	;ADDRESS OR BYTE POINTER
	HRLI	M,(POINT 7,)	;ADDRESS, MAKE INTO BYTE POINTER
EMSG1:	ILDB	CH,M		;NEXT CHARACTER
	JUMPE	CH,CPOPJ	;NUL ENDS STRING
	CAIE	CH,.CHLFD	;NEW LINE YET?
	JRST	EMSG2		;NO, REGULAR CHARACTER
	SOSL	EATCNT		;DECREMENT LINES TO BE EATEN
	JRST	EMSG1		;NEED TO EAT STILL MORE
EMSG2:	SKIPG	EATCNT		;ON SCREEN YET?
	PUSHJ	P,TYO		;YES, LIST CHARACTER
	JRST	EMSG1		;LOOP BACK FOR MORE


CHKDON:	SKIPGE	N,LINE		;GET LINES FILLED WITH DATA
	JRST	CPOPJ1		;LINE .LT. 0 MEANS FULL SCREEN
	CAIGE	N,<YSIZE/2>	;IF LESS THAN 4 LINES
	SKIPG	FIRJOB		;AND WE ARE "+"'ED
	CAIA			;NO
	SOS	(P)		;THEN FLAG TO REDO THE SCREEN IMMED.
	SUBI	N,YSIZE		;SEE HOW MANY LINES LEFT ON SCREEN
	JUMPGE	N,CPOPJ1	;IF SCREEN FULL JUST EXIT OK
	ADDB	N,FIRJOB	;SCREEN HAS EMPTY LINES, "-" IT
	JUMPGE	N,CPOPJ1	;AND LET NEXT CYCLE SKIPGE IT DOWN
	SETZM	FIRJOB		;BUT NEVER LET IT GO NEGATIVE
	JRST	CPOPJ1		;RETURN APPROPRIATELY
;PRINTERS OF PAGE ORIENTED DATA

KAYPAG:	MOVEI	CH,"P"		;ASSUME PAGING
	TRNN	F,FR.KIP	;SO LOOK TO PROCESSOR
	MOVEI	CH,"K"		;AND CHANGE TO KAYS IF KA10
	PJRST	TYO		;EXIT VIA PRINTER


;PRINT PAGING DATA FOR THE CURRENT JOB CONTAINED IN J
;BEFORE SWITCHING TO INLINE CODE THE FOLLOWING DATA IS COLLECTED
;1 GETAB1 MAX VIRTUAL AND PHYSICAL LIMITS
;2 GETAB2 INTEGER PAGING RATE FRACTION,,FRACTIONAL PGR DATA

PGDATA:	TRNE	F,FR.VMM	;HAS THE SYSTEM ANY VIRTUES
	JRST	PGDATV		;(YES) DO THINGS DIFFERENT
	CALL	DECPRT		;PRINT IN DECIMAL P
	PJRST	TAB		;RETURN AFTER THE TAB
PGDATV:	HRL	A,J		;GET JOB NUMBER
	HRRI	A,.GTMVL	;GET MAXIMUM VALUES FOR JOB
	CALL	GETZ		;NOW OR ZER
	AND	A,[1777,,1777]	;EDIT 18 ZAP NON CORE BITS
	MOVEM	A,GETAB1	;REMEMBER MAX VALUE
	HRL	A,J		;GET THE JOBNUMBER
	HRRI	A,.GTCVL	;GET GUIDELINE
	CALL	GETZ		;AND TAKE THAT AS PHYS
	AND	A,[1777,,1777]	;EDIT 18 ZAP NON CORE BITS
	HRRM	A,GETAB1	;AND STORE IT FOR PRINTING
	SETZM	GETAB2		;ZAP PAGING RATE COMPLETELY
	HLRZ	N1,@JBPGR	;GET PAGING RATE
	JUMPE	N1,PGDAT0	;CERTAINLY NOT PAGING
	CALL	CMPPGR		;COMPUTE PAGING RATE
PGDAT0:	.INL			;START INLINE PSEUDO CODE
	.PLD	JOBVIR		;PRINT LOWSEG VIRTUAL SIZE
	.PLS			;SEPARATE WITH A PLUS
	.PRD	JOBVIR		;PRINT HISEG VIRTUAL SIZE
	.LPA			;PRINT A LEFT PAREN
	.PLD	GETAB1		;PRINT MAXIMUM VIRTUAL
	.RPA			;AND A RIGHT PAREN
	.TAB			;SPACE 2 PRINTS
	.PLD	JOBPHY		;PRINT LOWSEG PHYSICAL SIZE
	.PLS			;SEPARATE WITH A PLUS SIGN
	.PRD	JOBPHY		;PRINT HIGHSEG PHYSICAL SIZE
	.PLS			;SEPARATE WITH A PLUS
	.PRD	JOBPPG		;PRINT MONITOR PER-PROCESS PAGES
	.LPA			;(
	.PRD	GETAB1		;MAX PHYS
	.RPA			;)
	.TAB
	.PLD	GETAB2		;PRINT FRACTION
	.PER			;PERIOD
	.PRDP	GETAB2,^D100	;FACTOR 100
	.END			;END OF PSEUDO CODE
	PJRST	TAB		;EXIT AFTER PRINTING A TAB

;CMPPGR COMPUTES THE PAGING RATE PER SECOND THE INVERSE IS PASSED
;IN N1 THE RESULT IS RETURNED IN GETAB2,
;THE LEFTHALF IS THE INTEGER PART
;THE RIGHT HALF THE FRACTION

CMPPGR:	PUSH	P,N1		;SAVE THE INTERVAL
	MOVEI	N,^D100000	;TO MAKE A FRACTION
	IDIVI	N,(N1)		;GET REMAINDER IN N1
	HRLM	N,GETAB2	;STORE INTEGER PART
	MOVE	N,N1		;GET THE FARCTION
	IMULI	N,^D100		;FACTOR 100
	POP	P,N1		;GET THE INTERVAL BACK
	IDIVI	N,(N1)		;GET FRACTION
	HRRM	N,GETAB2	;AND STORE IT FOR PRINTING
	RETURN
PAGSYS:	PUSHJ	P,THISIZ	;GIVE HEADER
	MOVE	A,[11,,113]	;GET USER  LIMIT
	CALL	GETZ		;GET THE VALUE
	MOVEM	A,N1		;GET VALUE FOR CONVERSION
	CALL	CMPPGR		;PRINT PAGING RATE
;GETAB1 CONTAINS SYSTEM PAGING RATE LIMIT AS AN INTEGER
;GETAB2 CONTAINS USER PGR LIMIT AS XWD FORMAT
	.INL			;START OF INLINE CODE
	.TXT	<VM(MAX=>
	.GTB	5,113,GETAB
	.PRD	GETAB		;PRINT MAX VALUE
	.TXT	<,USED=>
	.PGTBD	4,113
	.TXT	<) PGR.USER=>
	.PLD	GETAB2		;PRINT INTEGER PART
	.PER			;PERIOD
	.PRD	GETAB2		;AND FRACTION
	.TXT	< PFC:NIW=>
	.GTB	13,113,GETAB	;PAGE FAULT COUNT
	.PLD	GETAB
	.TXT	< IW=>
	.PRD	GETAB
	.NWLIN
	.END
	RETURN			;RETURN TO CALLER
;CPCPT  --  ROUTINE TO PRINT N IN HUNDREDTHS OF PERCENT
;CALL IS:
;
;	MOVX	N,<PERCENT*100>
;	PUSHJ	P,CPCPT
;	RETURN
;
;THE PERCENT IS ALWAYS PRINTED AS THREE CHARACTERS:
;	1)	100
;	2)	NN.
;	3)	N.M
;	4)	.NN

CPCPT:	CAIG	N,^D999		;NN% FORM?
	JRST	CPCPT2		;NO
	IDIVI	N,^D100		;YES, REDUCE TO JUST PERCENT
	CAILE	N,^D99		;100%?
	PJRST	DECPRT		;YES, THAT'S OUR THREE DIGITS
	PUSHJ	P,DECPRT	;NO, PRINT TWO DIGITS
	MOVEI	CH,"."		;FOLLOW BY PERCENT INDICATOR
	PJRST	TYO		;AND CAP IT OFF

CPCPT2:	CAIG	N,^D99		;N.N FORM?
	JRST	CPCPT4		;NO
	IDIVI	N,^D100		;GET PERCENTAGE DIGIT
	MOVEI	CH,"0"(N)	;IN ASCII
	PUSHJ	P,TYO		;AND PRINT IT OUT
	MOVEI	CH,"."		;SEPARATING DOT
	PUSHJ	P,TYO		;PRINT IT ALSO
	MOVE	N,N1		;GET BACK THE HUNDREDTHS
	IDIVI	N,^D10		;TENTHS OF PERCENT
	MOVEI	CH,"0"(N)	;IN ASCII
	PJRST	TYO		;AND PRINT IT OUT

CPCPT4:	MOVEI	CH,"."		;LEADING DECIMAL
	PUSHJ	P,TYO		;INDICATE HUNDREDTHS
	MOVEI	CH,"0"		;IN CASE NEED LEADING "0"
	CAIG	N,^D9		;LESS THAN .10 PERCENT?
	PUSHJ	P,TYO		;YES, NEED LEADING "0"
	PJRST	DECPRT		;TYPE HUNDREDTHS OF PERCENT
;SUBROUTINE TO DIVIDE A NUMBER IN AC N BY TEMP
;ROUND UP RESULT IF NECESSARY AND PRINT MESSAGE FOLLOWED BY N (%)
;CALL	MOVEM	AC,TEMP
;	MOVE	N,NUMBER TO BE DIVIDED
;	MOVEI	M,[ASCIZ /TEXT/]
;	PUSHJ	P,DIVRPT
;	ALWAYS	RETURN
;ACS N1,N,M,CH & R ARE DESTROYED

CMPCNA:	MOVE	N,A
CMPCNT:	IMULI	N,^D100
	IDIV	N,TEMP
	LSH	N1,1
	CAML	N1,TEMP
	ADDI	N,1
	PJRST	MSGDEC		;GO PRINT MESSAGE AND DECIMAL

CALCNA:	MOVE	N,A
CALCNT:	IMULI	N,^D100
	IDIV	N,TEMP
	LSH	N1,1
	CAML	N1,TEMP
	ADDI	N,1
	POPJ	P,




;CMPDNA  --  PRINT PERCENTAGE.HUNDREDTHS (N/TEMP)
;CALL IS:
;
;		TEMP/	BASE FOR PERCENTAGE
;	MOVX	A,VALUE
;	PUSHJ	P,CMPDNA
;	RETURN
;
;USES A-D, N, N1

CMPDNA:	IMULI	A,^D100*^D100	;TO GET HUNDREDTHS
	IDIV	A,TEMP		;A := PERCENT * ^D100
	IDIVI	A,^D100		;A := PERCENT
	MOVE	N,A		;POSITION FOR DECZ2
	PUSHJ	P,DECZ2		;PRINT TWO DIGIT PERCENTAGE
	PUSHJ	P,DOT		;FINISH WITH A "."
	MOVE	N,B		;POSITION FOR DECZ2
	PJRST	DECZ2		;TYPE TWO DIGIT HUNDREDTHS
MSPDEC:	AOJE	J,MSGDEC	;IF FIRST SKIP SPACE 
	PUSHJ	P,SPACE		;OTHERWISE NEED SPACE SEPARATOR
MSGDEC:	PUSHJ	P,MSG
	JRST	DECPRT

SIXDEC:	PUSHJ	P,SIXBP
	JRST	DECPRT

MSPOCT:	AOJE	J,MSGOCT	;IF FIRST NO SEPARATOR
	PUSHJ	P,SPACE		;OTHERWISE NEED SEPARATOR
MSGOCT:	PUSHJ	P,MSG		;PRINT LEADING TEXT
	PJRST	OCTPRT		;AND TRAILING OCTAL NUMBER

;SUBROUTINE TO PRINT INTEGER+1 DIGIT FRACTION
;CALL:	MOVEM	TEMP		NUMBER TO DIVIDE BY
;	MOVE	A,NUMBER TO BE DIVIDED
;	PUSHJ	P,CMPDFA
;	ALWAYS RETURN

CMPDFA:	MOVE	N,A
CMPDFN:	IMULI	N,^D10		;  * 10
	IDIV	N,TEMP		;DIVIDE BY #K AVAILABLE
	LSH	N1,1		;REMAINDER * 2
	CAML	N1,TEMP		;TEST FOR ROUNDING NEEDED
	AOJ	N,		;  YES, INCR QUOTIENT BY 1
	IDIVI	N,^D10		;DIVIDE TO GET INTEGER/FRACTION
	PUSH	P,N1		;SAVE FRACTION FOR LATER
	PUSHJ	P,MSGDEC	;PRINT MSG & INTEGRAL PART
	POP	P,N		;RESTORE FRACTIONAL DIGIT
	MOVEI	CH,"."		;DECIMAL POINT
	PUSHJ	P,TYO		;SEPARATE FRACTION
	PJRST	DECPRT		;AND TYPE FRACTION

;SUBROUTINE TO PRINT JIFFY TIME TO NEAREST TENTH OF SECONDS
;CALL:	MOVE	N,TIME IN JIFFIES
;	PUSHJ	P,PNTSEC

PNTSEC:	MOVE	T1,TCKSEC	;NO. OF JIFFIES IN 1 SECOND
	MOVEM	T1,TEMP		;STORE FOR CMPDFN
	PJRST	CMPDFN		;GO PRINT RATIO
;CMPCPT  --  PRINT "A" PER SECOND CPU UPTIME (FROM TEMP)
;CMPCTT  --  PRINT "A" PER SECOND SYS UPTIME (FROM UPTINC)

CMPCPT:	SKIPA	N,TEMP		;GET UPTIME FROM TEMP
CMPCTT:	MOVE	N,UPTINC	;GET UPTIME OF SYSTEM
	IDIV	N,TCKSEC	;CONVERT TO SECONDS
	EXCH	N,A		;(PRINT FROM N)
	IDIV	N,A		;WHATEVER'S PER SECOND
	PJRST	DECPRT		;TYPE NUMBER



;CALCPT  --  CALCULATE "A" PER SECOND CPU UPTIME (FROM TEMP)
;CALCTT  --  CALCULATE "A" PER SECOND SYS UPTIME (FROM UPTINC)

CALCPT:	SKIPA	N,TEMP		;GET UPTIME FROM TEMP
CALCTT:	MOVE	N,UPTINC	;GET UPTIME OF SYSTEM
	IDIV	N,TCKSEC	;CONVERT TO SECONDS
	EXCH	N,A		;(PRINT FROM N)
	IDIV	N,A		;WHATEVER'S PER SECOND
	POPJ	P,		;RETURN PER-SECOND COUNT IN N
;SUBROUTINE TO GET REL ENTRY FROM MONITOR GETTAB SUB-TABLE
;CALL:	MOVEI	A,DESIRED REL ENTRY IN RESPONSE TABLE
;	MOVEM	CPU #,CPU	;STORE CPU NUMBER = 0,1
;	PUSHJ	P,GETRSP
;	  ERROR RETURN NOT PRESENT FOR THIS CPU
;	OK RETURN CONTENTS IN AC A

GETRSP:	PUSH	P,N1		;SAVE N1
	PUSH	P,A		;SAVE RELATIVE ADR IN SUB-TABLE
	MOVE	A,[%CCRSP]	;GETTAB IN CPU CONSTANTS TABLE
				; FOR REL ENTRY IN CPU VARIABLE TABLE
				; FOR RESPONSE DATA
	ADD	A,CPU		;FORM FOR THIS CPU
	ADD	A,CPU		;CONSTANTS GETTABS ARE EVERY OTHER
	PUSHJ	P,GET		;GET ENTRY FROM MONITORJ
	  JRST	GTRSPX		;NOT PRESENT, ERROR RETURN
	ADD	A,(P)		;FORM ADR IN CPU VARIABLE TABLE
	HRL	A,A		;TO LH
	HRRI	A,.GTC0V	;VARIABLE GETTAB FOR CPU0
	ADD	A,CPU		;FOR FOR CPU N
	ADD	A,CPU		;VARIABLE TABLE IS EVERY OTHER
	PUSHJ	P,GET		;GET FROM MONITOR
	  SOS	-2(P)		;NOT PRESENT, SET FOR ERROR RETURN
	AOS	-2(P)		;SKIP RETURN(UNLESS ERROR)
GTRSPX:	POP	P,N1		;RESTORE PD LIST
	POP	P,N1		;RESTORE N1
	POPJ	P,		;ERROR OR OK RETURN
;STROLL STARTS THE OUTPUT OF A PAGE ON THE DISPLAY SCREEN

STROLL:	PUSH	P,A		;SAVE A SCRATCH ONE
	MOVEI	A,STREND	;SO ALWAYS GET EXIT FROM DISPLAY
	EXCH	A,-1(P)		;GET OLD RETURN
	EXCH	A,(P)		;GET A BACK
	SETZM	.FRAJS		;NO ONE SKIPPED YET
	SETZM	CLINE		;NO ONE PRINTED YET
	SETZM	NLTYPD		;NO ONE TYPED YET
	SETZM	HDRVAL		;NO RESIDUES
	RETURN

;SETEND FREEZE VALUE OF LINE IN SLNE SO STREND CAN ADAPT TO
;EMPTY SCREENS

SETEND:	PUSH	P,LINE		;GET CURRENT LINE VALUE
	POP	P,SLINE		;REMEMBER IT
	PUSH	P,BOTTOM	;GET BOTTOM
	POP	P,SBOTTM	;TO RECOMPUTE FIRJOB
	RETURN

;STREND IS ENTERED WHEN THE DISPLAY PROGRAM ENDS

STREND:	SKIPE	.FRAJR		;AUTOMATIC ROLL ON?
	JRST	STREN0		;(YES) DO DIFFERENT THINGS
	MOVE	A,SLINE		;ANY SPACE LEFT?
	JUMPL	A,CPOPJ		;NOPE ALL USED
	SUB	A,SBOTTM	;MINUS NUMBER LEFT
	ADDB	A,FIRJOB	;REINITIALIZE BORDER
	JUMPGE	A,CPOPJ		;ALL SET
	SETZM	FIRJOB		;NO NEGATIVE LINE NUMBERS
	RETURN
STREN0:	SETZM	FIRJOB		;ASSUME BACK TO THE BEGINNING
	MOVE	A,LSTLNE		;LAST LINE NUMBER
	SKIPE	.FRAJS		;ANY JOBS SKIPPED?
	MOVEM	A,FIRJOB	;(YES) UPDATE NEXT LINE START
	RETURN

;PRINTERS FOR THE PAGED F DISPLAY
;IFPRNT CHECKS WHETHER THE CURRENT LINE CAN BE PRINTED OR NOT
;CPOPJ LINE IS INVISIBLE
;CPOPJ1 LINE IS VISIBLE

IFPRNT:	SKIPL	VISIBL		;CAN WE SEE IT?
	RETURN			;NO ALL DONE
	PUSH	P,A		;SAVE A
	MOVE	A,HDRVAL	;IS A HEADER TO BE PRINTED?
	JUMPE	A,IFPRN0	;NOPE EXIT
	SETZM	HDRVAL		;NO RECURSIVE ENTRIES
	CALL	(A)		;GET IT OUT
IFPRN0:	POP	P,A		;GET A BACK
	JRST	CPOPJ1		;GO BACK
;SETVIS SORT OUT WHETHER LINE CAN BE SEEN

SETVIS:	PUSH	P,CH		;SAVE A SCRATCH
	SETZM	VISIBL		;ASSUME NO VISIBILITY
	SKIPGE	LINE		;BUT VERIFY FIRST
	JRST	SETVI0		;CHECK SCREEN LOGIC
	AOS	VISIBL		;IF BELOW HORIZONT
	MOVE	CH,CLINE	;GET CURRENT LINE NUMBER
	CAML	CH,FIRJOB	;IS BELOW THE HORIZONT
	SETOM	VISIBL		;NO ITS ON THE SCREEN
	JRST	SETVI1		;GO BACK
SETVI0:	SKIPE	.FRAJR		;IF NO AUTO ROLL OR
	SKIPE	.FRAJS		;SKIP LOGIC DONE
	JRST	SETVI1		;ALL SET
	SETOM	.FRAJS		;JOBS ARE SKIPPED
	MOVE	CH,CLINE	;GET LAST LINE
	MOVEM	CH,LSTLNE	;HERE TO BEGIN NEXT
SETVI1:	POP	P,CH		;GET JUNK BACK
	RETURN			;AND ALL HAS BEEN DONE

;ICRLF START A NEW LINE THIS MEANS UPDATE LINE LOGIC

ICRLF:	CALL	IFPRNT		;VISIBLE
	JRST	ICRLF0		;NOT TO US
	CALL	CRLF		;SHOW IT
	CALL	SETEND		;UPDATE LAST LINE VALUE
	AOS	NLTYPD		;ONE MORE TYPED
ICRLF0:	AOS	CLINE		;UPDATE THE LINE NUMBER
	PJRST	SETVIS		;AND SEE HOW OUR VISION IS NOW

;SETHDR GENERATE THE CALL TO A HEADER PRINTER

SETHDR:	POP	P,HDRVAL	;ROUTINE ADDRESS -1
	PUSH	P,HDRVAL	;RESTORE RETURN ADDRESS
	AOS	HDRVAL		;CODE IS JUST PAST RETURN
	RETURN
;CONDITIONAL PRINTERS

IMSG:	CALL	IFPRNT		;VISIBLE
	RETURN			;NO GO BACK
	PJRST	MSG		;YES PRINT IT

ISIXBP:	CALL	IFPRNT		;VISIBLE
	RETURN
	PJRST	SIXBP

IDECPR:	CALL	IFPRNT
	RETURN
	PJRST	DECPRT

ITAB:	CALL	IFPRNT
	RETURN
	PJRST	TAB

IFRCL:	PUSHJ	P,ICRLF		;GIVE A "FREE" <CR><LF>
	PUSHJ	P,ISPACE	;AND A SPACE TO INDENT
	PUSHJ	P,ISPACE	;AND ANOTHER
	PUSHJ	P,ISPACE	;AND YET ANOTHER
				;FALL INTO FINAL ISPACE

ISPACE:	CALL	IFPRNT
	RETURN
	PJRST	SPACE

IDECTA:	CALL	IFPRNT
	RETURN
	PJRST	DECTAB

IPRPCN:	CALL	IFPRNT
	RETURN
	PJRST	PRPCNT
SIXTAB:	PUSHJ	P,SIXBP
TAB:	SKIPA	CH,[11]
SPACE:	MOVEI	CH,40

TYO:	TLNN	F,FL.SUP	;SUPPRESSED?
	SKIPGE	LINE		;DO NOTHING IF OUT OF ROOM
	POPJ	P,
	ANDI	CH,177
	CAIN	CH,15
	JRST	TYCR		;SIMULATE CAR. RET.
	CAIN	CH,12
	JRST	TYLF		;SIMULATE LINE FEED
	SKIPGE	COL		;IGNORE LINE TOO WIDE
	JRST	TYO3		;GO CHECK FOR FREE CRLF
	CAIN	CH,11
	JRST	TYTAB		;SIMULATE TAB
	PUSHJ	P,GETCH
	ANDI	T2,377		;CLEAR 400 BIT
	CAIN	CH," "		;TEST FOR CHANGING TO BLANK
	MOVEI	CH,400(T2)	;  YES, CONVERT TO 400!<ORIGINAL VALUE>
	TRNE	CH,400		;TEST FOR 400 BIT NOW ON
	MOVEI	T2,(CH)		;  YES, COPY REGISTER TO AVOID 200 BIT
	CAME	CH,T2
	TRO	CH,200		;NOT THE SAME AS LAST TIME
	DPB	CH,T1
	AOS	T1,COL		;INCREMENT COLUMN COUNT
	CAMLE	T1,RTEND
	SETOM	COL		;LINE TOO WIDE
	POPJ	P,

;LINE EXHAUSTED, CHECK FOR FREE CRLF ACTION

TYO3:	TLNN	F,FL.CRF	;HIGH LEVEL WANT FREE CRLF?
	POPJ	P,		;NO, JUST TOSS OUT THE CHARACTER
	PUSH	P,CH		;YES, SAVE THE REAL CHARACTER
	PUSHJ	P,TYCR3		;GIVE THE FREE CR
	PUSHJ	P,TYLF		;AND THE FREE LF FOLLOWING
	PUSHJ	P,SPACE		;SPACE
	PUSHJ	P,SPACE		; OVER
	PUSHJ	P,SPACE		;  CONTINUATION
	PUSHJ	P,SPACE		;   LINES
	POP	P,CH		;RESTORE THE REAL CHARACTER
	PJRST	TYO		;AND FINALLY OUTPUT IT
TYCR:	MOVEI	CH," "
	PUSHJ	P,TYO		;CLEAR REMAINDER OF LINE
	SKIPL	COL
	JRST	TYCR
TYCR3:	MOVE	T1,LTEND	;MOVE TO LEFT EDGE OF WINDOW
	MOVEM	T1,COL
	MOVE	T1,LTTEND
	MOVEM	T1,TABCTR
	POPJ	P,

GETCH:	MOVE	T1,LINE
	IMULI	T1,XSIZE
	ADD	T1,COL		;CALC. CHAR POSITION IN BUF
	IDIVI	T1,4
	ADD	T1,BPTAB(T2)	;MAKE BYTE POINTER TO CHAR
	LDB	T2,T1		;GET THE CHAR
	POPJ	P,0		;RETURN
TYLF:	AOS	T1,LINE		;INCREMENT LINE COUNT
	CAMG	T1,BOTTOM
	POPJ	P,		;SPACE LEFT
	LDB	T2,PCONT
	JUMPN	T2,TYLF2	;CONTINUATION COLUMN?
TYLF1:	SETOM	LINE		;NO ROOM LEFT
	POPJ	P,
TYLF2:	ADD	T2,LTEND	;ADD SPACE BETWEEN COLUMNS
	LDB	T1,PWIDTH	;MOVE OVER A FULL COLUMN WIDTH
	ADD	T2,T1
	MOVEM	T2,COL
	EXCH	T2,LTEND
	ADD	T1,LTEND
	CAILE	T1,XSIZE
	JRST	TYLF1		;COLUMN WON'T FIT
	MOVEM	T1,RTEND
	SKIPA	T1,TABCTR	;GET CURRENT VALUE OF TABCTR & SKIP NEXT
	AOS	T1,TABCTR
	MOVEM	T1,LTTEND
	MOVE	T1,TAB0(T1)
	CAMG	T1,LTEND
	JRST	.-4
	LDB	T1,PTOP		;GO TO TOP OF NEW COLUMN
	MOVEM	T1,LINE
	TLZE	F,FL.NHED	;TEST FOR  HEADING SUPPRESSED
	POPJ	P,		;  YES, THEN EXIT W/O ACTION
	IMULI	T1,XSIZE	;COPY HEADING
	ADD	T1,T2
	SOS	T1
	IDIVI	T1,4		;SPLIT WORD/BYTE
	ADD	T1,BPTAB(T2)
	PUSH	P,T1
TYLF3:	ILDB	CH,(P)
	ANDI	CH,177
	PUSHJ	P,TYO
	SKIPL	COL
	JRST	TYLF3
	POP	P,T1		;MOVE TO FRESH LINE AND RETURN
	JRST	CRLF
TYTAB:	MOVE	T2,COL
	AOS	T2
	MOVE	T1,TABCTR	;GET NEXT TAB POSITION
	AOS	TABCTR		;UPDATE TAB COUNTER
	SUB	T2,TAB0(T1)	;CALCULATE # OF SPACES NEEDED
	PUSH	P,T2
TYTAB1:	MOVEI	CH," "
	PUSHJ	P,TYO		;OUTPUT SPACES
	AOSGE	(P)
	JRST	TYTAB1
	POP	P,T1
	POPJ	P,
PLTEND:	POINT	7,WINDOW,6
PWIDTH:	POINT	7,WINDOW,13
PTOP:	POINT	5,WINDOW,18
PBOTTO:	POINT	5,WINDOW,23
PCONT:	POINT	2,WINDOW,25
PTABST:	POINT	10,WINDOW,35


SETUP:	MOVE	T1,@(P)		;PICK UP INFO WORD
	MOVEM	T1,WINDOW
	LDB	T1,PLTEND	;UNPACK NECESSARY DATA
	MOVEM	T1,LTEND
	MOVEM	T1,COL
	LDB	T2,PWIDTH
	ADD	T1,T2
	MOVEM	T1,RTEND
	LDB	T1,PTOP
	MOVEM	T1,LINE
	LDB	T1,PBOTTO
	MOVEM	T1,BOTTOM
	LDB	T1,PTABST
SETUP7:	MOVEM	T1,LTTEND	;SET TAB STOPS
	MOVEM	T1,TABCTR
	JRST	CPOPJ1		;SKIP OVER INFO WORD

TSETUP:	MOVE	T1,@(P)		;GET INFO WORD
	DPB	T1,PTABST	;UPDATE "WINDOW"
	PJRST	SETUP7		;AND FIX TAB STOPS
	SUBTTL	DISPLAY WINDOW SETTERS

;DISPLAY INDEPENDENT WINDOW OPERATIONS
;WNDJOB SETS THE WINDOW FOR THE JOB AREA ON THE SCREEN
;WNDSYS SETS THE WINDOW FOR SYSTEM INFORMATION

WNDJOB:	TRNN	F,FR.VMM	;IS THERE VM DATA
	JRST	WNDJO0		;(NO) CLASSIC STUFF
	SET	1,68,1,YSIZE,0,TABV0
	RETURN			;THAT WAS ALL

WNDJO0:	TRNN	F,FR.JOB	;JOBS ONLY DISPLAY?
	JRST	WNDJO1		;NO
	SET	1,39,1,YSIZE,2,TABJ0	;SET FOR JOBS ONLY (MULTI COLUMN)
	RETURN			;THAT'S ALL

WNDJO1:	TRNN	F,FR.SJB	;EXPANDED JOB (NO SYSTEM STUFF)?
	JRST	WNDJO9		;NO
	SET	1,72,1,YSIZE,2,TABS0  ;SET FOR EXPANDED JOBS
	POPJ	P,		;RETURN WITH WINDOW SET UP

WNDJO9:	SET	1,39,1,YSIZE,0,TAB0
	RETURN



WNDSYS:	TRNN	F,FR.VMM	;A VM DISPLAY??
	JRST	WNDSY0		;(NO) CLASSIC
	CHANGE	1,XSIZE,1,2,0,TAB5
	RETURN

WNDSY0:	CHANGE	41,XSIZE,NSYSYS,YSIZE,0,TAB1
	RETURN
IFN V.DISP-V.DVBX,<
DPYOUT:	SKIPE	CCIOPC
	POPJ	P,
DPYOU2:	PUSH	P,CH		;SAVE CH IN CASE MULT CHARS
	ANDI	CH,177		;ONLY 7-BIT ASCII CHARACTERS GET OUTPUT
	PUSHJ	P,DPYCHO	;OUTPUT THIS CHARACTER
	POP	P,CH		;GET BACK CH
	LSH	CH,-^D9		;SHIFT OVER BY ONE "CHARACTER"
	JUMPN	CH,DPYOU2	;LOOP BACK IF MORE CHARACTERS
	POPJ	P,		;ALL DONE

DPYCHO:	SOSG	THED+2
	PUSHJ	P,FRCOUT	;FORCE OUTPUT
	IDPB	CH,THED+1
	POPJ	P,
NRMDEV=='TTY'		;NORMALLY TO TTY:
>;	END OF IFN V.DISP-V.DVBX
IFE V.DISP-V.DVBX,<
NRMDEV=='DIS'		;NORMALLY TO DIS:
>;	END IFE V.DISP-V.DVBX

OPNTTY:	MOVE	T1,[SIXBIT /SYSDPY/]
	DEVCHR	T1,
	JUMPN	T1,OPNTT1
	MOVSI	T1,NRMDEV
	DEVCHR	T1,
	MOVSI	B,NRMDEV
OPNTT2:
IFN V.DISP-V.DVBX,<
	TRNN	T1,1_10
	TDZA	A,A
	MOVEI	A,10
	TRO	A,700		;NO ECHO
	TXNN	T1,DV.TTY	;SEE IF A TTY
	TRZ	A,-1		;NO--KILL SPECIAL MODES
	MOVSI	C,THED
	OPEN	TTY,A
	  EXIT
	OUTBUF	TTY,3
	MOVE	A,[SIXBIT /SYSDPY/]
	MOVSI	B,(SIXBIT /TXT/)
	SETZB	C,D
	ENTER	TTY,A
	  JFCL
>;	END IFN V.DISP-V.DVBX
IFE V.DISP-V.DVBX,<
	MOVEI	A,15		;SET DISPLAY DUMP MODE
	MOVEI	C,0		;NO BUFFERS
	OPEN	DIS,A		;GET EQUIPMENT
	  JRST	[OUTSTR [ASCIZ /? DIS NOT AVAILABLE
/]
		 EXIT]
				;(EDIT 1 PART 2) CODE MOVED TO FRONT OF MODULE
	TRZ	F,FR.DIS	;INDICATE TO INITIALIZE DIS
>;	END OF IFE V.DISP-V.DVBX
	POPJ	P,0

OPNTT1:	MOVE	B,[SIXBIT /SYSDPY/]
	JRST	OPNTT2

;ROUTINE TO FORCE OUT TTY DISPLAY
FRCOUT:	SKIPE	CCIOPC		;UNLESS ^C INTERCEPT, SKIP
	JRST	FRCOU1		;IF SO--OMIT THE OUTPUT
FRCUUO:	OUTPUT	TTY,		;ELSE, DO THE OUTPUT
	POPJ	P,		;AND RETURN

FRCOU1:	PUSH	P,A		;FREE UP AN AC
	MOVEI	A,5*20		;NUM CHARS/BUF
	ADDM	A,THED+2	;MAKE ROOM
	MOVNI	A,20		;NUM WORDS/BUF
	ADDM	A,THED+1	;BACK UP POINTER
	POP	P,A		;RESTORE AC
	POPJ	P,		;RETURN
;TCKTIM  --  PRINT "A" IN HH:MM:SS OR MM:SS.CC FORMAT

TCKTIM:	IMULI	A,^D100		;"INCREASED" PRECISION
	IDIV	A,TCKSEC	;JUNK JIFFIES
	CAXGE	A,^D60*^D60*^D100  ;TIME EXTEND INTO HOURS?
	JRST	TCKTM4		;NO, PRINT MM:SS.CC INSTEAD
	IDIVX	A,^D60*^D60*^D100  ;YES, A := HOURS
	MOVE	N,A
	PUSHJ	P,DECZ2
	PUSHJ	P,COLON
TCKTM1:	IDIVI	B,^D60*^D100	;B := MINUTES
	MOVE	N,B
	PUSHJ	P,DECZ2
	PUSHJ	P,COLON
	IDIVI	C,^D100		;C := SECONDS
	MOVE	N,C
	PJRST	DECZ2		;CAP OFF WITH MINUTES

TCKTM4:	IDIVI	A,^D60*^D100	;A:= MINUTES
	MOVE	N,A		;POSTION FOR DECZ2
	PUSHJ	P,DECZ2		;TYPE TWO DIGIT DECIMAL
	PUSHJ	P,COLON		;TERMINATE MINUTES
	IDIVI	B,^D100		;B := SECONDS; C := HUNDREDTHS
	MOVE	N,B		;POSITION SECONDS FOR DECZ2
	PUSHJ	P,DECZ2		;TYPE TWO DIGIT DECIMAL
	PUSHJ	P,DOT		;TERMINATE WITH A "."
	MOVE	N,C		;POSITION HUNDREDTHS FOR DECZ2
	PJRST	DECZ2		;TYPE TWO DIGIT DECIMAL



;DECPRT  --  PRINT A GENERAL DECIMAL NUMBER

DECPRT:	MOVEI	R,12
RDXPRT:	MOVEI	CH,"-"
	JUMPGE	N,RADIX1
	PUSHJ	P,TYO
	MOVMS	N
RADIX1:	IDIVI	N,(R)
	HRLM	N1,0(P)
	SKIPE	N
	PUSHJ	P,RADIX1
	HLRZ	CH,0(P)
	ADDI	CH,60
	JRST	TYO
;DECPN?  --  PRINT A ?-DIGIT DECIMAL NUMBER
;CALL IS:
;
;	MOVX	N,<NUMBER>
;	MOVX	A,<-DIGITS,,"FILLER">
;	PUSHJ	P,DECPN
;
;WHERE DIGITS IS THE COUNT OF DIGITS TO BE OUTPUT; FILLER IS THE
;FILL CHARACTER TO USE FOR LEADING CHARACTERS. NEGATIVE NUMBERS
;DON'T WORK.

DECB8:	MOVE	A,[-^D8,," "]	;EIGHT-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF

DECB5:	MOVE	A,[-^D5,," "]	;FIVE-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF

DECB4:	MOVE	A,[-^D4,," "]	;FOUR-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF

DECB3:	MOVE	A,[-^D3,," "]	;THREE-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF

DECB2:	MOVE	A,[-^D2,," "]	;TWO-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF

DECZ2:	MOVE	A,[-^D2,,"0"]	;TWO-DIGIT NUMBER FIELD
	PJRST	DECPN		;GO DO GENERALIZED STUFF



DECPN:	MOVEI	R,^D10		;DECIMAL RADIX
RDXPN:	HRRZM	A,L0FILL	;LEADING ZERO FILL CHARACTER
RDXPN0:	IDIVI	N,(R)		;GET NEXT ---ADE
	ADDI	N1,"0"		;ASCII-IZE IT
	HRLM	N1,(P)		;AND SAVE IT AWAY FOR TYPEOUT
	AOBJN	A,.+1		;COUNT UP DIGITS
	JUMPE	N,RDXPN4	;EXIT LOOP IF DONE WITH NON-ZERO DIGITS
	PUSHJ	P,RDXPN0	;RECURSE FOR WHOLE NUMBER

RDXPN2:	HLRZ	CH,(P)		;RETRIEVE ASCII DIGIT
	PJRST	TYO		;AND OUTPUT IT

RDXPN4:	JUMPGE	A,RDXPN2	;IF ALREADY FULL, NO FILLERS
RDXPN5:	HRRZ	CH,L0FILL	;GET LEADING FILLER
	PUSHJ	P,TYO		;OUTPUT LEADING FILLER
	AOBJN	A,RDXPN5	;LOOP FOR NOT-YET-FILLED FIELD
	JRST	RDXPN2		;NOW OUTPUT THE REAL DIGITS
PNTPPN:	MOVE	N,A

;PRINT OCTAL AS UNSIGNED HALVES

OCTPRT:	PUSH	P,N
	HLRZ	N,(P)
	JUMPE	N,OCTRH
	MOVEI	R,10
	PUSHJ	P,RDXPRT
	PUSHJ	P,COMMA
OCTRH:	HRRZ	N,(P)
	MOVEI	R,10
	PUSHJ	P,RDXPRT
	POP	P,N
	POPJ	P,
	JRST	RDXPRT

DECTAB:	PUSHJ	P,DECPRT
	JRST	TAB

CONFIG:	MOVEI	M,[ASCIZ /This is /]
	PUSHJ	P,MSG
	MOVEI	B,0
	MOVEI	C,11
CONFL:	MOVEI	M,A
	MOVE	A,C
	PUSHJ	P,GETA
	PUSHJ	P,MSG
	AOBJN	C,.+1
	TRNE	A,376
	SOJA	C,CONFL
	POPJ	P,0
PDATIM:	MOVE	A,XDATE		;DATE 
	CALL	GETA		;GET THE DATE
	IDIVI	A,^D31
	MOVEI	N,1(B)
	MOVE	B,A		;[562] SAVE A
	PUSHJ	P,DECZ2		;PRINT TWO-DIGIT DAY OF THE MONTH
	MOVE	A,B		;[562] RESTORE A
	IDIVI	A,^D12
	MOVE	B,MONTAB(B)
	MOVEI	C,0
	MOVEI	M,B
	MOVEI	N,^D64(A)
	PUSHJ	P,MSGDEC	;PRINT MESSAGE FOLLOWED BY DECIMAL NO.
	PUSHJ	P,SPACE
	MOVE	A,XTIME
	PUSHJ	P,GETA
	JRST	TCKTIM


PUPTIM:	MOVEI	M,[ASCIZ/UP:/]	;IDENTIFY WHAT FOLLOWS
	PUSHJ	P,MSG		;TYPE IT
	MOVE	A,UPTINC	;GET APPROPRIATE UPTIME FIGURE
	PJRST	TCKTIM		;AND TYPE IT OUT

GUPTIM:	MOVE	A,XSMPTM	;SYSTEM UPTIME GETTAB
	PUSHJ	P,GET		;SEE HOW LONG SYSTEM UP
	 SKIPA	A,XUPTIM	;MUST BE PRE-SMP MONITOR
	POPJ	P,		;SMP TOTAL SYSTEM UPTIME
	PJRST	GETZ		;SEE HOW LONG MASTER UP
;ROUTINE TO COMPUTE INTEGER SQRT:  N=ISQRT(A,B)
;CALLED WITH POS ARG IN "A,B", RESULT RETURNED IN "N", USES N1

ISQRT:	MOVEI	N,0		;PRESET NULL ANSWER
	JUMPL	A,CPOPJ		;RETURN 0 IF NEG
	MOVE	N,A		;COPY ARG
	JFFO	N,.+2		;SET N1 TO NUM 0S
	MOVEI	N1,^D36		; IN CASE ALL ZERO
	SOS	N1		;BACK DOWN FOR SIGN BIT
	TRZ	N1,1		;MAKE SMALLER EVEN
	LSH	B,1		;COMPRESS OUT SIGN BIT OF B
	LSHC	A,-^D35(N1)	;POSITION MOST SIG. BITS IN B
	ASH	N1,-1		;DIVIDE SHIFT BY 2
	MOVNS	N1		;SET TO OTHER WAY FOR ANSWER

	TRO	B,1		;FORCE SOME BITS ON TO TERMINATE
	MOVEI	N,0		;CLEAR ANSWER
ISQ1:	ASH	N,1		;MOVE TO NEXT BIT
	CAMG	A,N		;SEE IF REMAINDER IS BIG
	JRST	ISQ2		;NO--LOOP ON
	SUB	A,N		;DECREASE REMAINDER
	SUBI	A,1		; ..
	TRO	N,2		;INCREASE RESULT
ISQ2:	LSHC	A,2		;SHIFT REMAINDER TWO BITS
	JUMPN	B,ISQ1		;LOOP UNTIL DONE
	ASH	A,-1		;BACK OFF REMAINDER
	CAMLE	A,N		;SEE IF ROUNDING NEEDED
	ADDI	N,1		;YES--INCREASE RESULT

	ASH	N,^D17(N1)	;POSITION RESULT
	POPJ	P,		;RETURN
SUBTTL CONSTANTS AND DATA

;CONSTANTS FOR GETTAB UUO

XTIME:	XWD	10,11
XDATE:	XWD	11,11
XSEGPT:	XWD	15,11
XUPTIM:	XWD	15,12
XSMPTM:	%CNSUP		;TOTAL SMP SYSTEM UPTIME
XDVLST:	XWD	14,11
XSTATS:	XWD	17,11
XLSTIM:	XWD	22,12
XK4SWP:	XWD	1,15
XSYSSZ:	XWD	12,11
XMEMSZ:	XWD	23,12
XSPPN:	XWD	1,16
XOPR:	XWD	13,11
XGETTS:	XWD	23,23		;GET TAB SELF POINTER
XSYSUNI:	XWD 7,16
XSWPER:	XWD	5,13
XSWPUN:	XWD	10,16
XPTYCN:	XWD	22,11		;PTY CONFIGURATION
XOPPN:	XWD	2,16		;OPERATOR PPN
XLPPN:	XWD	3,16		;LOGIN PPN
XHGHJB:	XWD	20,12		;HIGHEST JOB CURRENTLY ACTIVE
XPDBPT:	XWD	45,11		;PTR TO LIST OF PDB'S
XDDBLD:	XWD	75,11		;POINTER TO VALUE OF LDB LINK IN TTY DDB

QTAB:	SIXBIT	/RNWSTS/
	SIXBIT	/STAUMQ/
	SIXBIT	/DADTDC/
	SIXBIT	/MTIOTI/
	SIXBIT	/SLNL^C/
	SIXBIT	/AABBCC/
	SIXBIT	/DDEEFF/
	SIXBIT	/GGHHII/
	SIXBIT	/JJKKLL/
	SIXBIT	/MMNNOO/
	SIXBIT	/PPQQRR/
LQTAB==QTAB-.
MONTAB:	ASCII	/-Jan-/
	ASCII	/-Feb-/
	ASCII	/-Mar-/
	ASCII	/-Apr-/
	ASCII	/-May-/
	ASCII	/-Jun-/
	ASCII	/-Jul-/
	ASCII	/-Aug-/
	ASCII	/-Sep-/
	ASCII	/-Oct-/
	ASCII	/-Nov-/
	ASCII	/-Dec-/

SYSPPN:	XWD	1,1
OLDPPN:	Z
NEWPPN:	Z
OPRPPN:	XWD	1,2		;DEFAULT OPERATOR PPN
LOGPPN:	XWD	2,5		;DEFAULT LOGIN PPN
COMMENT &
TABPTR IS A TABLE USED TO INITIALIZE ALL TABLES NEEDED BY SYSDPY

BASICALLY THERE ARE TWO TYPES OF TABLES:
1 TABLES IN THE SPY SEGMENT
2 TABLES IN SYSDPY CORE

THE TABLES ARE DESCRIBED BY FOUR FIELDS IN THE LEFTHALF POINTER
OF THE TABPTR ENTRIES. THESE FIELDS ARE ADDRESSED BY 4 BYTE POINTERS:
1 PSIZE A TWO BIT LEFT ADJUSTED FIELD USED TO INDEX TABLE TSIZE
  THIS OPERATION GIVES THE THE TABLE LENGTH
2 PSPY A BIT IF SET FLAGGING THAT TABLE IS IN SPY SPACE NOW
3 PSPYTB A BIT THAT INDICATES TABLE IS SPYABLE FROM MONITOR
4 PTABLE AN INDEX OF THE TABLE FOR GETTAB UUOS (IFF SPYTAB SET)

NOTE: THE SIZE OF BOTH IS ONPURPOSE 2,THIS SATISFIES OLD SIGN TESTS
&

LJOBN==0B1		;TABLE INDEX BY JOB NUMBER
LSEGN==1B1		;TABLE INDEX BY SEGMENT NUMBER
LBOTH==2B1		;TABLE INDEX BY JOB OR SEGMENT NUMBER
			;3B1 IS ILLEGAL

			;1B2 IS USED BY PSPY
SPYTAB==1B3		;TABLE IS SPYABLE FROM MONITOR


PSIZE:	POINT	2,(D),1	;TSIZE INDEX
PSPY:	POINT	1,(D),2	;TABLE IS CURRENTLY BEING SPYED
PSPYTB:	POINT	1,(D),3	;TABLE IS SPYABLE FROM MONITOR
PTABLE:	POINT	9,(D),17;GETTAB TABLE INDEX (IFF SPYTAB SET)
;THE TABLE USED TO INITIALIZE SYSDPY'S JOB DATA TABLES
;
;THE TABLES AT TABLE ARE INTERNAL SYSDPY BOOKKEEPING TABLES.
;
;THE TABLES AT TABPTR ARE MONITOR TABLES WHICH, IF THEY CANNOT BE
;SPIED, ARE CONVERTED TO INTERNAL SYSDPY TABLES AND FILLED BY
;GETTAB'ING THE INFORMATION FROM THE MONITOR (SLOW, BUT SURE)

TABLE:	EXP	LJOBN+TTIOS
	EXP	LJOBN+TTLDB
	EXP	LJOBN+JTTIM
	EXP	LJOBN+JTRCT
	EXP	LJOBN+JTWCT
TABPTR:	EXP	LBOTH!SPYTAB+<.GTSTS,,JBSTS>
	EXP	LBOTH!SPYTAB+<.GTADR,,JBADR>
	EXP	LBOTH!SPYTAB+<.GTPPN,,JBPPN>
	EXP	LBOTH!SPYTAB+<.GTPRG,,JBPRG>
	EXP	LJOBN!SPYTAB+<.GTTIM,,JBTIM>
	EXP	LBOTH!SPYTAB+<.GTSWP,,JBSWP>
	EXP	LJOBN!SPYTAB+<.GTSGN,,JBSGN>
	EXP	LJOBN!SPYTAB+<.GTRCT,,JBRCT>
	EXP	LJOBN!SPYTAB+<.GTWCT,,JBWCT>
	EXP	LJOBN!SPYTAB+<.GTNM1,,JBNM1>
	EXP	LJOBN!SPYTAB+<.GTNM2,,JBNM2>
	EXP	LJOBN!SPYTAB+<.GTRTD,,JBRTD>
	EXP	LJOBN!SPYTAB+<.GTVRT,,JBPGR>
	EXP	LJOBN!SPYTAB+<.GTST2,,JBST2>
	EXP	LJOBN!SPYTAB+<.GTPC,,JBPC>
	EXP	LJOBN!SPYTAB+<.GTPDB,,JBPDB>
NTAB==.-TABPTR
	EXP	LSEGN+SGCNT

NTABLE=.-TABLE
;THE ACTUAL TABLE POINTERS (INITIALIZED BY GJBDAT TO EITHER BE
;INTERNAL TO SYSDPY TABLES (MEMORY ALLOCATED AT RUN TIME BASED
;ON MONITOR'S JOB CAPACITY) OR THE ACTUAL MONITOR TABLE ADDRESS
;RELOCATED INTO THE SPY SPACE.

;THE TT--- TABLES ARE UNAVAILABLE WITHOUT PEEKING OR SPYING ABILITIES.

TTIOS:	Z	0(J)		;CONTROLLING TTY DEVIOS WORD
TTLDB:	Z	0(J)		;TTY LDB ADDRESS

;THE JT--- TABLES ARE USED FOR PER-JOB INCREMENTAL STATISTICS DISPLAY

JTTIM:	Z	0(J)		;RUNTIME (TOTAL) LAST UPDATE CYCLE
JTRCT:	Z	0(J)		;DISK READS (TOTAL) LAST UPDATE CYCLE
JTWCT:	Z	0(J)		;DISK WRITES (TOTAL) LAST UPDATE CYCLE

;THE JB--- TABLES ARE THE REAL JOB TABLES

JBSTS:	Z	0(J)		;JOB STATUS (RUN, SWAPPED, ETC.)
JBADR:	Z	0(J)		;PROGRAM SIZE (NON-VM) 
JBPPN:	Z	0(J)		;JOB'S ACCOUNT (PPN)
JBPRG:	Z	0(J)		;PROGRAM NAME
JBTIM:	Z	0(J)		;TOTAL RUNTIME
JBSWP:	Z	0(J)		;SWAPPING POINTER AND SIZE
JBSGN:	Z	0(J)		;HIGH SEG NUMBER AND FLAGS
JBRCT:	Z	0(J)		;INCREMENTAL AND TOTAL DISK READS
JBWCT:	Z	0(J)		;INCREMENTAL AND TOTAL DISK WRITES
JBNM1:	Z	0(J)		;FIRST HALF OF USER NAME
JBNM2:	Z	0(J)		;SECOND HALF OF USER NAME
JBRTD:	Z	0(J)		;REAL-TIME (HPQ) WORD
JBPGR:	Z	0(J)		;PROGRAM (SEGMENT) VIRTUAL SIZES
JBST2:	Z	0(J)		;SECOND JOB STATUS (EW CODE, ETC.)
JBPC:	Z	0(J)		;IOWAIT DDB,,PROGRAM PC
JBPDB:	Z	0(J)		;ADDRESS OF PDB, MONITOR PAGES, ETC.
SGCNT:	Z	0(A)		;HIGH SEGMENT COUNTS
TAB0:	DEC	4,12,16,23,26,32		;FOR JOB DISPLAY
TABJ0:	DEC	4,12,16,23,26,32,44,52,56,63,66,72  ;JOBS ONLY
TABS0:	DEC	4,12,16,23,26,32,40,50,60	;FOR EXPANDED JOB DISPLAY
TABV0:	DEC	4,12,16,23,35,49,55,61
TAB1:	DEC	46,49,52,55,65,69,73,77		;CPU STUFF
TAB1CP:	DEC	46,50,54,58,62,66,70,74		;KL PERF PERCENTAGES
TAB1IO:	DEC	46,51,56,61			;DISK I/O
TAB1NT:						;NETWORK I/O
TAB1TT:	DEC	53,62				;TTY STATISTICS
TAB1ST:	DEC	48,52,61,68,72			;STRUCTURES DISPLAY
TAB1DV:	DEC	48,51,54,61,64,67,74,77		;DEVICES DISPLAY COLUMNS
TAB2:	DEC	48,51,54,65,68,71		;FOR HISEG DISPLAY
TABV2:	DEC	59,62,65,76,79,82
TAB4:	DEC	16,23,30,37,44,51,58,65,72	;FOR FILE SYSTEM DISPLAY
TAB5:	DEC	10
TAB6:	DEC	13,XSIZE-39,XSIZE-34,XSIZE-29,XSIZE-24,XSIZE-19,XSIZE-14,XSIZE-9,XSIZE-4
TAB6X:	DEC	13,XSIZE-31,XSIZE-27,XSIZE-23,XSIZE-19,XSIZE-15,XSIZE-11,XSIZE-7,XSIZE-3
TAB7:	DEC	8,16,24,32,40,48,56,64,72
TAB8:	DEC	X2SIZE+7,X2SIZE+15,X2SIZE+23,X2SIZE+31,X2SIZE+39
TAB9A:	DEC	1+16,1+16+9		;UNNUMBERED CTL
TAB9B:	DEC	X2SIZE+16,X2SIZE+16+9	;NUMBERED CTL
TAB10:	DEC	48,52,68,72		;STRUCTURE DISPLAY
BPTAB:	POINT	9,DBUF,8
	POINT	9,DBUF,17
	POINT	9,DBUF,26
	POINT	9,DBUF,35



	XLIST				;THE LITERALS
	LIT
	LIST
;MORE MONITOR INTERFACE

PJOBNO:	Z	(D)	;RH SET WITH DEVJOB OFFSET INTO DDB
PJOBNP:	Z	C	;LH SET WITH BYTE POINTER INTO C

;LENTAB CORRESPONDENCE BETWEEN TABLE LENGTH AND ENTRY TYPE IN NUMTAB

LENTAB:	EXP	0	;GT.UND UNDEFINED
	EXP	-2	;GT.ITM NUMTAB ENTRY HAS LENGTH
GT.JOB:	EXP	0	;GT.JOB CHANGED BY IJBDAT CODE
GT.SEG:	EXP	0	;GT.SEG SET BY IJBDAT CODE
	EXP	-1	;GTJBPDB PDB DATA

SPYGET:	EXP	RNG722	;ADDRESS OF SPY ROUTINE FOR NUMTAB

TPCJOB:	POINT	8,B,10
IMGOUT:	POINT	9,@JBSWP,26
IMGIN:	POINT	9,@JBSWP,35
DSKLEV:	POINT	3,STATES,9	;DISK MONITOR LEVEL NO.
TTYTAB:	EXP	;ADDRESS OF TTYTAB FOR EFFICIENT SPY
VDDLDB:	EXP		;VALUEDDBLDB
.SEGLS:	EXP		;LAST WORD IN SGCNT TABLE

CCINT:	4,,CCTYPD	;^C INTERCEPT BLOCK
	ER.ICC
CCIOPC:	Z
	Z

GODLY:	0		;SET IF CAN ACCESS SYSDPY.SAV FOR WRITES
TTYFLG:	EXP	0	;0 WHEN NO LINE NUMBERS CAN BE GOTTEN
			;-1 WHEN SPYING ON OLD TOPS10
			;+1 WHEN ISUING TRMNO. AND DEVNAM UUO'S TO GET DATA
CTYNDX:	EXP	0	;CONTAINS INDEX OF CTY WHEN TTYFLG=+1

L0FILL:	BLOCK	1	;HOLDS FILLER FOR DECP??

IFE V.DISP-V.DVBX,<
DISPLA:	020137		;MODE 0/1: FULL INTENSITY,SCALE=1, 60HZ. SYNC.
	221750,,160000	;MODE 1:X=1000.; MODE 1:Y=0.
	060000,,DISBUF	;MODE 7:JUMP AND GO TO MODE 3(SIXBIT)
>;	END IFE V.DISP-V.DVBX

PDLST:	BLOCK	PDLEN	;ALLOCATE STACK SPACE
IFN	FTNET,<

;LIST OF BYTE POINTERS INTO NDB (MATCHES NDBGTB)

NDBPTB:
NDBLEN:	24			;LENGTH OF NDB
NDBNXT:	POINT	18,XDBBLK+00,35	;ADDRESS OF NEXT NDB
NDBNNM:	POINT	18,XDBBLK+00,17	;NODE NUMBER
NDBSNM:	POINT	18,XDBBLK+02,17	;ADDRESS OF STATION NAME
NDBNGH:	POINT	18,XDBBLK+07,17	;FIRST NEIGHBOR ENTRY
NDBNGL:	POINT	18,XDBBLK+16,35	;LAST NEIGHBOR ENTRY
NDBNGN:	POINT	10,N,27		;NODE NUMBER FROM NDBNGH
NDBOPR:	POINT	18,XDBBLK+17,35	;ADDRESS OF OPR LDB IF ANY
NDBCTJ:	POINT	18,XDBBLK+23,17	;STATION CONTROL JOB NUMBER
NDBLAR:	POINT	8,XDBBLK+03,11	;LAST ACK RECEIVED
NDBLAP:	POINT	8,XDBBLK+03,19	;LAST OUTPUT MESSAGE# ACK'ED
NDBLMS:	POINT	8,XDBBLK+03,27	;LAST MESSAGE SENT
NDBLMA:	POINT	8,XDBBLK+03,35	;LAST MESSAGE NUMBER ASSIGNED
NDBLMR:	POINT	8,XDBBLK+02,35	;LAST INPUT MESSAGE RECEIVED
NDBLMP:	POINT	8,XDBBLK+02,27	;LAST MESSAGE PROCESSED

> ;END IFN FTNET



;PROTOTYPE QUEUES-LISTING REQUEST MESSAGE FROM QUASAR

QSRMSG:	XWD	QSRLEN,.QOLIS	;TYPE OF FUNCTION AND LENGTH
	XWD	0,'SYS'		;FLAGS AND 3 LETTER MNENOMIC
	EXP	0		;ACKNOWLEDGE WORD

	EXP	0		;NO SPECIAL FLAGS
	EXP	1		;ONE ARGUMENT BLOCK FOLLOWING

	XWD	2,.LSQUE	;QUEUE BLOCK
QSRFLG:	EXP	0		;WHICH QUEUES TO LIST, FILLED IN AT RUNTIME

	QSRLEN==.-QSRMSG	;SIZE OF PACKET
ZER:!	BLOCK	21	;START OF AREA TO ZERO

;9 BYTE/CH	CH IF SAME; 200+CH IF DIFF; 400+OLD IF SPACE
DBUF:	BLOCK	<YSIZE*XSIZE/4>+1
DBFEND=.-1

IFE V.DISP-V.DVBX,<
DISBUF:	BLOCK	<YSIZE*XSIZE/5>+10
DISBEN:	353537,,160000	;NULLS,ESCAPE; MODE 0:NULL
	0,,DISPLA	;MODE 7:JUMP TO START
DISBES:	DISBEN-1	;OLD END OF BUFFER
>;	END IFE V.DISP-V.DVBX

IFE V.DISP-V.DDLT, <
LASTCR:	BLOCK	YSIZE		;LAST CHARACTER POSITION ARRAY
				;  FOR DELTA-DATA TELTERM
>;	END OF	IFE V.DISP-V.DDLT

HIBTIM:	BLOCK	1	;WAIT TIME BETWEEN UPDATES
HIBTIW:	BLOCK	1	;AS ENTERED BY OPERATOR
HLPADR:	EXP	0	;ADDRESS OF HELP TEXT IF READ IN

P2WLSH:	BLOCK	1	;LSH @P2WLSH FOR "PAGES" TO WORDS
W2PLSH:	BLOCK	1	;LSH @W2PLSH FOR WORDS TO "PAGES"

GETAB:	Z		;TEMP USED BY PSEUDO CODE
GETAB1:	Z		;TEMP USED BY PSEUDO CODE
GETAB2:	Z		;USED BY PSEUDO CODE
GETAB3:	0		;ANOTHER TEMP
TEMP:	0
TEMP1:	0
REPS:	0

JOBPHY:	BLOCK	1	;JOB LOW,,HIGH PHYSICAL SIZE
JOBPPG:	BLOCK	1	;COUNT OF PER-PROCESS PAGES
JOBVIR:	BLOCK	1	;JOB LOW,,HIGH VIRTUAL SIZE
CPU:	BLOCK	1	;CPU NUMBER FOR RESPONSES(0,1)
CPMAX:	BLOCK	1	;MAX CPU NUMBER SYS IS BUILT FOR
CPMNY:	BLOCK	1	;.GT. 0 IF MULTI-CPU
CPBTS:	BLOCK	1	;SYSTEM BOOT CPU
CPHDR:	BLOCK	1	;ADDR OF HEADER STRING IF NEEDED
CPRLX:	BLOCK	1	;OFFSET FOR CPLQR
CPCSH:	BLOCK	1	;.NE. 0 IF CACHE MEMORY SYSTEM

;TABLES FOR CPU INCREMENTAL STATISTICS. THESE TABLES ARE TWO-WAY
;INTERLEAVED SINCE CPU INDEX IN CPULP IS A TWO-WORD INDEX FOR THE
;.CCXXX/.CVXXX MONITOR TABLES

CPNAM:	BLOCK	1	;CPU NAME
CPOKF:	BLOCK	1+5+5	;.NE. 0 THEN CPU NOT RUNNING
CPUPT:	BLOCK	1	;CPU UPTIME (IN TICKS)
CPNUL:	BLOCK	1+5+5	;CPU IDLE (NULL) TIME (IN TICKS)
CPOHT:	BLOCK	1	;CPU OVERHEAD TIME (IN TICKS)
CPLST:	BLOCK	1+5+5	;CPU LOST TIME (IN TICKS)
CPTJC:	BLOCK	1	;TOTAL JOB CONTEXT SWITCHS
CPNDB:	BLOCK	1+5+5	;NUMBER OF TIMES DOORBELL RUNG (MULTI-CPU)
CPCSN:	BLOCK	1	;NUMBER OF TIMES CACHE SWEPT (KL-10 ONLY)
CPTUC:	BLOCK	1+5+5	;TOTAL UUOS
CPFBI:	BLOCK	1	;DISK (FILE) BLOCKS INPUT
CPFBO:	BLOCK	1+5+5	;DISK (FILE) BLOCKS OUTPUT
CPSBI:	BLOCK	1	;DISK (SWAP) BLOCKS INPUT
CPSBO:	BLOCK	1+5+5	;DISK (SWAP) BLOCKS OUTPUT
CPMHD:	BLOCK	1	;DOUBLE WORD CLOCK RATE (MHZ)
CPMHZ:	BLOCK	1+5+5	;SINGLE WORD CLOCK RATE (MHZ)
			;CPMHD ALWAYS 0 SO CAN DDIV IN CPLQR

;THE KL-10 PERFORMANCE ANALYSIS COUNTS
;NOTE THEY ARE INDEXED "STRAIGHT" - THEY ARE NOT INTERLEAVED

CP0PAV:	BLOCK	^D16*4	;CPU0 BACKGROUND PERFORMANCE ANALYSYS
CP1PAV:	BLOCK	^D16*4	;CPU1 BACKGROUND PERFORMANCE ANALYSYS
CP2PAV:	BLOCK	^D16*4	;CPU2 BACKGROUND PERFORMANCE ANALYSYS
CP3PAV:	BLOCK	^D16*4	;CPU3 BACKGROUND PERFORMANCE ANALYSYS
CP4PAV:	BLOCK	^D16*4	;CPU4 BACKGROUND PERFORMANCE ANALYSYS
CP5PAV:	BLOCK	^D16*4	;CPU5 BACKGROUND PERFORMANCE ANALYSYS
NTBYI:	BLOCK	1	;NETWORK BYTES RECEIVED
NTBYO:	BLOCK	1	;NETWORK BYTES TRANSMITTED

SCNRI:	BLOCK	1	;NUMBER OF RECEIVED CHARACTERS
SCNXI:	BLOCK	1	;NUMBER OF TRANSMITTED CHARACTERS



IFN	FTNET,<

;NETWORKS STATISTICS INCREMENTAL DISPLAY DATA

NTXTP:	BLOCK	^D10	;UNNUMBERED CONTROL SENT
NTRTP:	BLOCK	^D10	;UNNUMBERED CONTROL RECEIVED
NTXMT:	BLOCK	^D10	;NUMBERED CONTROL SENT
NTRMT:	BLOCK	^D10	;NUMBERED CONTROL RECEIVED
NTXDL:	BLOCK	^D10	;MESSAGES SENT BY LENGTH
NTRDL:	BLOCK	^D10	;MESSAGES RECEIVED BY LENGTH

NTRTL:	BLOCK	1	;TOTAL MESSAGES RECEIVED
NTXTL:	BLOCK	1	;TOTAL MESSAGES TRANSMITTED

NTRTH:	BLOCK	1	;TOTAL DATA MESSAGES RECEIVED
NTXTH:	BLOCK	1	;TOTAL DATA MESSAGES SENT

> ;END IFN FTNET
UPTIME:	0			;UPTIME OF SYSTEM IN JIFFIES
UPTINC:	BLOCK	1		;UPTIME (MAYBE INCREMENTAL)

THED:	BLOCK	3

LOGOHD:	BLOCK	3		;LOG FILE RING HEADER

;THE SEQUENCE OF JOBN SEGN AND BOTH MUST NOT BE CHANGED NOR MUST
;OTHER ENTRIES BE INSERTED
TSIZE:
JOBN:	0
SEGN:	0
BOTH:	0

JBNMAX:	BLOCK	1	;LARGEST JOB NUMBER IN USE
CORMAX:	BLOCK	1	;LARGEST SIZE FOR SINGLE JOB
MAXMAX:	BLOCK	1	;TOTAL PHYSICAL USER MEMORY AVAILABLE
PHYMAX:	BLOCK	1	;MAX POSSIBLE MAXMAX

JBUBZR:			;START OF JOB USAGE FIGURES CLEARED EACH PASS
JBNUSE:	BLOCK	1	;NUMBER OF JOBS IN USE
JBNLOG:	BLOCK	1	;NUMBER OF JOBS LOGGED-IN
JBNDET:	BLOCK	1	;NUMBER OF JOBS DETACHED
ACTUSE:	BLOCK	1	;TOTAL MEMORY USED BY "ACTIVE" JOBS
DSKUSE:	BLOCK	1	;TOTAL DSK (SWAP) MEMORY USED
PHYUSE:	BLOCK	1	;TOTAL PHYSICAL (WORKING SET) MEMORY USED
VIRUSE:	BLOCK	1	;TOTAL VIRTUAL MEMORY USED
SHRSAV:	BLOCK	1	;MEMORY SAVED BY SHARING
JRNRN:	BLOCK	1	;JOBS RUNNING ACTIVELY
JRNIO:	BLOCK	1	;JOBS RUNNING OR IO BLOCKED
JRNSL:	BLOCK	1	;JOBS NOT ^C'ED
JBUEZR==.-1		;END OF JOB USAGE FIGURES CLEARED EACH PASS
SLQ:	BLOCK	1	;"SL" STATE Q CODE
HBQ:	BLOCK	1	;"HB" STATE Q CODE
TIQ:	BLOCK	1	;"TI" STATE Q CODE
EWQ:	BLOCK	1	;"EW" STATE Q CODE
SEGPTR:	0
ZERLOW:	0
ZERHGH:	0

TCKSEC:	0
STATES:	0
GTTSLF:	0

MONVER:	0		;VERSION OF RUNNING MONITOR
FREAK:	0		;FREQUENCY OF LINE CLOCK JIFFIES
ME:	0
MYJOB:	0
OPR:	0
LINE:	0
COL:	0
BOTTOM:	0
WINDOW:	0
LTEND:	0
LTTEND:	0
RTEND:	0
RELCKC:	0		;COUNT UP TO RELEASE /V
TABCTR:	0		;COUNTER OF TABS IN THIS LINE SO FAR
PROGRM:	0		;WHICH DISPLAY PROGRAM
CURFS:	0		;CURRENT FILESTRUCTURE
CURUN:	0		;CURRENT UNIT
CURUN2:	BLOCK	1	;CURRENT UNIT SECOND PORT UDB ADDRESS
CUINC:	0		;INCREMENT FOR CURRENT UNIT
UNIBLK:	0
DSKBLK:	BLOCK	DSKBKL	;DSKCHR UUO BLOCK
PTYOFS:	0
DUAL:	0		;-1 IF DUAL PROCESSOR SYSTEM ELSE 0
QSRPID:	BLOCK	1	;PID FOR [SYSTEM]QUASAR
IPCBLK:	BLOCK	.IPCFP+1;IPCF PACKET HEADER BLOCK
;PRINT CONTROL VARIABLES
;ONLY USED BY F DISPLAY CURRENTLY(FIRJOB BY N DISPLAY)

VISIBL:	Z		;MIN 1 WHEN CURRENT LINE IS VISIBLE
			;EQL 0 WHEN SCREEN IS FULL
			;PLS 1 WHEN LINE IS BELOW OUR HORIZONT
			;MANIPULATED BY ICRLF &STROLL

HDRVAL:	Z		;ZERO IF NO HEADER HAS BEEN DELAYED ELSE ADDRESS
			;OF HEADER STRING GENERATOR

NLTYPD:	Z		;NUMBER OF LINES TYPED ON SCREEN

CLINE:	Z		;LOGICAL LINE NUMBER E.G. JOB NUMBER +HEADER LENGTH

LSTLNE:	Z		;LAST LINE NOT TYPED
FIRJOB:	Z		;FIRST LINE VISIBLE IN CURRENT WINDOW
EATCNT:	BLOCK	1	;LINES TO EAT (EMSG)
SLINE:	Z		;SAVE REMAINDER ON SCREEN HERE
SBOTTM:	Z		;SAVE OLD BOTTOM VALUE
.FRAJR:	Z		;AUTO JOB ROLL FACILITY
.FRAJS:	Z		;JOBS SKIPPED DURING AUTO ROLL


PTYMAX:	0
PDBPTR:	0		;ADDR OF LIST OF PDB'S +400000 BIT FOR SPYING
			;LH=N1 TO OFFSET FOR THE DESIRED JOB
REALTT:	0		;-1 IF REAL TTY NAME DESIRED
SUPOPR:	0		;.NE. 0 THEN SUPPRESS [OPR] JOBS
PCTFLG:	BLOCK	1	;.NE. 0 THE RUNTIME IN PERCENTAGE OF CPU
NUMBER:	BLOCK	1	;NUMBER FOR COMMAND (E.G., "W")
NUMFLG:	BLOCK	1	;NUMBER FOR COMMAND WAS TYPED
HPQCMD:	BLOCK	1	;HPQ LEVEL FROM SET HPQ COMMAND
NETMNY:	BLOCK	1	;.GT. 0 IF NEED TO COMPRESS SCREEN
XDBBLK:	BLOCK	XDBLEN	;SCRATCH DATA BLOCK
FLPBLK:	BLOCK	FLPLEN	;FILOP. BLOCK
LKEBLK:	BLOCK	LKELEN	;LOOKUP/ENTER BLOCK

LZER==.-1
	XLIST			;THE LITERALS
	LIT
	LIST


REPEAT 0,<
IF1,<
  IFE	V.DISP-V.DVT6,<PRINTX [End of pass 1 SYSDPY]>
  IFE	V.DISP-V.DV5A,<PRINTX [End of pass 1 SYSDPA]>
  IFE	V.DISP-V.DV5B,<PRINTX [End of pass 1 SYSDPB]>
  IFE	V.DISP-V.DVBX,<PRINTX [End of pass 1 SYSVBX]>
  IFE	V.DISP-V.DV50,<PRINTX [End of pass 1 SYSV50]>
  IFE	V.DISP-V.DV52,<PRINTX [End of pass 1 SYSV52]>
  IFE	V.DISP-V.DV61,<PRINTX [End of pass 1 SYSV61]>
  IFE	V.DISP-V.DHZL,<PRINTX [End of pass 1 SYSHZL]>
  IFE	V.DISP-V.DDLT,<PRINTX [End of pass 1 SYSDLT]>
> ;END OF IF1
> ;END OF REPEAT 0


	END	SYSDPY