Google
 

Trailing-Edge - PDP-10 Archives - AP-D543V_SB - sysdpy.mac
There are 31 other files named sysdpy.mac in the archive. Click here to see a list.
SUBTTL	SYSTAT FOR DISPLAYS -- %433(550) -- 6 JUL 76
SUBTTL /TCK 11-JAN-74
VSYSDPY==433
VWHO==0
VMINOR==0
VEDIT==550
;*** COPYRIGHT 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976 DIGITAL EQUIPMENT CORP., MAYNARD, MASS. ***

SEARCH jobdat,C
;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 ALITTLE 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

LOC 137
.JBVER:	BYTE	(3)VWHO(9)VSYSDPY(6)VMINOR(18)VEDIT
RELOC

;ASSEMBLY INSTRUCTIONS:

;SYMBOLS NOT CORRECT IN OLD C FILE

%CNST2=106,,11
ST%VMS=1B33
.GTCVL==102	;GET CURRENT CORE LIMITS
.GTMVL==103	;GET CURRENT MAXIMUM LIMITS

;IFNDEF	%%C,<PRINTX	? .COMPILE C+SYSDPY
;		PASS2
;		END>
;AC ASSIGNMENTS

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

;I/O CHANNELS
TTY==1		;NORMAL DISPLAY OUTPUT (CHARACTER TERMINAL)
DIS==1		;VIDEO DISPLAY

;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==100	;HAZELTINE 2000
V.DDLT==101	;DELTA DATA TELTERM
;RECOMMEND CUSTOMERS ASSIGN NEGATIVE VALUES

IFNDEF FTNET,<FTNET==-1>	;DEFAULT FOR NETWORK TOPOLOGY DIPLAY
ND V.DISP,V.DV5B	;DEFAULT TO DIGITAL VT05A

IFE V.DISP-V.DVT6,<
	TITLE	SYSDPY -- SYSTEM DISPLAY FOR DIGITAL VT06 DISPLAY TERMINAL>
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>
IFE V.DISP-V.DVBX,<
	TITLE	SYSVBX -- SYSTEM DISPLAY FOR DIGITAL VB10C INCREMENTAL PRECISION DISPLAY>
IFE V.DISP-V.DV61,<
	TITLE	SYSV61 -- SYSTEM DISPLAY FOR DIGITAL VT61 DECSCOPE>
IFE V.DISP-V.DV50,<
	TITLE	SYSV50 -- SYSTEM DISPLAY FOR DIGITAL VT50 DECSCOPE>
IFE V.DISP-V.DV52,<
	TITLE	SYSV52 -- SYSTEM DISPLAY FOR DIGITAL VT52 DECSCOPE>
IFE V.DISP-V.DHZL,<
	TITLE	SYSHZL -- SYSTEM DISPLAY FOR HAZELTINE 2000 DISPLAY TERMINAL>
IFE V.DISP-V.DDLT,<
	TITLE	SYSDLT -- SYSTEM DISPLAY FOR DELTA DATA TELTERM DISPLAY TERMINAL>

IFE V.DISP-V.DVT6,<
	XSIZE==^D72	;WIDTH OF SCREEN
	YSIZE==^D25	;HEIGHT OF SCREEN
	UPDNJB==^D20	;NUMBER OF JOBS TO +-
	NDEVYS==^D20	;LINE TO START DEVICES IN "N"
	CFILL==177	;FILLER CODE
>;	END OF	IFE V.DISP-V.DVT6
IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>,<
	XSIZE==^D72
	YSIZE==^D20
	UPDNJB==^D15
	NDEVYS==^D16
	CFILL==0
>;	END OF IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>
IFE V.DISP-V.DVBX, <
	XSIZE==^D72
	YSIZE==^D25
	UPDNJB==^D20
	NDEVYS==^D20
>;	END OF	IFE V.DISP-V.DVBX
IFE V.DISP-V.DV61,<
	XSIZE==^D80
	YSIZE==^D24
	UPDNJB==^D10
	NDEVYS==^D16
>;	END V.DISP-V.DV61
IFE V.DISP-V.DV50,<
	XSIZE==^D80
	YSIZE==^D12
	UPDNJB==^D10
	NDEVYS==^D8
>;	END V.DISP-V.DV50
IFE V.DISP-V.DV52,<
	XSIZE==^D80
	YSIZE==^D24
	UPDNJB==^D10
	NDEVYS==^D18
>;	END V.DISP-V.DV52
IFE V.DISP-V.DHZL, <
	XSIZE==^D74
	YSIZE==^D27
	UPDNJB==^D25
	NDEVYS==^D22
>;	END OF	IFE V.DISP-V.DHZL
IFE V.DISP-V.DDLT, <
	XSIZE==^D80
	YSIZE==^D27
	UPDNJB==^D25
	NDEVYS==^D22
>;	END OF	IFE V.DISP-V.DDLT

ND JIFSEC,^D60	;LINE FREQ IF NO GETTAB
ND INTVAL,^D10	;**[13] NUMBER OF SECONDS BETWEEN UPDATES
ND REPRAT,^D100	;# OF REFRESSHES BEFORE REFRESH
ND RELOCK,INTVAL*REPRAT	;# PASSES BEFORE CANCELLING /V
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
	;SPARE
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.2PT==1000	;TWO PART OUTPUT PHASE FLAG
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.PDR==400000	;PRINT DORMANT SEGMENTS

;FLAGS (RH OF F)

;FR.AJR==1B18	;***UNUSED*****
;FR.AJS==1B19	;***UNUSED****
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 VEDIO
FR.ALR==1B30	;ALARM MODE

	;STATUS BITS TO INITIALIZE

	;STATUS BITS TO PRESERVE
FX.MSK==FL.GOD!FL.FLS!FL.SCN!FL.SPY!FL.REF!FL.HLP!FL.PEK!FL.LOCK!FL.PDR,,FR.ALT!FR.DIS!FR.KIX!FR.KIP!FR.VMO!FR.RVD!FR.ALR

;STUFF WHICH HAS TO AGREE WITH MONITOR, ASIDE FROM GETTAB DEFNS

CMWB==200000	;COMMAND WAIT IN JOB STATUS TABLE
JNA==40000
JLOG==4
ASSCON==400000
ASSPRG==200000
SNA==400000
JSWP==2000
JSLOCK==11000	;NOSWAP!NOSHUF
JSNSHF==1000	;NO SHUFFLE
SHRSEG==200000
OUTMSK==377000
RTDHPQ==17B9	;HPQ STATUS IN JBTRTD
GT.PRC==1B9	;BIT IN NUMTAB ENTRY FOR PDB ENTRIES

DV.NAM==0
DV.CHR==1
DEVIOS==2
DEVSER==3
DEVMOD==4
DEVJOB==16	;SINCE 60722
;AFTER VERSION 50634 THE VALUE OF DDBLDB CAN BE OBTAINED 
;VIA A 75,,11 GETTAB CALL
DDBLDB==11	;LINK TO LDB IF NEW SCNSER (5.02)
		;(ADD 3 IF 5.03-4; ADD 4 IF 5.05-6)
		;  SEE ALSO PJOBN AND TPCJOB

IOIMPM=400000
IODERR=200000
IODTER=100000

;PARAMETERS

SIGN=400000
DVDSK==200000
DVTTY==10


;VM PARAMETERS

UPMPSZ==1			;1 PAGE LONG
DSKBKL=20	;LENGTH OF DSKCHR BLOCK

;UNIT DATA BLOCK

UNINAM==0
UNILOG==1
UNIHID==2
UNISYS==3
UNISWP==7
UNIK4S==7
;MSKK4S WAS A 12 BIT FIELD UNTIL 50665 VERSION
;THERE AFTER THE FIELD WAS 13 BITS
	MSKK4S==17777
UNIHCT==10
UNISCT==11
UNIMCT==12
UNIERR==13
UNISOF==14
UNIHBN==15
UNIBRC==16
UNIBWC==17
UNIDRC==20
UNIDWC==21
UNIMRC==22
UNIMWC==23
UNIICT==24
UNIOCT==25
UNIMSC==26
UNIUSC==27
UNIPCT==30
IFNDEF UNIFKS,<UNIFKS==31>
UNISDI==32
UNIHDI==33
UNIECT==34
UNIHNG==35

;CALLI'S

CI.RES==0
CI.DEV==4
CI.COR==11
CI.PJO==30
CI.SLP==31
CI.PEK==33
CI.GET==41
CI.SPY==42
CI.DSK==45
CI.STR==46

;VT06 DEFS
CDOWN=12	;USE LINE FEED TO AVOID NONDESTRUCT MODE
CUP=32
CLEFT=31
CRIGHT=30
HOMEUP=35
ERASE=37
EREOL=36

DEFINE	CALL	(R)<
	PUSHJ	P,R
>
	DEFINE	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	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		;**[15] 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,PDP		;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
	CALLI	A,CI.GET	;GET MONITOR VERSION VIA UUO!!
	SETZM	A		;VERY OLD!!
	MOVEM	A,MONVER	;  TESTS
	TLZ	A,-1		;CLEAR CUSTOMER BITS
	CAIGE	A,50410		;SEE IF 5.05 OR BETTER
	TRZ	F,FR.KIP	;NO--CLEAR PAGE ALLOCATION FLAG
	CAIGE	A,60122		;OLD STYLE IF LESS AND >60000
	CAIGE	A,60000		;SO A SKIP MEANS OLD
	CAIGE	A,50722		;SINCE 50722 ALL IS OKAY TOO
	JRST	SYSD00		;(NO) LEAVE THINGS ALONE
	MOVEI	B,RNG722	;NEW STYLE SPY
	MOVEM	B,SPYGET	;CHANGE GET LOGIC
	MOVE	A,[POINT 9,C,35]	;GET JOB POINTER
	MOVEM	A,NPJOBN	;AND USE THIS
SYSD00:	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
	CALLI	CI.RES		;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)
	CALLI	A,CI.SPY		;ASK FOR IT
	SKIPA			;CANT HAVE IT
	TLO	F,FL.SPY		;GOT IT. REMEMBER IT
	HRRZ	A,GTTSLF	;GET A NON ZERO LOCATION
	CALL	PEEK		;PEEK OR SPY
	SKIPE	A		;  0, PEEK FAILED
	TLO	F,FL.PEK	;  ELSE SHOW PEEK WORKS
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 OFIFE 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
IFE <V.DISP-V.DHZL>*<V.DISP-V.DDLT>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>,<
	PUSHJ	P,CLEAR	;CLEAR SCREEN AT FIRST
>;	END OF IFE <V.DISP-V.DHZL>*<V.DISP-V.DDLT>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<V.DISP-V.DV52>
	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
REENT0:	SETOM	NLTYPD		;FLAG SOMETHING TYPED
	CALL	@PROGRM		;GO TO CURRENT DISPLAY PROGRAM
	SKIPN	NLTYPD		;ANYTHING TYPED
	JRST	REENT0		;NO GET NEXT 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:
IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<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.DV50>*<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
;	TLZ	F,FL.2PT
	SETZM	LINE
;	TRNE	F,FR.VMM	;**[4]A VM DISPLAY??
;	TLO	F,FL.REF	;**[4]YES THEN REFRESH
FIN5:	SETZM	COL
;	MOVEI	T1,HSIZE
;	TLNE	F,FL.2PT
;	MOVEM	T1,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
;	TLNE	F,FL.2PT+FL.REF
;	JRST	FIN3A
;	CAIGE	T1,HSIZE
;	JRST	FIN4
;	JRST	FIN3B
;FIN3A:
	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:;	TLNE	F,FL.2PT
;	JRST	FIN6A
	AOS	T1,LINE
	CAIGE	T1,YSIZE		;DONE WITH LAST LINE?
	JRST	FIN5		;NO
