Google
 

Trailing-Edge - PDP-10 Archives - dec-10-omona-u-mc9 - systat.mac
There are 8 other files named systat.mac in the archive. Click here to see a list.
	SUBTTL R CLEMENTS /CHW/TNH/PFC/RCC/CMF/SML/JMF/TCK/JNG/JMT/PMW 10 MAR 77
VSYSTAT==473
VEDIT==215
VMINOR==00
VWHO==0


;*** COPYRIGHT 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977
;BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS. ***

DEFINE	.TITL(VMAG,VMIN)<
TITLE	SYSTAT -- PRINT SYSTEM STASTICS -- V VMAG(VMIN)
>
	.TITL	(\VSYSTAT,\VEDIT)

;EDIT HISTORY

;EDIT LEVEL 27  TO LEVEL 30

;EDIT #1
;SY P PRINTED WRONG NUMBER OF FREE BLOCKS 

;EDIT LEVEL 30 TO LEVEL 31

;EDIT #2

;THE NUMBER OF EXTENDED READ AND WRITES IS WRONG FOR A MONITOR
;WITH FTVM OFF

;EDIT #3

;ONLY PRINT FANCY RESPONSE DATA WHEN FTRSP IS ON

;EDIT #4

;NO NEW ACCESSSES ALLOWED IS PRINTED ON VM MONITORS
;FOR RANDOM FILE STRUCTURES WHENEVER SYS IS TYPED,SYS F IS OAKY

;EDIT #5

;SPOOLED DEVICES SHOULD BE LISTED ON THE OPERATOR SYSTAT LIST
;FLAGGED WITH A ' SIGN .THIS DID NOT HAPPEN AS SPOOLED DEVICES
;DO NOT HAVE DVDSK ON IN DEVMOD DDB ENTRY.SO USE THE PROPER FLAG
;IN DEVSPL DDB ENTRY

;EDIT #6

;REPORT OF SWAPPING SPACE LOST IS TOO HIGH 3 MORE BITS HAVE TO BE
;ZEROED IN DATA PRINTED

;EDIT #7

;ONE MORE OCCURRENCE OF A WRONG UDB INDEX FOR VM SYSTEMS

;EDIT #8

;WARN USERS THAT NO OPERATOR IS ON DUTY (SPR 10,12,962)

;EDIT #9

;ADD P OR K TO AVERAGE SIZE PRINT OUT

;EDIT 10

;IF CONTROL C INTERRUPT THEN DO NOT TYPE HACK TABLE ENTRY BUT EXIT

;EDIT 11

;LOGICAL NAMES OF JOB ONER ARE NOT DISPLAYED

;EDIT 12

;SYS LEF PRODUCES AN EMPTY FILE

;EDIT 13

;SYS ...... MAKES SYSTAT GROW

;EDIT 14

;THE RIGHT TO WRITE SYSTAT.TXT IS NOT CHECKED

;EDIT 15

;/X BROKE DUE TO EDIT 13 RESET UUO!

;EDIT 16

;SPOOLING A CONTINUOUS SYSTAT TEXT RESULTS IN I/O TO AN UNASSIGNED CHANNEL
;DUE TO EDIT 12

;EDIT 17

;REENTER OPTION WAS BROKEN

;EDIT 18

;SYS XL FILE SPEC CAUSED THE MESSAGE CAN'T GET AT THAT FILE
;MAKE SYSTAT MORE CLEVER.

;EDIT 19

;SYSTAT CAN EAT TYPE AHAED 

;EDIT 20

;LOW SEGMENT SIZE OF PROGRAMS WITH SHARABLE
;HISEG IS WRONG

;EDIT 143

;MAKE EDIT NUMBER EQUAL REVISION HISTORY.
;USE C AS A UNIVERSAL.

;EDIT 144

;RESTRICT SYSTAT L WHEN NOT-LOGGED-IN TO LOCAL TTYS OR SUBJOBS OF
;PROJECT 1. [10-13028]

;EDIT 145

;MAKE SYSTAT EASIER TO ^C, AND ALLOW CONTINUES IF LOGGED IN.

;EDIT 146

;CLEAR .UXTRM OFFSET FROM A GETLCH TO AVOID "SY ." PROBS. [14434]

;EDIT 147

;SHOW BUSY DEVICES WHEN WILD PPN REQUESTED [10-14317]

;EDIT 150

;ALLOW COMMENTS ON THE SYSTAT COMMAND LINE [10-14543]

;EDIT 151

;FIX "SYSTAT OCL", BROKEN BY EDIT 145

;EDIT 152

;STARTING WITH LOAD 722 KNOW OF NEW NUMTAB FORMAT

;EDIT 153

;BELIEVE IN NEW DDB ENTRY DEVJOB FOR 722

;EDIT 154

;UPDATE DEVFIL PART OF DDB'S TO USE LENGTH OF SHORT DDB'S

;EDIT 155

;USE TRMNO. UUO FOR NON TOPS10 MONITORS,WHICH KNOW THE TRMNO.

;EDIT 156

;THE SEQUENCE : .ASS DSK LPT   SYS /L/X
;GIVES AN ILLEGAL UUO

;EDIT 157

;REPLACE ALL DDB OFFSETS BY A SYMBOL DV.XXX TO PREVENT DUPLICATING
;OF UUO NAMES

;EDIT 160

;NEVER USE A ZERO UPTIME TO COMPUTE PERCENTAGES

;EDIT 161

;DISK ERRORS ARE REPOTED WRONG FOR A CRASH FILE

;EDIT 162

;PRINT SYSTEM HEADER ASAP ON A /X AS THIS SAVES CONSIDERABLE
;TIME IF ONE LOOKS AT THE WRONG CRASH

;EDIT 163

;SUBTRACT THE MONITOR HIGH SEGSIZE FROM THE CORE SIZE

;EDIT 164

;ADD SUPPORT FOR READING EXE CRASHES

;;EDIT 166	(16236)

;;ADD SWAPPING SPACE LOST MESSAGE
;;AREAS AFFECTED: MUS3

;EDIT 167  (16461)

;INCREASE REMOTE STATION LOOP RESTRICTION

;edit 170  (15261)

;typing continue after running systat gives a logged in user the
;message "kjob"

;edit 171

;thisis uses the variable date to print the date this varible is 
;not initialized on a sys x command

;edit 172

;the vlalue of unixra was changed in 602 causing extended writes
;and reads column to be wrong

;edit 173

;ignore all structures and packs with zero mount count pack not mounted
;pack off line and zero reads and writes

;EDIT 174

;MAKE SYSTAT X GIVE ERROR MESSAGE FOR NON-DISK DEVICES

;EDIT 175

;USE UNIVERSAL JOBDAT FILE

;EDIT 176

;REMOVE SYSTEM 124 FROM IN-HOUSE LIST; IT'S BEEN SOLD.

;EDIT 177

;MAKE /X GIVE PROPER TIME FOR 50HZ COUNTRIES

;EDIT 200

;MAKE CONTINUOUS SYSTATING REMEMBER THE ARGUMENTS GIVEN IN
;THE COMMAND. THE COMMAND LINE IS NOW READ INTO A BUFFER SO
;THE COMMAND CAN BE REREAD ON EACH PASS THROUGH.

;EDIT 201

;TIME CALCULATION @ERRLY1 USES DECIMAL 60 EXPLICITLY RATHER
;THAN TCKSEC, THUS 50 HZ. COUNTRIES GET BAD TIMES !

;EDIT 202

;SYSTAT E TRIES TO DETERMINE STOPCD TYPE BY FOLLOWING ADDRESS
;IN %SYSPC. UNFORTUNATELY THIS PRODUCES AN ?ILL MEM REF IF
;SPYING SINCE %SYSPC POINTS INTO HIGH SEGMENT OF MONITOR.
;MAKE IT DO A PEEK INSTEAD FOR THE RUNNING MONITOR AND ONLY
;PRINT STOPCD NAME FOR A CRASHED MONITOR.

;EDIT 203

;THIS EDIT CHANGES THE ROUTINE GETFIL TO USE FILOP. TO OPEN
;THE CRASH FILE ON A .SYS X SO THAT PRIVILEGE CHECKING FOR
;FILE ACCESS IS DONE CORRECTLY. PREVIOUSLY A CHKACC WAS PERFORMED
;WHICH CORRECTLY CHECKED THE FILES PROTECTION, HOWEVER IT DOESN'T
;CHECK THE UFD PROTECTION. IN FACT, THERE IS NO CHKACC FUNCTION TO
;SEE IF ACCESS TO FILES IN A UFD IS ALLOWED. IF THE FILOP. IS NOT
;IMPLEMENTED, THE FORMER METHOD WILL BE USED, AND ONLY THE FILE
;PROTECTION WILL BE CHECKED BEFORE ALLOWING ACCESS.

;EDIT 204

;MAKE SYSTAT REPORT "TIMESHARING IS OVER" WHEN IT CHECKS
;KSYS AS IT DOES WHEN IT REPORTS "TIMESHARING WILL END IN ...".

;EDIT 205

;WHEN DOING .SYS F  DON'T PRINT BLANK STRUCTURES.
;EDIT 206

;BUSY DEVICE INFORMATION ON SYSTATS OF CRASHED MONITORS IS
;INCORRECT IF THE DDB FORMAT OF THE CRASHED MONITOR IS DIFFERENT
;THAN THAT OF THE RUNNING MONITOR.
;ON SYSTATS OF CRASHED MONITORS, THE MONITOR VERSION SHOULD BE GOTTEN
;FROM THE CRASH FILE. ITS NOW GOTTEN FROM THE RUNNING MONITOR BECAUSE
;IT IS DETERMINED AT INITIALIZATION TIME BEFORE WE KNOW WHETHER
;THIS IS A .SYS X OR A SYSTAT OF THE RUNNING MONITOR.  ALSO,
;FOR THE SAME REASON WHEN DETERMINING THE DISK DDB SIZE AND
;BUILDING THE DDB POINTERS, THE VALUE IS GOTTEN FROM THE RUNNING
;MONITOR RATHER THAN FROM THE CRASH FILE.
;AREA AFFECTED: DSKJN1

;EDIT 207

;EDIT #200 BROKE THE REENTER FEATURE OF SYSTAT SUCH THAT IF
;YOU TYPED REENTER, SYSTAT WOULD CONTINUALLY LOOP. THIS IS
;BECAUSE THE INPUT BUFFER IS NEVER CLEARED AFTER READING
;COMMAND INTO BUFFER.
;AREA AFFECTED: RDCMND

;EDIT 210
;IF PAGED OUTPUT IS REQUESTED, YOU TYPE ^C AS RESPONSE TO THE
;PROMPT, AND YOU'RE NOT LOGGED IN, THE "KJOB" MESSAGE IS NOT TYPED.
;AREA AFFECTED: HICCUP

;EDIT 211
;ADD STATISTICS REPORT FOR DUAL PORTED RPO4'S

;EDIT 212
;FIX SHORT DDB PROBLEM  [.DVDAT, DEVLP]



;EDIT 213
;FIX TYPE-AHEAD PROBLEM CAUSED BY EDIT 207'S FIX TO EDIT 200


;EDIT 214  /PMW  10 MAR 77
;IN RDCMND
;TEST FOR FULL INPUT BUFFER

;EDIT 215  /PMW  10 MAR 77
;AT GETFIL+1
;MODIFY EDIT 203 <USE FILOP. FOR CRASH.EXE> TO USE PRIVILEGED FILOP.
;SO [1,2] AND JACCT JOBS  GET FULL ACCESS.
;C FILE SYMBOLS WHICH ARE OVERRIDDEN

%FTDEB==5,,71		;WRONG IN OLD C FILE
F%RSP=1B28		;RESPONSE TIME FEATURE

;PRINTS ON SYSTAT:SYSTAT.TXT  OR  TTY:SYSTAT.TXT

SALL

	SEARCH	JOBDAT,C	;[143] GET STANDARD SYMBOLS
	LOC	.JBVER
	BYTE	(3)VWHO(9)VSYSTAT(6)VMINOR(18)VEDIT
RELOC


;AC ASSIGNMENTS

F=0
A=1
B=2
C=3
D=4
J=5
JS=6
R=7
N=10
N1=11
M=12
CH=13
BP=14
WD=15
P=17

;I/O CHANNEL

HLP==0	;CHANNEL 0 IS RESERVED FOR HELPER
TTY==1	;FOR OUTPUT
DSK==2	;FOR READING DSK:CRASH.XPN

;ASSEMBLY OPTIONS

IFNDEF PURESW,<PURESW==0>	;SHARABLE
IFNDEF LN.PDL,<LN.PDL==20>	;LENGTH OF PUSH-DOWN LIST
IFNDEF LN.BUF,<LN.BUF==200>	;LENGTH OF DISK BUFFER
IFNDEF STANSW,<STANSW==0>	;PPN IS ALWAYS SIXBIT
IFNDEF HACKSW,<HACKSW==-1>	;INCLUDE HACKS (IF -1, JUST FOR LISTED SYSTEMS)
IFNDEF JIFSEC,<JIFSEC==^D60>	;JIFFIES/SEC (IN CASE MONITOR REFUSES TO TELL US)
IFNDEF NSPMEM,<NSPMEM==^D1000>	;N-SEC/MEMORY CYCLE(IN CASE MONITOR REFUSED TO TELL US)
IFNDEF HIDPPN,<HIDPPN==0>	;HIDE DETACHED JOBS PPN
IFNDEF NCPUS,<NCPUS==^D2>	;NUMBER OF CPUS IN THE SYSTEM
IFNDEF FTAMPM,<FTAMPM==-1>	;-1=FORCE 24 HR. CLOCK, +1=FORCE AM/PM,
				; 0=MAKE FOLLOWING DUBIOUS ASSUMPTION:
;50 HZ POWER LINE MEANS USE 24 HR TYPEOUT, 60 HZ MEANS USE AM/PM

IFNDEF	FTEXE,<FTEXE==1>	;SUPPORT FOR EXE FILES
IFNDEF FTDEBUG,<FTDEBUG==0>	;-1 TO ENABLE SYSTAT TO BE DEBUGGED
;FTDEBUG ALLOWS COMMANDS OF THE FORM "START ;ARG" TO PASS
; "ARG" TO SYSTAT.  ALSO INCLUDES PATCH AREA.
;
;NOTE:  TO DEBUG WITH BREAKPOINTS VIA DDT, TYPE 
;  "HALT$X".  THIS WILL SET THE BREAKPOINTS AND TRAP
; TO THE MONITOR.  THEN TYPE "START ;ARGS"

;TO COPE WITH OLD C FILES THE NEXT 2 SYMBOLS ARE DEFINED

%CNST2==106,,11
ST%VMS=1B33
;COMMANDS

L.BDO=="B"	;B WAS TYPED  BUSY DEVICES
L.DSO=="D"	;D  "    "    DORMANT SEGMENTS
L.FSO=="F"	;F  "    "    FILE STRUCTURES
L.GSS=="G"	;G  "    "    GENERAL SYSTEM STATISTICS
L.DPO=="P"	;P  "    "    PERFORMANCE OF DISKS
L.SSO=="S"	;S  "    "    SHORT JOB STATUS
L.JSO=="J"	;J  "    "    JOB STATUS
L.EJS=="N"	;N  "    "    ALL BUT JOB STATUS
L.LPT=="L"	;L  "    "    LIST ON LPT
L.HSO=="H"	;H  "    "    HELP
L.RSO=="R"	;R  "    "    REMOTE STATION STATUS
L.DSC=="T"	;T  "    "    DATA SET STATUS (TTY)
L.ERR=="E"	;E  "    "    ERROR REPORTS (NON-DISK)
L.DSK=="X"	;X  "    "    READ FROM DSK:CRASH.XPN
L.MYJ=="."	;.  "    "    MY JOB ONLY
L.DPY=="V"	;V  "    "    VT05 OR VT06 USER...TYPE 20 LINES AT A TIME & WAIT 
L.CNT=="C"	;C  "    "    CONTINUOUS TO SAME FILE
L.GOD=="O"	;O  "    "    GODLY POSSESSOR OF SECRET CHARACTER
L.WLD=="*"	;*  "    "    PPN WILD CARD

;FLAGS (LH OF F)

FL.DSK==1	;DISK MODE
FL.HGH==2	;HIGH SEG PARAGRAPH NEEDED
FL.GOD==4	;I AM [1,N]
FL.LGI==10	;I AM LOGGED IN
FL.DTJ==20	;THIS JOB DETACHED
FL.DOR==40	;DORMANT SEG TABLE BEING PRINTED
FL.SCN==100	;NEW SCANNER SERVICE (FOR TTYTAB LAYOUT)
FL.DEV==200	;HEADER OUTPUT SYNC
FL.NUM==400	;IF # PRINTED
FL.NST==1000	;IF @ PRINTED
FL.SZR==2000	;SUPPRESS ZEROES
FL.BZR==4000	;BLANK OUT ZEROES
FL.HSG==10000	;WORKING ON HIGH SEGMENT
FL.LPT==20000	;LIST ON LPT
FL.RPT==40000	;REPEATING, WAITING FOR LPT
FL.EXM==40000	;IF ! PRINTED (DURING RUN)
FL.AMP==100000	;IF & PRINTED
FL.NBK==200000	;NON-BLANK LINE
FL.BRK==SIGN	;NO MORE CHS. TO I/P OR BREAK CH. SEEN

;FLAGS (RH OF F)

FR.OVR==1B35	;COLUMN OVERFLOW
IFGE  FTAMPM,<
FR.DAY==1B34	;DO TIME AS TIME OF DAY (AM/PM)
>
FR.XOM==1B33	;IF $ PRINTED
FR.HPQ==1B32	;IF HPQ # PRINTED
FR.NFS==1B31	;IF UNIT NOT IN A F/S
FR.NFP==1B30	;IF "UNIT-NOT-IN-AN-F/S" MESS NOT PRINTED
FR.CNT==1B29	;WE ARE DOING A CONTINUOUS SYSTAT
FR.DPY==1B28	;PAGE HIS OUTPUT....HE HAS A DISPLAY
FR.END==1B27	;WE HAVE BEEN THOUGH THE CONT. THING BEFORE
FR.CHG==1B26	;THIS IS NEW OR RE-LOGIN FOR JOB
FR.LGN==1B25	;SOME NEW LOGIN THIS PASS
FR.VMF=1B24	;THE VM FEATURE IS SUPPORTED
FR.INI==1B23	;THE TTY CHANNEL IS OPEN
FR.DSK==1B22	;OUTPUT IS TO A DISK FILE
FR.CMT==1B21	;[150] A COMMENT HAS BEEN SEEN
FR.EXE==1B20	;EXE MODE
;STUFF WHICH HAS TO AGREE WITH MONITOR, ASIDE FROM GETTAB DEFNS

ABSTB1==151	;OLD VALUE OF ABSTAB, POINTER TO NUMTAB
ABSTB2==410	;NEW VALUE OF ABSTAB AFTER 503+ MONITOR
JBTLOC==26	;TABLE FOR JOB LOCATIONS
STBSTS==2	;WORD IN STATION DATA BLOCK FOR STATUS
CMWB==200000	;COMMAND WAIT IN JOB STATUS TABLE
JNA==40000
JLOG==4
JDCON==20000	;JOB WAITING FOR DEVICE TO BE READIED
JDC==100000	;JOB WAITING FOR DCORE OR DUMP COMMAND
ASSCON==400000
ASSPRG==200000
SNA==400000
NSWP==10000		;NON-SWAPPABLE IN LH JBTSTS
JSWP==2000
NSHF==1000		;NON-SHUFFLABLE IN LH JBTSTS
CLKR==1B18		;JOB HAS A CLOCK REQUEST IN
JS.XO==1B25		;EXECUTE ONLY BIT IN RH OF JOB STATUS
SHRSEG==200000
CLKCYC==1B6		;CLOCK CYCLES (1=50 HERTZ)
CANXRC==1B13		;EXTENDED RIBS (1=MONITOR CAN READ/WRITE THEM)
GT.PRC==1B9		;BIT IN NUMTAB ENTRY MEANING DATA IN PDB
GT.PDB==4		;PDB ENTRY IN NUMTAB

IOIMPM==400000
IODERR==200000
IODTER==100000

DV.NAM==0
DV.CHR==1
DV.IOS==2	;DEVICE STATUS
DV.SER==3
DV.MOD==4
DV.LOG==5	;LOGICAL DEVICE NAME
DV.SPL==12	;SPOOL DATA
DV.JOB==16	;SINCE LOAD 722
;THE NEXT 3 SYMBOLS WERE INCREASED STARTING WITH MONITOR
;VERSION 50634
;THE SYMBOLS WERE CHANGED SINCE LOAD 722 TOO
DV.FIL==15	;FILE NAME IF DISK
DV.EXT==16	;FILE EXTENSION IF DISK
DV.PPN==17	;P,PN IF DISK
DV.UNI==23	;UDB POINTER IF DISK
;STARTING WITH VERSION 507 DDBLDB CAN BE OBTAINED WITH GETTAB 
DDBLDB==11	;LINK TO LDB IF NEW SCNSER
;SEE ALSO PJOBN AND TPCJOB

;PARAMETERS

SIGN=400000
DVDSK==200000
DVTTY==10
DVTTYC==20000	;TTY IN USE AS CONSOLE
OUTMSK==377000
UU.PHS==1B19		;PHYSICAL ONLY  BIT

MLON

OPDEF	PJRST [JRST]
OPDEF	DEVNAM	[CALLI	64]
OPDEF	CHKACC [CALLI 100]

DEFINE	BOMB(A),<JRST	[JSP	M,BOMB.
			ASCIZ	\A\]>
DEFINE	CALL(R)
<	PUSHJ	P,R
>
DEFINE	RETURN
<	POPJ	P,
>
;STR DATA BLOCK

STRNAM==0
STRSYS==1
STRUNI==2
STRTAL==11
STRMNT==13
STRJOB==20

;UNIT DATA BLOCK

UNINAM==0
UNILOG==1
UNIHID==2
UNISYS==3
UNISTR==4
UNISWP==7
UNIK4S==7	;RIGHT 12 BITS = K FOR SWAPPING
  MSKK4S==7777
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
;UNITA UNIDES AND UNIXRA ARE SINCE 50634 5 LARGER
UNITAL==47	;IN 503, 504
UNITL1==41	;UNITAL PRE 503
UNIDES==50	;IN 503,504 - BUT NOT IN 501
UNIDE1==42	;UNIDES PRE-503
  UNPZMT==10000
  UNPSAF==20000
UNIXRA==54
UNI2ND==72
;BITS IN REMOTE STATION STATUS

REMDWN==1B35	;REMOTE IS DOWN
REMNIC==1B34	;REMOTE IS NOT YET FULLY OPERATIONAL
REMLDG==1B33	;REMOTE IS LOADING
REMLDD==1B32	;REMOTE IS LOADED

;FIELDS IN DATA SET CONTROL TABLE

DSCSTS==7B2	;STATE OF DATA SET
DSCTIM==77B17	;TIMER FOR DATA SET

;ERROR INTERCEPT BITS

.ERMSG==1B0	;DON'T OUTPUT ERROR MESSAGE
.ERICC==1B34	;INTERCEPT CONTROL C


;EXE FILE DEFINITIONS

EXESIZ==^D512	;SIZE OF DIRECTORY

IFN	PURESW,<TWOSEG
		RELOC	400000>
	SUBTTL	INITIALIZATION
;START HERE

SYSTAT:	RESET			;CLEAR ALL I/O AND RESTORE CORE
	IFN	PURESW,<
	MOVE	A,[XWD HIGH,LOW]
	BLT	A,LOWEND-1
>
	MOVE	A,[XWD LOWEND,LOWEND+1]
	SETZM	LOWEND
	BLT	A,TEMEND
	SETZB	F,WD		;CLEAR WD FOR NORMAL SYSTAT O/P
	SKIPA
REENTR:	RESET			;REENTRY POINT
	TDZ	F,[FL.BRK,,FR.INI!FR.DSK!FR.CMT] ;[151] MARK RESET DONE
	SETZM	JOBINT+2	;[145] NO ^C TYPED YET
	MOVEI	A,SYSTAT	;SET REENTER POINT (RESET LATER)
	MOVEM	A,.JBREN	;SAVE IT
	SETOM	ONCE		;CLEAR ONCE THRU FLAG
	MOVEI	M,^D19		;PAGE SIZE LESS ONE FOR DISPLAYS
	MOVEM	M,LINECT	;RESET THE COUNTER
	MOVE	P,PDP		;SETUP STACK PNTR.

REPEAT 0,<
	OUTSTR	[ASCIZ /Systat V/]
	MOVE	N,.JBVER	;GET VERSION NUMBER
	PUSHJ	P,VERPRT	;TYPE IT TO USER
	PUSHJ	P,CRLF		;AND END LINE
>

	MOVE	A,XMNVER	;GET MONITOR VERSION
	CALL	GETZ		;GET VALUE IN A
	HRRZS	A		;ZAP NOISE BITS
	MOVEM	A,MONVER	;AND REMEMBER IT
	CAIGE	A,60122		;OLD STYLE IF LESS
	CAIGE	A,60000		;AN OLD MONITOR
	CAIGE	A,50722		;IF NOT VERSION 6 OR LATER
	JRST	SYSTA1		;OLD STYLE
SYSTA0:	SETOM	NEWSPY		;NEW SPY LOGIC
	MOVE	A,[POINT 9,C,35]	;NEW POINTER TO JOB NUMBER
	MOVEM	A,NPJOBN	;NEW JOB NUMBER POINTER
SYSTA1:	IFE	PURESW,<
	MOVE	A,XSYSSZ	;GET SIZE OF SYSTEM
	PUSHJ	P,GETA		;FROM THE MONITOR
	MOVEI	A,-1(A)		;(BACK UP ONE)
	SPY	A,		;AND TRY TO SPY
	  JRST	NOSPY		;CAN'T--USE GETTABS, ETC.
;NOTE THAT ALL SPY DATA WILL BE CHANGED BY SETDSK WHEN A SYSTAT
;OF A CRASHED MONITOR ISMADE
	SETOM	SPYFLG		;CAN--SET FLAG FOR PEEKS
	MOVE	A,XGTTBI	;SEE IF WE HAVE GETTAB IMMEDIATE
	PUSHJ	P,GETZ		; IN THIS MONITOR
	JUMPE	A,NOSPY		;IF NOT--STILL DO GETTABS
	HRRZM	A,OFSGTB	;YES--STORE OFFSET FOR PEEK VIA SPY
	LSH	A,-^D9		;POSITION LENGTH OF TABLE
	HLRZM	A,MAXGTB	;AND STORE FOR SIMULATOR
	MOVE	A,XPDBPT	;POINTER TO JBTPDB
	PUSHJ	P,GETZ		;GET IT IF IT EXISTS
	SKIPE	A		;IF IT DOES,
	TDO	A,[XWD A,400000]	;MAKE POINTER FOR INDIRECTING AND INDEXING
	MOVEM	A,PDBPTR	;STORE FOR LATER
>
NOSPY:	MOVE	A,[XWD 4,FINIS]	;SETUP TO INTERCEPT CONTROL C
	MOVEM	A,JOBINT
	MOVE	A,[EXP .ERMSG+.ERICC]
	MOVEM	A,JOBINT+1
	MOVEI	A,JOBINT
	HRRM	A,.JBINT
	PJOB	A,		;GET MY JOB NUMBER
	MOVEM	A,MYJOB
	HRROI	A,0		;MY STATUS
	PUSHJ	P,GETA
	HRROI	B,2		;MY PPN
	PUSHJ	P,GETTB
	  JRST	GODLY		;NON DISK SYSTEM-FLAG AS GODLY
	TLNE	A,JLOG		;LOGGED IN?
	TLO	F,FL.LGI	;YES-REMEMBER IT
	TLNN	B,-2		;PROJECT 1?
	TLNN	A,JLOG		;YES-LOGGED IN?
	SKIPA			;NO
GODLY:	TLO	F,FL.GOD	;WE'RE GOD
	TLNN	F,FL.LGI	;ARE WE LOGGED IN?
	SETZ	B,		;NO--CLEAR OUR NUMBER
	MOVEM	B,ME		;SAVE FOR FUTURE TESTS

	RESCAN	1		;RESET INPUT BUFFER
	SKPINC			;SEE IF ANYTHING THERE
	TLO	F,FL.BRK	;NO--SET FLAG
; [200] @GODLY+6 1/2, JMT, 3-MAR-76
	PUSHJ	P,RDCMND	;[200] YES--READ COMMAND INTO BUFFER

	SETOM	TTYFLG		;ASSUME OLD TOPS10 LINE LOGIC
	MOVE	A,[%CNMNT]	;GET MONITOR VERSION
	CALL	GETZ		;SEE IF KNOWN
	JUMPE	A,.DVDAT		;GET DEVICE DATA
	LDB	A,[POINT 6,A,23];GET MONITOR TYPE
	CAIN	A,1		;IT WAS TOPS10?
	JRST	.DVDAT		;I TOLD YOU
	MOVE	A,MYJOB		;GET MYJOB NUMBER
	SETZM	TTYFLG		;ASSUME NOT SUPPORTED
	TRMNO.	A,		;TRY TO GET UDX OF TTY
	JRST	.DVDAT		;COULD NOT GET IT
	AOS	TTYFLG		;HE KNOWS OUR UUO'S
	MOVSI	A,(SIXBIT /CTY/);GET INDEX OF CTY
	IONDX.	A,		;GET INDEX OF CTY
	SETOM	A		;NEVER MATCH IN THIS CASE
	MOVEM	A,CTYNDX	;AND REMEMBER IT
.DVDAT:	MOVE	A,[%CNLSD]	;GET LENGH OF SHORT DDB
	CALL	GETZ		;GET A ZERO OR VALUE
	JUMPE	A,COMND		;UNKNOWN
	HRRM	A,.DVFIL	;UPDATE POINTER
	SUBI	A,1		;[212] BACK UP 1
	HRRM	A,.DVJOB	;[212] AND GET THIS FOR LATER
	ADDI	A,2		;[212 ADD 2 NOT 1] EXTENSION POINTER
	HRRM	A,.DVEXT	;UPDATE 
	ADDI	A,1		;PPN POINTER
	HRRM	A,.DVPPN	;UPDATE THAT TOO
	ADDI	A,DV.UNI-DV.PPN	;POINT TO UNIT ENTRY INDISK DDB
	HRRM	A,.DVUNI	;UPDATE UNIT POINTER
	SUBTTL COMMAND DECODING
COMND:	PUSHJ	P,GETCHR	;INPUT A CH.
	  JRST	NOGO		;NO CHS. LEFT OR A BREAK CH.
	CAIG	WD,"Z"
	CAIGE	WD,"A"		;IGNORE ALL NON-ALPHABETIC CHS.
	JRST 	COMND