;	TLO	F,FL.2PT

;FIN6A:	SOSL	LINE
;	JRST	FIN5
	JRST	FINSLP
>;	END OF	IFE V.DISP-V.DVT6

IFE <V.DISP-V.DV5A>*<V.DISP-V.DV5B>*<V.DISP-V.DV61>*<V.DISP-V.DV50>*<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	POS,-<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	POS,FINIS0
	JUMPGE	POS,FINSLP
	DPB	T2,BP
	HRRZ	C,POS
	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
	POPJ	P,

HOMDWN:	Z
>;	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 RIGT 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		;PROCES OPERATOR REQUEST
	MOVEI	J,INTVAL		;NOW DELAY
	MOVE	JS,[XWD 30,INTVAL*^D1000]
	TLNE	F,FL.LOCK	;TEST FOR HI-SPEED MODE
	JRST	[MOVEI J,1	;  YES, GO TO 1-SECOND INTERVALS
		 MOVE  JS,[XWD 30,^D1000] ;  DITTO
		 JRST  HIBERN ]
	SKIPE	.FRAJS		;ANYONE SKIPPED?
	MOVE	JS,[ 30,,INTVAL*^D500 ]	;THEN SLEEP LESS
HIBERN:	HIBER	JS,
	  CALLI	J,CI.SLP
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		;PROCES 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	FINXC		;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
	MOVEI	B,^D4		;FOUR SECONDS FOR REST OF THE DIGITS
	CALLI	B,CI.SLP	;WAIT
	SETZ	C,
FINXC2:	IMULI	C,^D10
	ADDI	C,-<"0">(J)
	TTCALL	2,J		;ANOTHER CHARACTER
	JRST	FINXC3	;NO
	CAIL	J,"0"
	CAILE	J,"9"
	JRST	FINXC1+1
	JRST	FINXC2
FINXC3:	MOVEM	C,ONEJOB
	MOVEI	B,NORMAL
	TLZ	F,FL.HLP
	JRST	FINXC9
FINXC1:	CAIL	J,40		;SKIP IF NOT CONTROL
	TLO	F,FL.HLP	;NOT FOUND--SET HELP MESSAGE FLAG
	JRST	FINOPR		;AND TRY NEXT ONE
FINXC:	SETZM	ONEJOB
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 
	PJRST	FINOPR		;GET ANOTHER COMMAND
FINXC0:	TLO	F,FL.REF	;GET A FRESH SCREEN
	SETZM	FIRJOB		;ALWAYS START AT THE END
FINXC9:	HRRM	B,PROGRM	;STORE FINAL DISPLAY ADDRESS
	JRST	FINOPR		;AND SEE WHAT IS 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 LOOSE CHARACTER
LOSER:	TTCALL	2,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
;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	.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	"S",TGLDRM	;TOGGLE DORMANT-SEGMENT DISPLAY
	XWD	"A",ALTJOB	;AUTO ROLL JOBS
IFE <V.DISP-V.DV61>,<
	XWD	.CHCNR,RVEDIO
	XWD	.CHCNA,ALARM
>
IF2,<
IFNDEF DEVPRG,<DEVPRG=FILPRG>
IFNDEF JOBPRG,<JOBPRG=NORMAL>
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
>
CHRN==.-CHRTAB

;HERE WHEN USER TYPES +, TO ADVANCE JOBS BY 20.

UPJOB:	MOVEI	A,UPDNJB	;GET INCREMENT
	TRNE	F,FR.VMM	;VM TYPE OF DISPLAYAY
	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:	MOVNI	A,UPDNJB	;GET 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
	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

;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:	OUTSTR	HOMDWN		;HOME DOWN SCREEN
	RESET			;  & RESET EVERYTHING ELSE, TOO
	AOS	.JBFF		;FLAG INITIALIZED
	MOVE	A,ME		;GET MY PPN
	CAME	A,OPRPPN	;SEE IF OPER
	SKIPN	GODLY		;OR NOT GODLY
	JRST	ALLDNE		;YES--NO DEBUGGING
	SKIPE	A,.JBDDT	;SEE IF DDT LOADED
	JRST	(A)		;YES--GO TO IT
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)
	TTCALL	3,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
	MOVEI	A,1		;GET FLAGS FOR HPQ #1
	HPQ	A,		;GET IN A HPQ (MAYBE)
	  JFCL			;       & IGNORE FAILURES
	MOVNI	A,RELOCK	;SET FOR AUTO UNLOCK
	MOVEM	A,RELCKC	; IN CASE OPER FORGETS
	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
	HPQ	A,		;REQUEST NORMAL CPU PRIORITY
	  JFCL			;  IGNORE ERROR RETURN
	RETURN

TGLDRM:	TLC	F,FL.PDR	;INVERT BIT FOR DORMANT SEGMENT
	RETURN

REFRSH:	tlo	f,fl.ref	;force a refresh
	RETURN

	SUBTTL	GIVE EXPLANATION FOR NONPRIVILED USER

;FOR NONPRIVILIGED USERS THE F COMMAND IS ILLEGAL
;INSTEAD OF DOING A N DISPLAY EXPLAIN WHY F COMMAND IS IMPOSSIBLE

NOPRIV:	SET	1,XSIZE,1,YSIZE,0,TAB4
	MOVEI	M,EXPTXT	;EXPALNATION TEXT
	CALL	MSG		;TELL IT 
	JRST	ADVICE		;GIVE COMMON ADVICE

EXPTXT:	ASCIZ	\THE F COMMAND CAN ONLY BE EXECUTED IF:
1 THE REQUESTER HAS SPY OR PEEK PRIVILIGES.
2 AND IF THE MONITOR VERSION >=501 AND USES A SYSTEM DISK
\

	SUBTTL	WARN USER OF HIS LIMITATIONS

;SPY OR PEEK PRIVILIGES ARE REQUIRED FOR CERTAIN FUNCTIONS
;TELL THE USER OF HIS LIMITS

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 LACK THE SPY AND PEEK PRIVILIGES.
AND THE TRMNO. UUO FAILS AS A CONSEQUENCE NO LINE
NUMBERS CAN BE DISPLAYED!
\
	SUBTTL EXPLAIN THERE IS NO VM

NONVM:	SET	1,XSIZE,1,YSIZE,0,TAB4
	MOVEI	M,EX1TXT	;EXPLANATION
	CALL	MSG		;STORE THE TEXT

;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	;**[15] DO NOT GET STUCK BY $ MODE
	tlz	f,fl.ref	;wait a second
	RETURN

EX1TXT:	ASCIZ	\THE M COMMAND ONLY DISPLAYS VM DATA
AS YOUR SYSTEM DOES NOT HAVE THIS OPTION,
ONLY THE NORMAL DISPLAY IS AVAILABLE FOR JOB INFORMATION
\

ADVTXT:	ASCIZ	\
THIS DISPLAY WILL BE AUTOMATICALLY REPLACED BY THE NORMAL
DISPLAY. TYPE N OR SPACE TO SPEED UP THE REPLACEMENT
\
	SUBTTL	"H" -- DISPLAY HELP MESSAGE

HELP:	PUSHJ	P,THISIS	;GIVE HEADER LINE
	MOVEI	M,HELPMS	;GET MESSAGE
	PUSHJ	P,MSG		;OUTPUT IT
	RETURN			;END OF DISPLAY PROGRAM

	DEFINE	$PLSMN	($1),<
	ASCIZ	\
Type one character to have effect -- no carriage return needed
Either ^C or ^Z terminates execution
Space or any other control character updates screen immediately
Escape (Altmode) freezes screen until another character is typed

D   List device status  (FUTURE)
F   List file performance
H   List this text
J   List job status (FUTURE)
M   LIST VIRTUAL MEMORY DATA IF VM OPTION IS PRESENT
N   List normal (some of everything) status
R   Refresh entire screen immediately 
S   Toggle whether dormant segments are displayed
T   Topology for network display
V   Toggle cpu and core priority
+-  Advance/backup jobs by $1'.
A   Toggle Auto roll of all jobs
#   Toggle whether display of TTY number is PTY number or ctl job number
\
>
	RADIX	10
HELPMS:	$PLSMN	\UPDNJB
	RADIX	8

	SUBTTL	"N" -- NORMAL DISPLAY PROGRAM - 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
	TRO	F,FR.VMM	;THEN TURN THE FLAG ON
;AND FALL INTO NORMAL