IFE FTDEBUG,<
	CAIE	WD,"S"		;IGNORE FIRST WORD UNLESS IT BEGINS WITH S
	JRST	NOGO
>
COMND1:	PUSHJ	P,GETCHR	;GET CHARACTERS OF WORD
	  JRST	NOGO		;JUMP IF END OF LINE
	CAIG	WD,"Z"		;SKIP UNTIL NO ALPHAS
	CAIGE	WD,"A"		; ..
	JRST	AGAIN1		;DONE--CHECK SEPARATOR
	JRST	COMND1		;NO--LOOP
AGAIN:	PUSHJ	P,GETCHR	; 2ND. TIME AROUND LOOK FOR 1ST. CH. NOT A SPACE
	  JRST	NOGO		;NO CHS. LEFT OR A BREAK CH.
AGAIN1:	TLNE	F,FL.DSK
	CAIE	WD," "
	SKIPA
	JRST	NOGO
	CAIE	WD," "		;SKIP SPACES
	CAIN	WD,","		;AND COMMAS
	JRST	AGAIN		; ..
IFN FTDEBUG,<
	CAIE	WD,";"		;SKIP SEMICOLON
>
	CAIN	WD,"/"		;SKIP SLASH
	JRST	AGAIN		; ..
	JRST	.+2
NOGO:	MOVEI	WD,0		;CLEAR WORD IF NOT "SYSTAT" COMMAND
	CAIN	WD,L.DSK	;SEE IF CRASH FILE REQUESTED
	JRST	[TLO F,FL.DSK
		 JRST AGAIN]

;HERE TO INIT THE DEVICE AND ENTER THE FILE

	CAIN	WD,L.DPY	;IS THIS A DISPLAY?
	JRST	[TRO	F,FR.DPY	;REMEMBER IT
		JRST	AGAIN]
	CAIN	WD,L.CNT	;DO IT OVER AND OVER AND OVER?
	JRST	[TRO	F,FR.CNT	;REMEMBER IT
		JRST	AGAIN]
	CAIE	WD,L.GOD	;IS HE GODLY ANYWAY?
	JRST	SYSINI		;NO GET DEVICE
	TLO	F,FL.GOD	;HE KNEW THE SECRET THING
	JRST	AGAIN
	SUBTTL	COMMAND DISPATCH AND SET UP
SYSINI:	PUSH	P,F		;SAVE CURRENT F
	TLZ	F,FL.DSK	;TURN DISK USAGE OFF
	CALL	GETTTY		;MAKE OUTPUT AVALABLE
	POP	P,A		;GET OLD F BACK
	TLNE	A,FL.DSK	;WAS DISK FEATURE ON
	TLO	F,FL.DSK	;THEN MAKE IT VISIBLE AGAIN
	TLZ	F,FL.RPT	;CLEAR OUT FLAG FOR MESSAGE (LPT)
	CAIN	WD,L.LPT	;GETTING LPT??
	JRST	AGAIN		;NEXT CHARACTER
	TRNE	F,FR.DSK	;IF OUTPUT GOES TO A DISK
	TRZ	F,FR.DPY	;THEN DO NOT PAGE
	TLNE	F,FL.DSK	;WAS DISK FEATURE ALREADY THERE
	PUSHJ	P,SETDSK
SYSIN3:	TXZ	F,FR.VMF	;TEST HERE FOR VM  SUPPORT
	MOVE	A,[%CNST2]	;AS DSKSET COULD BE CALLED
	CALL	GETZ		;GET A ZERO OR THE FEATURE
	TXNE	A,ST%VMS	;VM SUPPORT
	TXO	F,FR.VMF	;YES FLAG IT
	SETZM	ONEJOB		;CLEAR SINGLE JOB FLAG
	SETZM	ONEPPN		;CLEAR SINGLE PPN FLAG
	SETOM	ONETTY		;CLEAR SINGLE TTY MODE
	SKIPE	DSKFLG		;SEE IF DISK MODE
	TLO	F,FL.GOD!FL.DSK	;YES--THEREFORE NO SECRETS

	MOVE	A,XFSFPP	;GET SOME SYSTEM STUFF
	PUSHJ	P,GETZ		;LIKE FAILSAFE PPN
	SKIPN	A
	MOVE	A,[1,,2]
	MOVEM	A,FSFPPN
	MOVE	A,XPTYCN	;ALSO PTY POINTER
	PUSHJ	P,GETZ
	HLRZM	A,PTYOFS
	ADD	A,PTYOFS
	HRRZM	A,PTYMAX

	MOVE	A,XOPR		;GET NAME OF "OPR"
	PUSHJ	P,GETA
	MOVEM	A,OPR
	MOVE	A,XDATE		;GET DATE NOW
	PUSHJ	P,GETA
	MOVEM	A,DATE		;SAVE TODAY'S DATE
	MOVE	A,XSPPN		;GET SYS: PPN PAIR
	PUSHJ	P,GETZ
	SKIPE	A
	MOVEM	A,SYSPPN
	SETZM	CPKI10		;ZERO KI10 FLAG
	HRLOI	B,-2		;AND TEST WHETHER WE RUN ON A KI10
	AOBJN	B,KI10		;IT IS AKI10
	JRST	NOKI		;IT IS A KA10
KI10:	CAILE	A,50510		;BUT FORGET IF AN EARLY VERSION
	SETOM	CPKI10		;ELSE SET THE KI10 FLAG
NOKI:	HRLZI	B,LQTAB		;GET Q TABLE NAMES IF WE CAN
	SETZB	C,TISL
QTLP:	HRRZI	A,25
	HRL	A,B
	PUSHJ	P,GETZ
	JUMPE	A,QTLP1
	MOVEM	A,QTAB(B)
	MOVE	D,[POINT 12,QTAB(B)] ;BYTE PTR TO CODES
	HRLI	C,-3		;3 CODES PER WORD
QTLP2:	ILDB	A,D		;NEXT CODE
	CAIN	A,'SL'		;SKIP IF NOT SLEEP
	HRRM	C,TISL		;REMEMBER WAIT STATE CODE FOR SLEEP
	CAIN	A,'TI'		;SKIP IF NOT TI
	HRLM	C,TISL		;REMEMBER CODE FOR TI
	AOBJN	C,QTLP2		;LOOP FOR ALL CODES IN THIS WORD
	AOBJN	B,QTLP
QTLP1:	MOVE	A,XSTATS
	PUSHJ	P,GETZ
	MOVEM	A,STATES
	JUMPE	A,DNTSTO	;DONT OVERRIDE TCKSEC IF GETTAB UUO UNDEFINED
	MOVEI	B,^D60
	TLNE	A,(CLKCYC)
	MOVEI	B,^D50
	MOVEM	B,TCKSEC
	TLNE	A,100		;NEW SCANNER SERVICE?
	TLO	F,FL.SCN	;YES. REMEMBER IT.
	SETZM	TNFRTY		;CLEAR 10/40N FLAG
	TLNN	A,(1B2)		;CHECK FOR LOGIN FEATURE
	SETOM	TNFRTY		;NONE--SET 10/40N FLAG
	MOVE	A,XSYSTP	;FIND OUT THE NAME OF "SYS:"
	PUSHJ	P,GETZ		;FROM THE MONITOR
	CAMN	A,[SIXBIT /DSK/]  ;IF "DSK:",
	MOVEI	A,0		;  CLEAR FOR EASY TESTS LATER
	MOVEM	A,SYSTAP	;STORE AWAY
DNTSTO:	MOVE	A,XMEMNS	;GET CORE SPEED
	PUSHJ	P,GETZ
	SKIPE	A
	MOVEM	A,MEMNSP	;DON'T OVERRIDE IF UNDEFINED
	CAIN	WD,L.BDO	;LIST BUSY DEVICES ONLY?
	JRST	DEVQ		;YES
	CAIN	WD,L.HSO	;HELP?
	JRST	HELP		;YES
	CAIE	WD,L.DSO	;LIST DORMANT SEGS ONLY?
	CAIN	WD,L.SSO	;NO - LIST SHORT JOB STATUS ONLY?
	JRST	GA		;YES
	CAIE	WD,L.JSO	;LIST JOB STATUS INFO. ONLY?
	CAIN	WD,L.EJS	;NO-LIST ALL BUT JOB STATUS?
	JRST	GA		;YES
	CAIN	WD,L.FSO	;LIST FILESTRUCTURES ONLY?
	JRST	FS		;YES
	CAIN	WD,L.DPO	;LIST DISK PERFORMANCE ONLY?
	JRST	DP		;YES
	CAIN	WD,L.RSO	;LIST REMOTE STATIONS ONLY?
	JRST	REMOTE		;YES
	CAIN	WD,L.DSC	;DATA SET CONTROL ONLY?
	JRST	DSCDO		;YES
	CAIN	WD,L.ERR	;NON-DISK ERRORS ONLY?
	JRST	ERRPT		;YES
	CAIN	WD,L.GSS	;GENERAL SYSTEM STATISTICS ONLY?
	JRST	GA		;YES
	CAIN	WD,L.MYJ	;LIST JUST MY JOB?
	JRST	[MOVE	N,MYJOB
		 JRST	GOTJOB]
	CAIL	WD,"0"		;SEE IF SPECIFIC JOB
	CAILE	WD,"9"		; ..
	JRST	CHKPPN		;NO--GO SEE IF PPN
	MOVEI	R,^D10		;SET FOR DECIMAL INPUT
	PUSHJ	P,GETRDX	;GET DECIMAL
GOTJOB:	JUMPE	N,HELPM		;ERROR IF JOB 0
	MOVEM	N,ONEJOB	;STORE REQUEST
	JRST	GOTJNK		;GO DO IT
CHKPPN:	SKIPN	TNFRTY		;NO PPNS IF 10/40
	CAIE	WD,"["		;SEE IF PPN
	JRST	CHKTTY		;NO--GO PROCESS
	MOVEI	R,10		;SET FOR OCTAL INPUT
	PUSHJ	P,GETRDC	;GET PROJECT
	JUMPL	N,HELPM		;ERROR IF LE 0
	PUSHJ	P,CHKWLD	;SEE IF WILD CARD PPN
	HRLZ	A,N		;SAVE FOR LATER
	PUSHJ	P,GETCHR	;REEAT CHARACTER
	  JRST	CHKONC		;IGNORE END
	PUSHJ	P,GETRDC	;GET PROGRAMMER
	JUMPL	N,HELPM		;ERROR IF LE 0
	PUSHJ	P,CHKWLD	;SEE IF WILD CARD PPN
	HRR	A,N		;ADD TO RESULT
	SKIPN	A		;*,*?
	SETO	A,		;YES, REMEMBER THAT
	MOVEM	A,ONEPPN	;STORE FOR TESTS
	JRST	GOTCT2		;AND SKIP BREAK CHARACTER

CHKWLD:	SKIPN	N		;WAS A NUMBER TYPED?
	PUSHJ	P,GETCHR	;NO, RETRIEVE LAST CHARACTER
	CAIN	WD,L.WLD	;* TYPED?
	JUMPN	N,HELPM		;YES, A NUMBER IS ILLEGAL
	CAIE	WD,L.WLD	;IF A * WAS NOT TYPED
	JUMPE	N,HELPM		;  A NUMBER MUST HAVE BEEN
	POPJ	P,		;EVERYTHING OK, RETURN
CHKTTY:	TLNE	F,FL.SCN	;SEE IF NEW SCANNER SERVICE
	CAIE	WD,"#"		;YES--SEE IF TTY NUMBER
	JRST	CHKONC		;NO--GO PROCESS
	PUSHJ	P,GETCHR	;YES--GET WHICH TYPE
	  JRST	.+2		;END--DO SELF
	CAIN	WD,"."		;SEE IF SELF
	JRST	[SETOM	A
		 GETLCH	A
;[146] CHKTTY+7 1/2,JNG,11/4/74
		 TRZ	A,.UXTRM	;[146] CLEAR .UXTRM OFFSET
		 JRST	GOTCT1]
	CAIN	WD,"C"		;SEE IF CTY
	JRST	GOTCTY		;YES--GO SET IT UP
	MOVEI	R,^D8
	CAIN	WD,"P"		;SEE IF PSEUDO LINE
	JRST	[PUSHJ	P,GETRDC
		 ADD	N,PTYOFS
		 JRST	GOTTTY]
	CAIN	WD,"T"		;SEE IF TTY
	JRST	[PUSHJ	P,GETRDC
		 JRST	GOTTTY]
	PUSHJ	P,GETRDX	;MUST BE JUST TTY NUMBER
GOTTTY:	HRRZM	N,ONETTY	;STORE RESULT
	JRST	GOTJNK		;GO DO THE WORK
GOTCTY:	MOVE	A,PTYOFS	;CTY IS BEFORE FIRST PTY
	SUBI	A,1		; ..
GOTCT1:	HRRZM	A,ONETTY	;STORE AWAY
GOTCT2:	PUSHJ	P,GETCHR	;GET BREAK CHARACTER
	  JFCL			;IGNORE EOL
GOTJNK:	MOVEI	WD,"["		;SETUP JUNK
	JRST	GA		;GO DO IT

CHKSW:	TDNE	F,[XWD FL.GOD,FR.DPY!FR.CNT]	;DID HE TYPE ONLY ONE OF THE NEW COMMANDS?
	JRST	CLRGA		;YES, GIVE HIM THE DEFAULT
CHKONC:	SKIPN	ONCE		;NO VALID ARGS. SUPPLIED-HAVE WE BEEN THRU BEFORE?
	JRST	HACKQ		;YES-EXIT.
	CAIL	WD,40		;IS IT JUNK GRAPHIC?
	JRST	HELPM		;NO--TELL USER HOW TO GET HELP
CLRGA:	MOVEI	WD,0		;CLEAR WD FOR NORMAL O/P
	SUBTTL	READ TTY STATUS DATA
GA:	MOVE	A,XSEGPT
	PUSHJ	P,GETA
	MOVEM	A,SEGPTR
	HLRE	B,A
	MOVNM	B,SEGN
	HRRZM	A,JOBN
	ADD	A,SEGN
	HRRZM	A,BOTH
	HRRZ	B,.JBFF
	MOVEM	B,ZERLOW
	MOVEM	B,FREE
	HRRZ	A,.JBREL
	CAIL	A,^D384(B)	;SEE IF TTY TABLE 128 WORDS LONG WILL EXCEED CORE
	JRST	SYS0A
	ADDI	A,1		;YES-INCREASE CORE BY 1K
	CORE	A,
	  JRST	NOCOR		;TROUBLE-PRINT MESSAGE & QUIT
	HRRZ	A,.JBREL
SYS0A:	MOVEM	A,ZERHGH
	SETZM	@ZERLOW
	MOVE	A,ZERLOW
	HRLS	A
	ADDI	A,1
	BLT	A,@ZERHGH
	MOVE	A,FREE
	HRRM	A,.DVIOS
	MOVE	A,JOBN
	ADDB	A,FREE
	HRRM	A,.TTY
	MOVE	A,JOBN		;GET NUMBER OF JOBS
	ADDB	A,FREE		;ADVANCE POINTER
	HRRM	A,.TTYN		;SETUP TABLE OF LINE NUMBERS
	MOVE	A,JOBN		;GET NUMBER OF JOBS
	ADDB	A,FREE		;AND UPDATE THE FREE BARRIER
	SETOM	(A)		;JOB 0 IS ON NO LINE
	MOVSI	D,10		;TABLE INDEX FOR TTYTAB, ENTRY #0
SYS0L:	MOVS	B,D
	SKIPGE	A,TTYFLG	;SEE IF TOPS10 STYLE
	JRST	SYST03		;YES USE THE OLD WAY
	HRRZ	J,D		;GET JOB NUMBER
	CAML	J,JOBN		;CHECK FOR THE END
	JRST	SYS0X		;END OF TY DATA
	JUMPE	A,SYST02	;0 IS DETACHED!!
	MOVE	A,J		;GET JOB NUMBER
	TRMNO.	A,		;GET I/O INDEX
	SETZM	A		;MAKE IT DETACHED
	CAMN	A,CTYNDX	;IS IT CTY?
	JRST	SYST01		;YES THEN NAME IS KNOWN
	DEVNAM	A,		;GET NAME
	SETZM	A		;DETACHED IF AN ERROR
	SKIPA			;SKIP CTY NAME
SYST01:	MOVSI	A,(SIXBIT /CTY/);GET REAL NAME
SYST02:	MOVEM	A,@.TTY		;REMEBER NAME
	JRST	TTYCN1	;SKIP TTYTAB LOGIC
SYST03:	PUSHJ	P,GETTB		;GET NEXT ENTRY
	  JRST	SYS0X		;END OF TTYTAB
	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		;CLEAR NAME
	TLZ	B,-1
	JUMPE	B,SYS0Z
	MOVEI	C,DV.NAM(B)	;GET TTY NAME
	PUSHJ	P,PEEKC		; ..
	MOVEM	C,@.TTY		;STORE IN TABLE
	MOVEI	C,DV.IOS(B)	;GET IOS
	PUSHJ	P,PEEKC
	MOVEM	C,@.DVIOS
	TLNN	F,FL.SCN	;WHICH SCANNER LAYOUT?
	JRST	SYS0Z		;OLD FORGET IT
	MOVE	A,XDDBLD	;GET CODE FOR LDB LINK
	PUSHJ	P,GETZ		;RETURN ZERO IF NOT IMPLEMENTED
	JUMPE	A,SYS0L0	;IN THAT CASE TAKE OLD NUMERIC LOGIC
	MOVE	C,B		;GET DDB ADDRESS
	ADDI	C,(A)		;AND ADD IN  LDB LINK OFFSET
	JRST	SYS0L1		;AND SKIP NUMERIC LOGIC
SYS0L0:	MOVEI	C,DDBLDB(B)	;NEW. SEE IF DETACHED.
	SKIPE	A,MONVER	;SEE IF OLD MONITOR
	ADDI	C,3		;NO, 5.03 OR LATER
	TLZ	A,-1		;CLEAR JUNK
	CAILE	A,50430		;5.05 OR LATER?
	ADDI	C,1		;ONE MORE WORD IN LDB
SYS0L1:	PUSHJ	P,PEEKC		; ..
	TRNN	C,-1		;ANY LDB LINK?
	HRLM	C,@.TTY		;CLEAR LEFT HALF
TTYCN1:	MOVE	A,[POINT 6,@.TTY,17]
	MOVEI	B,0		;GET TTY NUMBER
TTYCN2:	ILDB	C,A		;GET NEXT DIGIT
	SUBI	C,'0'		;CONVERT TO BINARY
	JUMPL	C,TTYCN3	;EXIT. WHEN DONE
	LSH	B,3		;ADVANCE RESULT
	IOR	B,C		;INCLUDE THIS DIGIT
	TLNE	A,(77B5)	;SEE IF AT END OF WORD
	JRST	TTYCN2		;NO--LOOP FOR MORE
TTYCN3:	MOVEI	A,-1		;SET RIGHT HALF MASK
	MOVE	C,PTYOFS	;GET CTY+1 JUST IN CASE
	TDNN	A,@.TTY		;SEE IF RH=0 (IE, CTY)
	MOVEI	B,-1(C)		;YES--CHANGE TO CTY LINE NUMBER
	MOVEM	B,@.TTYN	;STORE LINE NUMBER AWAY
	TSNN	A,@.TTY		;SEE IF DETACHED
	JRST	SYS0Z		;YES--SKIP PTY TEST
	CAML	B,PTYOFS	;SEE IF WITHIN THE PTY RANGE
	CAML	B,PTYMAX	; ..
	JRST	SYS0Z		;NO--LEAVE ALONE
	SUB	B,PTYOFS	;YES--REMOVE THE OFFSET
	HRLI	B,'PTY'		;SET FLAG FOR LATER
	MOVEM	B,@.TTY		;AND STORE

SYS0Z:	AOJA	D,SYS0L
SYS0X:	MOVE	J,MYJOB		;SEE IF WE ARE AT AN OPERATOR TTY
	MOVE	A,@.TTY
	CAME	A,[SIXBIT /CTY/]	;CHECK CTY
	CAMN	A,OPR		;CHECK OPR
	TLO	F,FL.GOD	;YES--SET GOD FLAG


	SUBTTL	READ JOB AND SEGMENT STATUS
	MOVE	B,[XWD -NTAB,TABPTR]
INIT1:	MOVE	C,(B)
	HRRZ	J,BOTH
	TLZN	C,SIGN
	HRRZ	J,JOBN
	MOVE	A,FREE
	HRRM	A,(C)		;GENERATE ADDRESS IN TABLE POINTER
	ADDI	A,(J)		;PROTECT TABLE 
	HRRZM	A,FREE		;UPDATE FREE FENCE FOR NEXT ROUND
	CAMG	A,.JBREL	;DO WE NEED MORE CORE?
	JRST	INIT0		;NO THERE IS STILL ENOUGH
	CORE	A,		;GET CORE
	JRST	NOCOR		;IF IT IS NOT THERE THEN TOO BAD
INIT0:	MOVNS	J
	HRLZS	J
INIT2:	MOVS	A,C
	HRLI	A,(J)
	PUSHJ	P,GETZ
	MOVEM	A,@0(C)
	AOBJN	J,INIT2
	AOBJN	B,INIT1
	MOVE	A,FREE
	HRRM	A,.SEGCT	;
	ADD	A,SEGN
	HRRZM	A,FREE
	CAMG	A,.JBREL	;IS THERE SILL ENOUGH CORE
	JRST	INIT3		;YES
	CORE	A,		;GET IT OR
	JRST	NOCOR		;JUST DIE
INIT3:	MOVE	A,.SEGCT
	HRLS	A
	SETZM	(A)
	ADDI	A,1
	BLT	A,@FREE
	MOVE	A,XMEMSZ		;GET SIZE OF USER CORE
	PUSHJ	P,GETZ
	JUMPE	A,INIT5		;IF LEVEL-C, USE CORMAX
	MOVE	B,A
	MOVE	A,XSYSSZ
	PUSHJ	P,GETA
	PUSH	P,A		;SAVE LOW SIZE
	MOVE	A,[ 122,,11]	;GET SYS LEN IF THERE
	CALL	GETZ		;ZERO OR THE VALUE
	ADD	A,(P)		;GET THE TOTAL
	POP	P,N		;JUNK IT
	SKIPE	CPKI10		;RUNNING ON A KI10>50510
	JRST	INIT4		;YES GO AWAY
	ADDI	A,1777		;ROUND UP
	TRZ	A,1777
INIT4:	MOVN	A,A
	ADD	A,B		;MEMSIZ-SYSSIZ
	JRST	INIT6
INIT5:	MOVE	A,XCORMX
	PUSHJ	P,GETA
INIT6:	MOVEM	A,CORMAX
	CAIN	WD,L.DSO	;LIST DORMANT SEGS. ONLY?
	JRST	DODORM		;YES - GO DO IT
	CAIN	WD,L.SSO	;SHORT STATUS ONLY?
	JRST	SYS4A		;YES
	SKIPN	ONEJOB		;SEE IF CROSS SECTION
	SKIPE	ONEPPN		; ..
	JRST	SYS4A		;YES--SKIP HEADERS, ETC.
	SKIPL	ONETTY		;..
	JRST	SYS4A		;..
	SUBTTL	PRINT GENERAL SYSTEM STATUS
;INIT6+12 [177]
;**; DELETED [177]	TLNN	F,FL.DSK	;WE DID IT ALREADY
	PUSHJ	P,THISIS	;OUTPUT NAME OF SYSTEM, DATE AND TIME
	MOVE	A,STATES	;REPORT LOGIN AVAILABILITY
	MOVEI	M,[ASCIZ /No LOGINs allowed
/]
	TRNN	A,1
	MOVEI	M,[ASCIZ /No remote LOGINs allowed
/]
	TRNE	A,3
	PUSHJ	P,MSG

	MOVEI	M,[ASCIZ /Batch only
/]
	TRNE	A,4		;CHECK BATCH BIT
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ /Unspooling allowed
/]
	TRNE	A,200		;CHECK SPOOL CONTROL
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ /NO OPERATOR ON DUTY
/]
	TRNE	A,400		;**[8] IS OPERATOR THERE
	CALL	MSG		;**[8] (NO) TELL IT
	MOVE	A,XSYKTM	;GET MINUTES TO SYSTEM KILL
	PUSHJ	P,GETZ		;FROM THE MONITOR
; [204] @INIT6+29 1/2, JMT, 21-MAY-76
	MOVEI	M,[ASCIZ/Timesharing is over
/]				;[204]
	SKIPGE	A		;[204] IS TIMESHARING OVER ?
	PUSHJ	P,MSG		;[204] YES--TELL USER ABOUT IT
	SKIPLE	N,A		;SEE IF SET
	CAILE	A,^D24*^D60	;YES--SEE IF WITHIN 24 HRS.
	JRST	GENSTS		;NO--SKIP MESSAGE
	MOVEI	M,[ASCIZ /Timesharing ends in /]
	IDIVI	N,^D60		;YES--GET HOURS
	PUSH	P,N1		;SAVE MINUTES
	JUMPE	N,KSYNHR	;JUMP IF NO HOURS LEFT
	PUSHJ	P,MSGDEC	;TELL USER HOW LONG
	MOVEI	M,[ASCIZ / hrs. /]
KSYNHR:	POP	P,N		;RECOVER MINUTES
	PUSHJ	P,MSGDEC	;OUTPUT IT
	MOVEI	M,[ASCIZ / mins.  (at /]
	PUSHJ	P,MSG		;AND WHEN THAT IS
	IMULI	A,^D60		;CONVERT TO SECS.
	IMUL	A,TCKSEC	;AND THEN JIFFIES
	ADD	A,NOW		;ADD CURRENT TIME
	MOVEI	B,^D24*^D3600	;GET NUMBER OF SECS. IN A DAY
	IMUL	B,TCKSEC	;CONVERT TO JIFFIES
	CAML	A,B		;SEE IF TOMORROW
	SUB	A,B		;YES--BACK OFF CLOCK
	IFGE  FTAMPM,<
	TRO	F,FR.DAY	;REQUEST AM/PM HACK
>
	PUSHJ	P,TCKTIS	;OUTPUT TIME OF DAY
	MOVEI	M,[ASCIZ /)
/]
	PUSHJ	P,MSG		;FINISH MESSAGE
GENSTS:	MOVEI	M,[ASCIZ/Incremental /]	;IN CASE THIS IS "C"
	TRNE	F,FR.END		;NOT FIRST TIME?
	PUSHJ	P,MSG			;NOT FIRST, TYPE IT
	MOVEI	M,[ASCIZ /Uptime /]
	PUSHJ	P,MSG
	MOVEI	N,NCPUS
	SETZB	J,CPNUPT-1(N)
	SOJG	N,.-1
	MOVE	A,XUPTIM
	PUSHJ	P,GETA		;GET TOTAL SYSTEM UPTIME
	MOVEM	A,CPNUPT
	MOVE	N,@.TIM		;GET TOTAL SYSTEM NULL TIME
	MOVEM	N,CPNNUL
	MOVE	A,XLSTIM
	PUSHJ	P,GETA		;GET TOTAL SYSTEM LOST TIME
	MOVEM	A,CPNLST
	MOVNI	N,NCPUS
	MOVNI	A,2
GENST1:	ADDI	A,2		;GET UPTIME, ETC. FOR EACH CPU
	MOVE	B,A
	ADD	B,[%CVUPT]
	PUSHJ	P,GETTB		;UPTIME
	  JRST	GENST2
	MOVEM	B,CPNUPT+NCPUS(N)
	MOVE	B,A
	ADD	B,[%CVNUL]
	PUSHJ	P,GETTB		;NULL TIME
	  JFCL
	MOVEM	B,CPNNUL+NCPUS(N)
	MOVE	B,A
	ADD	B,[%CVLST]
	PUSHJ	P,GETTB		;LOST TIME
	  JFCL
	MOVEM	B,CPNLST+NCPUS(N)
	AOJL	N,GENST1
GENST2:	SKIPA	D,[EXP -NCPUS]
GENST3:	PUSHJ	P,PLUS
	MOVE	A,CPNUPT+NCPUS(D)
	MOVN	B,OLDTIM+NCPUS(D)	;GET THE LAST UPTIME
	MOVEM	A,OLDTIM+NCPUS(D)	;SAVE THIS UPTIME FOR NEXT ITERATION
	ADD	A,B			;USE DIFFERENTIAL UPTIME
	MOVEM	A,DIFTIM+NCPUS(D)	;SAVE IT
	PUSHJ	P,TCKTIS	;TYPE UPTIME FOR EACH CPU
	SKIPE	CPNUPT+NCPUS+1(D)
	AOJL	D,GENST3
GENST4:	MOVEI	M,[ASCIZ /, /]
	PUSHJ	P,MSG
	SKIPA	D,[EXP -NCPUS]
GENST5:	PUSHJ	P,PLUS
	MOVE	N,CPNNUL+NCPUS(D)
	MOVN	B,OLDNUL+NCPUS(D)	;PICK UP OLD NULL TIME
	MOVEM	N,OLDNUL+NCPUS(D)	;SAVE THIS ONE FOR NEXT ITERATION
	ADD	N,B			;USE DIFFERENTIAL NULL TIME
	IMULI	N,^D100
	MOVEM	N,TEMP+NCPUS(D)		;SAVE FOR COMPUTING IDLE & LOST TIME
	IDIV	N,DIFTIM+NCPUS(D)	;COMPUTE % NULL TIME
	MOVEM	N,CPNNUL+NCPUS(D)
	PUSHJ	P,DECPRT		;TYPE NULL TIME FOR EACH CPU
	SKIPE	CPNUPT+NCPUS+1(D)
	AOJL	D,GENST5
GENST6:	MOVEI	M,[ASCIZ /%Null time/]
	PUSHJ	P,MSG
	SKIPE	TNFRTY
	JRST	PRSHUF
	MOVEI	M,[ASCIZ/ = /]
	PUSHJ	P,MSG
	SKIPA	D,[EXP -NCPUS]
GENST7:	PUSHJ	P,PLUS
	MOVE	N,CPNLST+NCPUS(D)
	MOVN	B,OLDLOS+NCPUS(D)	;SAME FOR LOST TIME
	MOVEM	N,OLDLOS+NCPUS(D)
	ADD	N,B
	IMUL	N,[EXP -^D100]
	ADD	N,TEMP+NCPUS(D)
	IDIV	N,DIFTIM+NCPUS(D)
	MOVEM	N,CPNLST+NCPUS(D)
	PUSHJ	P,DECPRT		;TYPE IDLE TIME FOR EACH CPU
	SKIPE	CPNUPT+NCPUS+1(D)
	AOJL	D,GENST7
GENST8:	MOVEI	M,[ASCIZ /%Idle + /]
	PUSHJ	P,MSG
	SKIPA	D,[EXP -NCPUS]
GENST9:	PUSHJ	P,PLUS
	MOVE	N,CPNLST+NCPUS(D)
	SUB	N,CPNNUL+NCPUS(D)
	MOVNS	N
	PUSHJ	P,DECPRT		;TYPE LOST TIME FOR EACH CPU
	SKIPE	CPNUPT+NCPUS+1(D)
	AOJL	D,GENST9
GENS10:	MOVEI	M,[ASCIZ /%Lost
/]
	PUSHJ	P,MSG
PRSHUF:	TLNN	F,FL.DSK!FL.LPT	;SEE IF OPERATOR WORK
	JRST	PRSHF1		;NO--CUT OUT JUNK TO SAVE TIME
	MOVEI	M,[ASCIZ/Incremental /]	;IN CASE THIS IS "C"
	TRNE	F,FR.END	;NOT FIRST TIME?
	PUSHJ	P,MSG		;NOT FIRST, TYPE IT
	MOVEI	M,[ASCIZ /Shuffle time = /]
	MOVE	A,XSHF		;GET WORDS SHUFFLED
	PUSHJ	P,GETA
	MOVN	B,OLDSFL	;GET THE LAST SHUFFLE
	MOVEM	A,OLDSFL	;SAVE THIS SHUFFLE THERE
	ADD	A,B		;USE DIFFERENTIAL SHUFFLE
	PUSHJ	P,MEMPR		;PRINT AS TIME
	MOVEI	M,[ASCIZ /,  Core Zeroing time = /]
	MOVE	A,XZCOR		;GET WORDS ZEROED
	PUSHJ	P,GETA
	MOVN	B,OLDZRO	;GET THE LAST ZEROED
	MOVEM	A,OLDZRO	;SAVE THIS ZEROED THERE
	ADD	A,B		;USE DIFFERENTIAL ZEROED
	PUSHJ	P,MEMPR		;PRINT AS TIME
	PUSHJ 	P,CRLF
	MOVEI	M,[ASCIZ/Incr avg response time:/]
	TRNN	F,FR.END	;PRINT ON 2ND,3RD,... PASS
	MOVEI	M,[ASCIZ /Average response time: /]
	PUSHJ	P,MSG		;ANNOUNCE RESPONSE TIME
	MOVE	A,[%FTDEB]	;[EDIT 2] GET OPTIONS
	CALL	GETZ		;[EDIT 2] ZERO IF NOT THERE
	TXNN	A,F%RSP		;[EDIT 2] THE FANCY STUFF?
	JRST	PRSHU0		;[EDIT 2] DEFINITELY NOT
	MOVE	A,MONVER	;IS MONITOR > 50500?
	CAIL	A,50500
	JRST	GENRSP		;YES, HANDLE FANCY RESPONSE TABLES
;[EDIT 2] LABEL PRSHU0 ADDED
PRSHU0:	TRNE	F,FR.END	;FIRST PASS?
	PUSHJ	P,SPACE		;NO, PRINT EXTRA SPACE
	MOVE	A,XRNUM
	PUSHJ	P,GETA
	EXCH	A,OLDNUM	;SWAP OLD AND NEW TOTAL RESPONSES
	SUB	A,OLDNUM	;-(NUMBER OF RESPONSES)
	MOVMM	A,TEMP		;+NUMBER OF RESPONSES THIS INTERVAL
	MOVE	A,XSRSP
	PUSHJ	P,GETA
	EXCH	A,OLDRSP	;SWAP NEW AND OLD JIFFIES RESPONDING
	SUB	A,OLDRSP	;-(JIFFIES SPENT RESPNDING)
	MOVMS	A
	MOVEM	A,TEMP1
	IDIV	A,TEMP		;JIFFIES PER RESPONSE THIS INTERVAL
	PUSHJ	P,TIMPR		;PRINT TIME IN SECONDS
	MOVEI	M,[ASCIZ / sec (/]
	PUSHJ	P,MSG
	MOVE	A,TEMP1
	PUSHJ	P,TIMPR
	MOVEI	M,[ASCIZ^ sec/^]
	MOVE	N,TEMP
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ/ resp.)/]
	PUSHJ	P,MSG
	PUSHJ	P,CRLF
	JRST	PRSHF1		;GO DO JOB STUFF
;HERE TO PRINT RESPONSE MEASURES

GENRSP:	MOVEI	M,[ASCIZ @	MEAN//ST.DEV.		RESP/MIN   # of RESP
@]
	PUSHJ	P,MSG
	HRREI	A,-4		;4 TYPES OF RESPONSE
	SETZM	D		;RELATIVE SUBTABLE POINTER
RSP:	MOVEM	A,RSPCNT	;SAVE RESPONSE TYPE COUNTER
	MOVE	M,RSPMSG+4(A)	;GET MSG FOR THIS RESPONSE TYPE
	SETZM	CPU		;SET FOR CPU0

;LOOP TO PRINT RESPONSE FOR EACH CPU

RSPLP1:	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRNO	;NO. OF RESPONSES SINCE STARTUP
	PUSHJ	P,GETRS0	;GET FROM MONITOR REL TABLE
	  JRST RSP1C		;NOT PRESENT FOR THIS CPU
	PUSHJ	P,GETDIF	;GET INCREMENTAL VALUE
	PUSH	P,A		;SAVE TOTAL NO. OF RESPONSES

	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRSO	;SUM OF RESPONSE TIMES IN JIFFIES
	PUSHJ	P,GETRSP	;GET FROM MONITOR REL TABLE
	  JRST	RSP1B		;NOT PRESENT FOR THIS CPU
	PUSHJ	P,GETDIF	;GET INCREMENTAL VALUE
	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 MEAN FROM STANDARD DEVIATION
	PUSHJ	P,MSG

	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRLO	;GET LOW SUM OF SQUARES OF RESPONSES
	PUSHJ	P,GETRSP	;GET FROM MONITOR REL TABLE
	  JRST	RSP1B		;NOT THERE
	PUSHJ	P,GETDIF	;GET INCREMENTAL VALUE
	MOVE	B,A		;POSITION FOR MULT.
	MOVE	A,RSPIDX	;GET INDEX TO DIFRSP TABLE
	MOVEM	A,RSPIX1	;SAVE IT (NEED TO DO DOUBLE
				; PRECISION SUBTRACT)

	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRHO	;ASK FOR HIGH SUM OF SQUARES
	PUSHJ	P,GETRSP	;FROM MONITOR
	  JRST	RSP1B		;(STRANGE!)
	PUSHJ	P,GETDIF	;GET INCREMENTAL VALUE
	SKIPL	B		;IS DIFFERENTIAL LOW ORDER PART NEGATIVE?
	JRST	RSPL1A		;NO, OK
				; YES, FUDGE DOUBLE PRECISION
	PUSH	P,N		;SAVE N
	MOVE	N,RSPIX1	;GET INDEX TO DIFRSP TABLE
	SETCAB	B,DIFRSP(N)	;COMPLEMENT LOW ORDER HALF
	MOVE	N,RSPIDX	;GET INDEX TO HIGH ORDER HALF
	SOS	A,DIFRSP(N)	;BORROW 1
	POP	P,N		;RESTORE N
RSPL1A:	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.
	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:	PUSHJ	P,TAB		;AND A SECOND ONE
	MOVE	A,DIFTIM	;UP TIME IN JIFFIES
	IDIV	A,TCKSEC	;NO. OF SECONDS UP
	IDIVI	A,^D60		;NO. OF MINUTES UP
	MOVEM	A,TEMP		;STORE FOR CMPCNA
	SETZM	CPU		;START WITH CPU0
RSPLP2:	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRNO	;NO. OF RESPONSES FOR THIS CPU
	PUSHJ	P,GETRS0	;CALL GETRSP TO SET UP INDEX
	  JRST	RSP2		;NOT THERE
	MOVE	A,RSPIDX	;DIDN'T REALLY WANT NEW VALUE
	MOVE	A,DIFRSP(A)	; GET INCREMENTAL VALUE
	PUSHJ	P,CMPDFA	;PRINT NO. RESPONSES PER MIN
	AOS	CPU		;STEP TO NEXT CPU
	JRST	RSPLP2		;TRY NEXT CPU

;HERE TO PRINT NUMBER OF RESPONSES FOR THIS TYPE

RSP2:	MOVEI	M,[ASCIZ /   /]
	PUSHJ	P,MSG
	SETZM	CPU		;START WITH CPU0
RSPLP3:	MOVE	A,D		;GET TYPE INDEX
	ADDI	A,%CVRNO	;NO. OF RESPONSES FOR THIS CPU
	PUSHJ	P,GETRS0	;CALL GETRSP TO SET UP INDEX
	  JRST RSP3		;NOT THERE
	MOVE	A,RSPIDX	;DIDN'T REALLY WANT NEW VALUE
	MOVE	N,DIFRSP(A)	; GET INCREMENTAL VALUE
	PUSHJ	P,DECPRT	;PRINT # OF RESPONSES
	AOS	CPU		;FIND OUT IF ANY MORE CPU'S
	JRST	RSPLP3		;TRY NEXT CPU

;HERE WHEN PRINTED FOR ALL CPUS

RSP3:	PUSHJ	P,CRLF
	ADDI	D,4		;STEP TO NEXT RESPONSE TYPE
	MOVE	A,RSPCNT
	AOJL	A,RSP		;PROCESS NEXT TYPE (IF ANY)

PRSHF1:	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:	MOVEM	N,NUMJOB	;SAVE NUMBER OF ACTIVE JOBS
	PUSHJ	P,DECPRT	;PRINT NUMBER OF JOBS IN USE
	MOVEI	M,[ASCIZ / Jobs in use out of /]
	MOVE	N,JOBN		;PRINT NO. IN SYSTEM
	SUBI	N,1		;ALLOW FOR NULL JOB
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ /.  /]
	SKIPE	TNFRTY		;SEE IF 10/40N
	JRST	PRDET		;YES--DON'T COUNT LOGINS
	MOVE	N,B		;PRINT NO. LOGGED IN
	MOVEM	B,LOGDIN	;SAVE FOR  KSEC COMPUTATION
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ / logged in, /]
PRDET:	MOVE	N,C		;PRINT NO. DETACHED
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ / detached/]
	PUSHJ	P,MSG
	SKIPE	TNFRTY		;NO LOGMAX IF 10/40
	JRST 	PRJBST		;GO DO JOB STUFF
	MOVE	A,XLGMAX	;GET LOGMAX
	PUSHJ	P,GETZ
	JUMPE	A,PRJBST	;NO LOGMAX
	MOVE	N,A
	MOVEI	M,[ASCIZ / out of /]
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ /.  (LOGMAX)/]
	PUSHJ	P,MSG
	SUBTTL	PRINT JOB STATUS
PRJBST:	PUSHJ	P,CRLF
	CAIE	WD,L.EJS	;LIST ALL BUT JOB STATUS?
	CAIN	WD,L.GSS	;ONLY GENERAL SYSTEM STATISTICS?
	TLOA	WD,SIGN		;YES
	JRST	SSTATS		;NO
	JRST	SYS4A
SSTATS:	MOVEI	M,[ASCIZ /
Job    Who     Line#	What   Size(K)	State	/]
	SKIPE	CPKI10		;IS IT A KA10?
	MOVEI	M,[ASCIZ /
Job    Who     Line#	What   Size(P)	State	/]
	SKIPE	TNFRTY		;SEE IF 10/40N
	MOVEI	M,[ASCIZ /
Job	Line#	What   Size(K)	State	/]
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ/% of CPU KCsecs

/]
	TRNN	F,FR.END	;FIRST PASS?
	MOVEI	M,[ASCIZ/Run Time

/]
	PUSHJ	P,MSG		;FINISH THE HEADING EITHER WAY
SYS4A:	MOVN	J,JOBN
	HRLZS	J
	SETZM	TOTKCT		;CLEAR TOTAL KILO=CORE SECS
	SETZM	CORUSE		;CLEAR TOTAL VIRT. CORE USED
	SETZM	DSKUSE		;CLEAR TOTAL SWAPPING SPACE USED
	SETZM	ACTUSE		;CLEAR COUNT OF ACTIVE SWAPPING SPACE USED
	SETZM	LOWUSE		;CLEAR COUNT OF LOW SEGMENT SIZES
	SETZM	PTYS		;CLEAR COUNT OF PTY JOBS
	SETZM	SEGFLG		;CLEAR SEGMENT FLAG
	TLZ	F,FL.NUM!FL.NST!FL.EXM!FL.AMP
SYSL1:	SKIPE	N,ONEJOB	;SEE IF ONE JOB REQUESTED
	CAIN	N,(J)		;YES--SEE IF THIS IS IT
	SKIPA	JS,@.STS	;A WINNER
	JRST	DUNJOB		;A LOSER
	TLNN	JS,JNA
	JRST	[SETZM	JOBTIM(J)	;FOR NEXT TIME
		SETZM	OLDPPN(J)	;FOR NEXT TIME AROUND
		SETZM	JOBKCT(J)	;START FRESH
		JRST	DUNJOB]
	TLO	F,FL.DTJ
	MOVE	A,@.TTY		;GET TTY NAME
	TLNN	A,-1		;TEST FOR DETACHED
	TLOA	A,(SIXBIT /DET/) ;YES
	TLZA	F,FL.DTJ	;YES. NOT DETACHED.
	TLNE	F,FL.GOD	;SEE IF GOD
	SKIPA			;YES (OR NOT DETACHED)
	TRZ	A,-1		;NOT GOD AND DETACHED--CLEAR TTY NUMBER
	MOVEM	A,JOBTTY
	SKIPE	TNFRTY		;SEE IF 10/40N
	JRST	SYSL1D		;YES--SKIP PRJ-PRG
	MOVE	A,@.PPN		;FETCH PPN OF JOB
	TLNN	F,FL.DTJ
	TLNN	JS,JLOG
	PUSHJ	P,NOWHO		;PRINT *'S OR PRJPRG DEPENDING UPON GODLINESS
	SKIPLE	N,ONEPPN	;SEE IF PPN CROSS SECTION
	CAMN	A,N		;YES--SEE IF MATCHES
	JRST	SYSL1D		;A WINNER
	TLNE	N,-1		;WILD CARD PROJECT NUMBER?
	JRST	SYSL0D		;NO
	CAIN	N,(A)		;PROGRAMMER NUMBERS MATCH?
	JRST	SYSL1D		;A WINNER
SYSL0D:	TRNE	N,-1		;WILD CARD PROGRAMMER NUMBER?
	JRST	DUNJOB		;A LOSER
	TRZ	A,-1		;ANY PROGRAMMER NUMBER WINS
	CAME	A,N		;SEE IF IT MATCHES
	JRST	DUNJOB		;A LOSER
	MOVE	A,@.PPN		;RESTORE PPN
SYSL1D:	SKIPGE	N,ONETTY	;SEE IF TTY CROSS SECTION
	JRST	TTYOK		;NO--MUST BE OK
	CAMN	N,@.TTYN	;YES--SEE IF CORRECT LINE NUMBER
	CAMN	A,[-1]		;SEE IF HIDDEN
	JRST	DUNJOB		;A LOSER
TTYOK:	HRRZ	N,J
	TRO	F,FR.OVR	;TENTATIVELY SET COLUMN OVERFLOW
	CAME	A,[-1]		;CLEAR IF HIDDEN
	CAIGE	N,^D100		;SEE IF WIDE JOB NUMBER
	TRZ	F,FR.OVR	;NO--CLEAR
	TLNE	A,7B20		;SEE IF WIDE PROJECT
	TRNN	A,7B20		;AND WIDE PROGRAMMER
	TRZ	F,FR.OVR	;NO--CLEAR
	PUSHJ	P,DECP2X	;PRINT AS TWO DIGITS OR SPACE AND ONE
	SKIPE	TNFRTY		;SEE IF 10/40
	JRST	NOPPN		;10/40 NO PPN'S
	SKIPN	N,ONEPPN	;SINGLE USER?
	JRST	PPNOK		;NO, DISPLAY PPN
	JUMPL	N,PPNOK
	TRNE	N,-1		;WILD CARD PROGRAMMER NUMBER?
	TLNN	N,-1		;OR WILD CARD PROJECT NUMBER?
	JRST	PPNOK		;YES, PRINT PPN SINCE MAYBE MORE THAN ONE
NOPPN:	TRZA	F,FR.OVR	;YES--SKIP PPN
PPNOK:	PUSHJ	P,PNTPPN	;PRINT PRJ-PRG #
	TRNE	F,FR.OVR	;SEE IF OVERFLOW
	PUSHJ	P,SPACE		;YES--JUST SPACE TO CATCH UP
	TRZN	F,FR.OVR	;NO--CLEAR AND
	PUSHJ	P,TAB		; TAB OVER
	SKIPN	A,JOBTTY
	MOVE	A,@.TTY
	HLRZ	CH,A		;GET PREFIX OF DEVICE
	CAIN	CH,'TTY'	;SEE IF TTY
	SKIPE	ONEJOB		;YES--SEE IF ALL JOBS
	JRST	.+2		;NO--GIVE FULL NAME
	HRLZ	A,A		;YES--JUST OUTPUT NUMBER
	CAIE	CH,'PTY'	;SEE IF PTY
	JRST	SYSLTT		;NO--OUTPUT IN SIXBIT
	AOS	PTYS		;COUNT THE PTY JOB
	MOVEI	CH,"P"		;YES--OUTPUT A P
	PUSHJ	P,TYO		; ..
	HRRZ	N,A		;FOLLOWED BY
	PUSHJ	P,OPRNT		; THE PTY DRIVING THIS PTY
	HRRZ	N,J		;GET JOB #
	CTLJOB	N,		;FIND CONTROLLING JOB
	  JRST	SYSLTY		;N.G.
	JUMPLE	N,SYSLTY	;N.G.
	MOVEI	CH,"J"		;PRINT A J
	PUSHJ	P,TYO
	PUSHJ	P,DECPRT	;PRINT CONTROLLING JOB #
SYSLTY:	PUSHJ	P,TAB
	JRST	SYSLTU		;DON'T DO THE SIXBIT THING
SYSLTT:	TDNN	A,[-77B5-1]	;SEE IF JUST ONE CHARACTER
	PUSHJ	P,SPACE		;YES--SPACE IN ONE
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB

SYSLTU:	MOVE	A,@.PRG
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	TLZ	F,FL.HSG	;FLAG LOW SEGMENT
	PUSHJ	P,SEGSZ		;COMPUTE SEGMENT SIZE
	PUSH	P,J		;SAVE JOB NO
	PUSH	P,N		;SAVE LOW SEG VALUE
	SKIPG	J,@.SGN		;GET SEGMENT # OF HISEG
	JRST	SYSLT0		;SPY OR NO HIGH SEGMENT
	TLO	F,FL.HSG	;FLAG THAT HISEG IS DESIRED
	PUSHJ	P,SEGSZ		;GET HISEG SIZE
	TRNE	F,FR.VMF	;IS THIS A VM SYSTEM?
	TLNE	J,SHRSEG	;AND IS SEGMENT SHARABLE?
	JRST	SYSLT1		;NO CLASSIC
	SUBM	N,(P)		;UPDATE LOW SEGSIZE
	MOVNS	(P)		;MAKE IT POSITIVE
SYSLT1:	HRLM	N,(P)		;STORE HISEG VALUE ON STACK
SYSLT0:	HRRZ	N,(P)		;GET LOW SEGMENT SIZE
	MOVE	A,N		;SAVE FOR LATER TEST
	ADDM	N,CORUSE
	EXCH	J,-1(P)		;GET OLD J VALUE
	PUSHJ	P,INACTC	;SKIP IF JOB IS INACTIVE
	  ADDM	N,ACTUSE	;NO, ACTIVE, COUNT ACTIVE VIRTUAL CORE
	ADDM	N,LOWUSE	;COUNT TOTAL LOW SEG SIZE
	PUSHJ	P,DECPRT
	EXCH	J,-1(P)		;GET JBTSGN ENTRY
	JUMPLE	J,SYS9		;IN CASE SPYING
	MOVEI	CH,"+"		;OUTPUT A PLUS
	PUSHJ	P,TYO
	HLRZ	N,(P)		;GET HISEG VALUE
	PUSHJ	P,DECPRT	;PRINT HI-SEG SIZE
SYS9:	JUMPGE	J,SYS8	;GET VALUABLES BACK
	MOVE	A,[SIXBIT /+spy/] ;SPYING--PRINT INDICATION
	PUSHJ	P,SIXBP
SYS8:	POP	P,J		;GET TEMPORARY OF STACK
	POP	P,J		;RESTORE JOB NUMBER

	CAIN	WD,L.SSO	;SHORT STATUS ONLY?
	JRST	RET2		;YES-DON'T PRINT STATE OR RUN TIME
	PUSHJ	P,TAB
	MOVSI	A,'^W '		;PREPARE FOR COMMAND WAIT
	TLNE	JS,400000	;SEE IF COMMAND TYPED
	MOVSI	A,'CW '		; .
	TLNE	JS,CMWB		; ..
	JRST	TSTATE		;YES
	MOVSI	A,'OW '		;SET IN CASE OPER WAIT
	TRNE	JS,JDCON	;SEE IF DEVICE HOLDING IT UP
	JRST	TSTATE		;YES--SEND IT
	MOVSI	A,'^D '		;SET IN CASE DAEMON WAIT
	TRNE	JS,JDC		;SEE IF DAEMON CALL FROM COMMAND
	JRST	TSTATE		;YES--SEND IT
	MOVSI	A,(SIXBIT /^C/)
	JUMPGE	JS,TSTATE
	LDB	B,[POINT 5,JS,14]
	IDIVI	B,3
	IMULI	C,^D12
	MOVE	A,QTAB(B)
	LSH	A,(C)
	AND	A,[7777B11]
	MOVSI	B,(SIXBIT /SL/)	;SEE IF SLEEP WAIT STATE CODE
	CAME	B,A		;IS IT?
	JRST	SYS10		;NO
	TRNN	JS,CLKR		;DOES THE JOB HAVE A CLOCK REQUEST IN?
	MOVSI	A,(SIXBIT /HB/)	;NO, THE JOB IS HIBERNATING
SYS10:	MOVSI	B,(SIXBIT /TI/)	;SEE IF TTY I/O WAIT STATE CODE
	CAMN	B,A		;IS IT?
	SKIPN	B,@.DVIOS	;AND IS IOS NON-ZERO
	JRST	TSTATE		;NO, TI WAIT
	TLNN	F,FL.SCN	;NEW SCANNER SERVICE?
	MOVNS	B		;NO, REVERSE THE SENSE OF THE BIT
	JUMPGE	B,TSTATE	;JUMP IF NOT OUTPUT
	MOVSI	A,(SIXBIT /TO/)	;TTY OUTPUT WAIT
TSTATE:	PUSHJ	P,LOPSWP	;PRINT STATE AND "SW"/"SWF" IF SWAPPED/& FRAGMENTED
	MOVE	C,@.KCT
	TRNN	F,FR.END
	MOVEM	C,JOBKCT(J)	;STORE ON FIRST PASS ONLY
	MOVE	A,@.TIM
	MOVE	B,JOBTIM(J)	;PICK UP OLD RUN TIME TICKS
	MOVEM	A,JOBTIM(J)	;SAVE THIS PASS
	TRNN	F,FR.END	;FIRST PASS?
	JRST	PRUNT		;YES
	MOVE	M,@.PPN		;PICK UP PPN
	CAMN	M,OLDPPN(J)	;NEW PPN?
	CAMGE	A,B		;NEW RUN TIME .LT. LAST?
	TROA	F,FR.CHG!FR.LGN	;YES. MUST HAVE LOGGED IN
	SUB	A,B		;USE DIFFERENTIAL
	JUMPE	A,[MOVEI	M,[ASCIZ/	/]
		PUSHJ	P,MSG	;FAKE IT
		JRST	CHKKCT]
	MOVE	CH,DIFTIM	;PICK UP ?incremental UPTIME
	MOVE	N,A		;SET UP CALLING SEQUENCE FOR
	PUSHJ	P,PCNT2		;PRINT PERCENTAGE OF CPU
CHKKCT:	MOVE	A,@.KCT		;PICK UP NEW KC TICKS
	MOVE	B,JOBKCT(J)	;OLD KC TICKS
	MOVEM	A,JOBKCT(J)	;SAVE NEW VALUE
	TRNN	F,FR.CHG	;USE NEW AMOUNT IF CHANGE
	SUB	A,B
	ADDM	A,TOTKCT	;FORM TOTAL THIS PASS
	JUMPE	A,[MOVEI	M,[ASCIZ /  /]
		   PUSHJ P,MSG
		   JRST DOFLGS]
	MOVEI	M,[ASCIZ/	/]
	PUSHJ	P,MSG
	MOVE	N,A
	IDIV	N,TCKSEC
	PUSHJ	P,DECP3X	;PRINT KILO-CORE-SECS
	JRST	DOFLGS
PRUNT:	PUSHJ	P,TCKTIB	;PRINT RUN TIME IS SECS
DOFLGS:	MOVE	C,[POINT 6,A]	;SET-UP POINTER FOR FLAGS
	MOVE	A,@.RTD		;SEE IF IN A HIGH PRIORITY QUEUE
	LDB	N,HPQPNT	;GET HPQ NUMBER
	JUMPE	N,SYSLK0	;ZERO MEANS  TS Q'S
	PUSHJ	P,SPACE
	PUSHJ	P,DECPR2	;PRINT Q NUMBER
	TRO	F,FR.HPQ	;REMEMBER IT FOR THE FOOTNOTE
SYSLK0:	MOVEI	A,0		;CLEAR FLAGS
	MOVE	B,@.STS		;GET JOB STATUS
	TLNN	B,NSWP!NSHF	;SEE IF LOCKED IN CORE
	JRST	SYSLKX		;NO
	TLNE	B,NSHF		;YES--SEE IF CAN BE SHUFFLED
	JRST	SYSLK1		;NO
	MOVEI	B,(SIXBIT /  !/)  ;YES
	TLO	F,FL.EXM	;FLAG FOR FOOTNOTE
	JRST	SYSLK2
SYSLK1:	MOVEI	B,(SIXBIT /  &/)  ;NOTE LOCKED
	TLO	F,FL.AMP	;FLAG FOR FOOTNOTE
SYSLK2:	IDPB	B,C		;PUT FLAG AWAY
SYSLKX:	MOVS	B,@.STS		;GET STATUS WORD, SWAPPED
	HRRI	B,'$'		;AND FLAG FOR EXECUTE ONLY
	TLNE	B,JS.XO		;IS THIS JOB EXECUTE ONLY?
	IDPB	B,C		;YES. ADD $ TO FLAGS
	TLNE	B,JS.XO	
	TRO	F,FR.XOM	;AND FLAG WANT EXECUTE ONLY MESSAGE
	SKIPG	B,@.SGN		;DOES JOB HAVE A HISEG?
	JRST	SYSL1E		;NO
	TLO	F,FL.HGH	;SET HISEGS IN USE FLAG
	PUSH	P,J		;SAVE J
	MOVE	J,B
	PUSH	P,A		;SAVE A
	HRRZ	A,B
	SUB	A,JOBN
	SKIPL	A		;RANGE CHECK
	CAML	A,SEGN		; ..
	MOVEI	A,0		;BAD. PROTECT ONESSELF
	AOS	@.SEGCT		;INCREMENT HI SEG USE COUNT
	POP	P,A		;RESTORE A
	SKIPE	B,@.PRG		;AN OBSOLETED SEGMENT?
	JRST	SYSL1A		;NO-CHECK IF IT'S A NON CUSP HISEG
	MOVE	B,@.STS
	TLNN	B,SHRSEG	;IS IT SHARABLE?
	JRST	SYSL1B		;NO-MUST BE PRIVATE
	MOVEI	B,(SIXBIT /  @/)
	IDPB	B,C		;PUT FLAG AWAY
	TLO	F,FL.NST	;YES-SET @ FLAG
	JRST	SYSL1B		;PRINT @
SYSL1A:	SKIPN	B,SYSTAP	;SEE IF SYSTEM TAPE IS NOT DISK
	JRST	SYSL1M		;IS DISK--CHECK PPN
	CAME	B,@.PPN		;CHECK LEV.C DEVICE NAME
	CAMN	B,@.DEV		;OR LEVEL D DEVICE NAME
	JRST	SYSL1B		;IS SYS
	JRST	SYSL1N		;IS NOT SYS
SYSL1M:	MOVE	B,@.PPN		;GET HISEG OWNER
	CAMN	B,SYSPPN	;IS IT A CUSP HISEG?
	JRST	SYSL1B		;YES-DON'T PRINT ANYTHING
SYSL1N:	MOVEI	B,(SIXBIT /  #/)  ;PREPARE TO FLAG JOB WITH #
	IDPB	B,C		;PUT FLAG AWAY
	TLO	F,FL.NUM	;SET # FLAG
SYSL1B:	POP	P,J		;RESTORE J & A
SYSL1E:	MOVEI	B,(SIXBIT /  +/)
	TRZE	F,FR.CHG	;NEW LOGIN?
	IDPB	B,C		;FLAG ON OUTPUT
	JUMPL	C,RET2		;IF NO FLAGS, JUMP
	PUSHJ	P,SPACE		;PRINT A SPACE
	PUSHJ	P,SIXBP		;PRINT @ OR #
RET2:	PUSHJ	P,CRLF

DUNJOB:	MOVE	A,@.PPN		;IN ANY CASE, SAVE THIS PPN
	MOVEM	A,OLDPPN(J)
	PUSHJ	P,NOWHO
	MOVEM	A,@.PPN		;IN CASE OF **,** WIPEOUT
	AOBJN	J,SYSL1
	MOVEI	M,[ASCIZ/Total KCS used = /]
	MOVE	N,TOTKCT
	IDIV	N,TCKSEC
	MOVEM	N,TEMP
	TRNE	F,FR.END	;2ND OR 3RD PASS?
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ/ Average KCS = /]
	MOVE	N,TEMP
	IDIV	N,LOGDIN
	TRNE	F,FR.END
	PUSHJ	P,MSGDEC	;ANNOUNCE AVERAGE KCS OVER INTERVAL
	TRNE	F,FR.END
	PUSHJ	P,CRLF
	MOVEI	M,REENTR	;SET REENTER POINT
	MOVEM	M,.JBREN	;SAVE IT
	TRO	F,FR.END	;MARK AS HAVING BEEN DONE NOW
	MOVEI	M,[ASCIZ /@ means superseded Hi-Seg	/]
	TLNE	F,FL.NST
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ /# means non-system Hi-Seg/]
	TLNE	F,FL.NUM
	PUSHJ	P,MSG
	TLZE	F,FL.NST!FL.NUM
	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ /& means locked in core	/]
	TLNE	F,FL.AMP
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ /! means locked in core--can be shuffled/]
	TLNE	F,FL.EXM
	PUSHJ	P,MSG
	TLZE	F,FL.AMP!FL.EXM
	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ /$ means Execute Only	/]
	TRNE	F,FR.XOM	;WAS THERE AN EXECUTE ONLY JOB?
	PUSHJ	P,MSG		;YES. EXPLAIN FLAG

	MOVEI	M,[ASCIZ /n means job runs in HPQ n/]
	TRNE	F,FR.HPQ	;SEEN ANY JOBS IN HPQ'S?
	PUSHJ	P,MSG		;YES, EXPLAIN NUMBER
	TRZE	F,FR.XOM!FR.HPQ
	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ &+ means LOGIN during interval&]
	TRNE	F,FR.LGN	;ANY NEW LOGINS?
	PUSHJ	P,MSG		;YES, EXPLAIN +
	TRZE	F,FR.LGN
	PUSHJ	P,CRLF
	SKIPN	PTYS		;SEE IF ANY PTY JOBS
	JRST	DONJOB		;NO--END OF FOOTNOTES
	MOVEI	M,[ASCIZ /Jnn is the controlling job, Pnn corresponds to TTY/]
	PUSHJ	P,MSG		;YES--OUTPUT NOTE
	MOVE	N,PTYOFS	;GET OFFSET
	PUSHJ	P,OPRNT		;OUTPUT IT
	MOVEI	M,[ASCIZ /+nn
/]
	PUSHJ	P,MSG		;(PTY0 DRIVES OFFSET TTY)