NORMAL:	CALL	STROLL		;START DISPLAY VARIABLES
	SETOM	NLTYPD		;MARK THAT LINES HAVE BEEN TYPED
	TRZ	F,FR.NRM	;**[15] ONLY WHEN NORMAL FORGET FLAG
	PUSHJ	P,GJBDAT	;READ ALL THE JOB DATA
	CALL	WNDJOB		;SET JOB WINDOW
	MOVEI	M,[ASCIZ /Job  Who  Where What/]
	CALL	MSG		;PRINT PART OF MESSAGE
	TRNE	F,FR.VMM	;IS VIRTUAL M THERE
	JRST	NORML0		;YES THEN ALL SET
	MOVEI	M,[ASCIZ /  #/]
	CALL	MSG		;PRINT MESSAGE
	CALL	KAYPAG		;KAYS OR PAGES
NORML0:	CALL	PAGRAT		;TYPE PAGE RATE
	MOVEI	M,[ASCIZ / State Runtime
/]
	CALL	MSG		;PRINT THE END OF THE LINE
	MOVN	J,JOBN
	HRLZS	J
	SETZM	CORUSE		;CLEAR TOTAL VIRT. CORE USED
	SETZM	DSKUSE		;CLEAR TOTAL SWAPPING SPACE USED
	SETZM	ACTUSE		;CLEAR ACTIVE SWAPPING SPACE
NORML1:	MOVE	JS,@.STS
	TLNN	JS,JNA
	JRST	NORMNJ
	SKIPN	N,ONEJOB
	JRST	NORML2
	CAIE	N,(J)
	JRST	NORMNJ
NORML2:	HRRZ	N,J
	HRRZM	J,CLINE		;WE ARE AT THIS LINE
	CALL	SETVIS		;DETERMINE VISIBLITY
	SKIPE	VISIBL		;NEXT SCREEN DISPLAY CAN SHOW IT
	CAMGE	N,FIRJOB
	JRST	[TLO F,FL.SUP	;SUPPRESS OUTPUT
		 JRST SYSL1I]	;SKIP MOST WORK
	PUSHJ	P,DECPRT
	PUSHJ	P,TAB

	MOVE	A,@.PPN		;
	CAMN	A,LOGPPN	;TEST FOR [2,5]
	JRST	[PUSHJ P,STRWHO	;  YES, PRINT **,** CAUSE WE DON'T KNOW
		 JRST  SYSL1D]
	CAMN	A,OPRPPN	;TEST FOR [1,2]
	JRST	[MOVE  A,[SIXBIT/[OPR]/] ;YES, PRINT [OPR]
		 PUSHJ P,SIXBP
		 JRST  SYSL1D]
	CAMN	A,ME		;TEST FOR MY PPN
	JRST	[MOVE  A,[SIXBIT/[SELF]/] ;YES, PRINT [SELF]
		 PUSHJ P,SIXBP
		 JRST  SYSL1D]
	PUSHJ	P,PNTPPN	;PRINT PRJ-PRG #
SYSL1D:	PUSHJ	P,TAB
	SKIPN	A,TTYFLG	;DO WE DECIDE HE IS DETACHED?
	JRST	SYS3LD		;YES HE LOOSES
	JUMPL	A,SYS2LD	;JUMP IF PRIVILIGED 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 FAILLURE
	JRST	SYS3LD		;PRINT IT
SYS2LD:	MOVE	A,@.TTY
SYS3LD:	PUSHJ	P,PTYCTL	;CHANGE TO CONTROLLING JOB IF PTY
	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,@.PRG
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	TRNN	F,FR.VMO	;**[5]HAS SYSTEM VMSER ACTIVE?
	JRST	SYS2LG		;**[5](NO) USE OLD LOGIC
	HRRZ	N,@.PGR		;**[16] GET SIZE OF VIRTUAL SEGMENTS
	JUMPE	N,SYSL2G	;**[16] NOT VIRTUAL
	LDB	A,[POINT 9,N,8+18]	;**[16] GET HISEG SIZE
	ANDI	N,777		;**[16] GET ONLY LOSEG SIZE
	ADD	N,A		;**[16] GET COMBINED SIZE
	JRST	NORM3A		;**[16] THAT'S IT
SYSL2G:	MOVE	N,@.SWP		;**[5]GET SWP TABLE ENTRY
	ANDI	N,777		;**[5]TAKE THE IMAGE IN
	JRST	NORM3A		;**[5]THATS IT FOR VM
SYS2LG:	MOVS	N,@.ADR		
	JUMPE	N,SYSL1I
	TLNN	JS,JSWP
	JRST	NORM3
SYSL1I:	MOVE	N,@.SWP
	ANDI	N,777
	JUMPN	N,NORM3A
	HLRZ	N,@.ADR		;IN PROCESS--USE IN CORE VALUE

NORM3:	ADDI	N,1
	ASH	N,-^D9
	TRNN	F,FR.KIP
	ASH	N,-1
	ANDI	N,777
NORM3A:	ADDM	N,CORUSE
	PUSHJ	P,INACTC	;TEST FOR ACTIVE PROGRAM
	  ADDM	N,ACTUSE	;  YES, ADD CORE SIZE IN
	TLNE	F,FL.SUP	;SEE IF SUPPRESSED
	JRST	TSTATL		;YES--SKIP MOST WORK
	CALL	PGDATA		;TYPE PAGING DATA
	MOVSI	A,'^W '
	TLNE	JS,400000	;RUN BIT ON?
	MOVSI	A,'CW '
	TLNE	JS,CMWB		;JOB IN COMMAND WAIT?
	JRST	TSTATE		;YES. SAY SO REGARDLESS OF STATE
	MOVSI	A,'OW '
	TRNE	JS,20000
	JRST	TSTATE
	MOVSI	A,'^D '
	TRNE	JS,100000
	JRST	TSTATE
	MOVSI	A,'^C '
	JUMPGE	JS,TSTATE
	LDB	B,[POINT 5,JS,14]
	IDIVI	B,3
	IMULI	C,14
	MOVE	A,QTAB(B)
	LSH	A,(C)
	AND	A,[7777B11]
	CAME	A,[SIXBIT /SL/]
	JRST	TSTATE
	TRNN	JS,400000
	MOVSI	A,(SIXBIT /HB/)
TSTATE:	CAMN	A,[SIXBIT /TI/]  ;SEE IF TTY I/O WAIT
	SKIPN	B,@.DVIOS	;YES--SEE IF I/O SETUP
	JRST	TSTATT		;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

TSTATT:	CAME	A,[SIXBIT /RN/]	;SEE IF RUN STATE
	JRST	TSTATR		;NO--GO ON
	MOVE	B,A		;YES--MAKE COPY
	HRLZ	A,J		;GET JOB NUMBER
	HRRI	A,.GTRTD	;LOOK IN REAL-TIME WORD
	PUSHJ	P,GETZ		; ..
	EXCH	B,A		;REPOSTION
	TLNN	B,(RTDHPQ)	;SEE IF HPQ SET
	JRST	TSTATR		;NOT IN HPQ
	LSH	B,-2		;YES--POSITION UNIT DIGIT
	AND	B,[RTDHPQ/4]  ;MASK TO JUST HPQ
	TLZN	B,(10B11)	;CLEAR TENS
	TLO	B,'H..'-'1..'	;SET H UNLESS GE 10
	ADD	B,[SIXBIT /10/]	;MAKE HN OR NN
	MOVE	A,B		;POSITION
TSTATR:	PUSHJ	P,SIXBP
	TLNN	JS,JSLOCK	;SEE IF LOCKED
	JRST	TSTATL		;NO--PROCEED
	MOVEI	CH,"!"		;YES--SET FLAG
	TLNE	JS,JSNSHF	;SEE IF NO SHUF
	MOVEI	CH,"&"		;YES--CHANGE FLAG
	PUSHJ	P,TYO		;OUTPUT IT
	SKIPN	@.SGN		;SEE IF HI-SEG LOGIC
	JRST	SYSL1E		;NO--FINISH UP
TSTATL:	SKIPN	A,@.SGN		;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,@.PRG		;AN OBSOLETED SEGMENT?
	JRST	SYSL1A		;NO-CHECK IF IT'S A NON CUSP HISEG
	MOVEI	CH,"@"
	MOVE	B,@.STS
	TLNE	B,SHRSEG	;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,@.PPN		;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	@.SEGCT		;INCREMENT HISEG USE COUNT
SYSL1E:	SETZB	CH,A		;ZAP BOTH V AND SW WORD
	TRNN	F,FR.VMO	;**[16] IS VM OPTION IN SYSTEM
	JRST	SYSL2E		;**[16] NO SKIP THE V FLAG
	HLRZ	N,@.PGR		;**[16] GET VIRTUAL FLAG
	JUMPE	N,SYSL2E	;**[16] NOT VIRTAUL
	MOVEI	CH,"V"		;**[16] FLAG JOB AS VIRTUAL
SYSL2E:	PUSHJ	P,LOPSWP	;PRINT STATE AND "SW"/"SF" IF SWAPPED/& FRAGMENTED
	MOVE	A,@.TIM
	PUSHJ	P,TCKTIM
	PUSHJ	P,CRLF
NORMNJ:	TLZ	F,FL.SUP
	AOBJN	J,NORML1
	CALL	SETEND		;SET SLINE VARIABLE TO ADAPT TO EMPTY
				;SCREEN

HIGH:	TRNE	F,FR.VMM	;IF VM DISPLAY THEN
	JRST	NODORM		;THEN FORGET HISEGS (FINAL???)
	CALL	WNDHSG		;SET WINDOW FOR HIGH SEGMENT
	MOVEI	M,[ASCIZ /HiSeg  #/]
	CALL	MSG		;PRINT FIRST PART
	CALL	KAYPAG		;NEXT K OR P
	MOVEI	M,[ASCIZ / SW #U
/]
	CALL	MSG		;PRINT THE LAST PART
	MOVE	J,SEGPTR
	SETZM	CORSAV		;CLEAR COUNTER FOR VIRT. CORE SAVED
HIGH00:	MOVE	JS,@.STS
	TLNN	JS,SNA
	JRST	DORMNT
	TLZ	F,FL.DOR
DOR1:	TLNE	F,FL.PDOR
	JRST	HIGH2A
	TLNN	F,FL.DOR
	PUSHJ	P,HIGH01
	JRST	DUNHGH
HIGH2A:	TLNN	F,FL.PDR		;TEST FOR DORMANT SEGS WANTED
	JRST	DUNHGH			;  NO, JUMP
	TLNE	F,FL.DOR
	PUSHJ	P,HIGH01
DUNHGH:	AOBJN	J,HIGH00	;ARE THERE ANY MORE HI SEGS.?
	MOVE	J,SEGPTR
	TLON	F,FL.PDOR
	JRST	HIGH00
	JRST	NODORM

HIGH01:	SKIPN	A,@.PRG
	JRST	[MOVE	A,[SIXBIT /(PRIV)/]
		TLNE	JS,SHRSEG
		MOVE	A,[SIXBIT /(OBS)/]
		JRST	.+1]
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	MOVEI	CH,0
	MOVE	N,@.PPN
	CAMN	N,OLDPPN
	MOVEI	CH,"O"
	CAMN	N,NEWPPN
	MOVEI	CH,"N"
	JUMPN	CH,[SKIPLE LINE
		    SKIPG  COL
		    JRST   .+1
		    SOS    COL
		    PUSHJ  P,TYO
		    JRST   .+1]
	TLNN	JS,SHRSEG	;**[6] A SHARABLE SEGMENT
	TLNN	F,FR.VMO	;**[6] (NO) A VM OPTION IN SYSTEM
	JRST	HIGH07		;**[6] (YES) OR (NO) RESPECTIVELY
	MOVS	N,@.SWP		;**[6] GETJBTSWP ENTRY
	JRST	HIGH04		;**[6] AND PROCES IT
HIGH07:	MOVS	N,@.ADR
	JUMPN	N,HIGH03
	MOVE	N,@.SWP		;IF NOTHING IN JBTADR - MUST BE SWAPPED
	JRST	HIGH04
HIGH03:	ADDI	N,1
	ASH	N,-^D9
	TRNN	F,FR.KIP
	ASH	N,-1
HIGH04:	ANDI	N,777
	TLNE	F,FL.DOR
	JRST	HIGH4A
	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,.SGN		;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,.SGN		;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,@.SEGCT
	IMULM	N,(P)
	AOS	N,@.SEGCT
	POP	P,A
	SKIPLE	A		;DON'T ADD TO CORSAV IF 0 OR -VE
	ADDM	A,CORSAV
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF

HIGH4B:	MOVE	A,@.PPN
	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,.SGN
		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,.SGN		;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 TI OR SL STATE
;ARGS	J=SEGMENT NUMBER IN RH
;NON-SKIP RETURN IF ACTIVE, SKIP RETURN IF INACTIVE

INACTC:	SKIPL	D,@.STS		;SKIP IF RUN BIT ON
	JRST	CPOPJ1		;OFF, INACTIVE
	LDB	D,[POINT 5,D,14]	;GET WAIT STATE CODE
	HLL	D,TISL		;SET UP FOR TEST
	CAMN	D,TISL		;SKIP IF DOESNT MATCH
	JRST	CPOPJ1		;YES, ONE MATCHES, INACTIVE
	MOVSS	TISL		;SET UP TO TEST OTHER HALF
	HLL	D,TISL
	CAMN	D,TISL		;SKIP IF DOESNT MATCH
	JRST	CPOPJ1		;YES, MATCHES, INACTIVE
	POPJ	P,		;NO, MUST BE ACTIVE

;VMHILO COMPUTE PHYSICAL HIGH AND LOW DATA
;THIS SHOULD BE COMPATIBLE WITH THE CORE COMMAND
;OUTPUT

VMHILO:	SETZ	N1,	;ASSUME NO HIGH SEG
	MOVE	N,@.SWP		;GET LOW SEGSIZE
	MOVE	A,@.SGN		;GET JBTSGN ENTRY
	JUMPLE	A,VMHIL1	;SPYING OR NO HIGH SEG
	TLNN	A,SHRSEG	;SHARABLE??
	JRST	VMHIL0		;NOPE OTHER ARITHMETIC
	ADD	A,.SWP		;GET JBT SWP ENTRY
	HRRZ	N1,(A)		;AND GET HISEG SIZE
	JRST	VMHIL1		;ALLSET
VMHIL0:	ADD	A,.SWP		;GET JBTSWP POINTER
	HLRZ	N1,(A)		;AND GET HISEG SIZE
	SUB	N,N1		;(NO) REDUCE LOW SEG SIZE
VMHIL1:	ADDI	N,UPMPSZ	;ADD IN UPMP SIZE
	HRL	N1,N		;MAKE  LOW,, HIGH VARIABLE
	AND	N1,[777,,777]	;NO NOISE
	MOVEM	N1,GETAB3	;REMEBER
	RETURN
;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:	TLNE	JS,JSWP		;IS HI SEG SWAPPED?
	JRST	LOPSW1		;YES - GO PRINT "SW" OR "SF"
	SKIPL	@.SWP		;CORE IMAGE FRAGMENTED ON DISK?
	JRST	LOPSW3		;NO
	MOVSI	A,(SIXBIT .F.)	;YES - PRESUME HISEG IN CORE
	JRST	LOPSW2		;YES - PRINT "FR"

LOPSWP:	TLNN	JS,JSWP		;IS SEG SWAPPED?
	JRST	LOPSW3		;NO - PRINT MSG & EXIT
LOPSW1:	MOVSI	A,(SIXBIT /SW/)	;PREPARE TO PRINT "SW"
	SKIPGE	@.SWP		;IS SEG FRAGMENTED?
	MOVSI	A,(SIXBIT .SF.)	;YES - INDICATE SWAPPED & FRAGMENTED
LOPSW2:	PUSH	P,CH		;SAVE APPENDENDUM
	PUSHJ	P,SIXBP		;PRINT "FR","SF" OR "SW"
	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
	ADDM	N,DSKUSE	;ADD TO TOTAL SPACE USED ON SWAPPING SPACE
	JRST	TAB		;PRINT TAB & EXIT

DORMNT:	MOVEI	N,OUTMSK
	SKIPN	@.ADR		;SEGMENT IN CORE?
	TDNE	N,@.SWP		;NO - ON DISK?
	TLOA	F,FL.DOR
	JRST	DUNHGH		;NOT IN USE
	JRST	DOR1

NODORM:	CALL	WNDSYS		;WINDOW FOR SYSTEM DATA
	PUSHJ	P,CONFIG
	TRNN	F,FR.VMM	;VM MONITOR REPORTING?
	JRST	NODOR0		;NO SKIP PAGING DATA
;**** MAKE TEMPORARY INACTIVE
;	SETZB	J,GETAB2	;ZAP JOB SO WE GET SYS PAGING
; 	MOVE	N,@.PGR		;GET SYSTEM WIDE PGR
;	JUMPE	N,NPGR		;ALL SET IF 0
;	IMUL	N,FREAK		;GET # OF PAGE FAULTS
;	MOVEM	N,GETAB2	;AND REMEMBER IT
NPGR:	.INL			;GO TO PSEUDO CODE
;	.TXT	<   SYS PAGING RATE=>
;	.PRD	GETAB2		;PRINT SYSTEM PAGING RATE
	.NWLIN			;A NEW LINE
	.END			;BACK TO MACRO CODE
	CALL	PAGSYS		;PRINT SYSTEM DATA
	RETURN			;END OF DISPLAY PROGRAM
NODOR0:	CALL	CRLF		;START A NEW LINE
	PUSHJ	P,PDATIM
	MOVEI	M,[ASCIZ / Up /]
	PUSHJ	P,MSG
	MOVE	A,XUPTIM
	PUSHJ	P,GETA		;GET UPTIME
	MOVEM	A,TEMP	;SAVE FOR CMPCMA ROUTINE(PERCENT)
	MOVEM	A,UPTIME	;SAVE FOR RESPONSE
	PUSHJ	P,TCKTIM
	MOVEI	M,[ASCIZ /
 %Idle:/]
	MOVE	A,XLSTIM	;CPU0 LOST TIME
	PUSHJ	P,GETA
	MOVEM	A,TEMP1		;SAVE CPU0 LOST TIME
	MOVE	A,[%CVNUL]	;CPU0 NULL TIME
	PUSHJ	P,GET		;MAYBE GETTAB NOT PRESENT
	  JRST NULL0		;GETTAB NOT THERE
	JRST	NULL1		;CPU0 CDB IS THERE

NULL0:	MOVEI	J,0		;USE JOB 0 NULL TIME FOR CPU0
	MOVE	A,@.TIM		;SINCE CANNOT BE A CPU1(5.04 OR EARLIER)
NULL1:	SUB	A,TEMP1		;CPU0 IDLE=CPU0 NULL-CPU0 LOST
	PUSHJ	P,CMPCNA	;PRINT AS % OF UPTIME(TEMP)
				; AND MESSAGE IN M
	SKIPN	DUAL		;ONLY IF DUAL
	JRST	NULL2		;PRINT
	MOVE	A,[%CVLST+2]	;CPU1 LOST
	PUSHJ	P,GET		;IS GETTAB PRESENT?
	  JRST	NULL2		;NO, NO CPU1
	MOVEM	A,N		;SAVE CPU1 LOST
	MOVEI	M,[ASCIZ /+/]	;SEPARATE CPU0 FORM CPU1 BY +
	MOVE	A,[%CVNUL+2]	;CPU1 NULL
	PUSHJ	P,GETA
	SUB	A,N		;CPU1 IDLE=CPU1 NULL-CPU1 LOST
	PUSHJ	P,CMPCNA	;PRINT AS % OF UPTIME(TEMP)
NULL2:	MOVEI	M,[ASCIZ / Lost:/]
	MOVE	A,TEMP1		;CPU0 LOST
	PUSHJ	P,CMPCNA	;PRINT AS % OF UPTIME(TEMP)
	SKIPN	DUAL		;ONLY IF DUAL
	JRST	LOST1		;PRINT
	MOVE	A,[%CVLST+2]	;CPU1 LOST
	PUSHJ	P,GET
	  JRST	LOST1		;NOT PRESENT
	MOVEI	M,[ASCIZ /+/]	;SEPARATE CPU0 CPU1 WITH +
	PUSHJ	P,CMPCNA	;PRINT AS % OF UPTIME(TEMP)
LOST1:

	MOVEI	M,[ASCIZ / OVH:/]	;OVERHEAD MESSAGE
	MOVE	A,[%CVOHT]	;OVER HEAD GETTAB
	PUSHJ	P,GET		;DO GETTAB
	  JRST	OVH2		;NOT THERE
	PUSHJ	P,CMPCNA	;PRINT PERCENT OF UPTIME(TEMP)
	SKIPN	DUAL		;A DUAL CPU SYSTEM
	JRST	OVH2	;NO SSKIP IT
	MOVE	A,[%CVOHT+2]	;CPU1 OVERHEAD GETTAB
	PUSHJ	P,GET		;GETTAB
	  JRST	OVH2		;NOT THERE
	MOVEI	M,[ASCIZ /+/]	;SEPARATE WITH +
	PUSHJ	P,CMPCNA	;PRINT CPU1 OVERHEAD
OVH2:	MOVEI	M,[ASCIZ /
Core Avail:/]
	MOVE	N,CORUNL	;GET UNLOCKED CORE
	CAMN	N,CORMAX	;SKIP IF SAME AS CORMAX
	JRST	DOCRMX		;YES
	ASH	N,-^D9		;POSITION TO P
	TRNN	F,FR.KIP
	ASH	N,-1
	PUSHJ	P,MSGDEC	;ISSUE
	MOVEI	M,[ASCIZ \/\]
DOCRMX:	MOVE	N,CORMAX
	ASH	N,-^D9
	TRNN	F,FR.KIP
	ASH	N,-1
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ / Used:/]
	MOVE	N,CORUSE
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ /
 Swapped:/]
	MOVE	N,DSKUSE
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ \/\]
	MOVE	A,XK4SWP
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ / Sharing svd:/]
	MOVE	N,CORSAV
	PUSHJ	P,MSGDEC

	MOVE	N,CORUNL	;SIZE OF UNLOCKED CORE
	ASH	N,-^D9		;CONVERT TO P
	TRNN	F,FR.KIP
	ASH	N,-1
	MOVEM	N,TEMP		;STORE FOR CMPDFA ROUT.
	MOVE	A,ACTUSE	;GET AMOUNT OF ACTIVE CORE (IN K)
	MOVEI	M,[ASCIZ /
ASR:/]				;GET MESSAGE FOR ACTIVE SWAPPING RATIO
	PUSHJ	P,CMPDFA	;PRINT INTEGER+FRACTION(TEMP)
	MOVX	A,%SYERR	;GET HARDWARE ERROR COUNT
	PUSHJ	P,GETZ		;  OR 0
	MOVEI	M,[ASCIZ / HE:/]
	SKIPE	N,A		;MOVE TO AC
	PUSHJ	P,MSGDEC	;PRINT IF NON-ZERO
	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 / SE:/]
	SKIPN	N,B		;MOVE TO AC
	SKIPE	A		; IF NON-ZERO
	PUSHJ	P,MSGDEC	;  PRINT
	MOVEI	M,[ASCIZ /D+/]
	SKIPN	N,A		;MOVE TO AC
	SKIPE	B		; IF NON-ZERO
	PUSHJ	P,MSGDEC	;  PRINT