DONJOB:	CAIN	WD,L.SSO	;SHORT STATUS ONLY?
	JRST	FINIS		;YES-GO SEE IF WE SHOULD EXIT. OR INTERPRET MORE CHS.
	TLZ	WD,SIGN		;CLEAR SIGN BIT IF IT WAS ON SO PRINTING MAY RESUME
	SKIPL	ONETTY		;SEE IF SINGLE TTY
	JRST	DEVQ		;YES--PROCEED TO DEVICE STATUS
	SKIPN	ONEJOB		;SEE IF SINGLE JOB
	SKIPE	ONEPPN		;OR SINGLE USER
	JRST	DEVQ		;YES--SKIP SEGMENT JUNK
	TLNN	F,FL.HGH
	JRST	DORMNT
	SUBTTL	PRINT HIGH-SEGMENT STATUS
	CAIN	WD,L.GSS	;ONLY GENERAL SYSTEM STATISTICS?
	TLO	WD,SIGN		;YES, SUPPRESS PRINTING
	LDB	D,DSKLEV
	SETOM	SEGFLG		;SEG SEGMENT FLAG
	MOVEI	M,[ASCIZ /
High Segments:
Program	/]
	PUSHJ	P,MSG
	JUMPE	D,.+3
	MOVEI	M,[ASCIZ /Device	/]
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ  /Owner	High(K)	Users

/]
	SKIPE	CPKI10
	MOVEI	M,[ASCIZ  /Owner	High(P)	Users

/]
	PUSHJ	P,MSG
	MOVE	J,SEGPTR
	SETZM	CORSAV		;CLEAR COUNTER FOR VIRT. CORE SAVED
HIGH00:	SKIPL	JS,@.STS
	JRST	DUNHGH
	SKIPN	A,@.PRG
	JRST	[MOVE	A,[SIXBIT /(priv)/]
		TLNE	JS,SHRSEG
		MOVE	A,[SIXBIT /(obs)/]
		JRST	.+1]
	PUSHJ	P,SIXBP		;PRINT SIXBIT MSG
	JUMPE	D,.+3
	MOVE	A,@.DEV
	PUSHJ	P,TABSIX
	SKIPN	A,SYSTAP	;SEE IF SYSTEM TAPE IS NOT A DISK
	JRST	HIGH04		;DISK--CHECK PPN
	CAME	A,@.PPN		;COMPARE WITH LEV.C DEVICE
	CAMN	A,@.DEV		;COMPARE WITH LEV.D DEVICE
	JRST	[MOVSI	A,(SIXBIT /SYS/)
		 JRST	HIGH2A]
	SKIPN	A,@.PPN		;NOT SYS, GET DEVICE NAME
	MOVE	A,@.DEV		;FROM TABLES
	JRST	HIGH2A		;AND GO PRINT IT
HIGH04:	MOVE	A,@.PPN
	CAMN	A,SYSPPN	;CUSP HISEG?
	JRST	HIGH2A		;YES-DON'T LOOK FOR DETACHED OWNER
	JUMPN	A,HIGH05
	PUSHJ	P,SEGSCN	;LOOK FOR JOB WITH THIS SEGMENT NO.
	  JRST	HIGH2C
	SKIPGE	B		;PRIVATE HISEG?
	JUMPE	A,[MOVEI M,[ASCIZ /	Job /]	;YES-COMPUTE JOB NO.
		SUB	B,.SGN
		HRRZ	N,B
		PUSHJ	P,MSGDEC	;AND PRINT IT
		JRST	HIGH2C]
IFE STANSW,<
HIGH05:	JUMPLE	A,HIGH2A	;OWNER MUST BE A DEVICE
	PUSH	P,J		;SAVE CURRENT SEGMENT NO.
	PUSHJ	P,SEGSCN	;FIND 1ST. JOB USING THIS HISEG
	  JRST	NOSEG		;NONE LEFT
	HRRZ	J,B
	SUB	J,.SGN		;GET JOB NO.
	HLRZ	C,@.TTY		;JOB DETACHED?
	CAIN	C,0
	CAME	A,@.PPN		;YES-IS THIS JOB HISEG OWNER?
	SKIPA	J,(P)		;NO-GET HISEG NO. AGAIN
	JRST	GO.ON		;YES-PRINT *'S UNLESS GOD
	AOBJN	P,.+1		;PRETEND WE DID A "PUSHJ"
	SOS	(P)		;DECREMENT PC
	AOBJN	B,HIGH06	;RE-ENTER SUBROUTINE (QUEL HACQUE!)
	POP	P,J		;POP OFF PC IF NO MORE JOBS TO CHECK
NOSEG:	POP	P,J		;RESTORE SEGMENT NO.
	JRST	HIGH2A		;PRINT OWNER
GO.ON:	POP	P,J		;RESTORE SEGMENT NO.
	PUSHJ	P,NOWHO		;PRINT *'S OR PRJPRG DEPENDING UPON GODLINESS
>
	JRST	HIGH2A

HIGH2C:	SETZ	A,		;PRINT BLANKS
HIGH2A:	PUSHJ	P,HIGH01
DUNHGH:	AOBJN	J,HIGH00	;ARE THERE ANY MORE HI SEGS.?
	JRST	DORMNT

HIGH01:	PUSHJ	P,PNTPPN	;PRINT AS P,PN PAIR
	PUSHJ	P,TAB
	TLO	F,FL.HSG	;FLAG HI-SEG
	PUSHJ	P,SEGSZ		;COMPUTE SEGMENT SIZE
	MOVE	B,N		;SAVE FOR LATER TEST
	TLNE	F,FL.DOR
	JRST	HIGH4A
	ADDM	N,CORUSE
	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
HIGH4A:	PUSHJ	P,DECP2X
	MOVSI	A,(SIXBIT //)
	PUSHJ	P,HIPSWP
	TLNE	F,FL.DOR
	JRST	CRLF
	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
	JRST	CRLF
	SUBTTL	PRINT DORMANT-SEGMENT STATUS
DORMNT:	TLZN	WD,SIGN		;SIGN ON?  YES IF GENERAL SYSTEM STATISTICS
	TLNN	F,FL.LPT!FL.DSK	;SEE IF FOR OPERATOR
	JRST	ENDDOR		;NO--SKIP
DODORM:	LDB	D,DSKLEV
	SETOM	SEGFLG		;SET SEGMENT FLAG
	MOVEI	M,[ASCIZ /
Dormant Segments:
Program	Owner	High(K)

/]
	JUMPE	D,.+2
	MOVEI	M,[ASCIZ /
Dormant Segments:
Program	Device	Owner	High(K)

/]
	SKIPE	CPKI10		;KI10 TEST
	MOVEI	M,[ASCIZ /
Dormant Segments:
Program	Device	Owner	High(P)

/]
	SETO	CH,
	MOVE	J,SEGPTR
DOR1:	SKIPGE	JS,@.STS	;SEGMENT DORMANT?
	JRST	DUNDOR		;NO
	MOVEI	N,OUTMSK
	SKIPN	@.ADR		;SEGMENT IN CORE?
	TDNE	N,@.SWP		;NO - ON DISK?
	JRST	DOR2		;YES - GO PRINT IT
	JRST	DUNDOR		;NOT IN USE

DOR2:	JUMPE	CH,DORMN
	PUSHJ	P,MSG
	TLO	F,FL.DOR
DORMN:	MOVE	A,@.PRG
	PUSHJ	P,SIXBP
	SKIPN	A,SYSTAP	;SEE IF "SYS:" NOT "DSK:"
	JRST	DORMN2		;DISK
	CAME	A,@.PPN		;CHECK LEV.C DEVICE
	CAMN	A,@.DEV		;CHECK LEV.D DEVICE
	JRST	[MOVSI	A,(SIXBIT /SYS/)
		 JRST	DORM2A]
	SKIPN	A,@.PPN
	MOVE	A,@.DEV
	JRST	DORM2A
DORMN2:	JUMPE	D,.+3
	MOVE	A,@.DEV
	PUSHJ	P,TABSIX
	MOVE	A,@.PPN
DORM2A:	PUSHJ	P,HIGH01
DUNDOR:	AOBJN	J,DOR1		;ARE THERE ANY MORE SEGS. TO LOOK AT?

ENDDOR:	TLZ	F,FL.DOR
	CAIN	WD,L.DSO	;LIST DORMANT SEGS. ONLY?
	JRST	FINIS		;YES - GO SEE IF WE SHOULD EXIT OR INTERPRET MORE CHS.
	SUBTTL	PRINT MEMORY UTILIZATION STATISTICS
MUSTAT:	PUSHJ	P,CRLF
	MOVEI	M,[ASCIZ /Swapping space used = /]
	MOVE	A,XK4SWP
	PUSHJ	P,GETZ
	JUMPE	A,[MOVE   A,CORMAX
		   ASH	  A,-12
		   MOVEM  A,TEMP
		   JRST   MUS3]
	MOVEM	A,TEMP
	MOVE	N,DSKUSE
	PUSHJ	P,PRPCNT
;**;[166], LD, MUS3-1/2, 3-JUN-75
	MOVEI	M,[ASCIZ /Swapping Space Lost = /]	;[166]
	MOVE	A,XSWPER	;[166]
	PUSHJ	P,GETZ		;[166]
	JUMPE	A,MUS3		;[166]
	HRRZ	N,A		;[166]
	TRZ	N,770000	;[166]
	PUSHJ	P,MSGDEC	;[166]
	PUSHJ	P,CRLF		;[166]
MUS3:	MOVEI	M,[ASCIZ /Virt. Core used = /]
	MOVE	N,CORUSE
	PUSHJ	P,PRPCNT
	MOVE	N,CORMAX
	ASH	N,-11
	SKIPN	CPKI10		;FOR A KI10 ALL IS OKAY
	ASH	N,-1		;BUT SHIFT 1 MORE FOR A KA10
	MOVEM	N,TEMP
	SUB	N,CORUSE
	JUMPL	N,SWAP01
	MOVEI	M,[ASCIZ /K Core left/]
	SKIPE	CPKI10
	MOVEI	M,[ASCIZ /P Core left/]
	PUSHJ	P,DECMSG
	JRST	SWAP02

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	M,[ASCIZ /%
/]
	JRST	MSG
SWAP01:	MOVEI	M,[ASCIZ /Swapping Ratio = /]
	MOVE	N,CORUSE
	PUSHJ	P,SWPPRT	;TYPE SWAPPING RATIO LINE
SWAP02:	MOVEI	M,[ASCIZ .
Active swapping ratio = .]
	MOVE	N,ACTUSE	;TOTAL ACTIVE VIRTUAL CORE
	PUSHJ	P,SWPPRT	;TYPE LINE
	SKIPN	N,CORSAV	;ANY CORE SAVED BY SHARING?
	JRST	SWAP03		;NO-DON'T PRINT ANYTHING
	MOVEI	M,[ASCIZ /
Virt. Core saved by sharing = /]
	PUSHJ	P,MSGDEC
	MOVSI	A,(SIXBIT ./(.)
	MOVE	N,CORSAV
	PUSHJ	P,SIXDEC
	MOVSI	A,(SIXBIT .+.)
	MOVE	N,CORUSE
	PUSHJ	P,SIXDEC
	MOVEI	M,[ASCIZ /) = /]
	MOVE	N,CORSAV
	ADD	N,CORUSE
	MOVEM	N,TEMP
	MOVE	N,CORSAV
	PUSHJ	P,CMPCNT	;COMPUTE PERCENTAGE & PRINT
	MOVSI	A,(SIXBIT .%.)
	PUSHJ	P,SIXBP
SWAP03:	PUSHJ	P,CRLF
	MOVE	N,NUMJOB	;NUMBER OF ACTIVE JOBS
	MOVEM	N,TEMP		;USE AS DIVISOR
	MOVEI	M,[ASCIZ .Average job size =.]
	MOVE	N,LOWUSE	;TOTAL OF LOW SEG SIZES
	PUSHJ	P,SWPPRT	;TYPE AVERAGE LOW SEG SIZE
	CALL	KAYPEE		;**[9] PRINT K OR P
	MOVEI	M,[ASCIZ .+.]
	MOVE	N,CORUSE	;TOTAL CORE USED
	ADD	N,CORSAV	;PLUS SAVED BY SHARING
	SUB	N,LOWUSE	;MINUS LOW SEGS= HIGH SEGS
	PUSHJ	P,SWPPRT	;TYPE AVERAGE HIGH SEGMENT SIZE
	CALL	KAYPEE		;**[9] PRINT K OR P
	MOVEI	M,[ASCIZ .  Total=.]
	MOVE	N,CORUSE	;TOTAL CORE USED
	ADD	N,CORSAV	;PLUS SAVED BY SHARING
	PUSHJ	P,SWPPRT	;TYPE AVERAGE TOTAL SIZE
	CALL	KAYPEE		;**[9] PRINT K OR P
	PUSHJ	P,CRLF
	CAIE	WD,L.GSS	;GENERAL SYSTEM STATISTICS ONLY?
	CAIN	WD,L.JSO	;PRINT JOB STATUS ONLY?
	JRST	FINIS		;YES-GO SEE IF WE SHOULD EXIT. OR INTERPRET MORE CHS.
	SUBTTL	"B" - DEVICE STATUS
DEVQ:	TLZ	F,FL.DEV	;CLEAR HEADER FLAG
	SETZM	DSKDDB		;CLEAR COUNTER OF DISK DDBS
	MOVE	A,XDVLST
	PUSHJ	P,GETZ
	HLRZ	D,A		;GET POINTER
	MOVEI	JS,^D10000	;PROTECT AGAINST INF. LOOP
DEVLP:	JUMPE	D,DEVEND	;EXIT. LOOP IF ALL DONE
	MOVEI	C,DV.MOD(D)
	PUSHJ	P,PEEKC
	MOVE	B,C
	TRNN	B,ASSCON+ASSPRG
	JRST	NXTDEV
	MOVEI	C,DV.LOG(D)	;GET LOGICAL NAME
	PUSHJ	P,PEEKC		;FROM DDB
	MOVEM	C,LOGNAM	;SAVE FOR LATER
	MOVEI	A,DV.NAM(D)
	PUSHJ	P,PEEKA
	MOVEI	C,@.DVJOB	;[212] NEW ENTRY IN DDB SINCE LOAD 722
	SKIPN	NPJOBN		;IF NEW STYLE THEN SKIP
	MOVEI	C,DV.CHR(D)
	PUSHJ	P,PEEKC
	LDB	J,PJOBN		;YES--GET JOB NUMBER
	SKIPE	NPJOBN		;IF NOT NEW STYLE
	LDB	J,NPJOBN	;GET JOB NUMBER SOMEWHERE ELSE
	MOVEI	C,DV.SPL(D)	;**[5] GET DEVSPL DDB ENTRY
	CALL	PEEKC		;**[C] IN C ASS J HAS BEEN SET
	SKIPL	C		;**[5] SPOOLED DEVICES USE A DISK DDB
	TLNE	B,DVDSK		;SEE IF DISK
	AOS	DSKDDB		;YES--COUNT IT
	TLNE	B,DVTTY		;SEE IF TTY
	TLNE	B,DVTTYC	;IF I/O TTY ALWAYS DO IT
	TLNN	B,DVTTY+DVDSK	;SEE IF TTY OR DISK
	JRST	DEVDO		;NO--JUST GO DO IT
	TLNE	F,FL.DSK	;IS IT DISK MODE?
	JRST	DEVDO		;YES--ALWAYS DO ALL DEVICES
	TLNN	F,FL.LPT!FL.GOD	;IF THIS IS OPER WORK
	CAMN	J,MYJOB		;OR SAME JOB
	SKIPN	LOGNAM		;AND THERE IS A LOGNAM
	JRST	NXTDEV		;**[5] FORGET THE THING
DEVDO:	SKIPE	N1,ONEJOB	;SEE IF SINGLE JOB
	CAMN	J,N1		;YES--SEE IF MATCHES
	JRST	.+2		;A WINNER
	JRST	NXTDEV		;NO--SKIP IT
				;**;[147]DEVDO+4,ELS,11/5/74
	SKIPN	N1,ONEPPN	;[147]MAKE WILD CARDS WORK; WAS ANY PPN
	JRST	DEVTTY		;[147]SPECIFIED?  NO; GO ON.
	MOVE	N,@.PPN		;[147]LOAD UP PPN OF DEVICE.
	TRNN	N1,-1		;[147]RIGHT HALF OF SPEC'D PPN WILD?
	TRZ	N,-1		;[147]YES; ZERO IT IN DEV PPN FOR MATCH.
	TLNN	N1,-1		;[147]HOW ABOUT THE LEFT HALF?
	TLZ	N,-1		;[147]DITTO.
	CAME	N,N1		;[147]IF THEY AREN'T SAME NOW,
	JRST	NXTDEV		;[147]GET ANOTHER DEVICE.
DEVTTY:	SKIPGE	N1,ONETTY	;[147](LABEL ADDITION) ;SEE IF SINGLE TTY MODE
	JRST	TTYOKD		;NO--PROCEED
	SETOM	N		;PRESET FOR TEST
	CAMN	N1,@.TTYN	;YES--SEE IF IT MATCHES
	CAMN	N,@.PPN		;SEE IF HIDDEN
	JRST	NXTDEV		;NO--SKIP IT
TTYOKD:	TLNE	B,DVTTY		;IF TTY
	TLNE	A,-1		;AND LH=0
	JRST	.+2		;NO
	HRLI	A,'DET'		;YES--DETACHED
	MOVEI	M,[ASCIZ /
Busy devices:
Device	Job	Why	Logical

/]
	TLNE	F,FL.DSK	;SEE IF DISK MODE
	MOVEI	M,[ASCIZ /
Busy devices:
Device	Job	Address	Why	Logical	UNILOG	DEVFIL	DEVEXT	DEVPPN

/]
	TLON	F,FL.DEV
	PUSHJ	P,MSG
	MOVEI	CH,"'"		;GET FLAG IN CASE DISK
	SKIPL	C		;**[6] IF SPOOLELED OR
	TLNE	B,DVDSK		;IS IT DISK?
	PUSHJ	P,TYO		;YES--OUTPUT FLAG FIRST
	HLRZ	CH,A		;GRAB FIRST 3 CHARS
	CAIN	CH,'PTY'	;IS IT A PTY?
	JRST	[MOVEI	CH,0	;YES, MAYBE LIST ANYWAY
		OR	CH,ONEJOB
		OR	CH,ONEPPN
		ORCM	CH,ONETTY
		SKIPE	CH	;NONE OF THESE
		JRST	.+1	;GIVE HIM THE PTY ANYWAY
		CAME	J,MYJOB	;ESPECIALLY IF IT IS HIS
		TLNE	F,FL.LPT!FL.GOD	;OR HE DESERVES IT
		JRST	.+1
		JRST	NXTDEV]	;SPARE HIM THE TYPEOUT
	PUSHJ	P,SIXTAB	;PRINT SIXBIT MSG FOLLOWED BY TAB
	MOVE	N,J		;**[5] GET JOB NUMBER
	PUSHJ	P,DECP2X
	PUSHJ	P,TAB
	TLNN	F,FL.DSK	;SEE IF DISK MODE
	JRST	DVWHY		;NO--PROCEED
	MOVEI	N,(D)		;YES--GET ADDRESS OF DDB
	MOVEI	CH,-1		;SET FOR 6 DIGITS
	PUSHJ	P,FIXOCT	;OUTPUT IT
	PUSHJ	P,TAB		;AND SPACE
DVWHY:	MOVEI	M,[ASCIZ /as/]
	TRNE	B,ASSCON
	PUSHJ	P,MSG
	TRNN	B,ASSPRG
	JRST	DVLOG
	MOVEI	CH,"+"
	TRNE	B,ASSCON
	PUSHJ	P,TYO
	MOVEI	M,[ASCIZ /init/]
	PUSHJ	P,MSG
DVLOG:	TLNN	F,FL.LPT!FL.GOD	;IF FOR OPERATOR
	CAMN	J,MYJOB		;OR THIS JOB
	SKIPN	A,LOGNAM	;AND THERE IS A LOGICAL NAME
	JRST	DVFILE		;NO--SKIP IT
	PUSHJ	P,TABSIX	;OUTPUT IT
DVFILE:	TLNE	F,FL.DSK	;IN DSK MODE?
	TLNN	B,DVDSK		;AND IS THIS A DSK DDB
	JRST	DVCRLF		;NO--SKIP IT
	SKIPN	LOGNAM		;NEED A TAB?
	PUSHJ	P,TAB		;YES
	MOVEI	A,@.DVUNI	;GET UDB ADDRESS
	PUSHJ	P,PEEKA
	TRNN	A,-1		;DOES "CURRENT" EXIST?
	MOVS	A,A		;IF NOT, USE "ORIGINAL" UDB
	TLZ	A,-1		;SEE IF WE HAVE AN ADDRESS
	JUMPE	A,DVLOG1	;?
	MOVEI	A,UNILOG(A)	;GET UNIT'S LOGICAL NAME
	PUSHJ	P,PEEKA		;...
DVLOG1:	PUSHJ	P,TABSIX	;AND PRINT IT
DVLOGN:	MOVEI	A,@.DVFIL	;USE D AS INDEX
	PUSHJ	P,PEEKA
	JUMPE	A,DVCRL0	;FORGET IT IF ITS ZERO
	PUSH	P,A		;SAVE FILE NAME
	MOVEI	A,@.DVEXT	;GET EXTENSION USE D AS INDEX
	PUSHJ	P,PEEKA
	TRZ	A,-1
	PUSHJ	P,TAB		;LINE IT UP
	CAME	A,[SIXBIT /UFD/]
	JRST	DVFIL1		;PRINT SIXBIT NAME
	EXCH	A,(P)		;GET UFD PPN
	PUSHJ	P,OCTPRA	;PRINT IT
	JRST	DVFIL2		;GO DO THE EXTENSION
DVFIL1:	EXCH	A,(P)		;GET SIXBIT FILE NAME
	PUSHJ	P,SIXBP		;DISPLAY IT
DVFIL2:	POP	P,A		;EXTENSION
	PUSHJ	P,TABSIX	;PRINT IT
	MOVEI	A,@.DVPPN	;GET OWNER USE D AS INDEX
	PUSHJ	P,PEEKA
	PUSHJ	P,PNTPPN	;AND PRINT IT
DVCRL0:
DVCRLF:	PUSHJ	P,CRLF
NXTDEV:	MOVEI	C,DV.SER(D)
	PUSHJ	P,PEEKC
	HLRZ	D,C
	SOJG	JS,DEVLP

DEVEND:	SKIPN	ONEJOB		;SEE IF SINGLE JOB
	SKIPE	ONEPPN		;SEE IF SINGLE PPN
	JRST	FINIS		;YES--ALL DONE
	SKIPL	ONETTY		;SEE IF SINGLE TTY
	JRST	FINIS		;YES--FINISH UP
	MOVEI	M,[ASCIZ /
No busy devices
/]
	TLZN	F,FL.DEV
	PUSHJ	P,MSG
	MOVEI	M,[ASCIZ / disk DDBs
/]
	SKIPE	N,DSKDDB	;GET DISK DDB COUNT
	PUSHJ	P,DECMSG	;OUTPUT IT IF THERE ARE ANY

DEVFIN:	CAIN	WD,L.BDO	;PRINT BUSY DEVICES ONLY?
	JRST	FINIS		;YES-GO SEE IF WE SHOULD EXIT. OR INTERPRET MORE CHS.
	SUBTTL	"F" - FILE STRUCTURE STATUS

FS:	TLZ	F,FL.DEV	;CLEAR HEADER FLAG
	SETZB	A,C
	MOVE	A,XSYSST
	PUSHJ	P,GETA
FS1:	HLRZ	D,A
	JUMPE	D,FSFIN
	MOVEI	A,STRNAM(D)
	PUSHJ	P,PEEKA
; [205] @FS1+3 1/2, JMT, 26-MAY-76
	JUMPE	A,FSL1		;[205] IF BLANK STRUCTURE NAME, PROCEED
	MOVEI	M,[ASCIZ /
System File Structures:
Name	Free	Mount
/]
	TLON	F,FL.DEV	;TYPED THIS HEADING YET?
	PUSHJ	P,MSG		;NO. DO IT NOW.
	PUSHJ	P,SIXTAB	;TYPE STRUCTURE NAME
	MOVEI	A,STRTAL(D)
	PUSHJ	P,PEEKA
	MOVE	N,A
	ADD	C,N		;ACCUMULATE IT IN THE TOTAL
	PUSHJ	P,DECTAB	;PRINT IT
	MOVEI	A,STRMNT(D)
	PUSHJ	P,PEEKA
	MOVE	N,A
	PUSHJ	P,DECPRT	;PRINT IT
	MOVEI	M,[ASCIZ /	Single Access by job /]
	MOVEI	A,STRJOB(D)
	PUSHJ	P,PEEKA
	JUMPLE	A,FSNNA
	HRRZ	N,A
	PUSHJ	P,MSGDEC	;AND PRINT HIS NUMBER
FSNNA:	MOVEI	M,[ASCIZ /	No New Accesses/]
	MOVEI	A,STRUNI(D)
	PUSHJ	P,PEEKA
	HLRZM	A,UNIBLK	;SET THE UDB ADDRESS
	PUSH	P,D		;SAVE STR ADDRESS
	CALL	GETDES		;GET UNIDES
	POP	P,D		;RESTORE D
	TLNE	A,(.UPNNA)	;SEE IF NNA
	PUSHJ	P,MSG		;YES--PRINT FLAG
FSL:	PUSHJ	P,CRLF		;GO TO NEW LINE
; [205] @FSL+1, ADD NEW LABEL, JMT, 26-MAY-76
FSL1:	MOVEI	A,STRSYS(D)	;[205]
	PUSHJ	P,PEEKA
	JRST	FS1		;LOOP

FSFIN:	MOVE	N,C		;TOTAL FREE
	MOVEI	M,[ASCIZ /Total Free /]
	PUSHJ	P,MSGDEC	;PRINT IT
	PUSHJ	P,CRLF		;NEW LINE
	CAIN	WD,L.FSO	;PRINT FILE STRUCTURES ONLY?
	JRST	FINIS		;YES-GE SEE IF WE SHOULD EXIT. OR INTERPRETMORE CHS.
	SUBTTL	"R" - REMOTE STATION STATUS

REMOTE:	TLZ	F,FL.DEV	;CLEAR HEADER FLAG
	SETOM	REMSNO		;INITIALIZE CURRENT STATION NUMBER
	MOVEI	A,JBTLOC	;FIND CENTRAL STATION NUMBER
	PUSHJ	P,GETZ		;FROM LOCATION TABLE (JOB 0)
	MOVEI	D,(A)		;JUST SAVE RH
	JUMPE	D,REMFIN	;SKIP IF NO STATION
	MOVE	A,XRMSTB	;START WITH STATION BLOCK POINTER
	PUSHJ	P,GETZ		;GET IT OR ZERO
	HRLZ	C,A		;INITIALIZE THE LOOP
	MOVEI	JS,1000		;[167] GUARD AGAINST INF. LOOP

REMLP:	HLRZ	C,C		;POSITION LINK
	JUMPE	C,REMFIN	;EXIT. WHEN DONE
	MOVEI	B,(C)		;SAVE STB FOR LATER
	PUSHJ	P,PEEKC		;GET NEXT STATION BLOCK
	JUMPE	C,REMFIN	;EXIT IF CAN'T READ CHAIN
	MOVEI	M,[ASCIZ /
Remote Stations
Number	Status

/]
	TLON	F,FL.DEV	;TEST-SET TITLE OUTPUT
	PUSHJ	P,MSG		;OUTPUT IT
	MOVEI	N,(C)		;GET STATION NUMBER
	CAMN	N,REMSNO	;SAME STATION AS BEFORE?
	JRST	REMNXT		;YES
	MOVEM	N,REMSNO	;NO. SAVE IT
	PUSHJ	P,OPRN2X	;PRINT IT LINED UP
	PUSHJ	P,TAB		;SPACE TO STATUS
	MOVEI	M,[ASCIZ /central/]
	CAIN	D,(C)		;SEE IF CENTRAL SITE
	JRST	REMOUT		;YES--OUTPUT THAT
	MOVEI	A,STBSTS(B)	;GET STATION STATUS
	PUSHJ	P,PEEKA		;FROM MONITOR
	MOVEI	M,[ASCIZ /down/]
	TRNE	A,REMDWN	;SEE IF DOWN
	JRST	REMOUT		;YES--OUTPUT IT
	MOVEI	M,[ASCIZ /running/]
	TRNN	A,REMNIC	;SEE IF IN CONTACT
	JRST	REMOUT		;YES--OUTPUT
	MOVEI	M,[ASCIZ /loading/]
	TRNE	A,REMLDG	;SEE IF LOADING
	JRST	REMOUT		;YES--OUTPUT
	MOVEI	M,[ASCIZ /not in contact/]
	TRNE	A,REMLDD	;SEE IF LOADED
	MOVEI	M,[ASCIZ /loaded--waiting for LOGIN/]

REMOUT:	PUSHJ	P,MSG		;OUTPUT STATUS
	PUSHJ	P,CRLF		;END LINE
REMNXT:	SOJG	JS,REMLP	;AND LOOP BACK

REMFIN:	CAIN	WD,L.RSO	;SEE IF REMOTES ONLY
	JRST	FINIS		;YES--FINISH UP
	SUBTTL	"T" - DATA SET TABLE

DSCDO:	MOVE	A,XDSCTB	;GET POINTER TO DATASET TABLE
	PUSHJ	P,GETZ		;(OPTIONAL)
	JUMPGE	A,DSCFIN	;SKIP TABLE IF EMPTY
	TLZA	F,FL.DEV	;CLEAR HEADER FLAG

DSCLP:	AOBJP	A,DSCFIN	;EXIT WHEN DONE
	HRRZ	C,A		;GET LOCATION OF THIS ENTRY
	PUSHJ	P,PEEKC		;LOOK AT IT
	TLNN	C,(DSCSTS)	;SEE IF OTHER THAN IDLE
	JRST	DSCLP		;IDLE--SKIP THIS ENTRY
	MOVEI	M,[ASCIZ /
Dataset Control
TTY#	Status

/]
	TLON	F,FL.DEV	;SEE IF HEADER OUTPUT YET
	PUSHJ	P,MSG		;NO--DO IT
	HRRZ	N,C		;GET TTY NUMBER (RH)
	PUSHJ	P,OPRN2X	;TYPE IT
	PUSHJ	P,TAB		;SPACE TO STATUS
	LDB	N,[POINT 3,C,2+^L<DSCSTS>]
	CAIN	N,6		;CHECK SPECIAL CASE FIRST
	TLNN	C,(DSCTIM)	;TIMED STATE 6
	JRST	DSCREG		;NO--REGULAR STUFF
	MOVEI	M,[ASCIZ /new call/]
	JRST	DSCMSG		;HAS NOT TYPED COMMAND YET

DSCREG:	SKIPE	M,DSCMTB-1(N)	;GET STANDARD MESSAGE IF ANY
	JRST	DSCMSG		;GO OUTPUT IT
	PUSHJ	P,OPRNT		;NO--TYPE OCTAL STATUS
	JRST	.+2		;AND SKIP
DSCMSG:	PUSHJ	P,MSG		;OUTPUT MESSAGE
	PUSHJ	P,CRLF		;AND END LINE
	JRST	DSCLP		;AND LOOP BACK

DSCMTB:	0	;STATE=1
	[ASCIZ /rang/]
	[ASCIZ /carrier interrupt/]
	0	;4
	0	;5
	[ASCIZ /in use/]
	0	;7

DSCFIN:	CAIN	WD,L.DSC	;SEE IF JUST THIS DISPLAY
	JRST	FINIS		;YES--EXIT
	SUBTTL	"E" - NON-DISK ERROR REPORT

	TLNN	F,FL.DSK!FL.LPT	;SEE IF FOR OPERATOR
	JRST	SWFIN		;NO--SKIP REST OF DISPLAYS
ERRPT:	TLZ	F,FL.DEV	;CLEAR TITLE FLAG
	MOVSI	D,-ERRTL1	;SETUP TABLE POINTER

ERRLP1:	MOVE	A,ERRTB1(D)	;GET NEXT GETTAB
	PUSHJ	P,GETZ		;GET IT IF POSSIBLE
	JUMPE	A,ERRLX1	;ZERO--EITHER NOT THERE OR NOT USED
	MOVEI	M,[ASCIZ /
non-disk Performance

/]
	TLON	F,FL.DEV	;SEE IF TITLE DONE YET
	PUSHJ	P,MSG		;OUTPUT TITLE
	MOVE	N,A		;SAVE COUNT
	HRRZ	M,ERRTM1(D)
	MOVE	B,ERRTM1(D)
	JUMPL	B,ERRLA1
	TLZE	B,200000	;DECIMAL HALF WORDS?
	JRST	ERRLA2		;YES
ERRLA3:	PUSHJ	P,DECMSG	;OUTPUT DECIMAL NUMBER AND MESSAGE
	JRST	ERRLY1		;JUMP TO FINISH LINE

ERRLA2:	HLRZS	N		;PRINT AS DECIMAL HALF WORDS
	PUSHJ	P,DECPRT	;PRINT LEFT HALF
	PUSHJ	P,COMMA
	HRRZ	N,A		;GET RIGHT HALF
	JRST	ERRLA3		;PRINT RH AND MSG
ERRLA1:	PUSHJ	P,OCTPRT	;OUTPUT OCTAL NUMBER
	PUSHJ	P,MSG		;OUTPUT MESSAGE
ERRLY1:	TLNN	B,140000
	JRST	ERRLY2
	MOVEM	A,TEMP
	MOVE	A,[%CVUPT]
	TLNE	B,20000
	ADDI	A,2
	PUSHJ	P,GETTB		;TRY TO GET UPTIME
	 JRST	[MOVE A,XUPTIM 	;DEFAULT TO TOTAL
		 PUSHJ P,GETA	;SYSTEMS UPTIME
		 JRST .+1 ]
	EXCH	A,TEMP
	IMULI	A,^D60
	TLNE	B,40000
; [201] @ERRLY1+11, JMT, 10-MAR-76
; [201] DELETE	IMULI	A,^D60
	IMUL	A,TCKSEC	;[201] REMEMBER ENGLAND !
	PUSHJ	P,CMPDFA
	MOVEI	M,[ASCIZ \/Second\]
	TLNE	B,40000
	MOVEI	M,[ASCIZ \/Minute\]
	PUSHJ	P,MSG
ERRLY2:	PUSHJ	P,CRLF		;END LINE
ERRLX1:	AOBJN	D,ERRLP1	;LOOP BACK UNTIL DONE
;PRINT LAST STOPCD INFORMATION
	MOVE	A,[3,,51]		;GET LAST SOPCODE DATA
	PUSHJ	P,GETZ			;GET IT OR A ZERO
	JUMPE	A,NSTOPC			;THERE WAS NO STOPCD
; [202] @ERRLX1+3 1/2, JMT, 12-MAY-76
	TLNE	F,FL.DSK	;[202] ARE WE IN DISK MODE ?
	JRST	DSKSTC		;[202] YES--CAN'T GET TYPE
	PUSH	P,SPYFLG	;[202] SAVE SPY FLAG ON STACK
	SETZM	SPYFLG		;[202] CLEAR SPY FLAG SO PEEK IS DONE
	HRRZ	A,A		;[202] STRIP OFF STOPCD NAME
	PUSHJ	P,PEEKA			;GET FLAG WORD
	POP	P,SPYFLG	;[202] RESTORE SPY FLAG FROM STACK
	HRLZ	BP,A			;GET SIXBT OF LAST STOPCD
	LDB	A,[POINT 4,A,12]	;GET TYPE OF CODE
	PUSH	P,A			;SAVE TYPE
	PUSHJ	P,SIXBP1			;PRINT SIXBIT CODE
	MOVEI	M,[ASCIZ / WAS LAST STOPCD TYPE=/]
	PUSHJ	P,MSG			;PRINT NAME
	POP	P,A			;GET THE TYPE BACK
	MOVE	M,STOPT(A)		;GET TYPE OF STOPCD
	PUSHJ	P,MSG			;PRINT IT AND
	PUSHJ	P,CRLF			;A NEW LINE
	JRST	NSTOPC		;[202] PROCEED ONWARD
DSKSTC:	HLLZ	BP,A		;[202] STRIP OFF PC FROM %SYSPC
	PUSHJ	P,SIXBP1	;[202] PRINT SIXBIT STOPCD
	MOVEI	M,[ASCIZ/ WAS THE LAST STOPCD/]	;[202]
	PUSHJ	P,MSG		;[202] PRINT IT
	PUSHJ	P,CRLF		;[202] ALONG WITH <CRLF>
NSTOPC:
	TLNN	F,FL.DSK	;SEE IF DISK MODE
	JRST	ERRXIT		;NO--SKIP CRASH STUFF
	MOVE	A,XPCMA		;GET PC AND MA (FROM SWITCHES)
	PUSHJ	P,GETZ		;FROM MONITOR
	JUMPE	A,ERRLX0	;NOT USEABLE
	MOVEM	A,D		;SAVE FOR LATER
	PUSHJ	P,CRLF		;START NEW LINE
	MOVEI	M,[ASCIZ /PC=/]
	HLRZ	N,A		;GET PC
	PUSHJ	P,MSGOCT	;OUTPUT PC
	MOVEI	M,[ASCIZ /  MA=/]
	HRRZ	N,A		;GET MA
	PUSHJ	P,MSGOCT	;OUTPUT MA
	MOVE	A,XPIIP		;GET PI SYSTEM
	PUSHJ	P,GETZ		;FROM MONITOR
	ANDI	A,77400		;MASK TO IN-PROGRESS
	JUMPE	A,ERRLXX	;SKIP IF NONE
	MOVSI	B,-^D8		;SET UP COUNT
	MOVEI	M,[ASCIZ /  PIs in prog=/]
ERRLPX:	AOBJP	B,ERRLXX	;COUNT EACH CHANNEL
	LSH	A,1		;POSITION BITS
	TRNN	A,100000	;SEE IF ON
	JRST	ERRLPX		;LOOP IF NOT
	HRRZ	N,B		;GET CHANNEL NUMBER
	PUSHJ	P,MSGDEC	;OUTPUT NUMBER
	MOVEI	M,[ASCIZ /,/]
	JRST	ERRLPX		;LOOP FOR MORE
ERRLXX:	PUSHJ	P,CRLF		;END LINE

ERRLX0:	MOVE	A,MONVER	;IS MONITOR > 5.04?
	CAIGE	A,50400
	JRST	ERRLX2		;NO, "JOB" IS 150
	MOVEI	A,20		;YES, "JOB" IS 20.  GET IT.
	PUSHJ	P,PEEKA
	TLNN	A,-1		;DUAL PROCESSOR?
	JRST	ERRLX3		;NO, PRINT C(JOB)
	MOVEI	M,[ASCIZ /Job (CPU1,,CPU0)  /]
	HLRZ	N,A		;GET CPU1 JOB
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ /,,/]
	HRRZ	N,A		;GET CPU0 JOB
	PUSHJ	P,MSGDEC	;PRINT IT
	JRST	ERRLX4		;DONE WITH C(JOB)

ERRLX2:	MOVEI	A,150		;GET JOB (FOR MONITOR OLDER THAN 5.04)
	PUSHJ	P,PEEKA		;FROM MONITOR
ERRLX3:	MOVE	N,A		;MOVE TO OUTPUT
	MOVEI	M,[ASCIZ /job  /]
	PUSHJ	P,MSGDEC	;OUTPUT IT
ERRLX4:	MOVEI	A,30		;READ LOCATION 30
	PUSHJ	P,PEEKA		;FROM MONITOR
	MOVE	N,A		;SETUP FOR OUTPUT
	MOVEI	M,[ASCIZ /	C(30)  /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	PUSHJ	P,CRLF		;NEW LINE
	MOVE	A,XAPRCN	;GET APR CONI
	PUSHJ	P,GETZ		;FROM CRASH
	ANDI	A,7		;GET CHANNEL OF APR
	ADDI	A,40(A)		;GET 40+2*A
	PUSHJ	P,PEEKA		;LOOK IN CORE AS JSR FOR CLOCK
	ANDI	A,-1		;CLEAR JUNK
	CAML	A,DSKFLG	;MAKE SURE IT IS OK
	JRST	ERRNCL		;NO--SKIP THIS LINE
	PUSHJ	P,PEEKA		;GET PC AT LAST CLOCK
	MOVE	N,A		;MOVE TO OUTPUT
	MOVEI	M,[ASCIZ /PC at trap  /]
	PUSHJ	P,MSGOCT	;OUTPUT LINE
	PUSHJ	P,CRLF		;AND END LINE
	PUSHJ	P,GETBTH	;GET IT AND IT-1
	  JRST	ERRNCL		;SKIP IF JUNK
	MOVE	N,C		;GET -1
	MOVEI	M,[ASCIZ /C(PCT-1)  /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	MOVE	N,A		;GET IT
	MOVEI	M,[ASCIZ /	C(PCT)	/]
	PUSHJ	P,MSGOCT	;PRINT IT
	PUSHJ	P,CRLF		;END OF LINE

ERRNCL:	HLRZ	A,D		;GET PC
	PUSHJ	P,GETBTH	;GET IT AND IT-1
	  JRST	ERRNPC		;SKIP IF BAD
	MOVE	N,C		;GET -1
	MOVEI	M,[ASCIZ /C(PC-1)   /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	MOVE	N,A		;GET IT
	MOVEI	M,[ASCIZ /	C(PC)   /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	PUSHJ	P,CRLF		;END LINE

ERRNPC:	HRRZ	A,D		;GET MA
	PUSHJ	P,GETBTH	;GET IT AND IT-1
	  JRST	ERRNMA		;SKIP IF BAD
	MOVE	N,C		;GET MA-1
	MOVEI	M,[ASCIZ /C(MA-1)   /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	MOVE	N,A		;GET MA
	MOVEI	M,[ASCIZ /	C(MA)   /]
	PUSHJ	P,MSGOCT	;OUTPUT IT
	PUSHJ	P,CRLF		;END LINE

ERRNMA:
ERRXIT:	CAIN	WD,L.ERR	;SEE IF JUST THIS DISPLAY
	JRST	FINIS		;YES--END
	JRST	DP		;NO--PROCEED

ERRTB1:
XMNVER:	EXP	%CNVER
	EXP	%CNPOK
	EXP	%CNPUC
	EXP	%NSTPE
	EXP	%NSSPE
	EXP	%NSMPC
	EXP	%NSMPA
	EXP	%NSMPW
	EXP	%NSMPP
	EXP	%NSEPO
	EXP	%NSEPR
	EXP	%NSABC
	EXP	%NSABA
	EXP	%SYNCP
	EXP	%CVTUC
	EXP	%CVTUC+2
	EXP	%CVTJC
	EXP	%CVTJC+2
	0,,51			;SYSERR COUNT
	2,,51			;DISABLED ERROR COUNT
	4,,51			;NUMBER OF STOPCD OCURRANCIES
	5,,51			;STOPCDS WHICH STOPPED A JOB
ERRTL1==.-ERRTB1

;ERROR PRINT MESSAGES:
;	BIT 0 - PRINT COUNT IN OCTAL
;	BIT 1 - PRINT COUNT AS DECIMAL HALF WORDS
;	BIT 2 - PRINT AVERAGE NUMBER OF OCCURRANCES/SECOND
;	BIT 3 - PRINT AVERAGE NUMBER OF OCCURRANCES/MINUTE

ERRTM1:	1B0+[ASCIZ /=monitor version/]
	1B0+[ASCIZ / address of last POKE uuo/]
	1B1+[ASCIZ / lh=job that POKEd, rh=# of POKEs/]
	[ASCIZ / user memory parity errors/]
	[ASCIZ / spurious memory parity errors/]
	[ASCIZ / continues after memory parity errors/]
    1B0+[ASCIZ / address of last memory parity error/]
    1B0+[ASCIZ / contents of last memory parity error/]
    1B0+[ASCIZ / PC of last memory parity error/]
	1B2+[ASCIZ / EXEC PDL overflows=/]
	1B2+[ASCIZ / recovered EXEC PDL overflows=/]
	[ASCIZ / address breaks/]
    1B0+[ASCIZ /=switches on last address break/]
	1B3+[ASCIZ /=Number of commands processed=/]
	1B2+[ASCIZ /=Number of UUOs executed on CPU0=/]
	1B2+1B4+[ASCIZ /=Number of UUOs executed on CPU1=/]
	1B2+[ASCIZ /=Number of context switches on CPU0=/]
	1B2+1B4+[ASCIZ /=Number of context switches on CPU1=/]
	[ASCIZ /=SYSTEM WIDE HARDWARE ERROR COUNT/]
	[ASCIZ /=NUMBER OF ERRORS FOR WHICH LOGGING WAS DISABLED/]
	[ASCIZ /=NUMBER OF STOPCD CODES/]
	[ASCIZ /=NUMBER OF STOPCD'S WHICH CAUSED A JOB TO STOP/]
SUBTTL "P" - PERFORMANCE OF DISKS INCLUDING ERRORS

DP:	PUSHJ P,CRLF
	LDB	D,DSKLEV	;DISK LEVEL NO. FROM STATES WORD
	SKIPE	D		;BEFORE 5.01?
	SKIPE	TNFRTY		;NO, SEE IF 10/40N
	JRST	SWFIN		;YES--SKIP DISK PERFORMANCE
	CAIN WD,L.DPO		;"P" TYPED?
	PUSHJ	P,THISIS	;YES--GIVE SYSTEM HEADER
	MOVEI M,[ASCIZ .
Disk performance statistics:
.]
	PUSHJ P,MSG
	SETZM CURFS
	TRZ	F,FR.NFS	;CLEAR "NOT IN A F/S" CODE FLAG
	MOVEI M,[ASCIZ .Unit or F/S
	BR	BW	DR	DW	XR	XW	MR	MW
.]
	PUSHJ P,MSG

	MOVE	A,XSYSST	;SYS STR LIST POINTER
	PUSHJ	P,GETA
FLFSL:	HLRZ	C,A
	JUMPE	C,FLNFS		;IF 0, GO TO UNITS NOT IN ANY F/S
	MOVEM	C,CURFS		;C GETS CLOBBERED LATER
	MOVEI	A,STRNAM(C)
	PUSHJ	P,PEEKA
	JUMPE	A,FILEXI	;(IN CASE WE CAN'T PEEK)
	PUSHJ	P,SIXBP		;TYPE F/S NAME
	PUSHJ	P,TAB
	MOVEI	A,STRTAL(C)	;GET BLOCKS LEFT
	PUSHJ	P,PEEKA
	MOVE	N,A
	PUSHJ	P,DECPRT	;PRINT IT
	MOVEI	M,[ASCIZ . Free
.]
	PUSHJ	P,MSG
;UNIT STUFF HERE

	MOVEI	A,STRUNI(C)
	PUSHJ	P,PEEKA
FLUNL:	HLRZ	D,A		;D NOW POINTS TO THE UDB
	JUMPE	D,FLFSN		;DONE ALL UNITS?
FLUNL1:	MOVEM	D,UNIBLK	;SET POINTER FOR USE BY ERROR STATISTICS CODE
	movsi	n,-6		;6 read write varibles
	hrri	n,unibrc(d)	;start at unibrc
	setzm	iocnt		;no one read
flu000:	hrrz	a,n		;get the address
	pushj	p,peeka		;get the count
	addb	a,iocnt		;store in both
	jumpn	a,flu010	;non zero then report
	aobjn	n,flu000	;try next entry
	CALL	GETDES		;GET UNIDES
	tlne	a,210000	;ofline zero mount
	pjrst	flunn		;next unit
	ldb	a,[point 2,a,8]	;uniust field
	jumpn	a,flunn		;unit is not mounted
	skipn	iocnt		;any i/o done
	jrst	flunn		;no do not report
flu010:	MOVEI	A,UNINAM(D)	;GET PHYSICAL UNIT NAME
	PUSHJ	P,PEEKA
	MOVEM	A,DSKBLK	;SAVE NAME IN CASE WE MUST DO DSKCHR UUO
	PUSHJ P,SIXBP
	MOVEI M,[ASCIZ /(/]
	PUSHJ P,MSG
	MOVEI A,UNIHID(D)
	PUSHJ	P,PEEKA
	PUSHJ P,SIXBP
	MOVEI M,[ASCIZ /): /]
	CALL	GETTAL		;GET UNITAL
	MOVE	N,A
	PUSHJ P,MSGDEC
	MOVEI M,[ASCIZ . Free, .]
	PUSHJ P,MSG
	MOVEI A,UNIUSC
	PUSHJ P,GETUDB
	MOVEI A,UNIMSC
	ADD A,UNIBLK
	PUSHJ P,PEEKA
	ADD N,A
	MOVEI M,[ASCIZ / Seeks
/]
	PUSHJ P,DECMSG
	MOVSI C,-UDTBL
FLUNL3:	HRRZ	A,UDTAB(C)
	CAIE	A,UNIXRA	;THIS OFFSET CHANGED IN 50634
	JRST	FLUNL0		;NO SKIP UPDATE
	CALL	GETXRA		;GET UNIXRA
	SKIPA	N,A		;SKIP GET UDB
FLUNL0:	PUSHJ P,GETUDB
	HLRE A,UDTAB(C)
	JUMPE A,FLUNLA
	JUMPL A,FLDIFF
	MOVE A,STATES
	TLNN A,(CANXRC)
	MOVEI N,0
	PUSH P,N
	TLZ N,-1
	PUSHJ P,TAB
	PUSHJ P,DECPRT
	POP P,N
	HLRZ N,N
	JRST FLUNLA

FLDIFF:	MOVNS A
	ADD A,UNIBLK
	PUSHJ	P,PEEKA
	SUB N,A
FLUNLA:	PUSHJ P,TAB
	PUSHJ P,DECPRT
	AOBJN C,FLUNL3
FLUN2:	PUSHJ P,CRLF
	TLZ F,FL.NBK+FL.DEV
	PUSHJ	P,SETDES	;GET DSKCHR BITS
	TLZ A,BITMSK
	JUMPE A,FLUN4
	PUSHJ P,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
	PUSHJ P,CRLF
	SKIPE	A,DOALT		;ARE WE DOING ALTERNATE PATH?
	 JRST FLMAIN		;YES, GO BACK TO MAIN FOR NEXT
	MOVEI	A,UNI2ND	;GO GET ALTERNATE PART WORD
	PUSHJ	P,PEEKA		;IF 0 NO ALT PATH, -1,,UDB ADDR IF THIS
	SKIPLE	A		;.. IS ALTERNATE, 0,,UDB PIONTER TO ALT
	 JRST FLALT		;SET UP TO DO ALTERNATE

FLUNN:	TRNE	F,FR.NFS
	JRST	FLNFS2
flunn2:	MOVEI	A,UNISTR(D)
	PUSHJ	P,PEEKA
	JRST FLUNL

FLFSN:	MOVE	C,CURFS
	MOVEI	A,STRSYS(C)
	PUSHJ	P,PEEKA
	JRST FLFSL		;LOOP FOR NEXT STRUCTURE

FLALT:	AOS	DOALT		;REMEMBER DOING ALTERNATE
	MOVEM	D,MAIND		;REMEMBER MAIN UDB (D)
	HRLZ	A,A		;PUT UDB (OF ALT) ADDR IN LEFT
	JRST	FLUNL		;GO THROUGH THIS LOOP AGAIN

FLMAIN:	MOVE	D,MAIND		;RESTORE D
	SETZM	DOALT		;RESET ALTERNATE FLAG
		JRST FLUNN
SETDES:	TLNE	F,FL.DSK	;DISK MODE?
	JRST	SETDE2		;YES
	MOVE	A,[XWD 1,DSKBLK]
	DSKCHR	A,		;NOTE! THIS IS THE ONLY WAY TO GET THE "SWP" BIT
	SETZ	A,
SETDE1:	HLLZ	A,A		;CLEAR OUT RH
	POPJ	P,0

SETDE2:	CALL	GETDES		;GET UNIDES
	HLLZ	B,A		;SAVE UNIDES
	SKIPN	C,CURFS		;GET F/S
	JRST	SETDE1		;RETURN IF NOT IN A F/S
	MOVEI	A,STRMNT(C)
	PUSHJ	P,PEEKA
	CAIN	A,0		;ZMT?
	TLO	B,UNPZMT
	MOVEI	A,STRJOB(C)
	PUSHJ	P,PEEKA
	CAILE	A,0		;SAF?
	TLO	B,UNPSAF
	HLLZ	A,B
	POPJ	P,0
;NOTE THAT SWP IS NEVER ON IF /X

;CODE FOR UNITS NOT IN ANY F/S
FLNFS:	TRO	F,FR.NFS!FR.NFP
	SETZM	CURFS
	MOVE	A,XSYSUN	;SYSTEM UNIT LIST POINTER
	PUSHJ	P,GETA
FLNFS1:	HLRZ	D,A
	JUMPE	D,FILEXI
	MOVEI	A,UNISTR(D)
	PUSHJ	P,PEEKA
	JUMPE	A,FLNFS3	;JUMP IF NOT IN A F/S
FLNFS2:	MOVEI	A,UNISYS(D)
	PUSHJ	P,PEEKA
	JRST	FLNFS1
FLNFS3:	MOVEI	M,[ASCIZ .Units not in any File Structure:
.]
	TRZE	F,FR.NFP
	PUSHJ	P,MSG
	JRST	FLUNL1
FILEXI:
SW:	MOVEI	M,[ASCIZ /
Active swapping statistics:
Unit	R	W	Used(K)
/]
	SKIPE	CPKI10
	MOVEI	M,[ASCIZ /
Active swapping statistics:
Unit	R	W	Used(P)
/]
	PUSHJ	P,MSG
	MOVE	A,XSWPUN
	PUSHJ	P,GETA
	MOVEM	A,SWPUNI
	HLRZ	D,A
SWLP1:	MOVEI	A,UNINAM(D)
	PUSHJ	P,PEEKA
	PUSHJ	P,SIXBP
	PUSHJ	P,TAB
	MOVEI	A,UNIICT(D)
	PUSHJ	P,PEEKA
	MOVE	N,A
	PUSHJ	P,DECTAB
	MOVEI	A,UNIOCT(D)
	PUSHJ	P,PEEKA
	MOVE	N,A
	PUSHJ P,DECPRT
	MOVEI A,UNIFKS(D)
	PUSHJ	P,PEEKA
	MOVEM A,N
	MOVEI A,UNIK4S(D)
	PUSHJ	P,PEEKA
	ANDI A,MSKK4S
	SKIPE	CPKI10		;A KA10
	LSH	A,1		;NO SHIFT ONE MORE
	MOVEM A,TEMP
	SUBB A,N
	MOVEI M,[ASCIZ /	/]
	PUSHJ P,PRPCNT
	MOVEI A,UNISWP(D)
	PUSHJ	P,PEEKA
	HLRZ D,A
	JUMPN D,SWLP1
	PUSHJ P,CRLF
;HERE TO CHECK FOR SWAP READ ERRORS
	MOVE A,XSWPER
	PUSHJ P,GETZ
	JUMPE A,SWFIN
	MOVE D,A
	MOVEI M,[ASCIZ /
Swap errors: /]
	PUSHJ P,MSG
	HLRZ N,D
	PUSHJ P,DECTAB
	MOVEI M,[ASCIZ / CHK/]
	TRZE D,IOIMPM
	PUSHJ P,MSG
	MOVEI M,[ASCIZ / DEV/]
	TRZE D,IODERR
	PUSHJ P,MSG
	MOVEI M,[ASCIZ / DAT/]
	TRZE D,IODTER
	PUSHJ P,MSG
	MOVEI M,[ASCIZ /   K Lost: /]
	SKIPE	CPKI10
	MOVEI M,[ASCIZ /   P Lost: /]
	HRRZ N,D
	TRZ	N,770000	;**[6] FIRST 3 ARE NOT NEEDED,BUT
	PUSHJ P,MSGDEC
	PUSHJ P,CRLF
SWFIN:	JRST FINIS
	SUBTTL ROTINES TO SETDES UNITAL AND UNIXRA FROM THE UDB

;ALL USE D TO STORE THE UDB ADDRESS FROM UNIBLK
;CLOBBER B AND RETURN THE VALUE IN A

GETTAL:	MOVE	D,UNIBLK	;GET UDB ADDRESS
	MOVEI	A,UNITAL(D)	;AND ENTRY
	CALL	UPDADR		;UPDATE THE ADDRESS
	LDB	B,DSKLEV	;GET VERSION
	CAIG	B,1		;SEE HOW OLD
	MOVEI	A,UNITL1(D)	;REUPDATE
	PJRST	PEEKA		;AND GET THE VALUE

GETDES:	MOVE	D,UNIBLK	;GET THE UDB ADDRESS
	MOVEI	A,UNIDES(D)	;GET THE ENTRY
	CALL	UPDADR		;UPDATE THE ADDRES
	LDB	B,DSKLEV	;GET THE DISK VERSION
	CAIG	B,1		;SEE HOW OLD
	MOVEI	A,UNIDE1(D)	;SO CHANGE
	PJRST	PEEKA		;AND GET IT

GETXRA:	MOVE	D,UNIBLK	;GET UDB ADDRES
	MOVEI	A,UNIXRA(D)	;AND ENTRY
	hrrz	b,monver	;get monitor version
	cail	b,50750		;if 602 then
	subi	a,1		;one less
	CALL	UPDADR		;UPDATE THE ADDRESS
	PJRST	PEEKA		;AND PEEK


UPDADR:	HRRZ	B,MONVER	;GET VERSION
	CAIL	B,50634		;HERE UNITAL XRA AND DES BECAME 3 LARGER
	ADDI	A,3		;SO UPDATE
	TXNE	F,FR.VMF	;IF VM THEN
	ADDI	A,2		;ADD ANOTHER 2
	RETURN

	;OFFSET IN A GETS CONTENTS INTO N

GETUDB:	ADD A,UNIBLK
	PUSHJ	P,PEEKA
	MOVE N,A
	POPJ P,
PRTBIT:	MOVEI M,BITTAB(C)
	PUSHJ P,MSG
	PUSHJ P,SPACE
	POPJ P,0

PRTUED:	JUMPE N,CPOPJ
	PUSH P,M
	MOVEI M,[ASCIZ / Errors: /]
	TLON F,FL.DEV
	PUSHJ P,MSG
	POP P,M
	PUSHJ P,MSGDEC
	JRST SPACE

PRTUEO:	JUMPE N,CPOPJ
	PUSH P,M
	MOVEI M,[ASCIZ / Errors: /]
	TLON F,FL.DEV
	PUSHJ P,MSG
	POP P,M
	PUSHJ P,MSG
	PUSHJ P,OCTPRT
	JRST SPACE

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 1,UNIXRA
	XWD -UNIICT,UNIMRC
	XWD -UNIOCT,UNIMWC
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 UNIERR,[ASCIZ /2CONI:/]
	XWD UNISOF,[ASCIZ /1CONI:/]
	XWD UNIHBN,[ASCIZ /LBN:/]
	XWD UNIHNG,[ASCIZ /PHUNG:/]
	XWD UNIHNG,[ASCIZ /THUNG:/]
	XWD UNIHNG,[ASCIZ /NTHUNG:/]
	XWD UNIHNG,[ASCIZ /SHUNG:/]
	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
	JFCL
	JFCL
	JFCL
	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
UER2T3:	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUEO
	PRTUEO
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUED
	PRTUEO
	PRTUEO
FINIS:	SKIPE	JOBINT+2	;CONTROL C TYPED?
	JRST	CTRAP		;[145] YES, GO SERVICE
;**[10]	JRST	HACKQ		;YES, EXIT
	PUSHJ	P,CRLF
; [200] @FINIS+3, JMT, 3-MAY-76
; [200] DELETE	TRNE	F,FR.CNT	;IS THIS CONTINUOUS?
; [200] DELETE	JRST	SNOOZE		;YES
	JUMPE	WD,HACKQ	;NO CHS. TYPED--EXIT.
	JUMPL	F,HACKQ		;BREAK CH. FOUND--EXIT.
	TRNN	F,FR.DSK	;DO NOT CLODE DISK FILE
	CLOSE	TTY,		;EMPTY BUFFERS (IN CASE OF TTY ^O)
	AND	F,[FL.GOD!FL.LGI!FL.LPT,,FR.CNT!FR.DPY!FR.DSK!FR.INI]
	SETZM	ONCE		;SET ONCE THRU FLAG
	JRST	AGAIN		;GO INTERPRET MORE CHS.


;HERE ON FATAL ERROR

BOMB.:	OUTSTR	[ASCIZ /
? /]
	OUTSTR	(M)		;OUTPUT MESSAGE
	OUTSTR	[ASCIZ /
/]
	CLRBFI			;CLEAR TYPE AHEAD
	JRST	EXIT.		;GO BIND OFF JOB

;HERE WHEN ^C TYPED

CTRAP:	TLNN	F,FL.LGI	;[145] ARE WE LOGGED IN?
	  JRST	KILL		;[145] NO, GO KJOB
	PUSH	P,JOBINT+2	;[145] SAVE RETURN
	CLRBFO			;[145] KILL TYPE-AHEAD
	EXIT	1,		;[145] STOP NOW
	SETZM	JOBINT+2	;[145] ALLOW MORE ^CS
	POPJ	P,		;[145] CONTINUE WHERE STOPPED
	SUBTTL	FINISH UP
; [200] @HACKQ, JMT, 3-MAY-76
HACKQ:	TRNE	F,FR.CNT	;[200] ARE WE CONTINUING ?
	JRST	SNOOZE		;[200] YES--GO SLEEP FOR AWHILE
	TRNE	F,FR.DSK	;KEEP DISK FILES OPEN
	JRST	EXIT.		;NO BIRTH DAYS
	CLOSE	TTY,
	IFN HACKSW,<
	IFL	HACKSW,<
	MOVE	A,XAPRSN	;GET SERIAL NUMBER
	PUSHJ	P,GETZ		; OF THIS MACHINE
	MOVSI	B,-LENHAQ	;SEARCH SPECIAL TABLE
HAQ1:	MOVE	C,HAQAPR(B)	; OF MACHINES TO BE
	CAME	A,C		; HACKED
	AOBJN	B,HAQ1		;LOOP
	JUMPGE	B,EXIT.		;EXIT. IF NOT THIS MACHINE
>
	SETZB	WD,TYOB		;CLEAR WD IN CASE -VE SO PRINTING WILL HAPPEN
	MOVE	A,DATE
	IDIVI	A,^D31*^D12	;GET MODULO YEAR
	MOVEM	B,DATE
	MOVSI	J,-HAKLEN
	JUMPE	J,EXIT.		;GO AWAY IF EMPTY TABLE
HAKLUP:	MOVE	A,HAKTAB(J)
	HLRZ	B,A		;THE DATE FROM TABLE
	ANDI	B,7777		;JUST DATE CODE
	CAME	B,DATE		;TODAY?
	JRST	HAKNXT		;NO
	PUSHJ	P,CRLF2
	MOVEI	M,BMSG
	SKIPL	A
	PUSHJ	P,MSG
	HRRZ	M,A
	PUSHJ	P,MSG
	PUSHJ	P,CRLF
HAKNXT:	AOBJN	J,HAKLUP
>
	JRST	EXIT.

	IFL	HACKSW,<
HAQAPR:	DEC	1,2,40,169,513,514,546,1026
LENHAQ==.-HAQAPR
>
NOCOR:	MOVEI	M,[ASCIZ /?Need more core for data

/]
	PUSHJ	P,MSG
EXIT.:	CLOSE	TTY,		;CLOSE TTY IN CASE OF ^O
	PUSHJ	P,GETCHR	;GOBBLE LEFTOVER CHS. UNTIL A BREAK CH. IS SEEN
	TLZA	F,FL.BRK	;CLEAR BREAK CHAR FLAG
	JRST	.-2
KILL:	TDZ	F,[FL.LPT,,FR.INI!FR.DSK]	;EDIT 17 FORGET ALL ABOUT IO
	RELEASE	TTY,		;[145] CLEAR BITS, THEN RELEASE TTY
	SKIPN	TNFRTY		;EXIT ON 10/40 SYSTEM
	TLNE	F,FL.LGI
	pjrst	[ EXIT	1,
		  pjrst	systat] ;restart it
	OUTSTR	KJMSG
	LOGOUT

KJMSG:	ASCII	/.KJOB/
	BYTE	(7) 15,12,".",4,0

MINUTE==^D12			;THIS IS THE SLEEP TIME

SNOOZE:	CLOSE	TTY,		;CLOSE TTY IN CASE OF ^O
	TLNN	F,FL.LGI
	JRST	KILL		;NOT LOGGED IN, CAN'T REPEAT
	RELEASE	TTY,
	TRZ	F,FR.INI	;**[16] NO MORE INITED
 	SETZM	TYOB		;TO FORCE USE OF TTCALL I/O
	TTCALL	2,M		;JUST TO RESET THE ^O BIT
	  JRST	SNOOZ1
	CAIN	M,3		;IS IT ^C ?
	EXIT	1,
	CLRBFI

SNOOZ1:	MOVEI	M,^D60/4	;SECONDS PER MINUTE/4
	MOVSI	A,-MINUTE*4	;HOW MANY MINUTES TO SLEEP*4
CNTRLC:	TTCALL	2,CH		;JUST IN CASE HE TYPED ^C
	  JRST	ZZZZZ		;NO
	CAIN	CH,3		;IS IT?
	EXIT	1,		;YES
	CLRBFI
ZZZZZ:	CALLI	M,31		;GO TO SLEEP FOR A MINUTE
	AOBJN	A,CNTRLC	;DO IT AGAIN AND AGAIN
	JRST	REENTR		;WAKE UP, WORLD! HERE WE GO AGAIN.
	SUBTTL	HELP

HELPM:	MOVEI	M,[ASCIZ /? Type "SYS H" for Help
/]
HELPER:	PUSHJ	P,MSG		;TELL ABOUT HELP
; [200] @HELPER+1, JMT, 3-MAY-76
; [200] DELETE	JRST	HACKQ		;GO EXIT
	JRST	EXIT.		;[200] GO EXIT

HELP:	MOVE	1,['SYSTAT']		;IT MUST BE REGISTER 1
	PUSHJ	P,.HELPR##		;GO TO THE HELPER
	JRST	HACKQ			;AND GO HACK IT

;O IS DELIBERATELY NOT TYPED BY HELP
;ALL JOB STATE CODES ARE LISTED (EVEN THOSE NOT TYPED BY SYSTAT)

	SUBTTL	"X" - INVOKE DSK:CRASH.XPN RATHER THAN RUNNING MONITOR
;COMMAND FORMAT:
; 'ANY NONGO SITCHES' X 'ATLEAST ONE SPACE' [FILE NAME]
;  FILE CRASH.XPN IS TAKEN WHEN FILE NAME IS EMPTY

SETDSK:	SETZM	INDEV
	SETZM	INFILE
	SETZM	INEXT
	SETZM	INPPN
	PUSHJ	P,GETNXT	;GET A SIXBIT FIELD OR ZERO
	JUMPE	A,SETDS2	;CHECK FOR PPN	;NOTHING FOUND THE JUMP
	CAIE	WD,":"
	JRST	SETDS1
	MOVEM	A,INDEV
	PUSHJ	P,GETNXT
	JUMPE	A,SETDS2	;IS THERE A FILE
SETDS1:	MOVEM	A,INFILE
	CAIE	WD,"."
	JRST	SETDS2
	PUSHJ	P,GETNXT
	  JFCL
	MOVEM	A,INEXT
SETDS2:	CAIN	WD,"["
	PUSHJ	P,INPPPN
SETDS3:	PUSHJ	P,GETFIL
	BOMB	(CAN'T GET AT THAT FILE)
	SETOM	DSKBLF		;CLEAR INITIAL DISK BLOCK
IFN FTEXE,<
	TRNN	F,FR.EXE	;EXE CRASH FILE?
	JRST	NOXCRS		;NO
	MOVEI	A,0		;FIRST, LET'S CHECK HEADER WORD
	PUSHJ	P,DSKA		;GET FIRST WORD FORM FILE
	HLRZS	A		;ISOLATE HEADER CODE
	CAIE	A,1776		;CORRECT?
	BOMB	(BAD HEADER CODE--NOT AN EXE FILE)
NOXCRS:
>;END OF IFN FTEXE
	MOVEI	A,ABSTB1	;GET POINTER TO GETTABS
DSKJN1:	MOVEM	A,MAXGTB	;BORROW THIS CELL TO REMEMBER WHICH ABSTAB TRYING
	PUSHJ	P,DSKA		;READ IT
	TLNE	A,-1		;MAKE SURE ZERO LH
	JRST	DSKJNK		;NO. NOT ABSTAB
	CAMLE	A,MAXGTB	;MAKE SURE IT MAKES SOME SENSE
	CAML	A,DSKFLG	; ..
	JRST	DSKJNK		;NO--GIVE UP
	HRRZ	B,A		;SAVE FOR TEST LATER
	ADD	A,XGTTBI	;ADD OFFSET FOR GETTAB IMMEDIATE
	PUSHJ	P,DSKA		;READ THAT PLACE
	CAIE	B,(A)		;SEE IF IT MATCHES
	JRST	DSKJNK		;NO--MUST BE JUNK
	HRRZM	A,OFSGTB	;YES--REMEMBER OFFSET
	LSH	A,-^D9		;GET NUMBER OF TABLES
	HLRZM	A,MAXGTB	;SAVE IT
	MOVE	A,XPDBPT	;SET UP PDB POINTER FOR CRASH FILE
	PUSHJ	P,GETZ		;SEE IIF IT IS THERE
	MOVEM	A,PDBPTR	;STORE ZERO OR VALUE
; [206] @DSKJN1+17 1/2, JMT, 26-MAY-76
	MOVE	A,XMNVER	;[206] GET CRASHED MONITORS
	CALL	GETZ		;[206] VERSION INTO A
	HRRZS	A		;[206] STRIP OFF NOISE BITS
	MOVEM	A,MONVER	;[206] AND STORE IT AWAY
	CAIGE	A,60122		;[206] OLD STYLE IF LESS
	CAIGE	A,60000		;[206] AN OLD MONITOR
	CAIGE	A,50722		;[206] IF NOT VERSION 6 OR LATER
	SETZM	NPJOBN		;[206] OLD STYLE SO CLEAR NEW JOB PTR.
	SKIPE	NPJOBN		;[206] IS IT OLD STYLE ?
	POPJ	P,		;[206] NO--RETURN
	MOVE	A,[%CNLSD]	;[206] GET LENGTH OF SHORT DDB
	CALL	GETZ		;[206] GET ZERO OR VALUE
	JUMPE	A,CPOPJ		;[206] IF ZERO, RETURN
	HRRM	A,.DVFIL	;[206] UPDATE FILE POINTER
	ADDI	A,1		;[206] EXTENSION POINTER
	HRRM	A,.DVEXT	;[206] . .
	ADDI	A,1		;[206] UPDATE
	HRRM	A,.DVPPN	;[206] PPN POINTER
	ADDI	A,DV.UNI-DV.PPN	;[206] POINT TO UNIT ENTRY IN DISK DDB
	HRRM	A,.DVUNI	;[206] UPDATE UNIT POINTER
;DSKJNK-1 [177]
	POPJ	P,		;[177] RETURN

DSKJNK:	MOVEI	A,ABSTB2	;TRY SECOND ONE
	CAME	A,MAXGTB	;OR DID WE ALREADY?
	JRST	DSKJN1		;NO, TRY IT.
	JSP	M,BOMB.		;GIVE JUNK ERROR
	ASCIZ	/Can't find gettabs in CRASH/
; [203] @GETFIL, JMT, 20-MAY-76
; [203] DELETE GETFIL:	MOVEI	A,17
; [203] DELETE 	SKIPN	B,INDEV
; [203] DELETE 	MOVSI	B,(SIXBIT/DSK/)
; [203] DELETE 	MOVEI	C,0
; [203] DELETE 	OPEN	DSK,A
; [203] DELETE 	  POPJ	P,
; [203] DELETE 	MOVEI	A,DSK		;[174] GET DEVICE CHARACTERISTICS
; [203] DELETE 	DEVCHR	A,		;[174]
; [203] DELETE 	TLNN	A,(DV.DSK)	;[174] DSK?
; [203] DELETE 	  JRST	[RELEAS	DSK,	;[174] NO, RELEASE THE CHANNEL
; [203] DELETE 		 JSP	M,BOMB.	;[174] AND TYPE ERROR
; [203] DELETE 		 ASCIZ	/DEVICE IS NOT A DISK/] ;[174]
; [203] DELETE 	SKIPN	A,INFILE
; [203] DELETE 	MOVE	A,CRASH
; [203] DELETE 	SKIPN	B,INEXT
; [203] DELETE IFE FTEXE,<
; [203] DELETE 	MOVE	B,CRSEXT
; [203] DELETE >;END OF IFE FTEXE
; [203] DELETE IFN FTEXE,<
; [203] DELETE 	MOVSI	B,'EXE'		;SET EXTENSION TO "EXE"
; [203] DELETE >;END OF IFN FTEXE
; [203] DELETE 	SKIPN	D,INPPN
; [203] DELETE 	MOVE	D,CRSPPN
; [203] DELETE 	LOOKUP	DSK,A
; [203] DELETE 	IFE	FTEXE,<
; [203] DELETE 	  POPJ	P,
; [203] DELETE >;END IFE FTEXE
; [203] DELETE IFN FTEXE,<
; [203] DELETE 	 JRST	[TRZ	B,-1	;JUST TO BE SURE
; [203] DELETE 		 CAME	B,[SIXBIT /EXE/]	;WAS THIS AN EXE FILE?
; [203] DELETE 		 POPJ	P,		;NO, GIVE UP
; [203] DELETE 		 MOVE	B,CRSEXT	;YES, TRY OLD FILE EXTENSION
; [203] DELETE 		 LOOKUP	DSK,A		;TRY IT
; [203] DELETE 		  POPJ	P,		;THAT FAILED TOO!
; [203] DELETE 		 JRST	.+1]		;IT WORKED, CONTINUE
; [203] DELETE 	HLRZS	B		;GET EXTENSION
; [203] DELETE 	CAIN	B,'EXE'		;WAS IT AN EXE FILE?
; [203] DELETE 	TRO	F,FR.EXE		;YES, SET BIT TO REMEMBER IT
; [203] DELETE >;END IFN FTEXE
; [203] DELETE 	HLRES	D
; [203] DELETE 	JUMPG	D,[IMULI D,200
; [203] DELETE 		   JRST  .+2]
; [203] DELETE 	MOVNS	D
; [203] DELETE 	MOVEM	D,DSKFLG
; [203] DELETE 	HLRZ	B,C
; [203] DELETE 	LSH	B,-^D9
; [203] DELETE 	HRLI	B,5
; [203] DELETE 	SKIPN	C,INPPN		;TAKE OTHER ONES PPN IF GIVEN
; [203] DELETE 	MOVE	C,ME
; [203] DELETE 	MOVE	D,ME		;I WANT TOO READ IT
; [203] DELETE 	MOVEI	A,B
; [203] DELETE 	CHKACC	A,
; [203] DELETE 	  JRST	CPOPJ1
; [203] DELETE 	JUMPL	A,[JSP	M,BOMB.
; [203] DELETE 		   ASCIZ /File read protected/]
; [203] DELETE 	JRST	CPOPJ1
GETFIL:	MOVSI	A,DSK		;[203] GET CHANNEL #
	TLO	A,400000	;-[215] - SET PRIV BIT FOR FILOP. SO JACCT AND
				;    [1,2] JOBS GET FULL ACCESS
	MOVEM	A,FLP+.FOFNC	;[203] AND STORE IT IN FILOP. BLOCK
	MOVEI	A,.FORED	;[203] SET FUNCTION CODE
	HRRM	A,FLP+.FOFNC	;[203]  TO READ FILE
	MOVEI	A,17		;[203] SET I/O MODE
	MOVEM	A,FLP+.FOIOS	;[203]  . .
	SKIPN	A,INDEV		;[203] DID USER SPECIFY A DEVICE ?
	MOVSI	A,'DSK'		;[203] NO--ASSUME DSK
	MOVEM	A,FLP+.FODEV	;[203] AND STORE IT
	DEVCHR	A,		;[203] GET DEVICE CHARACTERISTICS
	TLNN	A,(DV.DIR)	;[203] IS IT A DISK ?
	JRST	DNDERR		;[203] PROCESS ERROR
	SETZM	FLP+.FOBRH	;[203] NO BUFFERS
	SETZM	FLP+.FONBF	;[203]  . .
	MOVEI	A,LKB		;[203] ADDR. OF LOOKUP BLOCK
	MOVEM	A,FLP+.FOLEB	;[203]  . .
	SKIPN	A,INFILE	;[203] FILE SPECIFIED ?
	MOVE	A,CRASH		;[203] NO--ASSUME CRASH
	MOVEM	A,LKB+.RBNAM	;[203] STORE IT IN LOOKUP BLOCK
	SKIPN	A,INEXT		;[203] EXTENSION SPECIFIED ?
IFE FTEXE,<
	MOVE	A,CRSEXT	;[203] NO--GET CRASH EXTENSION
>;[203] END OF IFE FTEXE
IFN FTEXE,<
	MOVSI	A,'EXE'		;[203] NO--ASSUME EXE
>;[203] END IFN FTEXE
	MOVEM	A,LKB+.RBEXT	;[203] STORE IT
	SKIPN	A,INPPN		;[203] PPN SPECIFIED ?
	MOVE	A,CRSPPN	;[203] NO--USE CRASH PPN DEFAULT
	MOVEM	A,LKB+.RBPPN	;[203] STORE IT
	MOVEI	A,10		;[203] GET EXTENDED LOOKUP BLOCK SIZE
	MOVEM	A,LKB		;[203] STORE IT IN LOOKUP BLOCK
FLPAGN:	MOVE	A,[XWD 6,FLP]	;[203] POINT TO FILOP. BLOCK
	FILOP.	A,		;[203] OPEN CRASH FILE
	  JRST	FLPERR		;[203] GO PROCESS FILOP. ERROR
FILOPN:	HLRZ	A,LKB+.RBEXT	;[203] GET EXTENSION
	CAIN	A,'EXE'		;[203] IS THIS AN EXE FILE ?
	TRO	F,FR.EXE	;[203] YES--SET BIT TO REMEMBER IT
	MOVE	A,LKB+.RBSIZ	;[203] YES--GET FILE SIZE
	MOVEM	A,DSKFLG	;[203] AND SAVE IT AWAY FOR LATER
	JRST	CPOPJ1		;[203] GIVE GOOD RETURN

FLPERR:	CAME	A,[XWD 6,FLP]	;[203] IS FILOP. IMPLEMENTED ?
	JRST	CHKERR		;[203] YES--GO CHECK THE ERROR CODE THEN
	OPEN	DSK,FLP+.FOIOS	;[203] NO--DO MANUAL OPEN
	  POPJ	P,		;[203] CAN'T ACCESS FILE
	LOOKUP	DSK,LKB		;[203] LOOKUP FILE
	  JRST	CHKER1		;[203] GO PROCESS LOOKUP FAILURE
CHKPRV:	HLRZ	B,LKB+.RBPRV	;[203] GET PRIVILEGE WORD FROM LOOKUP BLOCK
	LSH	B,-^D9		;[203] RIGHT JUSTIFY PROT. CODE
	HRLI	B,5		;[203] SET CHKACC FUNC. CODE TO READ FILE
	MOVEI	C,DSK		;[203] GET CHANNEL #
	DEVPPN	C,		;[203] GET DEVICE'S ASSOCIATED PPN
	  MOVEI	C,ME		;[203] ASSUME MY PPN
	CAME	C,ME		;[203] IS IT ME ?
	MOVEM	C,INPPN		;[203] NO--OVERIDE ALL WITH ERSATZ PPN
	SKIPN	C,INPPN		;[203] IS THERE A PPN ARGUMENT ?
	MOVE	C,ME		;[203] NO--ASSUME OUR PPN
	MOVE	D,ME		;[203] PERFORM CHKACC AGAINST ME
	MOVEI	A,B		;[203] POINT TO CHKACC ARGUMENT BLOCK
	CHKACC	A,		;[203] ARE WE ALLOWED TO ACCESS THIS FILE ?
	  JRST	FILOPN		;[203] ASSUME YES AND PROCEED
	JUMPGE	A,FILOPN	;[203] YES--PROCEED
FILPRT:	JSP	M,BOMB.		;[203] NO--FILE'S PROTECTED AGAINST US
	ASCIZ/File is read protected/

DNDERR:	JSP	M,BOMB.		;[203] DEVICE MUST BE A DISK !!
	ASCIZ/Device must be a disk/

CHKER1:	HRRZ	A,LKB+.RBEXT	;[203] GET LOOKUP ERROR CODE
CHKERR:	CAIN	A,2		;[203] PROTECTION FAILURE ?
	JRST	FILPRT		;[203] YES--GIVE ERROR
	JUMPN	A,CPOPJ		;[203] FILE NOT FOUND ?
	HLRZ	A,LKB+.RBEXT	;[203] YES--GET EXTENSION
	CAIE	A,'EXE'		;[203] WAS IT 'EXE' ?
	POPJ	P,		;[203] NO--CAN'T ACCESS FILE
	MOVE	A,CRSEXT	;[203] YES--GET OLD EXTENSION
	MOVEM	A,LKB+.RBEXT	;[203] AND STORE IT
	JRST	FLPAGN		;[203] TRY AGAIN WITH NEW EXTENSION

INPPPN:	PUSHJ	P,GETPPN
	MOVEM	A,INPPN
	CAIE	WD,12
	PUSHJ	P,GETNXT
	  JFCL
	POPJ	P,
DSKBP1:	CAMN	BP,LASBPA	;SEE IF SAME AS LAST ONE
	JRST	[MOVE BP,LASBP1	;YES--GET SAME ANSWER
		 JRST CPOPJ1]	;GIVE SKIP RETURN
	MOVEM	BP,LASBPA	;NO--SAVE ADDRESS
	PUSH	P,A		;SAVE A
	MOVE	A,BP		;GET ARGUMENT
	PUSHJ	P,DSKA		;GET WORD
	MOVE	BP,A		;GIVE ANSWER
	POP	P,A		;RESORE A
	MOVEM	BP,LASBP1	;SAVE ANSWER
	JRST	CPOPJ1		;SKIP RETURN

DSKC:	PUSH	P,A		;SAVE A
	MOVE	A,C		;GET ARGUMENT
	PUSHJ	P,DSKA		;GET WORD
	MOVE	C,A		;GIVE ANSWER
	POP	P,A		;RESTORE A
	POPJ	P,		;RETURN
DSKA1:	AOS	(P)		;SKIP RETURN
DSKA:	PUSH	P,B		;SAVE B
	TLZ	A,-1		;CLEAR JUNK
	CAML	A,DSKFLG	;COMPARE TO AMOUNT IN FILE
	BOMB	(Ill disk mem ref)  ;BOMB OUT
IFN FTEXE,<
	JUMPE	A,.+3		;DON'T RELOCATE 0 (NEED TO READ
				; DIRECTORY HEADER WORD)
	TRNE	F,FR.EXE	;IS THIS AN EXE FILE?
	ADDI	A,EXESIZ	;YES, IGNORE DIRECTORY
>;END OF IFN FTEXE
	IDIVI	A,LN.BUF	;SPLIT INTO BLOCK AND WORD
	CAMN	A,DSKBLF	;SEE IF BLOCK IN CORE
	JRST	DSKARD		;YES--JUST GET WORD
	MOVEM	A,DSKBLF	;AND REMEMBER BLOCK
	IFN  LN.BUF-200,<PUSH P,B
			 IDIVI A,LN.BUF/200
			 POP  P,B>
	IFN	LN.BUF-<LN.BUF/200>*200,<PRINTX LN.BUF MUST BE MULT OF 200>
	USETI	DSK,1(A)	;NO--POSITION FILE
	IN	DSK,DSKIOW
	JRST	DSKARD		;READ OK
	PUSH	P,M		;BAD--SAVE LOTS STUFF
	PUSH	P,N
	PUSH	P,N1
	PUSH	P,R
	PUSH	P,CH
	PUSH	P,WD
	MOVEI	WD,0
	GETSTS	DSK,N
	MOVEI	M,[ASCIZ /
% Disk read error /]
	PUSHJ	P,MSG
	PUSHJ	P,OCTPRT
	PUSHJ	P,CRLF
	POP	P,WD
	POP	P,CH
	POP	P,R
	POP	P,N1
	POP	P,N
	POP	P,M

DSKARD:	MOVE	A,DSKBUF(B)
	POP	P,B
	POPJ	P,
;GETNXT IS CALLED TO COLLECT A SIXBIT FIELD IN ACCU A
;AND A DELIMITING CHARACTER IN REGISTER WD
;DELIMITERS ARE:
;LINE FEED COMMA PERIOD COLON LEFT BRACKET RIGHT BRACKET LEFTARROW
;IF A BREAK CHARACTER WAS FOUND A ZERO DELIMITER IS RETURNED CAUSING
;SYSTAT TO  FAIL AT ALL DELIMITER TESTS
GETNXT:	SETZ	A,
GETNX0:	SETZ	WD,		;LET TEST ON DELIMITER FAIL
	TLNE	F,FL.BRK
	POPJ	P,
	PUSHJ	P,GETCHR
	  JFCL
	CAIE	WD," "
	CAIN	WD,15
	JRST	GETNX0
GETNX1:	MOVE	B,DELMPT
GETNX2:	ILDB	C,B
	JUMPE	C,GETNX4
	CAIE	WD,(C)
	JRST	GETNX2
	SKIPE	A
GETNX3:	TLNE	A,770000
	JRST	CPOPJ1
	LSH	A,6
	JRST	GETNX3
GETNX4:	TLNE	A,770000
	JRST	GETNX0
	LSH	A,6
	ADDI	A,-40(WD)
	JRST	GETNX0

DELMPT:	POINT	7,DELMTB
DELMTB:	BYTE	(7) 12,54,56,72,133,135,137,0

GETPPN:	PUSHJ	P,GETNXT
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	SKIPE	C,A
	CAIE	WD,","
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	PUSHJ	P,GETNUM
	PUSH	P,A
	TLNN	A,-1
	PUSHJ	P,GETNXT
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	SKIPN	C,A
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	PUSHJ	P,GETNUM
	TLNE	A,-1
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	HRL	A,(P)
	POP	P,B
	POPJ	P,

GETNUM:	SETZ	A,
GETNM0:	SETZ	B,
	LSHC	B,6
	CAIL	B,"0"-40
	CAILE	B,"7"-40
	  BOMB	<COMMAND ERROR -- TYPE SYS /H FOR HELP>
	LSH	A,3
	ADDI	A,-20(B)
	JUMPN	C,GETNM0	;GET MORE DIGITS
	POPJ	P,
	SUBTTL	SUBROUTINES
;GETTAB OPTIONAL TABLE--RETURN 0 IF ABSENT (RESULT IN A)
GETZ:	PUSHJ	P,FGETTB	;GO DO GETTAB
	  SETZ	A,
	POPJ	P,

;GETTAB OPTIONAL TABLE--ERROR RETURN IF ABSENT (RESULT IN B)
GETTB:	PUSH	P,A		;SAVE A
	MOVE	A,B		;SETUP FOR GETTAB
	PUSHJ	P,FGETTB	;DO GETTAB
	  JRST	[POP	P,A
		 POPJ	P,]
	MOVE	B,A		;GET ANSWER
	POP	P,A		;RESTORE A
CPOPJ1:	AOS	(P)
	POPJ	P,

;GETTAB MANDATORY TABLES (RESULT IN A)
GETA:	PUSHJ	P,FGETTB	;GETTAB
	  TDZA	A,A
	POPJ	P,0
PRQM:	MOVEI	CH,"?"
	JRST	TYO
;ROUTINE TO FUDGE GETTABS VIA SPY IF POSSIBLE
;NOTE--DOES NOT HANDLE -2 IN LH, IF FAIL, CHANGES A

FGETTB:	SKIPE	N1,MAXGTB	;SEE IF GETTAB SPYING POSSIBLE
	JRST	GETTB1		;YES--GO DO IT
FGETT1:	SKIPN	DSKFLG		;DONT GETTAB IF IN /X
	GETTAB	A,		;NO--USE MONITOR
	  POPJ	P,		;ERROR RETURN
	JRST	CPOPJ1		;WIN RETURN
GETTB1:	HRRZ	BP,A		;GET TABLE INDEX
	CAMLE	BP,N1		;SEE IF IN RANGE
	POPJ	P,		;NO--ERROR RETURN
	ADD	BP,OFSGTB	;YES--GET CORE ADDRESS
	TLNE	F,FL.DSK	;SEE IF DISK MODE
	PUSHJ	P,DSKBP1	;YES--READ FROM IT AND SKIP
	MOVE	BP,400000(BP)	;GET NUMTAB POINTER
	CALL	SETSPY		;SET UP SPY DATA
	SKIPE	PDBPTR		;YES. HAVE WE THE POINTER TO JBTPDB?
	SKIPA			;OK
	JRST	FGETT1		;NO. GO USE A GETTAB
	HLRZ	A,A		;GET REQUESTED INDEX IN TABLE
	TRNE	A,1B18		;SEE IF JOB FLAG
	MOVE	A,MYJOB		;YES--GET JOB NUMBER
	CAMLE	A,N1		;SEE IF IN RANGE
	POPJ	P,		;NO--ERROR RETURN
	TLNN	BP,(17B17)	;SEE IF INDEXING
	MOVEI	A,0		;NO--CLEAR REQUEST
	TLNN	BP,(GT.PRC)	;PDB DATUM?
	JRST	FGETT2		;NO
	TLNE	F,FL.DSK	;DISK MODE?
	JRST	FGETP2		;YES, HANDLE IT
	ADD	BP,@PDBPTR	;GET ADDRESS IN JOBS PDB
	MOVEI	A,0		;HAVE ADDED IN A ALREADY
FGETT2:	ADDI	A,(BP)		;ADD TABLE LOCATION TO OFFSET
	TLNE	F,FL.DSK	;SEE IF DISK MODE
	PJRST	DSKA1		;YES--GET WORD FROM DISK
	MOVE	A,400000(A)	;GET WORD
	JRST	CPOPJ1		;GIVE WIN RETURN

FGETP2:	ADD	A,PDBPTR	;GET JOBS PDB POINTER FROM DISK
	PUSHJ	P,DSKA
	ADDB	BP,A		;POINT TO RELATIVE WORD
	PJRST	DSKA1		;GET THE PDB WORD

SETSPY:	LDB	N1,[POINT 9,BP,8];GET TABLE LENGTH
	PUSH	P,N1		;AND SAVE IT
	SKIPN	NEWSPY		;THE NEW STYLE OF SPYING
	JRST	SETSP0		;NO LEAVEIT AS IT IS
	LDB	N1,[POINT 3,BP,11];GET ENTRY TYPE
	TLZ	BP,777760	;ZAP ALL BUT INDEX FIELD
	CAIN	N1,GT.PDB	;SKIP IF NOT PDB DATA
	TLO	BP,(GT.PRC)	;COMPATIBLE
SETSP0:	POP	P,N1		;GET LENGTH OF TABLE BACK
	TLNN	BP,(GT.PRC)	;PDB DATA??
	AOS	(P)		;SET SKIP RETURN
	RETURN
;PEEK INTO C
PEEKC:	TLNE	F,FL.DSK	;SEE IF DISK MODE
	PJRST	DSKC		;YES--PEEK AT THE DISK
	SKIPE	SPYFLG		;SEE IF SPYING
	SKIPA	C,400000(C)	;YES--GET FROM CORE
	PEEK	C,		;NO--GET FROM MONITOR
	POPJ	P,

;PEEK INTO A
PEEKA:	TLNE	F,FL.DSK	;SEE IF DISK MODE
	PJRST	DSKA		;YES--PEEK AT THE DISK
	SKIPE	SPYFLG		;SEE IF SPYING
	SKIPA	A,400000(A)	;YES--GET FROM CORE
	PEEK	A,		;NO--GET FROM MONITOR
	POPJ	P,

GETBTH:	ANDI	A,-1		;MASK TO SIZE
	SKIPE	A		;ERROR IF 0
	CAML	A,DSKFLG	;SEE IF IT FITS
	POPJ	P,		;NO--GIVE ERROR
	MOVEI	C,-1(A)		;GET ADDR-1
	PUSHJ	P,PEEKA		;GET CONT(ADDR)
	PUSHJ	P,PEEKC		;GET CONT(ADDR-1)
	JRST	CPOPJ1		;SKIP RETURN

GETTTY:	TRNE	F,FR.CNT	;**[16] A CONTINUOUS SYSTAT?
	TLNN	F,FL.LPT	;**[16] (YES) AND GOING TO LPT
	SKIPA			;**[16] (NO) NORMAL
	JRST	GETTT0		;**[16] (YES)  FORCE OF INIT
	TLNE	F,FL.LPT	;IS LPT FILE OPEN?
	RETURN			;(YES) THEN KEEP IT THTA WAY
	CAIE	WD,L.LPT	;DID USER WANT LINE PRINTER
	JRST	SYSIN2		;(NO) SEE IF HE HAS TTY ALLREADY
	TLO	F,FL.LPT	;DID HE HAVE LPT ALLREADY
;[144] GETTTY+10+1/2,JNG,11/4/74
	SETOB	A,B		;[144] SETUP SOME ACS
	GETLCH	B		;[144] FIND OUT WHERE WE ARE
	TLNE	B,(GL.ITY!GL.DSL!GL.REM!GL.RBS)
				;[144] REMOTELY REMOTE?
	TLNE	F,FL.LGI	;[144] OR NOT LOGGED IN?
	  JRST	GETTT0		;[144] NO..OK TO USE LPT
	CTLJOB	A,		;[144] BEING CONTROLLED?
	  SETO A,		;[144] NOT IMPLEMENTED
	MOVSI	A,(A)		;[144] SETUP TO GETTAB ...
	HRRI	A,.GTPPN	;[144] OUR CONTROLLING JOB'S PPN
	PUSHJ	P,FGETTB	;[144] SIMULATE THE GETTAB
	  SETO	A,		;[144] DISALLOW IF NOT IMPLEMENTED
	TLNN	A,-2		;[144] PROJECTS 0 OR 1?
	  JRST	GETTT0		;[144] YES..YOU WIN
	BOMB	(LOGIN to use LPT)  ;[144] NO, TOO BAD
GETTT0:	MOVEI	C,5		;TRY INIT FIVE TIMES
	RESET			;GIVE BUFFERS BACK
SYSIN1:	INIT	TTY,0		;YES--INIT LPT
SYSDEV:	  SIXBIT /LPT/
	  XWD	TYOB,0
	  SKIPA
	JRST	SYSOPN		;IF SUCCESS
	MOVE	B,C
	SLEEP	B,		;WIAT AWHILE
	SOJG	C,SYSIN1	;TRY SOME,THEN GIVE MESSAGE
SYSNOT:	TLON	F,FL.RPT	;FAILED--SEE IF FIRST TIME
	OUTSTR	[ASCIZ /LPT busy--PLEASE ASSIGN LPT AND CONTINUE
/]
	EXIT	1,		;RETURN TO MONITOR MODE
	JRST	SYSIN1		;LOOP BACK FOR ANOTHER TRY
SYSIN2:	TROE	F,FR.INI	;IS THIS THE FIRST TRY
	RETURN			;(NO) YOU HAVE IT ALLREADY
	TLNN	F,FL.DSK	;**[16] DO NOT RESET DISK FILE
	RESET			;GET OLD BUFFERS AWAY
	INIT TTY,0		;FIRST TRY DEVICE SYSTAT
	  SIXBIT /SYSTAT/
	  XWD TYOB,0
	  SKIPA			;NOTHING ASSIGNED AS SYSTAT
	JRST SYSOPN		;OK. USE IT.
	INIT	TTY,0
	  SIXBIT /TTY/
	  XWD	TYOB,0
	  BOMB	(Output init failed)	;DIE IF CAN'T DO OUTPUT
SYSOPN:	TRO	F,FR.INI	;TURN ON FOR L OPTION
	OUTBUF	TTY,1		;ONLY ONE BUFFER
	TRZ	F,FR.DSK	;ASSUME NO DISK
	MOVEI	A,TTY		;GET CHANNEL NUMBER
	DEVTYP	A,		;AND GET IT'S TYPE
	JRST	SYSOP1		;GIVE UP TRY THE ENTER
	ANDI	A,TY.DEV	;GET THE TYPE FIELD
	CAIE	A,.TYDSK	;IS IT A DISK
	JRST	SYSOP1		;(NO) OPEN THE FILE
	TRO	F,FR.DSK	;FLAG THAT THIS IS A DISK FILE
	MOVE	A,[%LDSTP]	;GET STANDARD PROTECTION
	CALL	GETZ		;SEE WHAT IT IS
	ROT	A,^D9		;GET IT IN THE RIGHT HAND SIDE
	HRLI	A,.ACWRI	;WE WANT TO WRITE
	TRZ	A,777000	;MASK OUT JUNK
	MOVEI	B,TTY		;GET OWNERS PPN
	DEVPPN	B,		;FIND THE PPN
	JRST	SYSOP1		;NO PROTECTION
	MOVE	C,ME		;GET MY PPN
	MOVEI	N,A		;GET ADDRESS OF CHECK BLOCK
	CHKACC	N,		;SEE IF I MAY ENTER AND WRITE FILE
	JRST	SYSOP1		;NO CHKACC SO DO IT
	JUMPE	N,SYSOP1	;ALL IS FINE
	BOMB	(NO WRITE PRIVILIGE FOR FILE SYSTAT.TXT)
SYSOP1:	MOVE	A,[SIXBIT /SYSTAT/]
	MOVSI	B,(SIXBIT /TXT/)
	SETZB	C,D		;CLEAR DATE & PPN
	ENTER	TTY,A
	  BOMB	(Output enter failed)	;DIE IF CAN'T ENTER
	RETURN
;SUBROUTINE TO TYPE <MESSAGE> N/TEMP = NUM.NUM
;ARGS	M=ADDR OF FIRST ASCIZ MESSAGE
;	N=DIVIDEND
;	TEMP=DIVISOR

SWPPRT:	PUSH	P,N		;SAVE DIVIDEND
	PUSHJ	P,MSGDEC
	MOVSI	A,(SIXBIT ./.)
	MOVE	N,TEMP
	PUSHJ	P,SIXDEC
	MOVEI	M,[ASCIZ / = /]
	POP	P,N		;RESTORE DIVIDEND
	IMULI	N,^D10
	IDIV	N,TEMP
	LSH	N1,1		;CHECK FOR ROUNDING
	CAML	N1,TEMP
	AOS	N		;ROUND UP
	IDIVI	N,^D10
	MOVEM	N1,TEMP1
	PUSHJ	P,MSGDEC
	MOVEI	M,[ASCIZ /./]
	MOVE	N,TEMP1
	PJRST	MSGDEC
NOWHO:
IFN HIDPPN,<
	CAME	A,ME
	TLNE	F,FL.GOD
	POPJ	P,		;RETURN IF OK
	SETO	A,		;HIDE IT--CHANGE NAME
>
	POPJ	P,

ASTSIX:	MOVE	A,[SIXBIT /**,**/]
SP4SIX:	TDNE	A,[-1-77B5]	;SEE IF SHORT NAME
	SKIPE	SEGFLG		;NO--SEE IF SEGMENT MODE
	JRST	TABSIX		;YES--DO TAB THEN PRINT
	MOVEI	N,4		;SPACE 4, THEN SIXBIT
	PUSHJ	P,SPACE
	SOJG	N,.-1
SIXBP:	MOVE	BP,A
SIXBP1:	MOVEI	CH,0
	LSHC	CH,6
	IFN CH-BP+1,<PRINTX BP MUST BE CH+1>
	ADDI	CH,40
	PUSHJ	P,TYO
	JUMPN	BP,SIXBP1
CPOPJ:	POPJ	P,0

TABSIX:	PUSHJ	P,TAB		;SEND TAB
	JRST	SIXBP		;THEN SIXBIT MESSAGE

REPEAT 0,<
;SUBR VERPRT - CALL WITH (137) OR THE LIKE IN N, TYPES STD FORM VERSION
VERPRT:	PUSH	P,N
	LDB	N,[POINT 9,0(P),11]
	PUSHJ	P,OCTPRT
	LDB	CH,[POINT 6,0(P),17]
	JUMPE	CH,VERP1
	ADDI	CH,"A"-1
	PUSHJ	P,TYO
VERP1:	HRRZ	N,0(P)
	JUMPE	N,VERP2
	MOVEI	CH,"("
	PUSHJ	P,TYO
	PUSHJ	P,OCTPRT
	MOVEI	CH,")"
	PUSHJ	P,TYO
VERP2:	LDB	N,[POINT 3,0(P),2]
	JUMPE	N,VERP3
	MOVNS	N
	PUSHJ	P,DECPRT
VERP3:
NPOPJ:	POP	P,N
	POPJ	P,0
>
;SUBROUTINE CALLED TO INSURE THAT DATA FOR MULTIPLE CPU'S IS
;LINED UP PROPERLY.THE CALL IS IDENTICAL TO THE CALL OF GETRSP

GETRS0:	PUSHJ	P,GETRSP	;GET THE DATA
	JRST	STAB		;NO MORE SET TABS
	SKIPE	CPU		;DO NOT SEPERATE PRINT OUT THE FIRST TIME
	PUSHJ	P,PLUS		;PRINT THE SEPERATOR
	PJRST	CPOPJ1		;GIVE A SKIP RETURN

STAB:	MOVEI	A,NCPUS		;GET THE NUMBER OF CPUS
STAB0:	CAMG	A,CPU		;LIGNED UP ALLREADY
	POPJ	P,		;YES GIVE NORMAL RETURNS
	PUSHJ	P,TAB		;PRINT A TAB
	SOJA	A,STAB0		;FILL TILL ALL CPUS DONE

;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,B		;SAVE B (GETTB USES B INSTEAD OF A)
	PUSH	P,A		;SAVE RELATIVE ADR IN SUB-TABLE
	IMULI	A,NCPUS		;MAKE INDEX TO RESPONSE TABLE IN CORE
	ADD	A,CPU
	MOVEM	A,RSPIDX
	MOVE	B,[%CCRSP]	;GETTAB IN CPU CONSTANTS TABLE
				; FOR REL ENTRY IN CPU VARIABLE TABLE
				; FOR RESPONSE DATA
	ADD	B,CPU		;FORM FOR THIS CPU
	ADD	B,CPU		;CONSTANTS GETTABS ARE EVERY OTHER
	PUSHJ	P,GETTB		;GET ENTRY FROM MONITOR
	  JRST	GTRSPX		;NOT PRESENT, ERROR RETURN
	ADD	B,(P)		;FORM ADR IN CPU VARIABLE TABLE
	HRL	B,B		;TO LH
	HRRI	B,.GTC0V	;VARIABLE GETTAB FOR CPU0
	ADD	B,CPU		;FOR FOR CPU N
	ADD	B,CPU		;VARIABLE TABLE IS EVERY OTHER
	PUSHJ	P,GETTB		;GET FROM MONITOR
	  SOS	-3(P)		;NOT PRESENT, SET FOR ERROR RETURN
	AOS	-3(P)		;SKIP RETURN(UNLESS ERROR)
GTRSPX:	MOVE	A,B		;PUT RESULT IN A
	POP	P,N1		;RESTORE PD LIST
	POP	P,B		;RESTORE B
	POP	P,N1		;RESTORE N1
	POPJ	P,		;ERROR OR OK RETURN


;SUBROUTINE TO PROVIDE INCREMENTAL RESPONSE VALUE
; RETURNS WITH INCREMENTAL VALUE IN A,  OLD VALUE IN OLDRSP(RSPIDX)
; AND INCREMENTAL VALUE IN DIFRSP(RSPIDX).
;
;CALL:	MOVEI	A,VALUE		;VALUE FROM GETTAB
;	PUSHJ	P,GETDIF	;RSPIDX HAS POINTER (SET BY GETRSP)
;	RETURN HERE

GETDIF:	PUSH	P,B		;SAVE B,N
	PUSH	P,N
	MOVE	N,RSPIDX	;GET TABLE POINTER
	MOVE	B,OLDRSP(N)	;GET PREVIOUS VALUE
	MOVEM	A,OLDRSP(N)	;SAVE NEW AS OLD FOR NEXT TIME
	SUB	A,B		;GET DIFFERENCE
	MOVEM	A,DIFRSP(N)	;SAVE DIFFERENCE IN CASE NEED IT LATER
	POP	P,N		;RESTORE N,B
	POP	P,B
	POPJ	P,		;RETURN,  INCREMENTAL VALUE IN A


;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

CRLF2:	PUSHJ	P,CRLF
CRLF:	MOVEI	M,[ASCIZ /
/]
MSG:	TLOA	M,440700
MSG1:	PUSHJ	P,TYO
	ILDB	CH,M
	JUMPN	CH,MSG1
	POPJ	P,

;KAYPEE PRINTS A P OR K DDEPENDING ON THE SYSTEM
;WHOSE SYSTAT IS BEING PRINTED

KAYPEE:	MOVEI	CH,"K"		;ASSUME KA10 FIRST
	SKIPE	CPKI10		;IS IT A KI10?
	MOVEI	CH,"P"		;(YES) THEN A P
	PJRST	TYO		;RETURN AFTER PRINTING

PLUS:	MOVEI	CH,"+"
	JRST	TYO

PERIOD:	MOVEI	CH,"."
	JRST	TYO

COLON:	TLNE	F,FL.SZR	;DON'T PRINT IF SUPPRESSINGZEROES
	POPJ	P,
	MOVEI	CH,":"
	TLNE	F,FL.BZR	;PRINT BLANK IF BLANKING ZEROES
	MOVEI	CH," "
	JRST	TYO

COMMA:	MOVEI	CH,","
	JRST	TYO

SIXTAB:	PUSHJ	P,SIXBP
TAB:	SKIPA	CH,["	"]	;PRINT TAB
SPACE:	MOVEI	CH,40
TYO:	JUMPL	WD,CPOPJ
	TRNN	F,FR.DPY	;DOES HE WANT PAGED OUTPUT?
	JRST	TYO1		;NO
	CAIN	CH,12		;IS IT A LINE FEED?
	SOSE	LINECT		;COUNT LINES
	SKIPA
	PUSH	P,[HICCUP]	;HANDLE IT LATER
TYO1:	SOSG	TYOB+2
	OUTPUT	TTY,0
	IDPB	CH,TYOB+1
	POPJ	P,0
;WE TRICKED TYO INTO RETURNING HERE AFTER THAT LINE FEED
HICCUP:	PUSH	P,M		;SAVE THE REST FOR LATER
	CLRBFI			;CLEAR THE INPUT BUFFER
	OUTPUT	TTY,0		;EMPTY THE BUFFER JUST IN CASE
	TTCALL	2,M		;RESET THE ^O SWITCH
	  JRST	.+3		;NOTHING TYPED
	CAIN	M,3		;HE SAID SOMETHING, WAS IT ^C?
;  [210]  HICCUP+6,  JMT, 3-AUG-76
;  [210]	DELETE	EXIT	1,		;YES, QUIT!
	JRST	EXIT.		;[210] YES, QUIT
	OUTSTR	[ASCIZ/TYPE ANY SINGLE CHARACTER TO CONTINUE:/]
	INCHRW	M		;WAIT UNTIL HE TYPES SOMETHING, THEN EAT IT
	CAIE	M,15	
	OUTSTR	[ASCIZ /
/]				;SEND CAR.RETURN IF USER DIDN'T.
	CAIN	M,3		;IS IT ^C ?
; [210]	HICCUP +12,  JMT,  3-AUG-76
; [210]	DELETE	EXIT	1,		;YES
	JRST	EXIT.		;[210]YES, QUIT!
	CAIN	M,15
	INCHRW	M		;ACCEPT SCANNER SERVICE L.F.
	MOVEI	M,^D19		;PAGE SIZE LESS ONE
	MOVEM	M,LINECT	;RESET THE COUNTER
	POP	P,M		;RESTORE THE REGISTER
	POPJ	P,		;REMEMBER WE HAD STOLEN TYO'S RETURN

OPRN2X:	MOVEI	CH,77		;PRINT OCTAL AT LEAST 2 DIGITS

;PRINT OCTAL FIXED NUMBER OF PLACES
;CALL: CH=BIGGEST VALUE, N=VALUE
FIXOCT:	LSH	CH,-3		;POSITION MASK
	SKIPE	CH		;SEE IF OUT OF PREFIX
	CAMLE	N,CH		;SEE IF DONE
	JRST	OPRNT		;YES--OUTPUT NUMBER
	PUSH	P,CH		;PRESERVE MASK
	PUSHJ	P,SPACE		;OUTPUT FILLER
	POP	P,CH		;RESTORE MASK
	JRST	FIXOCT		;LOOP FOR MORE

;OCTAL OUTPUTS
OPRNT:	MOVEI	R,10		;REGULAR RADIX
	JRST	RDXPRT		;GO DO IT
TCKTIB:	TLOA	F,FL.BZR	;BLANK LEADING ZEROES
TCKTIS:	TLO	F,FL.SZR	;SUPPRESS ZEROES
TCKTIM:	IDIV	A,TCKSEC	;JUNK JIFFIES
	ASH	B,1		;ROUND?
	CAML	B,TCKSEC
	ADDI	A,1		;ROUND-UP
TIME:	PUSH	P,A		;ASVE TIME FOR LATER TEST
	IFGE  FTAMPM,<
	IFE   FTAMPM,<
	MOVSI	B,(CLKCYC)	;GET FLAG FOR 50 HERTZ
	TDNE	B,STATES	; IN STATES WORD
	TRZ	F,FR.DAY	;YES--CLEAR AM/PM REQUEST
>
	TRNE	F,FR.DAY	;SEE IF AM/PM HACK
	CAIGE	A,^D12*^D60*^D60  ;YES--SEE IF PM
	JRST	.+2		;NO--SKIP
	SUBI	A,^D12*^D60*^D60  ;YES--SUBTRACT 12 HOURS
>
	IDIVI	A,^D60*^D60
	IFL   FTAMPM,<
	MOVE	N,A
>
	IFGE  FTAMPM,<
	SKIPN	N,A
	TRNN	F,FR.DAY
	JRST	.+2
	MOVEI	N,^D12
>
	PUSHJ	P,DECP2X
	PUSHJ	P,COLON
	IDIVI	B,^D60
	MOVE	N,B
	PUSHJ	P,DECPR2
	PUSHJ	P,COLON
	MOVE	N,C
	MOVEI	C,DECPR2	;PRESET ROUTINE
	TLZE	F,FL.SZR
	MOVEI	C,DECPRT	;IF SUPPRESSING, MAKE SURE WE PRINT SOMETHING
	TLZE	F,FL.BZR
	MOVEI	C,DECP2X	;LIKEWISE FOR BLANKING
	PUSHJ	P,(C)		;PRINT FINAL FIELD
	POP	P,C		;RECOVER ARGUMENT
	IFGE  FTAMPM,<
	MOVEI	M,[ASCIZ / A.M./]
	CAIL	C,^D12*^D60*^D60
	MOVEI	M,[ASCIZ / P.M./]
	TRZE	F,FR.DAY	;SEE IF AM/PM HACK
	JRST	MSG		;YES--OUTPUT SUFFIX
>
	POPJ	P,		;NO--RETURN
DECP3X:	MOVEI	CH," "
	CAIG	N,^D99
	PUSHJ	P,TYO
	JRST	DECP2X		;PRINT 3 DECIMAL DIGITS
DECPR2:	MOVEI	CH,"0"
	TLNE	F,FL.BZR	;SUBSTITUTE BLANK IF BLANKING ZEROES
DECP2X:	MOVEI	CH," "
	CAIG	N,^D9
	TLNE	F,FL.SZR	;DON'T PRINT IF SUPPRESSING ZEROES
	JRST	DECPRT
	PUSHJ	P,TYO
DECPRT:	MOVEI	R,^D10
RDXPRT:	MOVEI	CH,"-"
	JUMPGE	N,RADIX1
	PUSHJ	P,TYO
	MOVMS	N
RADIX1:	JUMPN	N,RADIX2	;DEFINITELY PRINT IF NON-ZERO
	TLNN	F,FL.SZR!FL.BZR	;SEE IF BLANKING OR SUPPRESSING
	JRST	RADIX2		;NO--PRINT ONE ZERO
	MOVEI	CH," "
	TLNN	F,FL.SZR	;SEE IF SUPPRESSING ZEROES
	PUSHJ	P,TYO		;NO--BLANKING SO OUTPUT SPACE
	POPJ	P,		;YES--RETURN
RADIX2:	TLZ	F,FL.SZR!FL.BZR	;STOP ANY ZERO SUPPRESSION
	IDIVI	N,(R)
	HRLM	N1,0(P)
	SKIPE	N
	PUSHJ	P,RADIX2
	HLRZ	CH,0(P)
	ADDI	CH,"0"
	JRST	TYO

DECTAB:	PUSHJ	P,DECPRT
	JRST	TAB
THISIS:	MOVEI	M,[BYTE (7) 14,0,0,0]	;GIVE HIM A FORM FEED
	TLNE	F,FL.LPT	;IF HE IS OUTPUTTING TO THE LPT
	PUSHJ	P,MSG		;OTHERWISE NOT
	MOVEI	M,[ASCIZ /
Status of /]
	PUSHJ	P,MSG
	MOVEI	B,0
	MOVEI	C,11		;TAB
SYS2:	MOVEI	M,A
	MOVE	A,C
	PUSHJ	P,GETA
	PUSHJ	P,MSG
	AOBJN	C,.+1
	TRNE	A,376
	SOJA	C,SYS2
	MOVEI	M,[ASCIZ / at /]
	PUSHJ	P,MSG
	MOVE	A,XTIME
	PUSHJ	P,GETA
	MOVEM	A,NOW		;SAVE FOR LATER
	IFGE  FTAMPM,<
	TRO	F,FR.DAY	;SET FOR DATE AM/PM HACK
>
	PUSHJ	P,TCKTIM
	MOVEI	M,[ASCIZ / on /]
	PUSHJ	P,MSG
	move	a,xdate		;get today's date
	pushj	p,geta		;freshly
	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.
	CALL	CRLF2		;PRINT IT
	OUTPUT	TTY,		;AND FORCE IT OUT
	RETURN
;SUBROUTINE TO PRINT PROJECT PROGRAMMER NUMBER AS A PAIR
;IF ZERO, RETURN
;IF SAME AS SYSPPN, PRINT "SYS"
;IF SAME AS MY PPN, PRINT "[SELF]"
;IF SIGN BIT ON, PRINT IN SIXBIT
;ELSE, PRINT AS PAIR OR OCTAL NUMBERS
;ENTERED WITH PPN TO BE PRINTED IN A
;USES N,R,N1,BP,CH

PNTPPN:	SKIPN	A		;SEE IF NULL
	POPJ	P,		;YES--RETURN
	CAMN	A,[-1]		;SEE IF HIDDEN
	JRST	ASTSIX		;YES--PRINT ASTERISKS
	CAMN	A,FSFPPN	;SEE IF OPERATOR
	MOVE	A,[SIXBIT /[OPR]/]
	CAMN	A,SYSPPN
	MOVSI	A,(SIXBIT /SYS/)  ;TYPE NAME FOR SYS
	SKIPN	ONEJOB		;SEE IF SELF
	TLNE	F,FL.GOD!FL.LPT	;SEE IF OPERATOR
	JRST	NOTSLF		;YES--SKIP SELF CHECK
	CAMN	A,ME		;SEE IF ME
	MOVE	A,[SIXBIT /[SELF]/]
NOTSLF:	IFN STANSW,<JRST TABSIX>
	IFE STANSW,<
	JUMPLE	A,SP4SIX	;PRINT AS NAME IF SIXBIT
	PUSH	P,A		;SAVE ARGUMENT
	HLRZ	N,A		;GET LEFT HALF
	MOVEI	CH,-1		;SETUP MASK FOR 6 DIGITS
	PUSHJ	P,FIXOCT	;OUTPUT IN FIXED FORMAT
	JRST	OCTCRH		;GO FINISH IN  VARIABLE FORM
>

;PRINT OCTAL AS UNSIGNED HALVES
OCTPRA:	MOVE	N,A		;MOVE DATUM
OCTPRT:	PUSH	P,N
	HLRZ	N,N
	JUMPE	N,OCTRH
	PUSHJ	P,OPRNT		;OUTPUT IN OCTAL
OCTCRH:	PUSHJ	P,COMMA
OCTRH:	HRRZ	N,(P)
	PUSHJ	P,OPRNT		;OUTPUT IN OCTAL
	POP	P,N
	POPJ	P,
	JRST	RDXPRT
;SUBROUTINE TO GET A CH. FROM COMMAND BUFFER
;CALL	PUSHJ	P,GETCHR
;	NONE LEFT OR BREAK CH. FOUND
;	GOT A CH. RETURN
;AC WD IS RETURNED WITH THE CH.
;AC F WILL HAVE FL.BRK SET IF BREAK CH. FOUND

GETCHR:	SKIPE	WD,SAVCHR	;SEE IF ALREADY HOLDING CHAR
	JRST	[SETZM	SAVCHR	;YES--CLEAR IT
		 JRST	CPOPJ1]	;AND RETURN IT
; [200] @GETCHR+2, JMT, 3-MAY-76
; [200] DELETE	TLNN	F,FL.BRK	;SEE IF ALREADY AT END
; [200] DELETE	TTCALL	2,WD		;GET CH.
; [200] DELETE	  JRST	FLAGIT		;NONE LEFT
	TLNE	F,FL.BRK	;[200] SEE IF ALREADY AT END
	JRST	FLAGIT		;[200] YES
	ILDB	WD,CMDPTR	;[200] GET CHARACTER
	CAIN	WD,0		;[200] NULL CHARACTER ?
	JRST	FLAGIT		;[200] YES--NONE LEFT
	CAIN	WD,3		;IS IT ^C ?
	EXIT	1,		;YES, ABORT, ABORT, ABORT
	CAIL	WD,"A"+40	;CHECK LOWER CASE
	CAILE	WD,"Z"+40
	JRST	.+2		;NO
	SUBI	WD,40		;YES
	CAIN	WD,11		;SEE IF TAB
	MOVEI	WD," "		;YES--CHANGE TO SPACE
	CAIG	WD,14		;IS IT LF,VT
	CAIGE	WD,12		; FF OR
	CAIN	WD,33		; ALTMODE?
	JRST	FLAGIT		;YES - NON SKIP RETURN
;[150] GETCHR+21,JNG,11/20/74
	CAIE	WD,176		;[150] OTHER KINDS
	CAIN	WD,175		;[150] OF ALTMODE?
	JRST	FLAGIT		;[150] YES - NON SKIP
IFE FTDEBUG,<
	TRNE	F,FR.CMT	;[150] ARE WE IN A COMMENT?
	JRST	GETCHR		;[150] YES - THROW IT AWAY
	CAIE	WD,";"		;[150] IS THIS A COMMENT?
	CAIN	WD,"!"		;[150] EITHER KIND?
	JRST	.+2		;[150] YES, GO HANDLE IT
>
	JRST	CPOPJ1		;[150] NONE OF THE ABOVE, RETURN IT.
IFE FTDEBUG,<
	TRO	F,FR.CMT	;[150] INTO A COMMENT
	JRST	GETCHR		;[150] SO THROW THE CHAR AWAY.
>
FLAGIT:	TLO	F,FL.BRK	;FLAG THAT BREAK FOUND
	POPJ	P,		;NON SKIP RETURN

;GET RADIX INPUT
GETRDC:	TDZA	N,N		;CLEAR ANSWER AND SUCK CHAR
GETRDX:	TDZA	N,N		;CLEAR ANSWER
GETRD1:	PUSHJ	P,GETCHR	;GET NEXT DIGIT
	  JFCL			;IGNORE END
	CAIL	WD,"0"		;SEE IF DIGIT
	CAIL	WD,"0"(R)	; ..
	JRST	[EXCH	WD,SAVCHR	;NO--SAVE FOR NEXT SCAN
		 POPJ	P,]		;RETURN
	IMULI	N,(R)		;YES--ADVANCE RESULT
	ADDI	N,-"0"(WD)	;ADD DIGIT
	JRST	GETRD1		;LOOP FOR MORE
; [200] @GETRD1+7 1/2, ADD ROUTINE RDCMND, JMT, 3-MAY-76
;SUBROUTINE TO READ COMMAND INTO COMMAND BUFFER
;IF THIS IS THE FIRST TIME, AND TO RESET THE POINTER
;TO THE BEGINNING.
;CALL:
;	PUSHJ	P,RDCMND
;	 . .		;RETURNS HERE
;ACS A & WD ARE DESTROYED

RDCMND:	MOVE	A,ORGPTR	;[200] GET ORIGIONAL POINTER
	MOVEM	A,CMDPTR	;[200] AND RESET COMMAND POINTER
	SETZM	SAVCHR		;[200] RESET LOOK AHEAD
	TLZ	F,FL.BRK	;[200] AND CLEAR BREAK FLAG
; [207] @RDCMND+4, JMT, 27-MAY-76
; [207] DELETE 	SKIPE	GOTCMD		;[200] HAVE WE BEEN HERE BEFORE ?
	SKIPN	GOTCMD		;[200] HAVE WE BEEN HERE BEFORE ?
	JRST	RDCMD1		;[207] NO--PROCEED
	CLRBFI			;[207] YES--CLEAR INPUT BUFFER
	POPJ	P,		;[200] RETURN

RDCMD1:	TTCALL	2,WD		;[200] GET CHARACTER
	  JRST	RDCMD2		;[200] NO MORE LEFT
	IDPB	WD,CMDPTR	;[200] STORE CHARACTER IN BUFFER
	HRRZ	A,CMDPTR	;[214] WHERE DID WE PUT THAT CHAR?
	CAIL	A,CDENDP	;[214] IN THE LAST WORD??
	 JRST CBOFLO		;[214] YES, OVERFLOW ERROR
	CAIG	WD,14		;[200] IS IT LF, VT
	CAIGE	WD,12		;[200] FF OR
	CAIN	WD,33		;[200] ALTMODE ?
	JRST	RDCMD2		;[200] YES--NO MORE LEFT
	CAIE	WD,176		;[200] OTHER KINDS
	CAIN	WD,175		;[200] OF ALTMODES ?
	JRST	RDCMD2		;[200] YES--THAT'S IT
	JRST	RDCMD1		;[200] NO--LOOP BACK FOR REST OF LINE

RDCMD2:	SETZ	WD,		;[200] CLEAR WD TO MAKE NULL
	IDPB	WD,CMDPTR	;[200] MARK BUFFER END WITH NULL
	MOVE	A,ORGPTR	;[200] GET ORIGIONAL BUFFER POINTER
	MOVEM	A,CMDPTR	;[200] AND RESET COMMAND POINTER
	SETOM	GOTCMD		;[200] SET COMMAND GOTTEN FLAG
;[213]	PJRST	RDCMND		;[200] RESET COMMAND POINTER
	MOVE	A,ORGPTR	;[213] GET ORIGIONAL POINTER
	MOVEM	A,CMDPTR	;[213] AND RESET COMMAND POINTER
	SETZM	SAVCHR		;[213] RESET LOOK AHEAD
	TLZ	F,FL.BRK	;[213] AND CLEAR BREAK FLAG
	POPJ	P,0		;[213] RETURN



CBOFLO:	JSP	M,BOMB.		;[214]
	ASCIZ /Input line too long/
;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

DECMSG:	PUSHJ	P,DECPRT	;OUTPUT DECIMAL
	JRST	MSG		;THEN MESSAGE

MSGOCT:	PUSHJ	P,MSG		;SEND MESSAGE
	JRST	OCTPRT		;THEN OCTAL

;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

;SUBROUTINE TO PRINT (N) AS A PERCENTAGE OF (CH), RIGHT JUSTIFIED
;CALL	MOVE	CH,REFERENCE NUMBER
;	MOVE	N,NUMBER TO BE DIVIDED
;	PUSHJ	P,PNCT2
;	ALWAYS	RETURN
;ACS N1,N,CH & R ARE DESTROYED

PCNT2:	IMULI	N,^D100
	IDIV	N,CH
	LSH	N1,1
	CAML	N1,CH
	ADDI	N,1

	MOVEI	CH," "		;FOR A LEADING BLANK
	CAIG	N,^D9		;DO WE NEED IT TO RIGHT JUSTIFY?
	PUSHJ	P,TYO		;YES
	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
	MOVEI	M,[ASCIZ /./]
	PJRST	MSGDEC		;PRINT DEC. POINT & FRACTION

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

PNTSEC:	MOVE	A,TCKSEC	;NO. OF JIFFIES IN 1 SECOND
	MOVEM	A,TEMP		;STORE FOR CMPDFN
	PJRST	CMPDFN		;GO PRINT RATIO

;SUBROUTINE TO PRINT SMALL TIME VALUE
;CALL	MOVE A,VALUE IN JIFFIES
;	PUSHJ	P,TIMPR
;	 .. RETURN

TIMPR:	IMULI	A,^D100
	IDIV	A,TCKSEC	;FORM .01 SECONDS
	TLO	F,FL.SZR	;SUPPRESS ZEROES
	JRST	MEMPR1

;SUBROUTINE TO CONVERT BLT TIME TO SECONDS (ROUNDED)
;PRINTS MESSAGE FOLLOWED BY TIME
;CALL	MOVE	A,BLT COUNT
;	MOVEI	M,[ASCIZ /TEXT/]
;	PUSHJ	P,MEMPR
;	ALWAYS	RETURN
;ACS A,B,C,N,N1,M,CH & R ARE DESTROYED

MEMPR:	TLO	F,FL.SZR	;SUPPRESS ZEROES
	PUSHJ	P,MSG		;SEND MESSAGE
	MUL	A,MEMNSP	;=TOTAL N-SEC/2
	DIV	A,[^D5000000]	;=TOTAL .01 SEC
MEMPR1:	TLNE	B,200000	;CHECK ROUND
	ADDI	A,1		;ROUND-UP
	IDIVI	A,^D100		;GET SEC
	PUSH	P,B		;SAVE .01S
	PUSHJ	P,TIME		;PRINT HR:MIN:SEC
	PUSHJ	P,PERIOD	;PRINT .
	POP	P,N		;RESTORE .01S
	PUSHJ	P,DECPR2	;PRINT .01S
	POPJ	P,		;RETURN


;SUBROUTINE TO COMPUTE THE SIZE OF A HI OR LOW SEGMENT
;ENTERRED WITH J=JOB OR SEGMENT NUMBER;   IF JOB, JS=STATUS
;RETURN WITH N=SIZE IN K
;RESPECTS ALL AC'S

SEGSZ:	MOVEI	N,(J)		;CHECK RANGE.
	CAML	N,BOTH		; ..
	JRST	SEGSZ4		;NO GOOD
	TRNN	F,FR.VMF	;IS THIS A VM SYSTEM?
	JRST	SEGSZ7		;(NO) USE THE CLASSIC LOGIC
	MOVE	N,@.SWP		;(YES) ASSUME WE NEED IMGIN FIELD
	TLNN	F,FL.HSG	;IF THIS IS NO HIGH SEGMENT 
	JRST	SEGSZ6		;THEN RETURN LAST 9 BITS
	MOVE	N,@.STS		;    ELSE SEE IF IT IS
	TLNE	N,SHRSEG	;     NONSHARABLE
	JRST	SEGSZ7		;SHARABLE IS OLD LOGIC
	MOVS	N,@.SWP		;IT IS NONSHARABLE
	JRST	SEGSZ6		;RETURN 9 BITS
SEGSZ7:	MOVS	N,@.ADR		;FETCH SEGMENT ADDRESS AND SIZE IN CORE
	JUMPE	N,SEGSZ1	;JUMP IF NOT IN CORE
	TLNN	F,FL.HSG	;TEST IF HI-SEG REQUEST
	TLNN	JS,JSWP		;N0--SEE IF SWAPPED OUT
	JRST	SEGSZ2		;HI-SEG OR IN-CORE LO-SEG
SEGSZ1:	MOVE	N,@.SWP		;FETCH SWAPPING DATA
	TRNE	N,377		;SEE IF OUT YET
	JRST	SEGSZ3		;  (IN-CORE SIZE)
	MOVS	N,@.ADR		;NO. USE IN-CORE VALUE ANYWAY
SEGSZ2:	SKIPE	CPKI10
	JRST	SEGSZ5		;DO KI10 WORK
	ADDI	N,1777		;ROUND IN-CORE SIZE UP
	ASH	N,-^D10		;DIVIDE BY 1K
SEGSZ3:	ANDI	N,377		;MASK RESULT TO 256K
	POPJ	P,		;RETURN
SEGSZ4:	MOVEI	N,777		;RETURN HUGE NUMBER
	POPJ	P,0
SEGSZ5:	ADDI	N,777	;ROUND TO PAGES
	LSH	N,-^D9
SEGSZ6:	ANDI	N,777
	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
	JUMPL	B,CPOPJ1	;WE HAVE A MATCH?
	POPJ	P,		;NO-NONE FOUND 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
;	MOVE	B,CORE SIZE (HI ONLY)
;	MOVSI	A,(SIXBIT .XX.)
;	PUSHJ	P,LOPSWP/HIPSWP
;	ALWAYS GOOD RETURN
;AC'S A,B,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
	PUSHJ	P,SIXBP
	MOVSI	A,(SIXBIT .FR.)	;YES - PRESUME HISEG IN CORE
	JRST	LOPSW2		;YES - PRINT "FR"

LOPSWP:	SETZ	B,
	TLNN	JS,JSWP		;IS SEG SWAPPED?
	JRST	LOPSW3		;NO - PRINT MSG & EXIT
LOPSW1:	PUSHJ	P,SIXBP
	MOVSI	A,(SIXBIT /SW/)	;PREPARE TO PRINT "SW"
	SKIPGE	@.SWP		;IS SEG FRAGMENTED?
	MOVSI	A,(SIXBIT .SWF.)	;YES - INDICATE SWAPPED & FRAGMENTED
	CAIGE	B,^D100		;SKIP SPACE IF NO ROOM
LOPSW2:	PUSHJ	P,SPACE
LOPSW3:	PUSHJ	P,SIXBP		;PRINT "FR","SF" OR "SW"
	LDB	N,IMGOUT	;GET CORE SIZE ON DISK
	ADDM	N,DSKUSE	;ADD TO TOTAL SPACE USED ON SWAPPING SPACE
	TLNN	F,FL.DOR
	JRST	TAB		;PRINT TAB & EXIT
	POPJ	P,
	SUBTTL	TABLES
IFLE HACKSW,<XLIST>
IFN HACKSW,<	RADIX 10
DEFINE BDAY (MO,DA,WHO)
<XWD <<MO-1>*^D31+DA-1>,EXP [ASCIZ /WHO/]>
DEFINE SDAY (MO,DA,SALUD)
<XWD SIGN!<<MO-1>*^D31+DA-1>,EXP [ASCIZ /SALUD/]>
BMSG:	ASCIZ	/HAPPY BIRTHDAY /
HAKTAB:
	SDAY (01,01,<HAPPY NEW YEAR>)
	BDAY (01,03,<JOE FRIES>)
	BDAY (01,06,<BAR VAN HEEST>)
	BDAY (01,12,<DAN MURPHY>)
	BDAY (01,16,<DAN D'URSO>)
	BDAY (01,19,<ROBERT E LEE>)
	BDAY (01,22,<CYNDEE KROZAL>)
	BDAY (01,25,<LEONARD BOSACK & JOHN SHEA>)
	BDAY (02,02,<KAREN FITZGERALD>)
	BDAY (02,07,<PAULA ARCHIBALD>)
	BDAY (02,13,<MIKE SPIER>)
	BDAY (02,17,<AL PORTER>)
	BDAY (02,22,<SANDY LIBMAN>)
	BDAY (02,24,<CHUCK O'TOOLE>)
	BDAY (02,26,<DAVE ALMADA>)
	BDAY (03,01,<JOHN CONNOR>)
	BDAY (03,06,<MAGEE>)
	SDAY (03,17,<HAPPY EVACUATION DAY>)
	SDAY (03,17,<P.S. IT'S ALSO ST. PATTY'S DAY>)
	BDAY (03,18,<JOE FARRELL>)
	BDAY (03,21,<JOHANN SEBASTIAN BACH>)
	SDAY (03,21,<FIRST DAY OF SPRING, TRA-LA>)
	BDAY (03,30,<STEVE JABLONSKY>)
	SDAY (04,01,<2+2=5 --- APRIL FOOL>)
	BDAY (04,01,<JIM MILLS & ALAN WARSHAW>)
	BDAY (04,08,<ERIC OSMAN>)
	BDAY (04,10,<GERRY HARRINGTON>)
	BDAY (04,13,<DON LEWINE>)
	BDAY (04,15,<DOT SOCCI>)
	BDAY (04,19,<MARTY VOSHELL>)
	BDAY (04,20,<LAURIE CUSTER>)
	BDAY (04,24,<VALDEANE ALUSIC>)
	BDAY (04,28,<ERNIE SOCCI>)
	BDAY (04,30,<BUTCH CLARK>)
	BDAY (05,05,<TEUNIS KORTEWEG & ROBERT PETTY>)
	BDAY (05,13,<ED DONIE>)
	BDAY (05,15,<JACKIE PARSLOW>)
	BDAY (05,18,<ED CROWLEY>)
	BDAY (05,20,<ANNE BROPHY>)
	BDAY (05,22,<JIM FLEMMING>)
	BDAY (05,27,<JOANNE GORFINKLE>)
	BDAY (05,28,<DON TODD & SETH COHEN>)
	BDAY (05,30,<ALAN FRANTZ>)
	BDAY (06,15,<MIKE TIGHE>)
	BDAY (06,15,<BETTY SAVAGEAU & DAVE PLUMER>)
	BDAY (06,18,<DOUG VICKERY>)
	BDAY (06,21,<DAVE RUSSELL>)
	BDAY (06,26,<STEVE RUSSELL>)
	BDAY (06,28,<JIM TOTTON>)
	BDAY (07,02,<ARNOLD MILLER>)
	BDAY (07,03,<PAUL CLARK>)
	SDAY (07,04,<HAPPY INDEPENDENCE DAY>)
	BDAY (07,06,<BERNHARD EIBEN>)
	BDAY (07,07,<MARY PAYNE>)
	BDAY (07,13,<NORMA ABEL>)
	SDAY (07,14,<BASTILLE DAY>)
	BDAY (07,15,<SARA MURPHY & ROLAND BELANGER>)
	BDAY (07,16,<SARA MARSELLA>)
	SDAY (07,20,<LUNAR LANDING DAY>)
	BDAY (07,22,<WALT LUSE>)
	BDAY (07,30,<SUMNER BLOUNT & DALE COOK>)
	BDAY (08,06,<LARRY SAMBERG & RALPH WINSLOW>)
	BDAY (08,08,<STEVE MIDELL>)
	BDAY (08,14,<SUE PORADA>)
	BDAY (08,15,<RUTH GREEN>)
	BDAY (08,22,<DAVE TOLMAN>)
	SDAY (08,23,<TOMORROW IS PAUL BENNETT'S BIRTHDAY>)
	BDAY (08,24,<PAUL BENNETT>)
	BDAY (08,28,<JUD LEONARD>)
	BDAY (09,02,<STEVE PAAVOLA>)
	BDAY (09,08,<PAT HUGHES>)
	BDAY (09,19,<PAUL WEXELBLAT>)
	BDAY (10,02,<DICK STEPHENSON>)
	BDAY (10,05,<LINDA OGILVIE & JEAN TAYLOR>)
	BDAY (10,06,<TOM EGGERS>)
	SDAY (10,12,<REAL COLUMBUS DAY>)
	BDAY (10,13,<DAVE NIXON>)
	SDAY (10,17,<SUNDAY IS DARIEN ALPERN'S BIRTHDAY>)
	BDAY (10,19,<DARIEN ALPERN>)
	BDAY (10,21,<BOB HEYLIGER>)
	BDAY (10,23,<BOB CLEMENTS & JOHNNY CARSON>)
	BDAY (10,24,<MARIA BONSAVAGE>)
	SDAY (10,24,<UNITED NATIONS DAY>)
	BDAY (10,25,<GLORIA MACDONALD & DAWN FISHER>)
	BDAY (10,27,<TWIG MCKIE & EVALYN MCCARTHY>)
	SDAY (11,05,<GUY FAWKES DAY>)
	BDAY (11,09,<ALLAN KENT & ALAN KOTOK>)
	BDAY (11,12,<JIM DELAHOUSSAYE>)
	BDAY (11,15,<DON BENNETT>)
	BDAY (11,22,<LARRY PORTNER>)
	SDAY (11,23,<TIME TO UPDATE BIRTHDAY LIST>)
	BDAY (11,23,<KATHY WALSH>)
	BDAY (11,26,<TOM O'GORMAN>)
	BDAY (11,27,<ED GAUTHIER>)
	BDAY (12,04,<CLIFF ROMASH>)
	BDAY (12,13,<BILL HARDY>)
	BDAY (12,14,<TONY WACHS>)
	BDAY (12,16,<L BEETHOVEN>)
	SDAY (12,24,<LAST SHOPPING DAY BEFORE CHRISTMAS>)
	SDAY (12,25,<MERRY CHRISTMAS>)
	SDAY (12,26,<BOXING DAY>)
	BDAY (12,26,<ART ZINA>)
	BDAY (12,28,<INGRID BRABERG>)
	SDAY (12,31,<DRIVE CAREFULLY TONIGHT>)

HAKLEN==.-HAKTAB
	RADIX 8
>
	LIST

;CONSTANTS FOR GETTAB UUO

XTIME:	XWD	10,11
XPDBPT:	XWD	45,11		;POINTER TO JBTPDB
XDATE:	XWD	11,11
XSEGPT:	XWD	15,11
XUPTIM:	XWD	15,12
XDVLST:	XWD	14,11
XCORMX:	XWD	10,12
XSYSSZ:	XWD	12,11
XMEMSZ:	XWD	23,12
XSTATS:	XWD	17,11
XLSTIM:	XWD	22,12
XK4SWP:	XWD	1,15
XSPPN:	XWD	1,16
XTTY:	XWD	-1,10
XSHF:	XWD	16,12
XZCOR:	XWD	21,12
XSRSP:	XWD	42,12		;INDEX OF SYSRSP
XRNUM:	XWD	43,12		;INDEX OF NUMRSP
XMEMNS:	XWD	21,11
XOPR:	XWD	13,11
XSYSST:	XWD	6,16	;SYSTEM STR LIST
XSYSUN:	XWD	7,16
XSWPER:	XWD	5,13
XSWPUN:	XWD	10,16
XSYSTP:	XWD	7,11	;NAME OF SYSTEM TAPE ("SYS:")
XFSFPP:	XWD	2,16	;OPERATOR (FAILSAFE) NUMBER
XPTYCN:	XWD	22,11	;CONFIGURATION FOR PTYS
XRMSTB:	XWD	25,11	;POINTER TO REMOTE STATION CHAIN
XAPRSN:	XWD	20,11	;APR SERIAL NUMBER
XSYKTM:	XWD	35,12	;SYSTEM KILL TIME
XGTTBI:	XWD	23,23	;GETTAB IMMEDIATE
XDSCTB:	XWD	35,11	;DSC TAB POINTER
XPCMA:	XWD	2,44	;PC AND MA ON CRASH (SWITCHES)
XPIIP:	XWD	1,44	;PI SYSTEM ON CRASH
XAPRCN:	XWD	0,44	;APR CONI ON A CRASH
XLGMAX:	XWD	50,11	;LOGMAX
XDDBLD:	XWD	75,11	;VALUE OF DDBLDB

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

;TABLE OF STOPCD CODES INDEXED BY VALUE

STOPT:	[ASCIZ /HALT/]
	[ASCIZ /STOP/]
	[ASCIZ /STOP JOB/]
	[ASCIZ /DEBUG/]
TABPTR:	XWD	SIGN+0,.STS
	XWD	SIGN+1,.ADR
	XWD	SIGN+7,.SWP
	XWD	SIGN+2,.PPN
	XWD	     4,.TIM
	XWD	    14,.SGN
	XWD	SIGN+3,.PRG
	XWD	SIGN+24,.DEV
	XWD	5,.KCT		;TABLE 5,kilo core ticks
	XWD	37,.RTD
NTAB==.-TABPTR
	XWD	     0,.SEGCT


;MORE MONITOR INTERFACE

PJOBN:	POINT 7,C,6
NPJOBN:	Z		;NEW STYLE JOB POINTER
NEWSPY:	Z			;FOR LOAD 722 AND SUBSEQUENT 
.DVJOB:	D,,DV.JOB
.DVFIL:	D,,DV.FIL		;TO GET FILE NAMES
.DVEXT:	D,,DV.EXT		;TO GET FILE EXTENSIONS
.DVPPN:	D,,DV.PPN		;TO GET PPN
.DVUNI:	D,,DV.UNI		;TO GET UDB ADDRESS
TPCJOB:	POINT 8,B,10
IMGOUT:	POINT 8,@.SWP,26
DSKLEV:	POINT	3,STATES,9
HPQPNT:	POINT	4,A,9

;CRASH-FILE NAME DATA
; WANT TO BE ABLE TO ASK FOR "FILE" IF CAN'T FIND
; "CRASH.XPN", BUT FOR NOW CAN DEPOSIT OTHER FILE NAME HERE.
; (NOTE: ERRORS STILL SAY "CRASH.XPN")

CRASH:	SIXBIT /CRASH/
CRSEXT:	SIXBIT /XPN/
CRSPPN:	0

RSPMSG:	[ASCIZ /    'til TTY output:	/]
RSPMS2:	[ASCIZ /    'til TTY input:	/]
RSPMS3:	[ASCIZ /    'til requeued:	/]
RSPMS4:	[ASCIZ /    'til 1st of above:	/]

IFN FTDEBUG,<
PAT:
PATCH:
FOO:	BLOCK	50		;PATCH AREA
>
IFE FTDEBUG,<
	XLIST		;ONLY LIST LITERALS IF IN DEBUG MODE
>
	LIT
	LIST

PDP:	IOWD	LN.PDL,PDL	;POINTER TO PUSH DOWN LIST
;TEMPORARIES

	IFN	PURESW,<
HIGH:	RELOC
LOW:	RELOC
	PHASE	LOW>

DSKIOW:	IOWD	LN.BUF,DSKBUF	;HAS TO BE HERE DUE TO DUMB MONITOR
	0			;END OF LIST

QTAB:	SIXBIT /RNWSTS/
	SIXBIT /STAUMQ/
	SIXBIT /DADTDC/
	SIXBIT /MTIOTT/
	SIXBIT /SLNL^C/
	SIXBIT /AABBCC/
	SIXBIT /DDEEFF/
	SIXBIT /GGHHII/
	SIXBIT /JJKKLL/
	SIXBIT /MMNNOO/
	SIXBIT /PPQQRR/
LQTAB==QTAB-.

.DVIOS:	XWD	J,0	;L
.TTY:	XWD	J,0	;L
.TTYN:	XWD	J,0	;L	TTY LINE NUMBERS
.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
.DEV:	XWD	J,0	;L+H
.KCT:	XWD	J,0	;L
.RTD:	XWD	J,0	;L
.SEGCT:	XWD	A,0	;H
TCKSEC:	JIFSEC			;JIFFIES PER SECOND
SYSPPN:	XWD	1,1		;PPN OF SYS:
MEMNSP:	NSPMEM			;CORE SPEED

ORGPTR:	POINT 7,CMDBUF		;[200] ORIGIONAL COMMAND BUFFER POINTER

	IFN	PURESW,<
ZZZ==.-LOW
	RELOC
LOW:	BLOCK	ZZZ>
LOWEND:				;START OF ZEROED AREA

PDL:	BLOCK	LN.PDL+1	;PUSH-DOWN LIST

CPNUPT:	BLOCK	NCPUS
CPNNUL:	BLOCK	NCPUS
CPNLST:	BLOCK	NCPUS
TEMP:	BLOCK	1
IFG NCPUS-2,<
	BLOCK	NCPUS-2
>
TEMP1:	BLOCK	1

TYOB:	BLOCK	3	;LISTING DEVICE OUTPUT BUFFER POINTERS

CBSIZE==^D14		;[214] SIZE <WORDS> OF COMMAND BUFFER
CMDBUF:	BLOCK	CBSIZE+1	;[200] - [214] COMMAND BUFFER
CDENDP==CMDBUF+CBSIZE	;[214] END OF COMMAND BUFFER
CMDPTR:	BLOCK	1	;[200] CURRENT COMMAND POINTER
GOTCMD:	BLOCK	1	;[200] COMMAND GOTTEN FLAG

FLP:	BLOCK 6		;[203] FILOP. ARGUMENT BLOCK
LKB:	BLOCK 10	;[203] EXTENDED LOOKUP BLOCK

SEGPTR:	BLOCK	1	;LH=-# SEGS, RH=# JOBS
JOBN:	BLOCK	1	;NUMBER OF JOBS IN SYSTEM
SEGN:	BLOCK	1	;NUMBER OF SEGMENTS IN SYSTEM
BOTH:	BLOCK	1	;JOBN + SEGN

CORMAX:	BLOCK	1	;SIZE OF USER CORE
CORUSE:	BLOCK	1	;VIRTUAL CORE USED
DSKUSE:	BLOCK	1	;SWAPPING SPACE USED
ACTUSE:	BLOCK	1	;ACTIVE VIRTUAL CORE USED
LOWUSE:	BLOCK	1	;TOTAL VIRTUAL CORE IN LOW SEGMENTS

FREE:	BLOCK	1	;TEMPORARY .JBFF
ZERLOW:	BLOCK	1	;FIRST ADDRESS OF DYNAMIC TABLES
ZERHGH:	BLOCK	1	;LAST ADDRESS OF DYNAMIC TABLES

JOBTTY:	BLOCK	1	;NAME OF CURRENT JOB'S TTY
DATE:	BLOCK	1	;TODAY'S DATE
STATES:	BLOCK	1	;SYSTEM STATES WORD
ME:	BLOCK	1	;MY PPN
OPR:	BLOCK	1	;NAME OF "OPR" DEVICE
MYJOB:	BLOCK	1	;MY JOB NUMBER
CORSAV:	BLOCK	1	;VIRTUAL CORE SAVED BY SHARING
ONCE:	BLOCK	1	;-1 FIRST TIME THROUGH
TNFRTY:	BLOCK	1	;1 IF 10/40N (NO LOGIN)
SYSTAP:	BLOCK	1	;NAME OF SYSTEM TAPE ("SYS:"), 0=DSK:
FSFPPN:	BLOCK	1	;OPERATOR NUMBER
TTYFLG:	Z		;-1 IF TOPS10 STYLE ELSE 
				;0 IF NO TRMNO.
				;1 IF TRMNO. EXISTS
CTYNDX:	Z			;UDX OF CTY
PTYOFS:	BLOCK	1	;NUMBER OF FIRST TTY DRIVEN BY PTY
PTYMAX:	BLOCK	1	;NUMBER OF LAST+1 TTY DRIVEN BY PTY
		.UPSAF==1B4	;BIT FLAGGING S/A
		.UPNNA==1B10	;BIT FLAGGING NNA
CURFS:	BLOCK	1	;CURRENT FILESTRUCTURE
iocnt:	block	1	;# of reads and writes for unit
UNIBLK:	BLOCK	1
SYSUNI:	BLOCK	1
SWPUNI:	BLOCK	1
DSKBLK:	BLOCK	1		;DSKCHR UUO BLOCK
DSKDDB:	BLOCK	1	;COUNT OF DISK DDB'S
LOGNAM:	BLOCK	1	;LOGICAL NAME OF THIS DEVICE
NOW:	BLOCK	1	;CURRENT TIME
SPYFLG:	BLOCK	1	;-1 IF SPYING
MAXGTB:	BLOCK	1	;LARGEST GETTAB TABLE #
OFSGTB:	BLOCK	1	;START OF GETTAB TABLE POINTERS
PTYS:	BLOCK	1	;COUNT OF PTY DRIVEN JOBS
ONEJOB:	BLOCK	1	;NUMBER OF JOB IF SINGLE
ONEPPN:	BLOCK	1	;NUMBER OF PPN IF SINGLE
ONETTY:	BLOCK	1	;NUMBER OF TTY IF SINGLE
SAVCHR:	BLOCK	1	;CHARACTER TO RESCAN IF ANY
SEGFLG:	BLOCK	1	;-1 IF SEGMENT PRINTING
DSKFLG:	BLOCK	1	;FLAG (AND MAX SIZE) OF DISK INPUT FILE
DSKBLF:	BLOCK	1	;CURRENT BLOCK OF DISK FILE IN CORE
DSKBUF:	BLOCK	LN.BUF	;BUFFER FOR DISK FILE
LASBP1:	BLOCK	1	;VALUE OF LAST DSKBP1 CALL
LASBPA:	BLOCK	1	;ARGUMENT OF LAST DSKBP1 CALL
MONVER:	BLOCK	1	;MONITOR VERSION GETTAB (0 BEFORE 503)
OLDTIM:	BLOCK	NCPUS	;PREVIOUS UPTIME IN JIFFIES
OLDNUL:	BLOCK	NCPUS	;PREVIOUS NULL TIME IN JIFFIES
OLDLOS:	BLOCK	NCPUS	;PREVIOUS LOST TIME IN JIFFIES
OLDZRO:	BLOCK	1
OLDSFL:	BLOCK	1
OLDNUM:	BLOCK	1	;PREVIOUS NUMBER OF SYSTEM RESPONSES(OLD RSP CODE)
TOTKCT:	BLOCK	1	;TOTAL KC TICKS THIS PASS
LOGDIN:	BLOCK	1	;JOBS LOGGED IN
DIFTIM:	BLOCK	NCPUS	;DIFFERENTIAL UPTIME FOR THIS PASS
LINECT:	BLOCK	1	;LINES PER PAGE FOR DISPLAY USERS
JOBTIM:	BLOCK	^D256	;RUN TIM FOR EACH JOB NUMBER
OLDPPN:	BLOCK	^D256	;OLD PPN FOR EACH JOB NUMBER
JOBKCT:	BLOCK	^D256	;KILO CORE TICKS FOR EACH JOB
TISL:	BLOCK	1	;WAIT STATE CODES FOR TI AND SL
NUMJOB:	BLOCK	1	;NUMBER OF ACTIVE JOBS
REMSNO:	BLOCK	1	;CURRENT REMOTE STATION NUMBER
PDBPTR:	BLOCK	1	;ADDRESS OF JBTPDB FOR PEEKING
JOBINT:	BLOCK	4	;INTERRUPT BLOCK FOR INTERRUPTING ^C
CPU:	BLOCK	1	;TEMP FOR GETRSP
DOALT:	BLOCK	1	;FLAG FOR ALTERNATE PATH TYPE
MAIND:	BLOCK	1	;SAVE LOCATION FOR UDB OF MAIN
CPKI10:	BLOCK	1	;IF KI10 AND MONITOT>50510 THEN -1 ELSE 0
INDEV:	BLOCK	1
INFILE:	BLOCK	1
INEXT:	BLOCK	1
INPPN:	BLOCK	1
RSPCNT:	BLOCK	1	;COUNTER FOR GENRSP CODE
RSPIDX:	BLOCK	1	;INDEX INTO OLDRSP & DIFRSP
RSPIX1:	BLOCK	1	;TEMP FOR GETRSP
OLDRSP:	BLOCK	NCPUS*4*4	;4 DIFFERENT TYPES OF RESPONSE*4
DIFRSP:	BLOCK	NCPUS*4*4	; ENTRIES PER TYPE* # OF CPU'S
TEMEND==.-1		;END OF ZEROED AREA
	END	SYSTAT