;HERE TO PRINT RESPONSE MEASURES
	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 ADN 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

	SETZB	N,B		;COUNT JOBS AND LOGGED IN JOBS
	SETZB	C,D		;AND DETACHED JOBS
	MOVE	J,JOBN
CTJOB:	SOJLE	J,CTJOB1	;COUNT, PRINT IF DONE
	MOVE	A,@.STS
	TLNN	A,JNA		;SEE IF JOB NUMBER ASSIGNED
	JRST	CTJOB		;NO--DON'T COUNT
	AOS	N		;YES
	TLNE	A,JLOG		;SEE IF LOGGED IN
	AOS	B		;YES
	MOVE	A,@.TTY
	TLNN	A,-1		;SEE IF DETACHED
	AOS	C		;YES
	JRST	CTJOB		;LOOP

CTJOB1:	MOVEI	M,[ASCIZ /Jobs:/]
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ ./.]	;PRINT NUMBER OF JOBS IN USE
	MOVE	N,JOBN		;PRINT NO. IN SYSTEM
	SUBI	N,1		;ALLOW FOR NULL JOB
	PUSHJ	P,MSGDEC
	SKIPE	TNFRTY		;SEE IF 10/40N
	JRST	PRDET		;YES--DON'T COUNT LOGINS
	MOVEI	M,[ASCIZ / Log'd in:/]
	MOVE	N,B		;PRINT NO. LOGGED IN
	PUSHJ	P,MSGDEC
PRDET:	MOVEI	M,[ASCIZ / Det:/]
	MOVE	N,C		;PRINT NO. DETACHED
	PUSHJ	P,MSGDEC
	CALL	CRLF		;START ON A NEW LINE
	CALL	WNDDEV		;AND DEFINE DEVICE WINDOW

	MOVE	A,XDVLST	;GET THE BASE OF THE DDB CHAIN
	CALL	GET		;GET THE VALUE
	RETURN			;END OF DISPLAY PROGRAM
DEVLP:	TLNN	A,-1		;IS THIS THE END OF THE DDB LIST
	RETURN			;END OF DISPLAY PROGRAM
	HLRZ	D,A		;GET THE DDB ADDRESS
	MOVEI	A,DEVMOD(D)
	CALL	PEEK		;SPY OR PEEK
	MOVE	B,A		;(EDIT 2) REMEMBER THE DEMOD ENTRY
	TRNE	A,ASSCON+ASSPRG
	TLNE	A,DVTTY+DVDSK
	JRST	NXTDEV
	MOVEI	A,DV.CHR(D)
	SKIPE	NPJOBN		;NEW PJOB LOGIC?
	MOVEI	A,DEVJOB(D)	;(YES) GET OTHERE ENTRY
	CALL	PEEK		;SPY OR PEEK
	MOVE	C,A		;GET ACOPY OF THE RESULT
	MOVEI	A,DV.NAM(D)
	CALL	PEEK		;SPY OR PEEK
	HLRZ	BP,A
	CAIN	BP,'PTY'
	JRST	NXTDEV

	MOVEI	M,[ASCIZ /Dev By How
/]
	TLON	F,FL.nhed
	PUSHJ	P,MSG
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	LDB	N,PJOBN
	SKIPE	NPJOBN		;NEW OR OLD WAY?
	LDB	N,NPJOBN	;GET IT THE NEW WAY
	PUSHJ	P,DECPRT
	PUSHJ	P,TAB
	MOVEI	CH,"A"
	TRNE	B,ASSCON
	PUSHJ	P,TYO
	MOVEI	CH,"I"
	TRNE	B,ASSPRG
	PUSHJ	P,TYO
	PUSHJ	P,CRLF
NXTDEV:	MOVEI	A,DEVSER(D)
	CALL	PEEK		;SPY OR PEEK
	JRST	DEVLP

	SUBTTL	"F" -- FILE SYSTEM DISPLAY PROGRAM

FILPRG:	LDB	D,DSKLEV	;FIND TYPE IF FILE SERVICE
	SKIPE	D		;BEFORE 5.01?
	SKIPE	TNFRTY		;OR NON-DISK?
	JRST	NOPRIV		;EXPLAIN WHY DISPLAY PROGRAM DOES NOT WORK
	TLNN	F,FL.SPY!FL.PEK	;TEST FOR ENOUGH PRIVILEGES
	JRST	NOPRIV		; NO EXPLAIN IT
	CALL	STROLL		;START THE ROLL CALL
	SET	1,XSIZE,1,YSIZE,0,TAB4
	PUSHJ	P,THISIS	;OUTPUT HEADER
	SETZM	CURFS
	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
	CALLI	A,CI.STR
	  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
	CALLI	A,CI.DSK		;FOR THE STRUCTURE FIRST
	JRST	FILEXI	;SHOULDNT 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
	CALL	IDECPR		;PRINT IF VISIBLE
	CALL	ICRLF		;END OF STRUCTURE

;UNIT STUFF HERE

	MOVE	A,DSKBLK+.DCULN
	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
	MOVEM	A,DSKBLK
	MOVE	A,[XWD DSKBKL,DSKBLK]
	CALLI	A,CI.DSK
	 JRST FLFSN
	MOVEM	A,DSKBLK	;SAVE BITS
	MOVE	A,XSYSUN	;GET SYSTEM UNIT BLK LIST
	PUSHJ	P,GETA
	HLRZ	D,A
FLUNL2:	MOVEI	A,UNILOG(D)
	PUSHJ	P,PEEK		;GET NAME OF UNIT
	CAMN	A,CURUN		;SAME AS CURRENT?
	JRST	FLUN3		;YES
	MOVEI	A,UNISYS(D)	;NO. LOOK ON
	PUSHJ	P,PEEK
	HLRZ	D,A
	JUMPN	D,FLUNL2
	JRST	FLUNN		;NOT FOUND. STRANGE.

FLUN3:	MOVEM	D,UNIBLK	;SAVE UNIT DATA BLOCK ADDR
	MOVE	A,DSKBLK+.DCUPN	;PHYSICAL NAME
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /(/]
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	A,UNIHID(D)
	PUSHJ	P,PEEK
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /)	/]
	CALL	IMSG		;PRINT IF VISIBLE
	MOVE	N,DSKBLK+.DCUNT
	CALL	IDECPR		;PRINT IF VISIBLE
	MOVSI	C,-UDTBL
FLUNL3:	HRRZ	A,UDTAB(C)
	PUSHJ	P,GETUDB
	HLRE	A,UDTAB(C)
	JUMPE	A,FLUNLA
	JUMPL	A,FLDIFF
	ADD	A,UNIBLK
	CALL	PEEK		;SPY OR PEEK
	ADD	N,A
	JRST	FLUNLA

FLDIFF:	MOVNS	A
	ADD	A,UNIBLK
	CALL	PEEK		;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
	CALL	ISPACE		;IF VISIBLE A SPACE
	TLO	F,FL.NBK
	MOVSI	C,-BITTL
FLBTL:	SKIPGE	A
	PUSHJ	P,PRTBIT
	LSH	A,1
	AOBJN	C,FLBTL
FLUN4:	LDB	C,DSKLEV	;DISK LEVEL NO.
	CAILE	C,1		;5.01, 5.02 OR EARLIER?
	JRST	FLUN5		;NO, MUST BE 5.03 OR LATER

;HERE TO DO 5.01, OR 5.02 UNIT ERROR INFO
	MOVSI	C,-UERRTL
FLUNL4:	HLRZ	A,UERRT1(C)
	PUSHJ	P,GETUDB
	HRRZ	M,UERRT1(C)
	XCT	UERRT2(C)
	PUSHJ	P,@UERRT3(C)
	AOBJN	C,FLUNL4
	JRST	FLUNN0		;FINISHED

;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)
	PUSHJ	P,@UER2T3(C)
	AOBJN	C,FLUNL5
FLUNN0:	TLNE	F,FL.NBK+FL.DEV
	CALL	ICRLF		;NEW LINE IF VISIBLE

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

FLFSN:	JRST	FLFSL		;LOOP FOR NEXT STRUCTURE

FILEXI:	HEADER	<	MOVEI	M,[ASCIZ /Swap Unit	R	W	Used(/]
	CALL	MSG		;AND PRINT IT
	CALL	KAYPAG		;**[10] 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)
	CALL	PEEK		;SPY OR PEEK
	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
	PUSHJ	P,PEEK		;  & GET IT FROM MONITOR
	CALL	ISIXBP		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /)	/] ;GET RIGHT-PAREN & TAB MESSAGE
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	A,UNIICT(D)
	CALL	PEEK		;SPY OR PEEK
	MOVE	N,A
	CALL	IDECTAB		;PRINT IF VISIBLE
	MOVEI	A,UNIOCT(D)
	CALL	PEEK		;SPY OR PEEK
	MOVE	N,A
	movei	m,[asciz/	/] ;precede by a tab
	PUSHJ	P,IDECPRT
	MOVEI	A,UNIFKS(D)
	CALL	PEEK		;SPY OR PEEK
	MOVEM	A,N
	MOVEI	A,UNIK4S(D)
	CALL	PEEK		;SPY OR PEEK
	ANDI	A,MSKK4S
	HRRZ	CH,MONVER	;GET THE MONITOR VERSION
	CAIGE	CH,50665	;CHANGED TO 13 BITS
	TRZ	A,10000		;(NO) 12BITS STILL
	TRNE	F,FR.KIP
	LSH	A,1
	MOVEM	A,TEMP
	SUBB	A,N
	CALL	IPRPCNT		;PRINT PERCENTAGE
	CALL	ICRLF		;END THE LINE NICELY
	MOVEI	A,UNISWP(D)
	CALL	PEEK		;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/]
	TRZE	D,IOIMPM
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ / DEV/]
	TRZE	D,IODERR
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ / DAT/]
	TRZE	D,IODTER
	CALL	IMSG		;PRINT IF VISIBLE
	MOVEI	M,[ASCIZ /   Lost: /]
	HRRZ	N,D
	TRZ	N,070000	;**[12] 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
	CALL	PEEK		;SPY OR PEEK
	MOVE	N,A
	POPJ	P,

PRTBIT:	MOVEI	M,BITTAB(C)
	CALL	IMSG		;PRINT IF VISIBLE
	CALL	ISPACE		;PRINT IF YOU CAN SEE IT
	RETURN

PRTUED:	JUMPE	N,CPOPJ
	PUSH	P,M
	MOVEI	M,[ASCIZ / Errors: /]
	TLON	F,FL.DEV
	CALL	IMSG		;PRINT IF VISIBLE
	POP	P,M
	CALL	IMSG		;PRINT IF VISIBLE
	CALL	IDECPRT		;PRINT IF VISIBLE
	PJRST	ISPACE

PRTUEO:	JUMPE	N,CPOPJ
	PUSH	P,M
	MOVEI	M,[ASCIZ / Errors: /]
	TLON	F,FL.DEV
	CALL	IMSG		;PRINT IF VISIBLE
	POP	P,M
	CALL	IMSG		;PRINT IF VISIBLE
	SKIPGE	VISIBL		;CAN WE SEE IT?
	PUSHJ	P,OCTPRT
	PJRST	ISPACE

BITTAB:	ASCIZ	/RHB/
	ASCIZ	/OFL/
	ASCIZ	/HWP/
	ASCIZ	/SWP/
	ASCIZ	/SAF/
	ASCIZ	/ZMT/
	ASCIZ	/PRF/
	ASCIZ	/PNM/
	ASCIZ	/DWN/
	ASCIZ	/MSB/
	ASCIZ	/NNA/
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.01 AND 5.02 MONITOR ERROR INFO TABLES:

UERRT1:	XWD	UNIHCT,[ASCIZ /HDEV:/]
	XWD	UNIHCT,[ASCIZ /HDAT:/]
	XWD	UNISCT,[ASCIZ /SDEV:/]
	XWD	UNISCT,[ASCIZ /SDAT:/]
	XWD	UNIPCT,[ASCIZ /HPOS:/]
	XWD	UNIPCT,[ASCIZ /SPOS:/]
	XWD	UNIMCT,[ASCIZ /SER:/]
	XWD	UNIMCT,[ASCIZ /RER:/]
	XWD	UNIMCT,[ASCIZ /CER:/]
	XWD	UNIERR,[ASCIZ /HERR status:/]
	XWD	UNISOF,[ASCIZ /SERR status:/]
	XWD	UNIHBN,[ASCIZ /LBN:/]
UERRTL==.-UERRT1

UERRT2:	HLRZS	N
	HRRZS	N
	HLRZS	N
	HRRZS	N
	HLRZS	N
	HRRZS	N
	LDB	N,[POINT 12,N,11]
	LDB	N,[POINT 12,N,23]
	ANDI	N,7777
	JFCL
	JFCL
	JFCL

UERRT3:	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUEO
	PRTUEO
	PRTUEO

;5.03 AND LATER MONTIORS ERROR INFO TABLES:


UER2T1:	XWD	UNIHCT,[ASCIZ /HDEV:/]
	XWD	UNIHCT,[ASCIZ /HDAT:/]
	XWD	UNISCT,[ASCIZ /1DEV:/]
	XWD	UNISCT,[ASCIZ /1DAT:/]
	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	UNIERR,[ASCIZ /2CONI:/]
	XWD	UNISOF,[ASCIZ /1CONI:/]
	XWD	UNIHBN,[ASCIZ /LBN:/]
	XWD	UNIHDI,[ASCIZ /2DATAI:/]
	XWD	UNISDI,[ASCIZ /1DATAI:/]
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
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUEO
	PRTUED
	PRTUED
	PRTUED
	PRTUEO
	PRTUEO
	PRTUEO
	PRTUEO
	PRTUEO

X2SIZE==XSIZE/2
SUBTTL " " NETWORK STATISTICS DISPLAY PROGRAM


%GTNET==141
%NTCOR==0
%NTMAX==1
%NTAVG==2
%NTBAD==3
%NTRTP==4
%NTRMT==5
%NTRDL==6
%NTXTP==7
%NTXMT==10
%NTXDL==11
NETSTS:
;LINE 1
	SET	1,XSIZE,1,2,0,TAB7
	PUSHJ	P,CONFIG
	PUSHJ	P,SPACE
	PUSHJ	P,PDATIM
	PUSHJ	P,SPACE
	MOVEI	M,[ASCIZ /UP:/]
	PUSHJ	P,MSG
	MOVE	A,XUPTIM
	PUSHJ	P,GETA
	PUSHJ	P,TCKTIM
	PUSHJ	P,CRLF

;LINE 2
	MOVEI	M,[ASCIZ /NTCOR=	/]
	PUSHJ	P,MSG
	MOVE	A,[XWD %NTCOR,%GTNET]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /NTMAX=	/]
	PUSHJ	P,MSG
	MOVE	A,[XWD %NTMAX,%GTNET]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /NTAVG=	/]
	PUSHJ	P,MSG
	MOVE	A,[XWD %NTAVG,%GTNET]
	PUSHJ	P,GETA
	ASH	A,-4
	MOVE	N,A
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /NTBAD=	/]
	PUSHJ	P,MSG
	MOVE	A,[XWD %NTBAD,%GTNET]
	PUSHJ	P,GETA
	MOVEI	N,(A)
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF

;UN-NUMBERED CONTROL WINDOW
	SET	1,X2SIZE-1,3,12,0,TAB7
	MOVEI	M,[ASCIZ /UNNUMBERED CTL	SENT		RECEIVED
/]
	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,[XWD %NTXTP,%GTNET]	;RECEVICE TABLE
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,DECTAB
	MOVE	A,[XWD %NTRTP,%GTNET]
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF
	AOBJN	J,UNPRT1

;NUMBERED MESSAGE WINDOW
	SET	X2SIZE,XSIZE,3,12,0,TAB8
	MOVEI	M,[ASCIZ /NUMBERED CTL		SENT	RECEIVED
/]
	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,[XWD %NTXMT,%GTNET]	;RECEVICE TABLE
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,DECTAB
	MOVE	A,[XWD %NTRMT,%GTNET]
	PUSHJ	P,GETA
	ADDI	A,(J)
	MOVSI	A,(A)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	MOVE	N,A
	PUSHJ	P,DECPRT
	PUSHJ	P,CRLF
	AOBJN	J,NUPRT1
;HERE TO DO A HISTROGRAM OF MESSAGE LENGTHS

	SET	1,X2SIZE-1,11,YSIZE,0,TAB7
	MOVE	A,[XWD %NTXDL,%GTNET]
	PUSHJ	P,GETA
	LDB	J,[POINT 9,A,8]	;NUMBER OF ENTRIES
	MOVNS	J
	MOVSI	J,(J)		;AOBJN POINTER
	HRRI	J,(A)		;TABLE INDEX
	PUSH	P,J		;SAVE THE INDEX
	SETZB	N,D
LEN1:	HRLI	A,(J)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	ADD	N,A
	AOBJN	J,LEN1		;COMPUTE
	POP	P,J		;RESTORE THE POINTER
	PUSH	P,N		;SAVE THE SUM
	MOVEI	M,[ASCIZ /XMIT'ed= /]
	PUSHJ	P,MSG
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ /AVG=/]
	PUSHJ	P,MSG
	MOVE	N,(P)
	MOVE	A,XUPTIM
	PUSHJ	P,GETA
	IDIV	A,TCKSEC
	IDIV	N,A
	PUSH	P,N+1
	PUSHJ	P,DECPRT
	MOVEI	CH,"."
	PUSHJ	P,TYO
	POP	P,N
	PUSHJ	P,DECPRT
	MOVEI	M,[ASCIZ \/sec\]
	pushj	p,msg
	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ / 2**N	0%   20%  40%  60%  80%  99%
/]
	PUSHJ	P,MSG
LEN2:	HRLI	A,(J)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	IMULI	A,^D100
	IDIV	A,(P)
	AOS	N,D
	PUSHJ	P,DECPRT
	PUSHJ	P,SPACE
	MOVE	N,A
	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
	AOBJN	J,LEN2
	POP	P,N

;HERE TO DO THE HISTROGRAM OUT RECEIVED MESSAGES

	SET	X2SIZE,XSIZE,11,YSIZE,0,TAB8
	MOVE	A,[XWD %NTRDL,%GTNET]
	PUSHJ	P,GETA
	LDB	J,[POINT 9,A,8]	;NUMBER OF ENTRIES
	MOVNS	J
	MOVSI	J,(J)		;AOBJN POINTER
	HRRI	J,(A)		;TABLE INDEX
	PUSH	P,J		;SAVE THE INDEX
	SETZB	N,D
LEN4:	HRLI	A,(J)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	ADD	N,A
	AOBJN	J,LEN4		;COMPUTE
	POP	P,J		;RESTORE THE POINTER
	PUSH	P,N		;SAVE THE SUM
	MOVEI	M,[ASCIZ /REC'ed= /]
	PUSHJ	P,MSG
	PUSHJ	P,DECTAB
	MOVEI	M,[ASCIZ/AVG=/]
	PUSHJ	P,MSG
	MOVE	N,(P)
	MOVE	A,XUPTIM
	PUSHJ	P,GETA
	IDIV	A,TCKSEC
	IDIV	N,A
	PUSH	P,N+1
	PUSHJ	P,DECPRT
	MOVEI	CH,"."
	PUSHJ	P,TYO
	POP	P,N
	PUSHJ	P,DECPRT
	MOVEI	M,[ASCIZ \/sec\]
	pushj	p,msg
	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ / 2**N	0%   20%  40%  60%  80%  99%
/]
	PUSHJ	P,MSG
LEN5:	HRLI	A,(J)
	HRRI	A,%GTNET
	PUSHJ	P,GETA
	IMULI	A,^D100
	IDIV	A,(P)
	AOS	N,D
	PUSHJ	P,DECPRT
	PUSHJ	P,SPACE
	PUSHJ	P,SPACE
	MOVE	N,A
	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
	AOBJN	J,LEN5
	POP	P,N
	POPJ	P,
SUBTTL "T" NETWORK DISPLAY OF THE TOPOLOGY
IFN FTNET,<
NETPRG:NETPRY:

	SET	1,XSIZE,1,1,0,TAB7
	PUSHJ	P,CONFIG
	PUSHJ	P,SPACE
	PUSHJ	P,PDATIM
	PUSHJ	P,SPACE
	MOVEI	M,[ASCIZ /UP:/]
	PUSHJ	P,MSG
	MOVE	A,XUPTIM
	PUSHJ	P,GETA
	PUSHJ	P,TCKTIM
	PUSHJ	P,CRLF
	MOVE	A,[XWD 125,11]	;GET THE GETTAB POINTER TO THE NDB'S
	PUSHJ	P,GET		;GET IT
	  CAIA
	JUMPN	A,NETPR1	;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 previliges.
2. And the monitor was built for NETWORK support =603
\]
	call	msg
	jrst	advice
netpr1:	movem	a,curndb	;save the currect ndb pointer
	tlnn	f,fl.spy!fl.pek	;is the user privileged
	jrst	nopriv		;no
	call	stroll
	SETOM	NLTYPD		;YES, WE TYPED
	set	1,xsize,2,ysize,0,tab6
	movei	m,[asciz \ NODE #	NEIGHBORS /LINK	OPR	CTL	LAR	LAP	LMS	LMA	LMR	LMP
\]
	call	msg
netpr2:	pushj	p,nxtndb
	  popj	p,		;end of the nodes
	hlrz	a,ndbsnm	;get the node name
	pushj	p,peek
	pushj	p,sixbp
	movei	ch,"("
	pushj	p,tyo
	hlrz	n,ndbnnm	;get the node number
	pushj	p,octprt
	movei	m,[asciz \)\]
	call	msg
	pushj	p,tab
	MOVE	C,[POINT 18,NDBTOP]	;GET THE TOPOLOGY POINTER
	MOVEI	B,^D16		;MAX NEIGHBORS
	ILDB	N,C		;GET AN ENTRY
	LSH	N,-^D8		;POSITION
	ANDI	N,77
	SKIPE	N
	PUSHJ	P,[TRNN N,70	;HOW MAY DIGITS
		PUSHJ	P,SPACE	;ONLY ONE
		PUSHJ P,OCTPRT
		PJRST COMMA]
	SOJG	B,.-5
	PUSHJ	P,TAB
	HRRZ	A,SCBOPR	;GET THE OPR ENTRY
	JUMPE	A,NETPR3	;NO
	ADDI	A,16		;YES, POINT THE LDBDCH ENTRY IN THE LDB
	PUSHJ	P,PEEK		;READ IT
	ANDI	A,777		;ONLY NINE BITS
	MOVEI	N,(A)		;COPY
	pushj	p,octprt
NETPR3:	pushj	p,tab
	hlrz	n,scbctl	;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

;start of line 2
	JRST	NETPR2		;SHORT FORM
	MOVEI	M,[ASCIZ \NBR's=\]
	CALL	MSG
	MOVE	C,[POINT 18,NDBTOP]	;GET THE TOPOLOGY POINTER
	MOVEI	B,^D16		;MAX NEIGHBORS
	ILDB	N,C		;GET AN ENTRY
	LSH	N,-^D8		;POSITION
	ANDI	N,77
	SKIPE	N
	PUSHJ	P,[PUSHJ P,OCTPRT
		JRST SPACE]
	SOJG	B,.-5
	PUSHJ	P,CRLF		;END OF THE LINE
	JRST	NETPR2		;TRY ANOTHER NODE
NXTNDB:	SKIPN	D,CURNDB	;IS THERE ANOTHER NODE
	POPJ	P,		;NO
	MOVSI	C,-NDBLEN	;GET THE LENGTH
NXTND1:	MOVEI	A,(D)		;ADDRESS OF THE ENTRY
	PUSHJ	P,PEEK		;GET A WORD
	MOVEM	A,NETNDB(C)	;STORE
	ADDI	D,1
	AOBJN	C,NXTND1	;CONTINUE
	HRRZ	A,NETNDB	;GET THE LINK POINTER
	MOVEM	A,CURNDB	;STORE FOR THE NEXT CALL
	JRST	CPOPJ1		;EXIT
SUBTTL LOCAL STORAGE FOR "T" DISPLAY
CURNDB:	BLOCK	1
NETASC:	BLOCK	^D8
	Z
NETNDB:
NDBNNM:0;XWD	OURNNM,0		;(0)  NNM,NEXT NDB
NDBSID:0;XWD	SYSDAT##,CONFIG##	;(1)  SYSTEM CREATION DATE,NAME
NDBSNM:0;BYTE	(18)STANAM(2)0(8)0(8)0	;(2)  STATION NAME,0
NDBMNM:0;BYTE	(4)0(8)0(8)0(8)0(8)0	;(3) LAST ACHED,LAST SENT,LAST ASSGN
NDBFEK:0;XWD	0,0			;(4)  FLASGS,FEK
NDBQUE:0;XWD	0,0			;(5)  INPUT QUEUE,,OUTPUT QUEUE
NDBCTL:0;BYTE	(10)0(8)0(18)0		;(6)  MML,FLAGS,0
NDBTOP: BLOCK	^D8			;(7)  TOPOLOGY TABLE
SCBSTS:;				;(10)STATUS IN LEFT HALF
SCBOPR:0;BLOCK	1			;(11)LDB OF OPR, OR 0 IF NONE
SCBDEV:0;BYTE	(6)1,0,M.CDR,M.LPT,M.PTR,M.PTP,M.PLT,M.MTA,M.DTA,M.RJOB
	Z
	Z
SCBCTL:0;BLOCK	1			;(13)SWD JOB,,ADR OF STATION CONTROL DEVICE
NDBLEN==.-NETNDB				;LENGTH
;BYTE POINTERS
NDBMML:POINT	10,NDBCTL,9		;DDCMP MAX MESSAGE LENGTH
NDBRFL:POINT	8,NDBCTL,17		;STATUS FLAGS

;	MESSAGE NUMBER RELEVANT TO OUTPUT MESSAGES
NDBLAR:POINT	8,NDBMNM,11		;LAST ACK RECEIVED
NDBLAP:POINT	8,NDBMNM,19		;LAST OUTPUT MESSAGE# ACK'ED
NDBLMS:POINT	8,NDBMNM,27		;LAST MESSAGE SENT
NDBLMA:POINT	8,NDBMNM,35		;LAST MESSAGE NUMBER ASSIGNED
NDBLAS:POINT	8,NDBFEK,17		;LAST ACK SENT

;	MESSAGE NUMBERS RELEVANT IN INPUT MESSAGES
NDBLMR:POINT	8,NDBSNM,35		;LAST INPUT MESSAGE RECEIVED
NDBNCA:
NDBLMP:POINT	8,NDBSNM,27		;LAST MESSAGE PROCESSED
					;THIS IS THE NCA ON OUTPUT

>;END FTNET
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 HETRZ 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
	JUMPN	A,IJBDA0	;IT WAS SO SAVE IT
	MOVEI	A,DDBLDB	;FOR OLDER MONITOTRS
	HRRZ	B,MONVER	;UNTIL VERSION 50410
	CAIL	B,50410		;THE NUMERIC VALUE IS OKAY
	ADDI	A,1		;ELSE VALUE IS ONE BIGGER
	CAIL	B,50300		;EDIT 20 OLDER THAN 503
	ADDI	A,3		;EDIT 20 YES ADD 3 TO DDBLDB
IJBDA0:	MOVEM	A,VDDLDB	;REMEMBER THE VALUE
	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:	CALLI	A,CI.PJO
	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
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,0		;MY STATUS
	PUSHJ	P,GETA
	HRROI	B,2		;MY PPN
	CALLI	B,CI.GET
	  TLOA	B,-1		;NON DISK SYSTEM-FLAG AS UNGODLY
	CAMN	B,OPRPPN	;SEE IF OPERATOR
	TLNN	A,JLOG		;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

	MOVSI	B,LQTAB
	SETZB	C,TISL		;CLEAR WORK AREAS
QTLP:	MOVEI	A,25		;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'		;TEST FOR SLEEP QUEUE
	HRRM	C,TISL		;  YES, REMEMBER QUEUE INDEX
	CAIN	A,'TI'		;TEST FOR TTY QUEUE
	HRLM	C,TISL		;  YES, REMEMBER QUEUE INDEX
	AOBJN	C,QTLP2	;LOOP OVER 3 ENTRIES PER WORD
	AOBJN	B,QTLP
QTLP1:
	MOVE	A,XSTATS
	PUSHJ	P,GETZ
	MOVEM	A,STATES
	SETZM	TNFRTY		;CLEAR TEN/40 SYSTEM FLAG
	JUMPE	A,DNTSTO	;DONT OVERRIDE TCKSEC IF GETTAB UUO UNDEFINED
	TLNN	A,(1B2)		;LOGIN FEATURE?
	SETOM	TNFRTY		;NO. ASSUME TEN FORTY SYSTEM
	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:

	SUBTTL FIND NUMBER OF JOBS AND SEGMENTS 
	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
	MOVEM	B,FREE

	SUBTTL CORE ALLOCATION
	MOVE	D,[-NTABLE,,TABLE]
GJB6:	LDB	A,PTABLE	;GET THE TABLE  INDEX
	SOJL	A,GJB4		;ONLY A TABLE TO ALLOCATE??
	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,FREE		;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,FREE		;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		;PROCES ALL TABLES
	HRRZ	A,.SEGCT	;ADDRESS OF SEGMENT COUNT
	ADD	A,SEGN		;AND COMPUTE LAST ADDRESS FOR
	SOS	A		;FOR A BLT
	MOVEM	A,.SEGLS	;IN SET UP LOOP
	SETZM	@ZERLOW		;CLEAR CORE
	MOVE	A,ZERLOW
	HRLS	A
	ADDI	A,1
INIT4:	MOVE	A,XCORMX	;GET GETTAB CODE FOR UNLOCKED CORE
	PUSHJ	P,GETA		;GET AMOUNT OF UNLOCKED CORE
	MOVEM	A,CORUNL	;  & SAVE IT
	MOVE	A,XMEMSZ	;GET SOME MORE PARAMS
	PUSHJ	P,GETZ
	JUMPE	A,INIT5
	MOVE	B,A
	MOVE	A,[ 122,,11] ;GET HISEG SIZ
	CALL	GETZ		;GET A ZERO OR VALUE
	PUSH	P,A		;SAVE A
	MOVE	A,XSYSSZ
	PUSHJ	P,GETA
	ADD	A,(P)		;ADD HISEG SIZE
	POP	P,N		;CLEAN UP STACK
	TRNE	F,FR.KIP
	JRST	INIT4A
	ADDI	A,1777
	TRZ	A,1777
INIT4A:	MOVNS	A
	ADD	A,B
	JRST	INIT6
INIT5:	MOVE	A,CORUNL
INIT6:	MOVEM	A,CORMAX
	POPJ	P,

NOCOR:	TTCALL	3,[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
	CALLI	B,CI.GET	;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	@.TTY
	TLZ	B,-1
	JUMPE	B,GJBN2
	MOVEI	A,DV.NAM(B)	;GET TTY NAME
	PUSHJ	P,PEEK		;GET THE WORD
	MOVEM	A,@.TTY		;STORE IN TABLE
	MOVEI	A,DEVIOS(B)	;GET TTY DEVIOS
	PUSHJ	P,PEEK		;GET THE WORD
	MOVEM	A,@.DVIOS	;STORE
	TLNN	F,FL.SCN	;WHICH SCANNER LAYOUT?
	JRST	GJBN2		;OLD.
	MOVE	A,VDDLDB	;GET OOFSET
	ADDI	A,(B)		;AND GET ADDRESS
	PUSHJ	P,PEEK		;GET THE VALUE
	TRNE	A,-1		;ANY LDB LINK?
	JRST	GJBN2		;YES. OK TO TYPE NAME.
	HRLM	A,@.TTY
GJBN2:	AOBJN	D,GJBL2		;ALL JOBS

GJB3:	MOVE	J,MYJOB
	MOVE	A,@.TTY
	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 POITER TO TABLE POINTER
	HRR	B,(C)		;GET TABLE ADDRESS
INIT2:	LDB	J,PTABLE	;GET THE TABLE VALUE
	SUBI	J,SPYTAB	;GET THE COORECT TABLE INDEX
INIT3:	MOVE	A,J		;GET GETTAB PARAMETER
	PUSHJ	P,GETZ		;GET THE VALUE
	MOVEM	A,(B)		;SORE THE RESULT
	ADD	J,[1,,0]	;NEXT JOB
	AOBJN	B,INIT3		;FOR ALL TABLE MEMBERS
INIT1:	AOBJN	D,INIT0
	MOVE	A,.SEGCT
	HRLS	A
	SETZM	(A)
	ADDI	A,1
	BLT	A,@.SEGLS
	MOVE	A,XCORMX	;GET GETTAB CODE FOR UNLOCKED CORE
	PUSHJ	P,GETA		;GET AMOUNT OF UNLOCKED CORE
	MOVEM	A,CORUNL	;  & SAVE IT
	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
	PUSHJ	P,CONFIG
	PUSHJ	P,SPACE
	PUSHJ	P,PDATIM
	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:	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,0

>;	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:	BYTE	(7)16,<" "+YSIZE-2>," ",0

>;	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 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 COUNRIES.
;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
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:	BYTE	(7)ESC61,"Y",<" "+YSIZE-2>," ",0


IFE <V.DISP-V.DV61>,<

;SUBROUTINE TO HOME UP AND FILL
HOME:	MOVEI	CH,ESC61	;ISSUE HOME
	PUSHJ	P,DPYOUT	;TO DISPLAY
	MOVEI	CH,"P"
	PUSHJ	P,DPYOUT
	MOVEI	CH,"Q"
	JRST	DPYOUT
>


IFE <V.DISP-V.DV50>*<V.DISP-V.DV52>,<

HOME:	MOVEI	CH,ESC61	;ISSUE HOME
	PUSHJ	P,DPYOUT	;TO DISPLAY
	MOVEI	CH,"H"
	JRST	DPYOUT
>
;SUBROUTINE TO CLEAR THE SCREEN
CLEAR:	PUSHJ	P,HOME
	MOVEI	CH,ESC61
	PUSHJ	P,DPYOUT
	MOVEI	CH,"J"
	PJRST	DPYOUT
	POPJ	P,
RVEDIO:
	MOVEI	CH,ESC61
	PUSHJ	P,DPYOUT
	MOVEI	CH,"P"
	PUSHJ	P,DPYOUT
	MOVEI	CH,"I"
	TRCN	F,FR.RVD
	MOVEI	CH,"i"
	PUSHJ	P,DPYOUT
	JRST	FRCOUT
ALARM:	MOVEI	CH,ESC61
	PUSHJ	P,DPYOUT
	MOVEI	CH,"O"
	PUSHJ	P,DPYOUT
	MOVEI	CH,"I"
	TRCN	F,FR.ALR
	MOVEI	CH,"i"
	PUSHJ	P,DPYOUT
	JRST	FRCOUT
>;	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:	BYTE	(7)176,34,177,177,177,176,22,0
>;	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	POS,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,POS		;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	POS,DPYSP2	;  NO, UPDATE POSITION & LOOP
	MOVEI	T2,23		;GET A CLEAR LINE CHARACTER
	JUMPE	A,CPOPJ		;TEST FOR BLANK LINE
	MOVE	POS,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:	BYTE	(7)20,22,20,05,24,0
>;	END OF	IFE V.DISP-V.DHZL

PEEK:	TLNE	F,FL.SPY
	SKIPA	A,400000(A)
	CALLI	A,CI.PEK
	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 MONOITOR 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,

	COMMENT	&
;THERE ARE 2 GET ROUTINE:
1 GET A WORD
2 GET A BLOCK OF CORE
BOTH USE THE ROUTINE GET0.THIS ROUTINE HAS 3 EXITS:
1 ENTRY REQUESTED DOES NOT EXIST
2 GETTAB HAS TO BE USED
3 SPYING CAN BE DONE
IN CASE 3 N1 CONTAINS THE SPT ADDRESS OF THE REQUESTED ITEM

GETBLK PARAMETERS:
A RIGHT HALF CONTAINS TABLE INDEX
J LENGTH OF TABLE REQUESTED
C POINTS TO A POINTER TO THE BLOCK TO BE INITIALIZED
 ACCU J IS IN THE REGISTER WORD OF THE POINTER
&

	REPEAT	0,<
GETBLK:	PUSH	P,A		;SAVE THE TABLE INDEX
	TRZ	F,FR.PDB	;CLEAR PDB DATA FLAG
GETBL0:	HRL	A,J		;VALUE WISHED
	PUSHJ	P,GET0		;GET DATA ON VALUE
	JRST	WRONG1		;DOES NOT EXIST INDEX OR TABLE
	JRST	ONEBY1		;GETTAB GETS THEM ONE BY ONE
	TRZN	F,FR.PDB	;PDB DATA??
	JRST	GETBL1		;NO DO A BLT
	MOVE	A,(N1)		;GET THE WORD
	JRST	STORE1		;AND SAVE IT
GETBL1:	MOVE	A,N1		;LAST ADDRESS TO GO
	SUB	A,J		;MINUS LENGTH GIVES FIRST
	HRL	A,0(C)		;GET THE TARGET ADDRESS
	MOVSS	A		;GET THINGS IN THE RIGHT PLACE
	BLT	A,@0(C)		;GET THE TABLE COMPLETELY
TPOPJ:	POP	P,A		;RESTORE ACCU
	POPJ	P,

ONEBY1:	CALLI	A,CI.GET	;GET THE VALUE
WRONG1:	SETZ	A,		;ZERO IF NOT THERE
STORE1:	MOVEM	A,@0(C)		;STORE THE ENTRY IN TABLE
	MOVE	A,(P)		;GET THE OLD A BACK
	SOJGE	J,GETBL0	;DO THE NEXT ENTRY
	JRST	TPOPJ		;RETURN WITH ACC A RESTORED
>
;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

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:	CALLI	A,CI.GET
	  POPJ	P,		;ERROR GETTAB NOT THERE
	JRST	CPOPJ1		;OK, RETURN

RNGOLD:	LDB	CH,[POINT 9,BP,8]	;GET TABLE LENGTH
	TLNE	BP,(GT.PRC)		;PROCES DATA
	AOS	(P)			;(YES) READY TO SKIP
	RETURN

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

CRLF:	MOVEI	M,[ASCIZ /
/]
MSG:	HRLI	M,(<POINT 7>)
MSG1:	ILDB	CH,M
	JUMPE	CH,CPOPJ
	PUSHJ	P,TYO
	JRST	MSG1

COLON:	MOVEI	CH,":"
	JRST	TYO
COMMA:	MOVEI	CH,","
	JRST	TYO

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

PAGRAT:	TRNN	F,FR.VMM	;VIRTUAL MEMORY??
	RETURN			;(NO) FORGET MESSAGE
	MOVEI	M,[ASCIZ /  VIRT.       PHYS.       PGR.  /]
	PJRST	MSG		;AND PRINT IT

;PRINT PAGING DATA FOR THE CURRENT JOB CONTAINED INJ
;BEFORE SWITCHING TO INLINE CODE THE FOLLOWING DATA IS COLLECTED
;1 GETAB SIZE OF LOW VIRTUAL SEGMENT,,SIZE OF HIGH VIRTUAL SEGMENT
;2 GETAB1 MAX VIRTUAL AND PHYSICAL LIMITS
;3 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:	CALL	VMHILO		;SET HIGH LOW VALUES FOR VM
	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
	HRRZ	N,@.PGR		;GET THE SIZE OF THE SEGMENTS
	LDB	N1,[POINT 9,N,18+8]	;EDIT 18 GET THE HISEG SIZE
	ANDI	N,777		;AND OUT ALL BUT LOW DATA
	HRL	N1,N		;MAKE IT A XWD FORMAT
	MOVEM	N1,GETAB	;GET SEGMENTS LIMITS
	JUMPE	N1,PGDAT0	;JOB IS NOT VIRTUAL
	HLRZ	N1,@.PGR	;GET PAGING RATE
	JUMPE	N1,PGDAT0	;CERTAINLY NOT PAGING
	CALL	CMPPGR		;COMPUTE PAGING RATE
PGDAT0:	.INL			;START INLINE PSEUDO CODE
	.PLD	GETAB		;PRINT LOWSEG SIZE
	.PLS			;SEPERATE WITH A PLUS
	.PRD	GETAB		;PRINT HISEG SIZE
	.LPA			;PRINT A LEFT PAREN
	.PLD	GETAB1		;PRINT MAXIMUM VIRTUAL
	.RPA			;AND A RIGHT PAREN
	.TAB			;SPACE 2 PRINTS
	.PLD	GETAB3		;PRINT LOW SEGSIZE
	.PLS			;PERIOD
	.PRD	GETAB3		;PRINT HIGH SEGSIZE
	.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:	TRNN	F,FR.VMM	;A VIRTUAL SYSTEM??
	RETURN			;FORGET THIS
;****TEMPORARY INACTIVE
;	MOVE	A,[6,,113]	;GET VALUE OF VMRMAX
;	CALL	GETZ		;GET THE VALUE
;	IMUL	A,FREAK		;GET SYSTEM LIMIT IN # PER SECOND
;	MOVEM	A,GETAB1	;STORE FOR PRINTING
	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

;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

MSGDEC:	PUSHJ	P,MSG
	JRST	DECPRT

SIXDEC:	PUSHJ	P,SIXBP
	JRST	DECPRT

;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
	PJSP	M,MSGDEC	;PRINT DEC. POINT & FRACTION
	ASCIZ	/./
;SUBROUTINE TO PRINT JIFFY TIME TO NEAREST TANTH 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

;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

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
	POPJ	P,
	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,

TYCR:	MOVEI	CH," "
	PUSHJ	P,TYO		;CLEAR REMAINDER OF LINE
	SKIPL	COL
	JRST	TYCR
	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
	MOVEM	T1,LTTEND
	MOVEM	T1,TABCTR
	JRST	CPOPJ1		;SKIP OVER INFO WORD
	SUBTTL	DISPLAY WINDOW SETTERS

;DISPALY INDEPENDENT WINDOW OPERATIONS
;WNDJOB SETS THE WINDOW FOR THE JOB AREA ON THE SCREEN
;WNDHSG SETS THE WINDOW FOR HIGH SEGMENT INFORMATION
;WNDSYS SETS THE WINDOW FOR SYSTEM INFORMATION
;WNDDEV SETS THE WINDOW FOR DEVICE INFORMATION
;E ND OF SETTERS FOR JOB NORMAL

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


WNDHSG:	TRNN	F,FR.VMM	;VM THERE ??
	JRST	WNDHS0		;(NO) THEN ANOTHER SCREEN

;THIS IS UNUSED NOW WAIT FOR FINAL SCREEN DEFINITION
	CHANGE	52,XSIZE,6,NDEVYS-1,3,TABV2
	RETURN
WNDHS0:	CHANGE	41,55,9,NDEVYS-1,3,TAB2
	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,1,8,0,TAB1
	RETURN

WNDDEV:	CHANGE	41,50,NDEVYS,YSIZE,2,TAB3
	RETURN
IFN V.DISP-V.DVBX,<
DPYOUT:	SKIPE	CCIOPC
	POPJ	P,
	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/]
	CALLI	T1,CI.DEV
	JUMPN	T1,OPNTT1
	MOVSI	T1,NRMDEV
	CALLI	T1,CI.DEV
	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

	COMMENT	\	;MAYBE USEFUL SOMEDAY
TCKTM0:	IDIV	A,TCKSEC
	IDIVI	A,^D60*^D60
	JUMPE	A,TCKTM1	;JUMP IF .LT. 1 HOUR
	IMULI	A,^D60*^D60		;GET # OF MINUTES REPRESENTED BY HRS.
	ADD	B,A		;  & ADD TO MINUTES
	CAIGE	B,^D100*^D60		;TEST FOR TIME .GE. 100 MINUTES
	JRST	TCKTM1		;  NO, GO SHOW IT
	PUSHJ	P,TWOAST	;CAN'T DISPLAY TIME .GE. 100 MINUTES
	PUSHJ	P,COLON
TWOAST:	PUSHJ	P,ONEAST	;CALL TO WRITE ONE '*'
ONEAST:	MOVEI	CH,"*"		;GET CHARACTER CONSTANT
	PJRST	TYO		;WRITE IT & RETURN
\	;END OF COMMENT MAYBE USEFUL SOMEDAY

TCKTIM:	IDIV	A,TCKSEC	;JUNK JIFFIES
	IDIVI	A,^D60*^D60
	MOVE	N,A
	PUSHJ	P,DECPR2
	PUSHJ	P,COLON
TCKTM1:	IDIVI	B,^D60
	MOVE	N,B
	PUSHJ	P,DECPR2
	PUSHJ	P,COLON
	MOVE	N,C
DECPR2:	MOVEI	CH,60
	CAIG	N,11
	PUSHJ	P,TYO
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

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)
	PUSHJ	P,DECPR2
	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

;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
XDVLST:	XWD	14,11
XCORMX:	XWD	10,12
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
BASICAALLY THERE ARE TWO TYPES OF TABLES:
1 TABLES IN THE SPY SEGMENT
2 TABLES IN SYSDPY CORE
THE TABLES ARE DESCRIBED BY THREE FIELDS IN THE LEFTHALF POINTER
OF THE TABPTR ENTRIES.THESE FIELDS ARE ADDRESSED BY 3 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
3 PTABLE AN INDEX OF THE TABLE FOR GETTAB UUOS
NOTE: THE SIZE OF BOTH IS ONPURPOSE 2,THIS SATISFIES OLD SIGN TESTS
	&

LSEGN==200000
LJOBN==0
LBOTH==400000
SPYTAB==1


PSIZE:	POINT	2,(D),1
PSPY:	POINT	1,(D),2
PTABLE:	POINT	9,(D),17

TABLE:	XWD	LJOBN,.DVIOS
	XWD	LJOBN,.TTY
TABPTR:	XWD	LBOTH+SPYTAB+0,.STS
	XWD	LBOTH+SPYTAB+1,.ADR
	XWD	LBOTH+SPYTAB+7,.SWP
	XWD	LBOTH+SPYTAB+2,.PPN
	XWD	LJOBN+SPYTAB+4,.TIM
	XWD	LJOBN+SPYTAB+14,.SGN
	XWD	LBOTH+SPYTAB+3,.PRG
	XWD	LJOBN+SPYTAB+114,.PGR
NTAB==.-TABPTR
	XWD	LSEGN,.SEGCT

NTABLE=.-TABLE

.DVIOS:	XWD	J,0		;L
.TTY:	XWD	J,0		;L
.STS:	XWD	J,0		;L+H
.ADR:	XWD	J,0		;L+H
.SWP:	XWD	J,0		;L+H
.PPN:	XWD	J,0		;L+H
.TIM:	XWD	J,0		;L
.SGN:	XWD	J,0		;L
.PRG:	XWD	J,0		;L+H
.PGR:	XWD	J,0		;L PAGING RATE TABLE
.SEGCT:	XWD	A,0		;H

CORSAV:	0

TAB0:	DEC	4,12,16,23,26,32	;FOR JOB DISPLAY
TABV0:	DEC	4,12,16,23,35,47,55,61
TAB1:	DEC	56			;FOR HEADING
TAB2:	DEC	48,51,54,65,68,71	;FOR HISEG DISPLAY
TABV2:	DEC	59,62,65,76,79,82
TAB3:	DEC	46,49,57,60,68,71	;FOR DEVICE DISPLAY
TAB4:	DEC	15,21,28,35,42,49,56,63,70	;FOR FILE SYSTEM DISPLAY

TAB5:	DEC	10
TAB6:	DEC	12,35,40,45,50,55,60,65,70
TAB7:	DEC	8,16,24,32,40,48,56,64,72
TAB8:	DEC	44,52,60,68,76
BPTAB:	POINT	9,DBUF,8
	POINT	9,DBUF,17
	POINT	9,DBUF,26
	POINT	9,DBUF,35

;MORE MONITOR INTERFACE

PJOBN:	POINT	7,C,6
NPJOBN:	EXP	0	;IF NONZERO THEN JOB NO SITS IN DEVJOB
			;AND THIS WORD CONTAINS A BYTE POINTER
			;TO THE JOB FIELD IN 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	;GT.PDB PDB DATA

SPYGET:	EXP	RNGOLD	;ADDRESS OF SPY ROUTINE FOR NUMTAB

TPCJOB:	POINT	8,B,10
IMGOUT:	POINT	9,@.SWP,26
IMGIN:	POINT	9,@.SWP,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 .SEGCT 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

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


;TEMPORARIES

PDP:	XWD	-20,.
ZER:!		;START OF AREA TO ZERO
	BLOCK	21

;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

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
CPU:	0			;CPU NUMBER FOR RESPONSES(0,1)
UPTIME:	0			;UPTIME OF SYSTEM IN JIFFIES

THED:	BLOCK	3

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

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

CORUNL:	0		;AMOUNT OF UNLOCKED CORE
CORMAX:	0
SEGPTR:	0
CORUSE:	0
DSKUSE:	0
TISL:	0			;RUN QUEUE INDICES FOR TI & SL
ACTUSE:	0			;TOTAL CORE WITH ACTIVE JOBS

FREE:	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
TNFRTY:	0		;0 IF TEN-FIFTY SYSTEM, -1 IF TEN-FORTY
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
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

;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
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
ONEJOB:	Z			;NON ZERO IF A SPECIFIC JOB REQUESTED

LZER==.-1

	LIT

IF1,<PRINTX END OF PASS 1 SYSDPX>
	END	SYSDPY