Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-03 - 43,50314/opr.mac
There are 37 other files named opr.mac in the archive. Click here to see a list.
	TITLE OPR
	TWOSEG
	SEARCH JOBDAT,UUOSYM
	.REQUEST REL:HELPER.REL
;
;	FEATURES
;
	IFNDEF DEBUG,<DEBUG==0>	;DEBUGGING FEATURE SWITCH
	IFNDEF PLEN,<PLEN==200>	;PUSH DOWN LIST LENGTH
	IFNDEF OPRLOG,<OPRLOG==1>	;OPR LOGGING FEATURE
	IFNDEF SPTWHO,<SPTWHO==0>	;SPIRIT WHO FEATURE
	IFNDEF SPTWHT,<SPTWHT==0>	;SPIRIT WHAT FEATURE
	IFNDEF SPTTIM,<SPTTIM==1>	;SPIRIT TIMES FEATURE
	IFNDEF SPTTLG,<SPTTLG==1>	;SPIRIT TIMES LOGGING FEATURE
	IFNDEF SPTKJO,<SPTKJO==0>	;SPIRIT KJOB FEATURE
	IFNDEF SPTKJD,<SPTKJD==0>	;SPIRIT KJOB FEATURE FOR DETACHED JOBS
	IFNDEF SPTDSK,<SPTDSK==0>	;SPIRIT DSK WATCH FEATURE
	IFNDEF SPTWRN,<SPTWRN==^D45>	;SPIRIT DEFAULT WARNING TIME
	IFNDEF SPTSIZ,<SPTSIZ==^D100>	;SPIRIT DEFAULT MAXIMUM TIMES
					;  LOG FILE BLOCK SIZE
	IFNDEF SCLSES,<SCLSES==^D10>	;MAX SCHEDULER CLASS TABLE SIZE
	IFNDEF TUFSER,<TUFSER==777777>	;TUFTS CPU SERIEL NUMBER
;
;	ACC'S
;
	SW==0
	PDP==1
	CHAR==2
	DEC==3
	SIX==4
	OCT==3
	STS==5
	CHAN==6
	ADR==7
	RNG==10
	INS==7
	LINE==3
	DAT==3
	TIM==3
;
;	SWITCHES
;
	RRD==400000
	PRV==200000
	DB==100000
	JLG==040000
	LCK==020000
	CF==010000
;
;	TEMPORARY SWITCHES
;
	FST==000400		;LEFT HALF
	SLW==000200
	PRF==000100
	CPRV==400000		;RIGHT HALF
	DEP==200000
	CCB==040000
	ERI==020000
	SPT==010000
	FND==004000
	TOPN==002000
	FCM==001000
	POUT==000400
	PTL==000200
	TLGN==000100
	AGN==000020
	PLG==000010
	NFL==000004
	WHY==000002
	CLG==000001
;
;	CHANNELS
;
	TTY==1
	PTY==2
	LOG==3
	DWHO==4
	DWHT==5
	TMS==6
	TMSL==7
	TMSR==10
	LPT==11
	CMD==12
	CMF==13
;
;	OPDEF'S
;
	OPDEF CALL [PUSHJ PDP,]
	OPDEF RETURN [POPJ PDP,]
	OPDEF NOP [JUMP]
	OPDEF NOTDEF [CALL ER090]
;
;	MISC
;
	JRUN==400000	;JBTSTS BITS
	CMWB==200000
	JNA==040000
	NSWP==010000
	SWP==002000
	JLOG==000004
	CLKR==400000
	JDCON==020000
	SPYSEG==400000	;JBTSGN BITS
	SHRSEG==200000
	JQ.PQ1==31	;JOB QUEUES
	JQ.PQ2==32
	JQ.HPQ==34
	DDBLDB==21	;DDB WORDS
	LDBBYT==17	;LDB WORDS
	AT.MON==400000	;ATTACH UUO BITS
	AT.USR==200000
	AT.DET==100000
	W.BAT==400000	;WHO STATUS BITS
	W.USR==200000
	W.LCL==100000
	W.DSL==040000
	W.LNE==020000
	W.ACT==010000
	W.VM==004000
	W.SYJ==002000
	W.ADJ==001000
	W.ACJ==000400
	T.NLG==400000	;TIMES STATUS BITS
	IF2,<IFNDEF CTEST,<CTEST=DCTEST>>	;DUMMY CTEST COMMAND
	PRO==<JRST 2,@.JBOPC>	;PROCEED AFTER ^C COMMAND
	CRSHWD==30	;INTERNAL BITS
	VERSION==6
	MOD==36
	SUBTTL LOW DATA
;
	LOC .JBVER
	<2>B2+<VERSION>B11+<MOD>B35
;
	RELOC 0
	INTEGER MYPPN,MYJOB,PTYDSP,CTYLNE,PPN,JOB,ADDR,VALUE
	INTEGER PRVPPN,LERR,QUEPPN,TOPJOB,HBCNT,LST,LSTJOB
	INTEGER JIFFY,PAGE,TABPOS
	INTEGER WRNOUT,CCADR,OLDLNE,SYSSER,HLPPPN,CCLENT
	INTEGER MYLINE,CRETIM,NXTTIM,NOW,CMDCNT,BREAK
	INTEGER WHOPPN,WHOLNE,WHOPRG,WHORUN,WHOHPQ,WHODSK,WHOLOK
	INTEGER WHODRD,WHODWT,WHORAT,WHOSTS,WHOLIM
	INTEGER REECNT,CMDADR,LCLSW,LCLSW2,LOGDEV,CNTJOB,CNTDET
	INTEGER CNTSWP,CNTUSR,CNTTIW,CNTSLP,CNTTOW,CNTBAT
	INTEGER KOP,TSTJOB,TSTSTS,TSTLNE,TSTCOR,SRCLNE,TOPLNE
	INTEGER TIMSTS,CNTLOG
	ARRAY ARNG[6],SRNG[6],STRS[20],FCFS[20],LOW[20]
	ARRAY TRNG[6],PRNG[6],LRNG[6],ORNG[6],PLIST[PLEN]
	ARRAY CRNG[6],DRNG[6],SYSFEA[2],WHOCON[2]
	ARRAY COMAND[21],WHOUSR[4],WHOCOR[4],WHOSTA[2],MRNG[6],RRNG[6]
	ARRAY CNTRUN[2],CNTCOR[2],FRNG[6],REPLY[21],DCHRS[20]
	ARRAY GOBS[5],TSTUSR[2],TSTPRG[2],TSTPPN[2],CNTDSK[2]
	ARRAY UTIME[2],NTIME[2],LTIME[2],RTIME[2],RCOUNT[2]
	ARRAY OTIME[2],SCLASS[2*SCLSES],SCOUNT[2]
	VAR
;
;	LOW DATA ALLOCATION
;
	LOWDAT=.
	RELOC 400000
	HIDAT=.
	OPENT=LOWDAT+<.-HIDAT>
	0
	SIXBIT /TTY/
	XWD TRNG,TRNG+3
	OPENP=LOWDAT+<.-HIDAT>
	0
	SIXBIT /PTY/
	XWD PRNG,PRNG+3
	OPENL=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD LRNG,LRNG+3
	LOOKL=LOWDAT+<.-HIDAT>
	SIXBIT /OPR/
	SIXBIT /LOG/
	0
	XWD 3,3
	OPENO=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD ORNG,ORNG+3
	LOOKO=LOWDAT+<.-HIDAT>
	SIXBIT /SPIRIT/
	SIXBIT /WHO/
	0
	XWD 3,3
	OPENA=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD ARNG,ARNG+3
	LOOKA=LOWDAT+<.-HIDAT>
	SIXBIT /SPIRIT/
	SIXBIT /WHT/
	0
	XWD 3,3
	OPENS=LOWDAT+<.-HIDAT>
	0
	SIXBIT /SYS/
	XWD SRNG,SRNG+3
	LOOKS=LOWDAT+<.-HIDAT>
	SIXBIT /TIMES/
	SIXBIT /SYS/
	0
	0
	OPENM=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD MRNG,MRNG+3
	LOOKM=LOWDAT+<.-HIDAT>
	SIXBIT /TIMES/
	SIXBIT /LOG/
	0
	0
	OPENR=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD RRNG,RRNG+3
	LOOKR=LOWDAT+<.-HIDAT>
	SIXBIT /TIMES/
	SIXBIT /LOG/
	0
	0
	OPENF=LOWDAT+<.-HIDAT>
	0
	SIXBIT /LST/
	XWD FRNG,FRNG+3
	LOOKF=LOWDAT+<.-HIDAT>
	SIXBIT /OPR/
	SIXBIT /LST/
	0
	0
	OPEND=LOWDAT+<.-HIDAT>
	0
	SIXBIT /DSK/
	XWD DRNG,DRNG+3
	LOOKD=LOWDAT+<.-HIDAT>
	SIXBIT /OPR/
	SIXBIT /DAT/
	0
	0
	CCSPEC=LOWDAT+<.-HIDAT>
	XWD 4,CINT
	XWD 400000,ER.ICC
	0
	0
	DATLEN==.-HIDAT
	RELOC
	BLOCK DATLEN
;
;	SPIRIT DATA ALLOCATION
;
	SPTDAT=.
	RUNTIM=SPTDAT
	TIME=RUNTIM+200
	WARN=TIME+200
	PPNS=WARN+200
	HUNG=PPNS+200
	SPTTOP=HUNG+200
;
	RELOC
	SUBTTL HIGH DATA
;
RNGTAB:	-1
	TRNG
	PRNG
	LRNG
	ORNG
	ARNG
	SRNG
	MRNG
	RRNG
	FRNG
	CRNG
	DRNG
;
STAB0:	SIXBIT /W/
	SIXBIT /E/
	SIXBIT /LOCATE/
	SIXBIT /DETACH/
	SIXBIT /STOP/
	SIXBIT /TALK/
	SIXBIT /CONTIN/
	SIXBIT /KILL/
	SIXBIT /FREE/
	SIXBIT /PURGE/
	SIXBIT /WHO/
	SIXBIT /WHAT/
	SIXBIT /PEEK/
	SIXBIT /HELP/
	SIXBIT /WATCH/
	SIXBIT /ATTACH/
	SIXBIT /DEBUG/
	SIXBIT /KSYS/
	SIXBIT /BOMB/
	SIXBIT /PRIVIL/
	SIXBIT /VM/
	SIXBIT /LIMIT/
	SIXBIT /FORCE/
	SIXBIT /ECHO/
	SIXBIT /REPEAT/
	SIXBIT /AT/
	SIXBIT /EXIT/
	SIXBIT /LOGIN/
	SIXBIT /CTEST/
	0
DTAB0:	XWD 0,WHO
	XWD 0,EX
	XWD 0,LOCT
	XWD CPRV,DET
	XWD CPRV+WHY,STOP
	XWD CPRV,TALK
	XWD CPRV,CONT
	XWD CPRV+WHY,KILL
	XWD CPRV,FREE
	XWD CPRV,PURG
	XWD 0,WHO
	XWD 0,WHAT
	XWD CPRV,PEK
	XWD 0,HELP
	XWD CPRV,WAT
	XWD CPRV,ATT
	XWD CLG,DBUG
	XWD CPRV+WHY,KSYS
	XWD CPRV+WHY,BOMB
	XWD CPRV+WHY,PRIV
	XWD CPRV+WHY,VM
	XWD CPRV+WHY,LIM
	XWD CPRV+WHY,FOR
	XWD CPRV,ECHO
	XWD CLG,REPEAT
	XWD CLG,AT
	XWD 0,EX
	XWD 0,LOGIN
	XWD 0,CTEST
;
;	MISC
;
KJOB1:	ASCIZ "KJOB /B"
KJOB2:	ASCIZ "KJOB /F"
KJOB3:	ASCIZ "KJOB /N"
	SUBTTL INITL
;
;	STARTING POINT OF PROGRAM (ONCE ONLY CODE)
;
INITL:	PORTAL .+2
	PORTAL .+2
	SKIPA		;SKIP OVER CCL ENTRY
	SETOM CCLENT
	MOVE 17,[XWD HIDAT,LOWDAT]	;BUILD LOW SEG
	BLT 17,LOWDAT+DATLEN-1
	RESET		;SETUP
	SETZ SW,
	MOVE PDP,[IOWD PLEN,PLIST]
	SETZM LSTJOB
	GETPPN 17,	;CHECK FAILSA PPN
	NOP
	MOVEM 17,MYPPN
	MOVE 16,[%LDFFA]
	GETTAB 16,
	MOVE 16,[XWD 1,2]
	MOVEM 16,PRVPPN
	IFE DEBUG,<CAMN 16,17>
	TLO SW,PRV
	PJOB 17,		;GET JOB NUMBER
	MOVEM 17,MYJOB
	MOVE 17,[XWD -1,.GTSTS]		;CHECK IF LOGGED IN
	GETTAB 17,
	SKIPA
	TLNE 17,JLOG
	TLO SW,JLG
	MOVE 17,[%CNPTY]	;GET CTY LINE
	GETTAB 17,
	MOVSI 17,177
	HLRZ 16,17
	MOVEM 16,PTYDSP
	SUBI 16,1
	MOVEM 16,CTYLNE
	ADDI 16,(17)
	MOVEM 16,TOPLNE
	MOVE 17,[%CNSJN]	;GET TOP JOB NUMBER
	GETTAB 17,
	MOVEI 17,^D128
	SUBI 17,1
	ANDI 17,177
	MOVEM 17,TOPJOB
	MOVE 17,[%LDQUE]	;GET LOG PPN + STR
	GETTAB 17,
	MOVE 17,[XWD 3,3]
	MOVEM 17,QUEPPN
	MOVE 17,[%LDQUS]
	GETTAB 17,
	MOVE 17,[SIXBIT /DSK/]
	MOVEM 17,OPENL+1
	MOVEM 17,OPENO+1
	MOVEM 17,OPENA+1
	MOVEM 17,OPENM+1
	MOVEM 17,OPENR+1
	MOVE 17,[%LDHLP]	;GET LOGIN PPN
	GETTAB 17,
	MOVE 17,[XWD 2,5]
	MOVEM 17,HLPPPN
	MOVE 17,[%CNTIC]	;GET JIFFY SIZE
	GETTAB 17,
	MOVEI 17,^D60
	MOVEM 17,JIFFY
	MOVEI 17,^D512		;GET PAGE SIZE
	MOVEI 16,"P"
	HRLOI 15,-2
	AOBJN 15,IZ010
	MOVEI 17,^D1024
	MOVEI 16,"K"
IZ010:	MOVEM 17,PAGE
	MOVEM 16,KOP
	MOVE 17,[%CNSTS]	;GET SYSTEM FEATURES WORDS
	GETTAB 17,
	SETZ 17,
	MOVEM 17,SYSFEA
	MOVE 17,[%CNST2]
	GETTAB 17,
	SETZ 17,
	MOVEM 17,SYSFEA+1
	MOVE 17,[%CNSER]	;GET SYSTEM SERIAL NUMBER
	GETTAB 17,
	SETZ 17,
	MOVEM 17,SYSSER
	SETZM UTIME	;SETUP
	SETZM NTIME
	SETZM LTIME
	SETZM OTIME
	SETZM RTIME
	SETZM RCOUNT
	SETZM SCLASS
	MOVE 17,[XWD SCLASS,SCLASS+1]
	BLT 17,SCLASS+SCLSES-1
	MOVEI 17,ERROR	;SET UP JOB DATA AREA
	HRRM 17,.JBREN
	MOVEI 17,CCSPEC
	HRRM 17,.JBINT
	MOVSI 17,'TTY'	;INIT TTY
	DEVCHR 17,
	TLNN 17,(DV.TTY)
	JRST ER020
	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
	JRST MAIN
	SUBTTL CINT
;
;	^C INTERCEPT SERVICE ROUTINE
;
CINT:	PORTAL .+1
	PUSH PDP,CCSPEC+2
	SETZM CCSPEC+2
	TRNE SW,CCB
	JRST @CCADR
	TLNE SW,DB
	JRST CT010
	TRNE SW,SPT
	JRST CT020
CT010:	CALL SAVACS
	TLNE SW,LCK
	PUSH PDP,[EXP LOCKS]
	PUSH PDP,[EXIT1]
	TLNE SW,LCK
	PUSH PDP,[LOCKE]
CT020:	RETURN
	SUBTTL MAIN
;
;	MAINLINE (COMMAND PROCESSOR)
;
MAIN:	RESET
	CALL PRIO
	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
	MOVEI CHAN,TTY
	SETZM LOGDEV
	SKIPN CCLENT
	JRST MN010
	RESCAN		;CCL ENTRY
	JRST MN020
MN010:	MOVEI CHAR,"/"	;NORMAL ENTRY
	CALL OTCHAR
	OUTPUT TTY,
MN020:	TLZ SW,RRD
	INPUT TTY,
	MOVEI 17,^D80	;BUILD COMMAND
	MOVE 16,[POINT 7,COMAND]
	MOVEM 16,CRNG+4
MN030:	CALL NXCHAR
	JUMPE CHAR,MN040
	IDPB CHAR,16
	SOJG 17,MN030
MN040:	SETZ CHAR,
	IDPB CHAR,16
	SOS 17
	MOVEI 16,^D80
	SUB 16,17
	MOVEM 16,CMDCNT
	MOVEM 16,CRNG+5
	PUSH PDP,[CMDRET]	;INTERPRET COMMAND
COMINP:	MOVEI CHAN,CMD
	CALL INCR
	SKIPA
	JRST NULCOM
	CALL NXCHAR
	CAIE CHAR,"@"
	JRST MN050
	MOVSI SIX,(SIXBIT /AT/)
	JRST MN060
MN050:	CAIE CHAR,"/"
	TLO SW,RRD
	CALL INSIX
	JUMPE SIX,ER030
MN060:	CALL INSP
	MOVEI ADR,STAB0
	CALL DSPTCH
	JUMPL 17,ER040
	MOVE 16,DTAB0(17)
	MOVEM 16,CMDADR
	TLZ SW,777
	HLR SW,CMDADR
	HRRZ ADR,CMDADR
	TLNN SW,PRV+DB
	TRNN SW,CPRV
	SKIPA
	JRST ER100
	TLNN SW,JLG
	TRNN SW,CLG
	SKIPA
	JRST ER160
	JRST (ADR)
DCTEST:	CALL INCR	;DEFAULT CTEST
	JRST ER030
NULCOM:	RETURN		;NULL COMMAND
CMDRET:	TRZN SW,AGN	;COMMAND RETURN
	JRST MN090
	PUSH PDP,[CMDRET]	;DO COMMAND AGAIN
	MOVEI CHAN,CMD
	TLZ SW,777
	HLR SW,CMDADR
	HRRZ ADR,CMDADR
	JRST (ADR)
MN090:	CALL LOCKE	;MAKE SURE JOB IS UNLOCKED
	SKIPE CCLENT	;FINISH
	CALL EXIT2
	JRST MAIN
	SUBTTL ERROR
;
;	ERROR PROCESSOR (FATAL ERRORS ONLY)
;
ERROR:	PORTAL .+1
	TDZ SW,[XWD RRD+CF,AGN+PLG]
	MOVE PDP,[IOWD PLEN,PLIST]
	JRST CMDRET
CSET:	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
	MOVEI CHAN,TTY
	RETURN
ER010:	CALL CSET
	MOVEI ADR,[ASCIZ /FAILED/]
	CALL OUTASC
	SKIPN DEC,JOB
	JRST ER900
	MOVEI ADR,[ASCIZ / ON JOB /]
	CALL OUTASC
	CALL OUTDEC
	JRST ER900
ER020:	OUTSTR [ASCIZ /? LOGICAL TTY IS NOT PHYSICAL TTY/]
	OUTSTR [BYTE (7) 15,12]
	JRST EXIT0
ER030:	CALL CSET
	MOVEI CHAR,"?"
	CALL OTCHAR
	MOVE 17,CMDCNT
	SUB 17,CRNG+5
	SUBI 17,1
	JUMPLE 17,ER032
	MOVEI CHAR,"-"
	CALL OTCHAR
	SOJG 17,.-1
ER032:	MOVEI ADR,[ASCIZ /^     COMMAND ERROR/]
	CALL OUTASC
	JRST ER900
ER040:	CALL CSET
	MOVEI ADR,[ASCIZ /? INDETERMINATE COMMAND: /]
	CALL OUTASC
	CALL OUTSIX
	JRST ER900
ER050:	CALL CSET
	MOVEI ADR,[ASCIZ /? NON-EXISTENT DEVICE: /]
	CALL OUTASC
	CALL OUTSIX
	JRST ER900
ER060:	CALL CSET
	MOVEI ADR,[ASCIZ /? ILLEGAL JOB NUMBER: /]
	CALL OUTASC
	MOVE DEC,JOB
	CALL OUTDEC
	JRST ER900
ER070:	CALL CSET
	MOVEI ADR,[ASCIZ /? NO PTY'S AVAILABLE/]
	CALL OUTASC
	JRST ER900
ER080:	CALL CSET
	MOVEI ADR,[ASCIZ /? DEVICE IS ALREADY FREE/]
	CALL OUTASC
	JRST ER900
ER090:	TRNE SW,SPT
	TLNE SW,DB
	SKIPA
	JRST SPTREE
	CALL CSET
	MOVEI ADR,[ASCIZ /? ILLEGAL MONITOR CALL AT USER PC /]
	CALL OUTASC
	HRRZ OCT,(PDP)
	SUBI OCT,2
	CALL OUTOCT
	JRST ER900
ER100:	MOVE SIX,STAB0(17)
	CALL CSET
	MOVEI ADR,[ASCIZ /? OPERATOR PRIVILEGED COMMAND: /]
	CALL OUTASC
	CALL OUTSIX
	JRST ER900
ER110:	CALL CSET
	MOVEI ADR,[ASCIZ /? JOB IS ALREADY DETACHED: /]
	CALL OUTASC
	MOVE DEC,JOB
	CALL OUTDEC
	JRST ER900
ER120:	CALL CSET
	MOVEI ADR,[ASCIZ /? MUST BE LOGGED IN FOR LIST SPECIFICATION/]
	CALL OUTASC
	JRST ER900
ER130:	CALL CSET
	MOVEI ADR,[ASCIZ /? NOT ENOUGH CORE AVAILABLE FOR SPIRIT/]
	CALL OUTASC
	JRST ER900
ER140:	CALL CSET
	MOVEI ADR,[ASCIZ /? MUST BE LOGGED IN FOR COMMAND FILES/]
	CALL OUTASC
	JRST ER900
ER150:	CALL CSET
	MOVEI ADR,[ASCIZ /? MULTI-LEVEL COMMAND FILES ILLEGAL/]
	CALL OUTASC
	JRST ER900
ER160:	MOVE SIX,STAB0(17)
	CALL CSET
	MOVEI ADR,[ASCIZ /? MUST BE LOGGED IN FOR COMMAND: /]
	CALL OUTASC
	CALL OUTSIX
	JRST ER900
ER170:	CALL CSET
	MOVEI ADR,[ASCIZ /? NO PREVIOUS JOB SPECIFIED/]
	CALL OUTASC
	JRST ER900
ER900:	CALL OUTCR
	OUTPUT TTY,
	JRST ERROR
	SUBTTL AT
;
;	AT COMMAND
;	CALLING SEQUENCE:	*AT FOO<CR>	OR
;				*@FOO<CR>
;
AT:	TLNN SW,JLG	;CHECK IF LOGGED IN
	JRST ER140
	TLNE SW,CF	;SEE IF MULTI-LEVEL COMMAND FILES
	JRST ER150
	CALL INFOO	;GET FILE SPECS
	JRST ER030
	SKIPN 13	;CHECK FOO
	SKIPE 14
	SKIPA
	JRST ER030
	SKIPN 13	;MAKE DEFAULTS
	MOVSI 13,'DSK'
	MOVEM 13,OPEND+1
	MOVEM 14,LOOKD
	MOVEM 15,LOOKD+1
	MOVEM 16,LOOKD+2
	MOVEM 17,LOOKD+3
	SKIPE LOOKD
	JRST AF010
	MOVE 17,[SIXBIT /000OPR/]
	MOVEM 17,LOOKD
	LDB 17,[POINT 3,MYJOB,29]
	DPB 17,[POINT 3,LOOKD,5]
	LDB 17,[POINT 3,MYJOB,32]
	DPB 17,[POINT 3,LOOKD,11]
	LDB 17,[POINT 3,MYJOB,35]
	DPB 17,[POINT 3,LOOKD,17]
	MOVSI 17,'CMD'
	SKIPN LOOKD+1
	MOVEM 17,LOOKD+1
AF010:	CALL INCR
	JRST ER030
	MOVEI CHAN,CMF	;LOOKUP FILE
	OPEN CMF,OPEND
	CALL OPCHK
	LOOKUP CMF,LOOKD
	CALL LKCHK
AF020:	MOVEI 17,^D80	;GET COMMAND
	MOVE 16,[POINT 7,COMAND]
	MOVEM 16,CRNG+4
AF030:	SKIPLE DRNG+5	;GET NEXT CHAR
	JRST AF040
	INPUT CMF,
	GETSTS CMF,STS
	CALL STSCHK
	TRNE STS,IO.EOF
	JRST AF060
AF040:	ILDB CHAR,DRNG+4
	SOS DRNG+5
	CAIN CHAR,00	;TEST FOR EOR
	JRST AF030
	CAIN CHAR,15
	JRST AF030
	CAIN CHAR,33
	JRST AF050
	CAIN CHAR,12
	JRST AF050
	IDPB CHAR,16	;STORE CHAR
	SOJG 17,AF030
AF050:	SETZ CHAR,	;EOR
	IDPB CHAR,16
	SOS 17
	MOVEI 16,^D80
	SUB 16,17
	MOVEM 16,CMDCNT
	MOVEM 16,CRNG+5
	TLO SW,CF	;DO THE COMMAND
	CALL COMINP
	TLZ SW,CF
	JRST AF020
AF060:	RELEAS CMF,	;NO MORE COMMANDS
	RETURN
	SUBTTL REPEAT
;
;	REPEAT COMMAND
;	CALLING SEQUENCE:	*REPEAT N COMMAND<CR>
;
REPEAT:	CALL INDEC	;GET REPEAT COUNT
	JUMPE DEC,ER030
	PUSH PDP,DEC
	CALL INSP	;SETUP FOR COMMAND
	CALL NXCHAR
	JUMPE CHAR,ER030
RP010:	LDB CHAR,CRNG+4	;DO COMMAND
	TLO SW,RRD
	PUSH PDP,CRNG+4
	PUSH PDP,CRNG+5
	CALL COMINP
	POP PDP,CRNG+5
	POP PDP,CRNG+4
	MOVE 17,(PDP)	;HIBER FOR N
	IMULI 17,^D1000
	HRLI 17,(HB.RTL)
	HIBER 17,
	NOTDEF
	SKPINL		;SOMETHING TYPED
	JRST RP010	;NO, DO COMMAND AGAIN
	CLRBFI		;YES, DONE
	POP PDP,17
	RETURN
	SUBTTL LOCT
;
;	LOCATE COMMAND
;	CALLING SEQUENCE:	*LOCATE DEVICE:<CR>
;
LOCT:	CALL INSIX	;GET DEVICE NAME
	JUMPE SIX,ER030
	CALL NXCHAR
	CAIE CHAR,":"
	TLO SW,RRD
	CALL INCR
	JRST ER030
	MOVEI CHAN,TTY
	MOVE 17,SIX	;WHAT IS IT?
	DEVCHR 17,
	JUMPE 17,ER050
	TLNE 17,(DV.DSK)	;A DSK DEVICE?
	JRST LC030	;YES
	TRNN 17,DV.ASC+DV.ASP	;A NORMAL DEVICE, IS IT FREE?
	JRST LC140
	MOVE 16,SIX	;NOT FREE, REPORT
	DEVTYP 16,
	NOTDEF
	LDB 15,[POINT 9,16,26]
	MOVEM 15,JOB
	MOVEM 15,LSTJOB
	PUSH PDP,17
	TRNN 17,DV.ASC
	JRST LC010
	MOVEI ADR,[ASCIZ /AS/]
	CALL OUTASC
LC010:	POP PDP,17
	TRNN 17,DV.ASP
	JRST LC020
	MOVEI CHAR,"+"
	TRNE 17,DV.ASC
	CALL OTCHAR
	MOVEI ADR,[ASCIZ /INIT/]
	CALL OUTASC
LC020:	MOVEI ADR,[ASCIZ / TO JOB /]
	CALL OUTASC
	MOVE DEC,JOB
	CALL OUTDEC
	CALL OUTCR
	JRST LC150
LC030:	MOVEM SIX,DCHRS	;A DSK DEVICE
	MOVE 17,[XWD 20,DCHRS]
	DSKCHR 17,
	NOTDEF
	MOVEI ADR,[ASCIZ /MOUNT COUNT: /]	;REPORT
	CALL OUTASC
	MOVE DEC,DCHRS+.DCSMT
	CALL OUTDEC
	CALL OUTCR
	MOVEI 17,1	;SEARCH JOBS
	MOVEM 17,GOBS
	TRZ SW,FND
LC040:	HRL 17,GOBS
	HRRI 17,.GTSTS
	GETTAB 17,
	JRST LC090
	TLNN 17,JNA
	JRST LC090
	HRL 17,GOBS
	HRRI 17,.GTPPN
	GETTAB 17,
	JRST LC090
	MOVEM 17,GOBS+1
	SETOM GOBS+2
LC050:	MOVE 17,[XWD 5,GOBS]
	GOBSTR 17,
	JRST LC090
	MOVE 17,GOBS+2
	CAMN 17,[-1]
	JRST LC090
	JUMPE 17,LC080
	CAME 17,DCHRS+.DCSNM
	JRST LC080
	MOVE 17,GOBS
	MOVEM 17,JOB
	MOVEM 17,LSTJOB
	TROE SW,FND
	JRST LC060
	MOVEI ADR,[ASCIZ /BY JOB(S) /]
	CALL OUTASC
	JRST LC070
LC060:	MOVEI CHAR,","
	CALL OTCHAR
LC070:	MOVE DEC,JOB
	CALL OUTDEC
LC080:	JRST LC050
LC090:	AOS 17,GOBS
	CAMG 17,TOPJOB
	JRST LC040
	TRZE SW,FND
	CALL OUTCR
	JRST LC150
LC140:	MOVE 17,SIX	;DEVICE IS FREE, REPORT
	DEVTYP 17,
	SETZ 17,
	MOVEI ADR,[ASCIZ /SPOOLED /]
	TLNE 17,(TY.SPL)
	CALL OUTASC
	MOVEI ADR,[ASCIZ /DEVICE IS FREE/]
	CALL OUTASC
	CALL OUTCR
LC150:	OUTPUT TTY,
	RETURN
	SUBTTL DET
;
;	DETACH COMMAND
;	CALLING SEQUENCE:	*DETACH JOB<CR>
;
DET:	CALL INJOB
	  JRST ER030
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL CHKJOB
	MOVEM 17,OLDLNE
	TLOE 17,AT.DET
	JRST ER110
	CALL PUTJOB
	CALL DOLOG
	MOVEI CHAN,TTY
	HLR LINE,OLDLNE
	MOVEI ADR,[ASCIZ /DETACHED FROM /]
	CALL OUTASC
	CALL OUTLNE
	CALL OUTCR
	OUTPUT TTY,
	RETURN
	SUBTTL STOP
;
;	STOP COMMAND
;	CALLING SEQUENCE:	*STOP JOB<CR>
;
STOP:	CALL INJOB
	  JRST ER030
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL DOLOG
	HRLI 17,AT.MON
	CALL GETJOB
	MOVEI ADR,[ASCIZ /HALT/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	CALL RETJOB
	CALL CHKJOB
	TLNN 17,AT.MON
	JRST ER010
	RETURN
	SUBTTL TALK
;
;	TALK COMMAND
;	CALLING SEQUENCE:	*TALK JOB/SWITCH<CR>
;	SWITCHES:		USER FOR USER MODE IF POSSIBLE
;				MONITOR FOR MONITOR MODE
;	EXIT SEQUENCE:		^Z
;
TALK:	CALL INJOB
	  JRST ER030
	SETZM LCLSW
	CALL INCR
	SKIPA
	JRST TK010
	CALL NXCHAR
	CAIE CHAR,"/"
	JRST ER030
	CALL INSIX
	JUMPE SIX,ER030
	CALL INCR
	JRST ER030
	MOVEI ADR,STAB3
	CALL DSPTCH
	JUMPL 17,ER040
	MOVE 16,DTAB3(17)
	MOVEM 16,LCLSW
TK010:	CALL CHKBAT
	CALL DOLOG
	HRLZ 17,LCLSW
	CALL GETJOB
	MOVEI 17,TK060
	MOVEM 17,CCADR
	MOVEI 17,TTY
	MOVEM 17,LOGDEV
	TRO SW,CCB+PLG
TK030:	CALL PTYALL
	MOVE 17,[HB.RTL+^D1000]
	HIBER 17,
	NOTDEF
	SKPINL
	JRST TK030
	INPUT TTY,
TK040:	SOSGE TRNG+5
	JRST TK070
	ILDB CHAR,TRNG+4
	CAIN CHAR,32
	JRST TK080
TK050:	IDPB CHAR,PRNG+1
	SOSG PRNG+2
	OUTPUT PTY,
	JRST TK040
TK060:	POP PDP,17
	SETZM TRNG+5
	MOVEI CHAR,3
	JRST TK050
TK070:	OUTPUT PTY,
	JRST TK030
TK080:	OUTPUT PTY,
	CALL PTYALL
	SETZM LOGDEV
	TRZ SW,CCB+PLG
	CALL RETJOB
	RETURN
;
STAB3:	SIXBIT /USER/
	SIXBIT /MONITO/
	0
;
DTAB3:	0
	AT.MON
	SUBTTL CONT
;
;	CONTINUE COMMAND
;	CALLING SEQUENCE:	*CONTINUE JOB<CR>
;
CONT:	CALL INJOB
	  JRST ER030
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL DOLOG
	HRLI 17,AT.MON
	CALL GETJOB
	MOVEI ADR,[ASCIZ /HALT/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,[ASCIZ /CONTINUE/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	CALL RETJOB
	CALL CHKJOB
	TLNN 17,AT.USR+AT.DET
	JRST ER010
	RETURN
	SUBTTL KILL
;
;	KILL COMMAND
;	CALLING SEQUENCE:	*KILL JOB<CR>
;
KILL:	CALL INJOB
	  JRST ER030
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL DOLOG
	CALL KJOB
	  JRST ER010
	RETURN
	SUBTTL FREE
;
;	FREE COMMAND
;	CALLING SEQUENCE:	*FREE DEVICE:/SWITCH<CR>
;	SWITCHES:		DEASSIGN TO DEASSIGN ONLY
;				FINISH TO FINISH IF NECESSARY
;
FREE:	CALL INSIX
	JUMPE SIX,ER030
	PUSH PDP,SIX
	CALL NXCHAR
	CAIE CHAR,":"
	TLO SW,RRD
	SETZM LCLSW
	CALL INCR
	SKIPA
	JRST FR010
	CALL NXCHAR
	CAIE CHAR,"/"
	JRST ER030
	CALL INSIX
	JUMPE SIX,ER030
	CALL INCR
	JRST ER030
	MOVEI ADR,STAB2
	CALL DSPTCH
	JUMPL 17,ER040
	MOVE 16,DTAB2(17)
	MOVEM 16,LCLSW
FR010:	MOVE 17,(PDP)
	DEVTYP 17,
	NOTDEF
	JUMPE 17,ER050
	LDB 16,[POINT 9,17,26]
	JUMPE 16,ER080
	MOVEM 16,JOB
	MOVEM 16,LSTJOB
	MOVE 17,(PDP)
	DEVCHR 17,
	TRNN 17,DV.ASP
	SETZM LCLSW
	HRL 17,JOB
	HRRI 17,.GTSTS
	GETTAB 17,
	  NOTDEF
	SETZM LCLSW2
	TLNE 17,JRUN
	SETOM LCLSW2
	CALL CHKBAT
	CALL DOLOG
	HRLI 17,AT.MON
	CALL GETJOB
	SKIPN LCLSW2
	JRST FR020
	MOVEI ADR,[ASCIZ /HALT/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
FR020:	MOVEI ADR,[ASCIZ /DEASSIGN /]
	SKIPE LCLSW
	MOVEI ADR,[ASCIZ /FINISH /]
	CALL OUTASC
	MOVE SIX,(PDP)
	CALL OUTSIX
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	SKIPE LCLSW2
	SKIPE LCLSW
	JRST FR030
	MOVEI ADR,[ASCIZ /CONTINUE/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
FR030:	CALL RETJOB
	POP PDP,17
	DEVCHR 17,
	MOVEI 16,DV.ASC
	SKIPE LCLSW
	MOVEI 16,DV.ASC+DV.ASP
	TDNE 17,16
	JRST ER010
	RETURN
;
STAB2:	SIXBIT /DEASSI/
	SIXBIT /FINISH/
	0
;
DTAB2:	0
	-1
	SUBTTL PURG
;
;	PURGE COMMAND
;	CALLING SEQUENCE:	*PURGE<CR>
;
PURG:	CALL INCR
	JRST ER030
	MOVE 17,TOPJOB
	MOVEM 17,JOB
PG010:	HRL 17,JOB	;TEST JOB NUMBER
	HRRI 17,.GTSTS
	GETTAB 17,
	JRST PG040
	TLNN 17,JNA
	JRST PG040
	MOVE 17,JOB	;TEST IF DETACHED
	TRMNO. 17,
	SKIPE 17
	JRST PG040
	HRL 17,JOB	;TEST IF DAEMON
	HRRI 17,.GTPPN
	GETTAB 17,
	NOTDEF
	CAME 17,PRVPPN
	JRST PG020
	HRL 17,JOB
	HRRI 17,.GTPRG
	GETTAB 17,
	NOTDEF
	CAMN 17,[SIXBIT /DAEMON/]
	JRST PG040
	CAMN 17,[SIXBIT /SPIRIT/]
	JRST PG040
PG020:	MOVE 17,JOB		;A GOOD ONE
	MOVEM 17,LSTJOB
	CALL DOLOG
	HRL 17,JOB	;GET JOB INFO
	HRRI 17,.GTPPN
	GETTAB 17,
	NOTDEF
	MOVEM 17,PPN
	HRL 17,JOB
	HRRI 17,.GTNM2
	GETTAB 17,
	SETZ 17,
	PUSH PDP,17
	HRL 17,JOB
	HRRI 17,.GTNM1
	GETTAB 17,
	SETZ 17,
	PUSH PDP,17
	CALL KJOB
	  JRST PG030
	MOVEI ADR,[ASCIZ /LOGGED OFF JOB /]
	JRST PG035
PG030:	MOVEI ADR,[ASCIZ /FAILED ON JOB /]
PG035:	MOVEI CHAN,TTY
	CALL OUTASC
	MOVE DEC,JOB
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / USER /]
	CALL OUTASC
	POP PDP,SIX
	CALL OUTSIX
	POP PDP,SIX
	CALL OUTSIX
	MOVEI ADR,[ASCIZ / [/]
	CALL OUTASC
	HLRZ OCT,PPN
	CALL OUTOCT
	MOVEI CHAR,","
	CALL OTCHAR
	HRRZ OCT,PPN
	CALL OUTOCT
	MOVEI CHAR,"]"
	CALL OTCHAR
	CALL OUTCR
	OUTPUT TTY,
PG040:	SOSLE JOB
	JRST PG010
	RETURN
	SUBTTL WHO
;
;	WHO COMMAND
;	CALLING SEQUENCE:	*WHO SWITCHES<CR>
;
WHO:	TDZ SW,[XWD FST+SLW+PRF,FND]
	SETZM TSTUSR
	SETZM TSTUSR+1
	SETZM TSTPRG
	SETZM TSTPRG+1
	SETZM TSTPPN
	SETZM TSTPPN+1
	SETZM TSTJOB
	SETZM TSTCOR
	SETZM TSTSTS
	SETZM TSTLNE
	TRNE SW,SPT
	JRST WH550
	MOVEI 17,TTY
	MOVEM 17,LST
WH010:	CALL INCR
	SKIPA
	JRST WH660
	CALL NXCHAR
	CAIN CHAR,"#"
	JRST WH040
	CAIN CHAR,"%"
	JRST WH460
	CAIN CHAR,"."
	JRST WH030
	CAIN CHAR,"-"
	JRST WH560
	CAIN CHAR,"!"
	JRST WH570
	CAIN CHAR,">"
	JRST WH260
	CAIN CHAR,"_"
	JRST WH340
	CAIN CHAR,"$"
	JRST WH350
	CAIN CHAR,"["
	JRST WH180
	CAIN CHAR,"/"
	JRST WH290
	CAIN CHAR,"@"
	JRST WH580
	TLO SW,RRD
	CAIL CHAR,"0"
	CAILE CHAR,"9"
	JRST WH490
WH020:	CALL INJOB	;WHO /JOB:<N>
	  JRST ER030
	MOVE 17,JOB
	MOVEM 17,TSTJOB
	JRST WH010
WH030:	MOVE 17,MYJOB	;WHO /ME
	MOVEM 17,LSTJOB
	MOVEM 17,TSTJOB
	JRST WH010
WH040:	CALL INSIX	;WHO /TTY:<LINE>
	JUMPE SIX,ER030
	HLRZ 17,SIX
	CAIN 17,'TTY'
	JRST WH050
	CAIN 17,'CTY'
	JRST WH100
	CAIN 17,'DET'
	JRST WH130
	CAIN 17,'PTY'
	JRST WH060
	CAIN 17,'BAT'
	JRST WH140
	CAIN 17,'LOC'
	JRST WH150
	CAIN 17,'DIA'
	JRST WH160
	TRNE SIX,-1
	JRST ER030
	HLRZ SIX,SIX	;WHO /TTY:<N>
WH050:	SETZM TSTLNE	;WHO /TTY:TTY<N>
	JRST WH070
WH060:	MOVE 17,PTYDSP	;WHO /TTY:PTY<N>
	MOVEM 17,TSTLNE
WH070:	TRNN SIX,-1
	JRST ER030
	SETZ 17,
	MOVE 16,[POINT 6,SIX,17]
	MOVEI 15,3
WH080:	ILDB 14,16
	JUMPE 14,WH090
	CAIL 14,'0'
	CAILE 14,'7'
	JRST ER030
	SUBI 14,'0'
	LSH 17,3
	ADD 17,14
	SOJG 15,WH080
WH090:	ADD 17,TSTLNE
	TRO 17,200000
	MOVEM 17,TSTLNE
	JRST WH010
WH100:	MOVE 17,CTYLNE	;WHO /TTY:CTY
	TRO 17,200000
	MOVEM 17,TSTLNE
	JRST WH010
WH130:	SETOM TSTLNE	;WHO /DETACH
	JRST WH010
WH140:	MOVEI 17,W.BAT	;WHO /BATCH
	IORM 17,TSTSTS
	JRST WH010
WH150:	MOVEI 17,W.LCL	;WHO /LOCAL
	IORM 17,TSTSTS
	JRST WH010
WH160:	MOVEI 17,W.DSL	;WHO /DIALUP
	IORM 17,TSTSTS
	JRST WH010
WH170:	CALL NXCHAR	;WHO /PPN:[P,PN]
	CAIE CHAR,"["
	TLO SW,RRD
WH180:	SETZM TSTPPN	;WHO [P,PN]
	SETOM TSTPPN+1
	CALL NXCHAR
	CAIE CHAR,"*"
	JRST WH190
	SETZ 17,
	HRLM 17,TSTPPN+1
	JRST WH200
WH190:	TLO SW,RRD
	CALL INOCT
	JUMPE OCT,ER030
	HRLM OCT,TSTPPN
WH200:	CALL NXCHAR
	CAIE CHAR,","
	JRST ER030
	CALL NXCHAR
	CAIE CHAR,"*"
	JRST WH230
	SETZ 17,
	HRRM 17,TSTPPN+1
	JRST WH240
WH230:	TLO SW,RRD
	CALL INOCT
	JUMPE OCT,ER030
	HRRM OCT,TSTPPN
WH240:	CALL NXCHAR
	CAIE CHAR,"]"
	TLO SW,RRD
	JRST WH010
WH250:	CALL NXCHAR	;WHO /CORE:<N>
	CAIN CHAR,":"
WH260:	CALL NXCHAR	;WHO >CORE
	TLO SW,RRD
	CAIL CHAR,"0"
	CAILE CHAR,"9"
	JRST WH270
	CALL INDEC
	JUMPE DEC,ER030
	JRST WH280
WH270:	MOVE 16,[%NSCMX]
	GETTAB 16,
	MOVEI 16,^D<30*1024>
	ADD 16,PAGE
	SUBI 16,1
	IDIV 16,PAGE
	MOVE DEC,16
WH280:	MOVEM DEC,TSTCOR
	JRST WH010
WH290:	CALL INSIX	;WHO /VERB:MODIFIER
	JUMPE SIX,ER030
	MOVEI ADR,STAB4
	CALL DSPTCH
	JUMPL 17,ER040
	HLRZ 16,DTAB4(17)
	JUMPE 16,WH330
	CALL NXCHAR
	CAIE CHAR,":"
	JRST ER030
WH330:	HRRZ 16,DTAB4(17)
	JRST (16)
WH340:	CALL COMINP	;WHO /FROM:COMMAND
	MOVEI CHAN,TTY
	MOVEM CHAN,LST
	SKIPN 17,LSTJOB
	JRST WH670
	MOVEM 17,TSTJOB
	JRST WH660
WH350:	CALL INCR	;WHO /STATISTICS
	JRST ER030
	MOVE CHAN,LST
	SETZM CNTJOB
	SETZM CNTLOG
	SETZM CNTDET
	SETZM CNTBAT
	SETZM CNTSWP
	SETZM CNTTIW
	SETZM CNTTOW
	SETZM CNTSLP
	SETZM CNTUSR
	SETZM CNTCOR
	SETZM CNTCOR+1
	SETZM CNTRUN
	SETZM CNTRUN+1
	SETZM CNTDSK
	SETZM CNTDSK+1
	MOVEI 17,1
	MOVEM 17,JOB
WH360:	CALL WHO3
	JRST WH370
	AOS CNTJOB
	MOVE 17,WHOSTS
	TLNE 17,JLOG
	AOS CNTLOG
	SKIPGE WHOLNE
	AOS CNTDET
	HRL 17,JOB
	HRRI 17,.GTLIM
	GETTAB 17,
	SETZ 17,
	TLNE 17,(JB.LBT)
	AOS CNTBAT
	SKIPN WHOSTA+1
	AOS CNTSWP
	MOVE 17,WHOSTA
	CAME 17,[SIXBIT /^C/]
	CAMN 17,[SIXBIT /TI/]
	AOS CNTTIW
	CAMN 17,[SIXBIT /TO/]
	AOS CNTTOW
	CAME 17,[SIXBIT /SL/]
	CAMN 17,[SIXBIT /HB/]
	AOS CNTSLP
	MOVE 17,WHOPPN
	CAMN 17,PRVPPN
	JRST WH370
	AOS CNTUSR
	SKIPGE 17,WHOCOR
	SETZ 17,
	SKIPL WHOCOR+1
	ADD 17,WHOCOR+1
	ADDM 17,CNTCOR
	IMUL 17,17
	ADDM 17,CNTCOR+1
	SKIPGE 16,WHORUN
	SETZ 16,
	ADDM 16,CNTRUN
	IDIV 16,JIFFY
	IMUL 16,16
	ADDM 16,CNTRUN+1
	SKIPGE 16,WHODRD
	SETZ 16,
	SKIPL WHODWT
	ADD 16,WHODWT
	ADDM 16,CNTDSK
	ADDI 16,^D100-1
	IDIVI 16,^D100
	IMUL 16,16
	ADDM 16,CNTDSK+1
WH370:	AOS 17,JOB
	CAMG 17,TOPJOB
	JRST WH360
	MOVE DEC,TOPJOB
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / JOBS: /]
	CALL OUTASC
	MOVE DEC,CNTJOB
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / ASSIGNED, /]
	CALL OUTASC
	MOVE DEC,CNTLOG
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / LOGGED IN, /]
	CALL OUTASC
	MOVE DEC,CNTDET
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / DETACHED, /]
	CALL OUTASC
	MOVE DEC,CNTBAT
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / BATCHED,/]
	CALL OUTASC
	CALL OUTCR
	MOVEI ADR,[ASCIZ /  /]
	CALL OUTASC
	MOVE DEC,CNTTIW
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / TYPING IN, /]
	CALL OUTASC
	MOVE DEC,CNTTOW
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / TYPING OUT, /]
	CALL OUTASC
	MOVE DEC,CNTSLP
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / SLEEPING, /]
	CALL OUTASC
	MOVE DEC,CNTJOB
	SUB DEC,CNTTIW
	SUB DEC,CNTTOW
	SUB DEC,CNTSLP
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / RUNNING, /]
	CALL OUTASC
	MOVE DEC,CNTSWP
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / IN CORE/]
	CALL OUTASC
	CALL OUTCR
	MOVE DEC,CNTUSR
	CALL OUTDEC
	MOVEI ADR,[ASCIZ / USERS:  MEAN /]
	CALL OUTASC
	MOVE 16,CNTCOR
	IDIV 16,CNTUSR
	MOVEM 16,CNTCOR
	MOVE DEC,16
	CALL OUTDEC
	MOVE CHAR,KOP
	CALL OTCHAR
	MOVEI CHAR," "
	CALL OTCHAR
	MOVE 16,CNTRUN
	IDIV 16,CNTUSR
	IDIV 16,JIFFY
	MOVEM 16,CNTRUN
	MOVE TIM,16
	CALL OUTTIM
	MOVEI CHAR," "
	CALL OTCHAR
	MOVE 16,CNTDSK
	IDIV 16,CNTUSR
	MOVEM 16,CNTDSK
	MOVE DEC,16
	CALL OUTDEC
	MOVEI ADR,[ASCIZ /;  SD /]
	CALL OUTASC
	MOVE 16,CNTCOR+1
	IDIV 16,CNTUSR
	MOVE 17,16
	MOVE 16,CNTCOR
	CALL WH800
	MOVEM 17,CNTCOR+1
	MOVE DEC,17
	CALL OUTDEC
	MOVE CHAR,KOP
	CALL OTCHAR
	MOVEI CHAR," "
	CALL OTCHAR
	MOVE 16,CNTRUN+1
	IDIV 16,CNTUSR
	MOVE 17,16
	MOVE 16,CNTRUN
	CALL WH800
	MOVEM 17,CNTRUN+1
	MOVE TIM,17
	CALL OUTTIM
	MOVEI CHAR," "
	CALL OTCHAR
	MOVE 16,CNTDSK+1
	IDIV 16,CNTUSR
	MOVE 17,16
	MOVE 15,CNTDSK
	IDIVI 15,^D100
	MOVE 16,15
	CALL WH800
	IMULI 17,^D100
	MOVEM 17,CNTDSK+1
	MOVE DEC,17
	CALL OUTDEC
	CALL OUTCR
	MOVEI 17,1
	MOVEM 17,JOB
WH380:	CALL WHO3
	JRST WH400
	MOVE 17,WHOPPN
	CAMN 17,PRVPPN
	JRST WH400
	SETZ 17,
	SKIPGE 16,WHOCOR
	SETZ 16,
	SKIPL WHOCOR+1
	ADD 16,WHOCOR+1
	MOVE 15,CNTCOR+1
	LSH 15,1
	ADD 15,CNTCOR
	CAMLE 16,15
	SETO 17,
	SKIPGE 15,WHORUN
	SETZ 15,
	IDIV 15,JIFFY
	MOVE 14,CNTRUN+1
	LSH 14,1
	ADD 14,CNTRUN
	CAMLE 15,14
	SETO 17,
	SKIPGE 16,WHODRD
	SETZ 16,
	SKIPL WHODWT
	ADD 16,WHODWT
	MOVE 15,CNTDSK+1
	LSH 15,1
	ADD 15,CNTDSK
	CAMLE 16,15
	SETO 17,
	JUMPE 17,WH400
	TRNE SW,FND
	JRST WH390
	CALL OUTCR
	MOVEI ADR,[ASCIZ /PIGS (>MEAN+2*SD):/]
	CALL OUTASC
	CALL OUTCR
WH390:	CALL WHO4
WH400:	AOS 17,JOB
	CAMG 17,TOPJOB
	JRST WH380
	JRST WH670
WH430:	CALL WHO3
	JRST WH440
	HLRZ 17,WHOPPN
	CAME 17,(PDP)
	JRST WH440
	CALL WHO4
WH440:	AOS 17,JOB
	CAMG 17,TOPJOB
	JRST WH430
	POP PDP,17
	JRST WH670
WH450:	CALL INCR	;WHO /HELP
	JRST ER030
	MOVE CHAN,LST
	MOVEI ADR,WH910
	CALL OUTASC
	JRST WH670
WH460:	CALL INFSX	;WHO /PROGRAM:NAME
	JUMPE SIX,ER030
	MOVEM SIX,TSTPRG
	MOVEI 17,6
	SETO 16,
WH470:	TRNE SIX,77
	JRST WH480
	LSH SIX,-6
	LSH 16,6
	SOJG 17,WH470
WH480:	MOVEM 16,TSTPRG+1
	JRST WH010
WH490:	SKIPE TSTUSR	;WHO NAME
	JRST ER030
WH500:	CALL INFSX	;WHO /USER:NAME
	JUMPE SIX,ER030
	MOVEM SIX,TSTUSR
	MOVEI 17,6
	SETO 16,
WH530:	TRNE SIX,77
	JRST WH540
	LSH SIX,-6
	LSH 16,6
	SOJG 17,WH530
WH540:	MOVEM 16,TSTUSR+1
	JRST WH010
WH550:	OPEN DWHO,OPENO	;WHO FOR SPIRIT
	CALL OPCHK
	MOVE 17,QUEPPN
	MOVEM 17,LOOKO+3
	ENTER DWHO,LOOKO
	CALL LKCHK
	OUTPUT DWHO,
	MOVEI CHAN,DWHO
	MOVEM CHAN,LST
	JRST WH660
WH560:	MOVEI 17,W.USR	;WHO /NOOPR
	IORM 17,TSTSTS
	JRST WH010
WH570:	TLO SW,FST	;WHO /FAST
	JRST WH010
WH580:	CALL LIST	;WHO /ON:FILE
	JRST ER030
	JRST WH010
WH585:	MOVEI 17,W.LNE	;WHO /BYLINE
	IORM 17,TSTSTS
	JRST WH010
WH590:	MOVEI 17,W.ACT	;WHO /ACTIVE
	IORM 17,TSTSTS
	JRST WH010
WH600:	MOVEI 17,W.VM	;WHO /VM
	IORM 17,TSTSTS
	JRST WH010
WH610:	TLO SW,SLW	;WHO /SLOW
	JRST WH010
WH620:	TLO SW,PRF	;WHO /PERFORMANCE
	JRST WH010
WH630:	MOVEI 17,W.SYJ	;WHO /SYSTEM
	IORM 17,TSTSTS
	JRST WH010
WH640:	MOVEI 17,W.ADJ	;WHO /ADMINISTRATIVE
	IORM 17,TSTSTS
	JRST WH010
WH650:	MOVEI 17,W.ACJ	;WHO /ACADEMIC
	IORM 17,TSTSTS
	JRST WH010
WH660:	MOVE CHAN,LST	;TYPE THE WHO
	CALL WHO1
WH670:	TRNN SW,SPT
	JRST WH680
	OUTPUT DWHO,
	GETSTS DWHO,STS
	CALL STSCHK
	RELEAS DWHO,
	JRST WH690
WH680:	CALL LISTE
WH690:	RETURN
;
WH800:	IMUL 16,16	;CALCIULTATE SD, 17=MEAN(X**2), 16=MEAN(X)
	SUB 17,16
WH810:	MOVE 16,17	;CALCULATE SQRT(17)
	LSH 16,-1
	SETZ 15,
	MOVEI 14,^D16
WH820:	MOVE 13,15
	ADD 13,16
	LSH 13,-1
	MOVE 12,13
	IMUL 12,13
	CAML 12,17
	MOVEM 13,16
	CAMG 12,17
	MOVEM 13,15
	SOJG 14,WH820
	MOVE 17,13
	RETURN
;
WHO1:	MOVEI 17,1	;LOOP FOR ALL JOBS OR LINES
	MOVEM 17,JOB
	SETZM SRCLNE
WS010:	MOVE 17,TSTSTS
	TRNN 17,W.LNE
	JRST WS015
	MOVE 17,SRCLNE
	TRO 17,200000
	DEVTYP 17,
	JRST WS040
	LDB 16,[POINT 9,17,26]
	JUMPE 16,WS040
	MOVEM 16,JOB
WS015:	CALL WHO3
	JRST WS040
	MOVE 17,WHOUSR
	AND 17,TSTUSR+1
	CAME 17,TSTUSR
	JRST WS040
	MOVE 17,WHOPRG
	AND 17,TSTPRG+1
	CAME 17,TSTPRG
	JRST WS040
	MOVE 17,WHOPPN
	AND 17,TSTPPN+1
	CAME 17,TSTPPN
	JRST WS040
	SKIPE 17,TSTJOB
	CAMN 17,JOB
	SKIPA
	JRST WS040
	SKIPN TSTCOR
	JRST WS020
	SKIPGE 17,WHOCOR
	JRST WS040
	SKIPLE WHOCOR+1
	ADD 17,WHOCOR+1
	CAMG 17,TSTCOR
	JRST WS040
WS020:	MOVE 17,WHOLNE
	SKIPE TSTLNE
	CAMN 17,TSTLNE
	SKIPA
	JRST WS040
	MOVE 17,TSTSTS
	MOVE 16,WHOPPN
	TRNE 17,W.USR
	CAME 16,PRVPPN
	SKIPA
	JRST WS040
	HRL 16,JOB
	HRRI 16,.GTLIM
	GETTAB 16,
	SETZ 16,
	TRNE 17,W.BAT
	TLNE 16,(JB.LBT)
	SKIPA
	JRST WS040
	TRNN 17,W.LCL+W.DSL
	JRST WS030
	SKIPG 16,WHOLNE
	JRST WS040
	GETLCH 16
	TRNE 17,W.LCL
	TLNN 16,(GL.ITY+GL.DSL)
	SKIPA
	JRST WS040
	TRNE 17,W.DSL
	TLNE 16,(GL.DSL)
	SKIPA
	JRST WS040
WS030:	MOVE 17,TSTSTS
	TRNN 17,W.ACT
	JRST WS032
	MOVE 17,WHOSTA
	CAMN 17,[SIXBIT /^C/]
	JRST WS040
	CAMN 17,[SIXBIT /TI/]
	JRST WS040
	CAMN 17,[SIXBIT /SL/]
	JRST WS040
	CAMN 17,[SIXBIT /HB/]
	JRST WS040
WS032:	MOVE 17,TSTSTS
	TRNN 17,W.VM
	JRST WS034
	SKIPN WHORAT
	JRST WS040
WS034:	MOVE 17,TSTSTS
	LDB 16,[POINT 3,WHOPPN,11]
	MOVE 16,[OCT -1,1,1,1,1,0,1,1](16)
	TRNE 17,W.SYJ
	JUMPGE 16,WS040
	TRNE 17,W.ADJ
	JUMPN 16,WS040
	TRNE 17,W.ACJ
	JUMPLE 16,WS040
	MOVE 17,JOB	;A GOOD ONE, TYPE IT
	MOVEM 17,LSTJOB
	CALL WHO4
WS040:	MOVE 17,TSTSTS
	TRNE 17,W.LNE
	JRST WS042
	AOS 17,JOB
	CAMG 17,TOPJOB
	JRST WS010
	JRST WS044
WS042:	AOS 17,SRCLNE
	CAMG 17,TOPLNE
	JRST WS010
WS044:	TRNE SW,FND
	JRST WS050
	MOVEI ADR,[ASCIZ /NO ONE/]
	CALL OUTASC
	CALL OUTCR
WS050:	RETURN
;
WHO2:	CALL WHO3	;DO A JOB
	SKIPA
	CALL WHO4
	RETURN
;
WHO3:	MOVE 17,JOB	;TEST JOB NUMBER
	CAMLE 17,TOPJOB
	JRST WS200
	HRL 17,JOB
	HRRI 17,.GTSTS
	GETTAB 17,
	JRST WS200
	TLNN 17,JNA
	JRST WS200
	MOVEM 17,WHOSTS	;AN ACTIVE JOB
	HRL 16,JOB	;GET PPN
	HRRI 16,.GTPPN
	GETTAB 16,
	SETZ 16,
	MOVEM 16,WHOPPN
	AOS (PDP)	;VALID JOB
	HRL 16,JOB	;GET USER NAME
	HRRI 16,.GTNM1
	GETTAB 16,
	SETZ 16,
	SKIPN 16
	TLNE 17,JLOG
	SKIPA
	MOVE 16,[SIXBIT /HELP/]
	MOVEM 16,WHOUSR+2
	HRL 16,JOB
	HRRI 16,.GTNM2
	GETTAB 16,
	SETZ 16,
	MOVEM 16,WHOUSR+3
	MOVE 16,[POINT 6,WHOUSR+2]
	SETZM WHOUSR
	SETZM WHOUSR+1
	MOVE 15,[POINT 6,WHOUSR]
	MOVEI 14,^D12
	MOVEI 13,1
WS103:	ILDB 12,16
	CAIN 12,' '
	MOVEI 12,'-'
	CAIN 12,'-'
	JRST [JUMPGE 13,WS107
	      SETZ 13,
	      JRST WS107]
	CAIN 12,','
	JRST [JUMPG 13,WS107
	      MOVEI 13,1
	      JRST WS105]
	JUMPE 13,[MOVEI 13,'-'
	          IDPB 13,15
	          SETO 13,
	          JRST WS105]
	SETO 13,
WS105:	IDPB 12,15
WS107:	SOJG 14,WS103
	MOVE 16,JOB	;GET LINE NAME
	TRMNO. 16,
	SETO 16,
	MOVEM 16,WHOLNE
	HRL 16,JOB	;GET PROGRAM NAME
	HRRI 16,.GTPRG
	GETTAB 16,
	SETZ 16,
	MOVEM 16,WHOPRG
	LDB 15,[POINT 5,17,14]	;GET PROGRAM STATUS
	IDIVI 15,3
	HRL 15,15
	HRRI 15,.GTWSN
	GETTAB 15,
	SETZ 15,
	LDB 16,WH900(16)
	CAIE 16,'TI'
	JRST WS110
	MOVN 15,JOB
	JOBSTS 15,
	SETZ 15,
	TLNE 15,(JB.UOA)
	MOVEI 16,'TO'
WS110:	TLNN 17,JRUN
	MOVEI 16,'^C'
	TLNE 17,CMWB
	MOVEI 16,'^W'
	TRNE 17,JDCON
	MOVEI 16,'OW'
	CAIE 16,'SL'
	JRST WS120
	TRNN 17,CLKR
	MOVEI 16,'HB'
WS120:	CAIE 16,'RN'
	JRST WS140
	HRL 15,JOB
WS130:	HRRI 15,.GTQJB
	GETTAB 15,
	JRST WS140
	JUMPG 15,WS130
	HLRE 15,15
	MOVNS 15
	CAIN 15,JQ.PQ1
	MOVEI 16,'R1'
	CAIN 15,JQ.PQ2
	MOVEI 16,'R2'
	CAIN 15,JQ.HPQ
	MOVEI 16,'RH'
WS140:	LSH 16,^D24
	MOVEM 16,WHOSTA
	SETZM WHOSTA+1
	TLNE 17,SWP
	SETOM WHOSTA+1
	SETOM WHOCOR	;GET PROGRAM CORE AND PAGING RATE
	SETZM WHOCOR+1
	SETOM WHOCOR+2
	SETOM WHOCOR+3
	SETZM WHORAT
	MOVE 15,SYSFEA+1
	TRNE 15,ST%VMS
	JRST WS155
	TLNE 17,SWP
	JRST WS150
	HRL 15,JOB
	HRRI 15,.GTADR
	GETTAB 15,
	JRST WS190
	HLRZS 15
	JUMPE 15,WS150
	ADD 15,PAGE
	SUBI 15,1
	IDIV 15,PAGE
	ANDI 15,777
	JRST WS160
WS150:	HRL 15,JOB
	HRRI 15,.GTSWP
	GETTAB 15,
	JRST WS190
	ANDI 15,777
	JUMPE 15,WS190
	JRST WS160
WS155:	HRL 15,JOB
	HRRI 15,.GTSWP
	GETTAB 15,
	JRST WS190
	ANDI 15,777
	JUMPE 15,WS190
	HRL 14,JOB
	HRRI 14,.GTVRT
	GETTAB 14,
	JRST WS160
	MOVE 13,14
	ANDI 13,777
	SUBI 13,1
	MOVEM 13,WHOCOR+2
	HLRZS 14
	JUMPE 14,WS160
	MOVE 13,[DEC 100000*100]
	IDIV 13,14
	MOVEM 13,WHORAT
WS160:	MOVEM 15,WHOCOR
	HRL 16,JOB
	HRRI 16,.GTSGN
	GETTAB 16,
	JRST WS190
	TLNE 16,SPYSEG
	JRST WS185
	TRNN 16,777777
	JRST WS190
	TLNE 16,SHRSEG
	JRST WS165
	MOVE 15,SYSFEA+1
	TRNE 15,ST%VMS
	JRST WS175
WS165:	HRL 15,16
	HRRI 15,.GTADR
	GETTAB 15,
	JRST WS190
	HLRZS 15
	JUMPE 15,WS170
	ADD 15,PAGE
	SUBI 15,1
	IDIV 15,PAGE
	ANDI 15,777
	JRST WS180
WS170:	HRL 15,16
	HRRI 15,.GTSWP
	GETTAB 15,
	JRST WS190
	ANDI 15,777
	JUMPE 15,WS190
	JRST WS180
WS175:	HRL 15,16
	HRRI 15,.GTSWP
	GETTAB 15,
	JRST WS190
	HLRZS 15
	ANDI 15,777
	JUMPE 15,WS190
	MOVE 14,WHOCOR
	SUB 14,15
	MOVEM 14,WHOCOR
	HRL 14,JOB
	HRRI 14,.GTVRT
	GETTAB 14,
	JRST WS180
	LDB 14,[POINT 9,14,26]
	MOVEM 14,WHOCOR+3
WS180:	MOVEM 15,WHOCOR+1
	JRST WS190
WS185:	SETOM WHOCOR+1
WS190:	SETOM WHOCON	;GET CONNECT TIME
	SETOM WHOCON+1
	HRL 16,JOB
	HRRI 16,.GTJLT
	GETTAB 16,
	JRST WS195
	MOVEM 16,WHOCON
	MOVE 16,[%CNDTM]
	GETTAB 16,
	JRST WS195
	SUB 16,WHOCON
	MULI 16,^D<24*60*60>
	DIV 16,[XWD 1,0]
	MOVEM 16,WHOCON+1
WS195:	HRL 16,JOB	;GET RUN TIME
	HRRI 16,.GTTIM
	GETTAB 16,
	SETO 16,
	MOVEM 16,WHORUN
	HRL 16,JOB	;GET DISK READS
	HRRI 16,.GTRCT
	GETTAB 16,
	SKIPA 15,[-1]
	LDB 15,[POINT 24,16,35]
	MOVEM 15,WHODRD
	HRL 16,JOB	;GET DISK WRITES
	HRRI 16,.GTWCT
	GETTAB 16,
	SKIPA 15,[-1]
	LDB 15,[POINT 24,16,35]
	MOVEM 15,WHODWT
	HRL 16,JOB	;GET HPQ NUMBER
	HRRI 16,.GTRTD
	GETTAB 16,
	SETZ 16,
	LDB 15,[POINT 4,16,9]
	MOVEM 15,WHOHPQ
	HRL 16,JOB	;GET DSKPRI NUMBER
	HRRI 16,.GTSPL
	GETTAB 16,
	SETZ 16,
	LDB 15,[POINT 3,16,26]
	MOVEM 15,WHODSK
	SETZM WHOLOK	;GET LOCKED
	TLNE 17,NSWP
	SETOM WHOLOK
	HRL 16,JOB	;GET TIME LIMIT
	HRRI 16,.GTLIM
	GETTAB 16,
	SKIPA 15,[-1]
	LDB 15,[POINT 24,16,35]
	MOVEM 15,WHOLIM
WS200:	RETURN
;
WHO4:	TRO SW,FND	;TYPE THE STUFF
	SETZM TABPOS
	MOVE DEC,JOB	;TYPE JOB NUMBER
	CALL OUTDEC
	TLNN SW,SLW
	JRST WS310
	TRNN SW,SPT
	JRST WS305
	MOVE 17,JOB	;TYPE HUNG
	SKIPN HUNG(17)
	JRST WS305
	CALL TABW
	MOVEI CHAR,"*"
	CALL OTCHAR
WS305:	SKIPGE TIM,WHOCON+1	;TYPE CONNECT TIME
	JRST WS310
	CALL TABW
	CALL OUTTIM
WS310:	SKIPN SIX,WHOUSR	;TYPE USER NAME
	JRST WS320
	CALL TABW
	CALL OUTSIX
	SKIPE SIX,WHOUSR+1
	CALL OUTSIX
WS320:	TLNE SW,FST
	JRST WS330
	HLRZ OCT,WHOPPN	;TYPE USER PPN
	JUMPE OCT,WS330
	CALL TABW
	CALL OUTOCT
	MOVEI CHAR,","
	CALL OTCHAR
	HRRZ OCT,WHOPPN
	CALL OUTOCT
WS330:	CALL TABW	;TYPE LINE NAME
	MOVE LINE,WHOLNE
	CALL OUTLNE
	MOVE SIX,WHOPRG	;TYPE PROGRAM NAME
	JUMPE SIX,WS340
	CALL TABW
	CALL OUTSIX
WS340:	MOVE SIX,WHOSTA	;TYPE PROGRAM STATUS
	JUMPE SIX,WS350
	CALL TABW
	CALL OUTSIX
WS350:	TLNE SW,FST
	JRST WS490
	SKIPN WHOSTA+1
	JRST WS360
	CALL TABW
	MOVEI ADR,[ASCIZ /SW/]
	CALL OUTASC
WS360:	MOVE DEC,WHOCOR	;TYPE PROGRAM CORE
	JUMPL DEC,WS400
	CALL TABW
	CALL OUTDEC
	SKIPL DEC,WHOCOR+2
	CAMN DEC,WHOCOR
	JRST WS365
	MOVEI CHAR,"("
	CALL OTCHAR
	CALL OUTDEC
	MOVEI CHAR,")"
	CALL OTCHAR
WS365:	SKIPN DEC,WHOCOR+1
	JRST WS370
	JUMPL DEC,WS380
	MOVEI CHAR,"+"
	CALL OTCHAR
	CALL OUTDEC
	SKIPL DEC,WHOCOR+3
	CAMN DEC,WHOCOR+1
	JRST WS370
	MOVEI CHAR,"("
	CALL OTCHAR
	CALL OUTDEC
	MOVEI CHAR,")"
	CALL OTCHAR
WS370:	MOVE CHAR,KOP
	CALL OTCHAR
	JRST WS400
WS380:	MOVE CHAR,KOP
	CALL OTCHAR
	MOVEI ADR,[ASCIZ /+SPY/]
	CALL OUTASC
WS400:	MOVE 16,WHORUN	;TYPE RUN TIME
	JUMPL 16,WS410
	IDIV 16,JIFFY
	MOVE TIM,16
	CALL TABW
	CALL OUTTIM
WS410:	TLNN SW,SLW
	JRST WS490
	SKIPL WHODRD	;TYPE DISK I/O
	SKIPGE WHODWT
	JRST WS440
	CALL TABW
	MOVEI ADR,[ASCIZ /DSK:/]
	CALL OUTASC
	MOVE DEC,WHODRD
	CALL OUTDEC
	MOVEI CHAR,","
	CALL OTCHAR
	MOVE DEC,WHODWT
	CALL OUTDEC
WS440:	MOVE DEC,WHOHPQ	;TYPE HPQ NUMBER
	JUMPE DEC,WS450
	CALL TABW
	MOVEI ADR,[ASCIZ /HPQ/]
	CALL OUTASC
	CALL OUTDEC
WS450:	MOVE DEC,WHODSK	;TYPE DSKPRI NUMBER
	JUMPE DEC,WS460
	CALL TABW
	MOVEI ADR,[ASCIZ /DSKPRI/]
	CALL OUTASC
	MOVEI CHAR,"-"
	TRZE DEC,4
	CALL OTCHAR
	CALL OUTDEC
WS460:	SKIPN WHOLOK	;TYPE LOCKED
	JRST WS470
	CALL TABW
	MOVEI ADR,[ASCIZ /LOCKED/]
	CALL OUTASC
WS470:	SKIPN DEC,WHORAT	;TYPE PAGE RATE
	JRST WS480
	CALL TABW
	MOVEI ADR,[ASCIZ /PGR:/]
	CALL OUTASC
	CALL OUTPDC
WS480:	SKIPG 16,WHOLIM	;TYPE JOB TIME LIMIT
	JRST WS490
	IDIV 16,JIFFY
	MOVE TIM,16
	CALL TABW
	MOVEI ADR,[ASCIZ /LIMIT:/]
	CALL OUTASC
	CALL OUTTIM
WS490:	TLNN SW,PRF
	JRST WS500
	SKIPL WHOCON+1	;TYPE RUN/CONNECT RATIO
	SKIPGE WHORUN
	JRST WS492
	CALL TABW
	MOVE 16,WHORUN
	IDIV 16,JIFFY
	IMULI 16,^D<100*100>
	IDIV 16,WHOCON+1
	MOVE DEC,16
	MOVEI ADR,[ASCIZ .R/C:.]
	CALL OUTASC
	CALL OUTPDC
	MOVEI ADR,[ASCIZ /%/]
	CALL OUTASC
WS492:	SKIPL WHODRD	;TYPE DISK/CONNECT RATIO
	SKIPGE WHODWT
	JRST WS500
	CALL TABW
	MOVE 16,WHODRD
	ADD 16,WHODWT
	IMULI 16,^D100
	IDIV 16,WHOCON+1
	MOVE DEC,16
	MOVEI ADR,[ASCIZ .D/C:.]
	CALL OUTASC
	CALL OUTPDC
WS500:	CALL OUTCR
	RETURN
;
STAB4:	SIXBIT /TTY/
	SIXBIT /PROGRA/
	SIXBIT /ME/
	SIXBIT /NOOPR/
	SIXBIT /FAST/
	SIXBIT /CORE/
	SIXBIT /FROM/
	SIXBIT /STATIS/
	SIXBIT /PPN/
	SIXBIT /ON/
	SIXBIT /JOB/
	SIXBIT /HELP/
	SIXBIT /USER/
	SIXBIT /DETACH/
	SIXBIT /BATCH/
	SIXBIT /LOCAL/
	SIXBIT /DIALUP/
	SIXBIT /BYLINE/
	SIXBIT /ACTIVE/
	SIXBIT /VM/
	SIXBIT /SLOW/
	SIXBIT /PERFOR/
	SIXBIT /SYSTEM/
	SIXBIT /ADMINI/
	SIXBIT /ACADEM/
	0
;
DTAB4:	XWD -1,WH040
	XWD -1,WH460
	XWD 0,WH030
	XWD 0,WH560
	XWD 0,WH570
	XWD 0,WH250
	XWD -1,WH340
	XWD 0,WH350
	XWD -1,WH170
	XWD -1,WH580
	XWD -1,WH020
	XWD 0,WH450
	XWD -1,WH500
	XWD 0,WH130
	XWD 0,WH140
	XWD 0,WH150
	XWD 0,WH160
	XWD 0,WH585
	XWD 0,WH590
	XWD 0,WH600
	XWD 0,WH610
	XWD 0,WH620
	XWD 0,WH630
	XWD 0,WH640
	XWD 0,WH650
;
WH900:	POINT 12,15,11
	POINT 12,15,23
	POINT 12,15,35
;
WH910:	ASCIZ "WHO SWITCHES:
/ME		FOR YOUR JOB
/NOOPR		FOR ALL EXCEPT OPR JOBS
/FAST		FOR A FAST WHO
/SLOW		FOR A SLOW WHO
/PERFORMANCE	FOR A WHO WITH PERFORMANCE STATISTICS
/JOB:<N>	FOR A JOB, <N> = JOB NUMBER
/TTY:<LINE>	FOR A LINE, <LINE> = NN, TTYNN, PTYNN, OR CTY
/DETACH		FOR ALL DETACHED JOBS
/BATCH		FOR ALL BATCH JOBS
/LOCAL		FOR ALL REMOTE AND LOCAL JOBS
/DIALUP		FOR ALL DIALUP JOBS
/USER:<NAME>	FOR A USER, <NAME> = FIRST LETTERS OF USERS NAME
/PROG:<NAME>	FOR A PROGRAM, <NAME> = FIRST LETTERS OF PROGRAM NAME
/CORE		FOR USERS RUNNING WITH MORE CORE THAN CORMAX
/CORE:<N>	FOR JOBS WITH LARGE CORE, <N> = AN AMOUNT OF CORE
/FROM:<COMMAND>	FOR JOB REFERENCED BY A COMMAND, <COMMAND> = ANY COMMAND
/STATISTICS	FOR STATISTICS AND LARGE JOBS
/PPN:[P,PN]	FOR USER OF A PPN, P,PN = PROJECT PROGRAMMER NUMBER
/HELP		FOR HELP ON WHO
/ON:<FOO>	FOR A WHO OUTPUT TO A FILE, <FOO> = A FILE SPEC
/BYLINE		FOR A WHO SORTED BY TTY LINE
/ACTIVE		FOR ALL ACTIVE JOBS
/VM		FOR ALL VIRTUAL MEMORY JOBS
/SYSTEM		FOR SYSTEM JOBS
/ADMINISTRATIVE	FOR ADMINISTRATIVE JOBS
/ACADEMIC	FOR ACADEMIC JOBS
"
	SUBTTL ECHO
;
;	ECHO COMMAND
;	CALLING SEQUENCE:	*ECHO JOB/SWITCH<CR>
;	SWITCHES:		NOWRITE TO NOT ALLOW WRITING ON JOB'S TERMINAL
;				WRITE TO ALLOW WRITING ON JOBS TERMINAL
;	EXIT SEQUENCE:		^Z
;
ECHO:	CALL INJOB
	  JRST ER030
	SETZM LCLSW
	CALL INCR
	  SKIPA
	JRST EC010
	CALL NXCHAR
	CAIE CHAR,"/"
	JRST ER030
	CALL INSIX
	JUMPE SIX,ER030
	CALL INCR
	  JRST ER030
	MOVEI ADR,STAB5
	CALL DSPTCH
	JUMPL 17,ER040
	MOVE 16,DTAB5(17)
	MOVEM 16,LCLSW
EC010:	HRL 17,JOB
	HRRI 17,.GTSTS
	GETTAB 17,
	NOTDEF
	TLNN 17,JNA
	JRST ER060
	MOVE 17,JOB
	TRMNO. 17,
	JRST ER060
	HRL 16,JOB
	HRRI 16,.GTTTY
	GETTAB 16,
	  NOTDEF
	ADDI 16,DDBLDB
	PEEK 16,
	ADDI 16,LDBBYT
	HRL 17,16
	MSTIME 16,
	SETZ 15,
	TRZ SW,RRD
EC020:	INCHRS CHAR
	JRST EC050
EC040:	CAIN CHAR,32
	JRST EC100
	SKIPN LCLSW
	JRST EC020
	CAIN CHAR,"^"
	JRST [TLCN 15,(1B3)
	      JRST EC020
	      JRST EC045]
	TLZE 15,(1B3)
	ANDI CHAR,77
EC045:	CAIN CHAR,12
	TLZN 15,(1B2)
	SKIPA
	JRST EC020
	TLZ 15,(1B2)
	CAIN CHAR,15
	TLO 15,(1B2)
	LSH CHAR,^D<36-7>
	MOVE 14,[XWD 3,11]
	MOVEI 11,.TOTYP
	HRRZ 12,17
	MOVEI 13,CHAR
	TRMOP. 14,
	  JFCL
	TLO 15,(1B0)
	JRST EC020
EC050:	HLRZ 14,17
	PEEK 14,
	LDB 13,[POINT 16,14,35]
	TLZE 15,(1B0)
	HRR 15,13
	CAIN 13,(15)
	JRST EC070
	MSTIME 16,
	MOVE 12,[XWD 7,7]
	TLON SW,LCK
	LOCK 12,
	  JFCL
	HRR 15,13
	HRRZ CHAR,15
	ANDI CHAR,177
	CAIN CHAR,15
	JRST EC060
	CAIN CHAR,12
	JRST EC060
	TLZ 15,(1B1)
	CAIE CHAR,177
	OUTCHR CHAR
	JRST EC080
EC060:	TLOE 15,(1B1)
	JRST EC080
	OUTCHR [15]
	OUTCHR [12]
	JRST EC080
EC070:	MSTIME 14,
	SUB 14,16
	CAIG 14,^D15000
	JRST EC080
	MOVE 14,[XWD 1,1]
	TLZE SW,LCK
	UNLOK. 14,
	  JFCL
	MOVEI 14,^D500
	JRST EC090
EC080:	MOVEI 14,^D20
EC090:	HIBER 14,
	NOTDEF
	JRST EC020
EC100:	MOVE 17,[XWD 1,1]
	TLZE SW,LCK
	UNLOK. 17,
	  JFCL
	RETURN
;
STAB5:	SIXBIT /NOWRIT/
	SIXBIT /WRITE/
	0
;
DTAB5:	0
	-1
	SUBTTL LOGIN
;
;	LOGIN COMMAND
;	CALLING SEQUENCE:		*LOGIN PASSWORD DD<CR>
;
LOGIN:	CALL INSIX
	JUMPE SIX,ER030
	CAME SIX,[SIXBIT /LOGPAS/]
	JRST ER030
	CALL INCR
	JRST LG010
	MOVEI DEC,^D1		;WITHOUT NUMBER
	JRST LG020
LG010:	CALL INDEC		;WITH NUMBER
	CALL INCR
	JRST ER030
LG020:	MOVE 17,[%CNLNM]	;SUBTRACT FROM LOGNUM
	GETTAB 17,
	  NOTDEF
	SUB 17,DEC
	MOVE 16,[%CNSTS]	;GET SCHED
	GETTAB 16,
	  NOTDEF
	ANDI 16,-1
LG030:	MOVEI 15,1		;SLEEP A BIT
	SLEEP 15,
	MOVE 15,[%CNLNM]	;IS LOGNUM SMALL ENOUGH NOW?
	GETTAB 15,
	  NOTDEF
	CAMG 15,17
	JRST LG040		;YES, DONE
	MOVE 15,[%CNSTS]	;SCHED CHANGED?
	GETTAB 15,
	  NOTDEF
	ANDI 15,-1
	CAME 15,16
	JRST LG040		;YES, DONE
	JRST LG030		;LOOP AGAIN
LG040:	JRST EXIT2		;DO AN EXIT
	SUBTTL WHAT
;
;	WHAT COMMAND
;	CALLING SEQUENCE:	*WHAT DEV:FILE.EXT<PROT>[P,PN]<CR>
;
WHAT:	TRO SW,NFL
	TRNE SW,SPT
	JRST WA010
	CALL LIST
	JRST ER030
	CALL INCR
	JRST ER030
	MOVE CHAN,LST
	JRST WA020
WA010:	OPEN DWHT,OPENA
	CALL OPCHK
	MOVE 17,QUEPPN
	MOVEM 17,LOOKA+3
	TRO SW,ERI
	LOOKUP DWHT,LOOKA
	CALL LKCHK
	TRZ SW,NFL+ERI
	MOVE 17,QUEPPN
	MOVEM 17,LOOKA+3
	ENTER DWHT,LOOKA
	CALL LKCHK
	OUTPUT DWHT,
	TRNN SW,NFL
	USETI DWHT,-1
	MOVEI CHAN,DWHT
WA020:	MOVE 17,[%CVUPT]	;GENERATE INCRIMENTAL STATISTICS
	GETTAB 17,
	  NOTDEF
	MOVE 16,17
	SUB 16,UTIME
	MOVEM 17,UTIME
	MOVEM 16,UTIME+1
	MOVE 17,[%CVNUL]
	GETTAB 17,
	  NOTDEF
	MOVE 16,17
	SUB 16,NTIME
	MOVEM 17,NTIME
	MOVEM 16,NTIME+1
	MOVE 17,[%CVLST]
	GETTAB 17,
	  NOTDEF
	MOVE 16,17
	SUB 16,LTIME
	MOVEM 17,LTIME
	MOVEM 16,LTIME+1
	MOVE 17,[%CVOHT]
	GETTAB 17,
	  NOTDEF
	MOVE 16,17
	SUB 16,OTIME
	MOVEM 17,OTIME
	MOVEM 16,OTIME+1
	MOVE 17,[%CCRSP]
	GETTAB 17,
	  NOTDEF
	JUMPE 17,WA023
	HRLZS 17
	MOVE 16,[XWD %CVRSX,.GTC0V]
	ADD 16,17
	GETTAB 16,
	  NOTDEF
	MOVE 15,16
	SUB 15,RTIME
	MOVEM 16,RTIME
	MOVEM 15,RTIME+1
	ADD 17,[XWD %CVRNX,.GTC0V]
	GETTAB 17,
	  NOTDEF
	MOVE 16,17
	SUB 16,RCOUNT
	MOVEM 17,RCOUNT
	MOVEM 16,RCOUNT+1
WA023:	SETZM SCOUNT
	SETOM SCOUNT+1
	HRLZI 17,-SCLSES
WA025:	HRL 16,17
	HRRI 16,.GTCRT
	GETTAB 16,
	  SETZ 16,
	MOVE 15,16
	SUB 15,SCLASS(17)
	MOVEM 16,SCLASS(17)
	MOVEM 15,SCLASS+SCLSES(17)
	ADDM 15,SCOUNT
	SKIPE 15
	HRRZM 17,SCOUNT+1
	AOBJN 17,WA025
	TRZN SW,NFL
	JRST WA030
	MOVEI ADR,[ASCIZ /TIME      PERIOD    NULL IDLE LOST OVRHD OTHER RESPONSE SCHED-CLASSES/]
	CALL OUTASC
	CALL OUTCR
	TRNE SW,SPT
	CALL OUTCR
WA030:	SETZM TABPOS
	MSTIME 16,
	IDIVI 16,^D1000
	MOVE TIM,16
	CALL OUTTIM
	CALL TAB
	^D11
	MOVE 16,UTIME+1
	IDIV 16,JIFFY
	MOVE TIM,16
	CALL OUTTIM
	CALL TAB
	^D21
	MOVE 16,NTIME+1
	IMULI 16,^D100
	MOVE 17,UTIME+1
	LSH 17,-1
	ADD 16,17
	IDIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	CALL TAB
	^D26
	MOVE 16,NTIME+1
	SUB 16,LTIME+1
	SKIPG 16
	SETZ 16,
	IMULI 16,^D100
	MOVE 17,UTIME+1
	LSH 17,-1
	ADD 16,17
	IDIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	CALL TAB
	^D31
	MOVE 16,LTIME+1
	IMULI 16,^D100
	MOVE 17,UTIME+1
	LSH 17,-1
	ADD 16,17
	IDIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	CALL TAB
	^D36
	MOVE 16,OTIME+1
	IMULI 16,^D100
	MOVE 17,UTIME+1
	LSH 17,-1
	ADD 16,17
	IDIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	CALL TAB
	^D42
	MOVE 16,UTIME+1
	SUB 16,NTIME+1
	SUB 16,OTIME+1
	SUB 16,SCOUNT
	SKIPG 16
	SETZ 16,
	IMULI 16,^D100
	MOVE 17,UTIME+1
	LSH 17,-1
	ADD 16,17
	IDIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	CALL TAB
	^D48
	MOVE 16,RTIME+1
	IMULI 16,^D100
	IDIV 16,JIFFY
	IDIV 16,RCOUNT+1
	MOVE DEC,16
	CALL OUTPDC
	CALL TAB
	^D57
	SKIPGE SCOUNT+1
	JRST WA050
	PUSH PDP,[0]
WA040:	MOVE 17,(PDP)
	MOVE 16,SCLASS+SCLSES(17)
	MULI 16,^D100
	DIV 16,UTIME+1
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"%"
	CALL OTCHAR
	MOVEI CHAR," "
	CALL OTCHAR
	AOS 17,(PDP)
	CAMG 17,SCOUNT+1
	JRST WA040
	POP PDP,17
WA050:	CALL OUTCR
	TRNN SW,SPT
	JRST WA060
	OUTPUT DWHT,
	GETSTS DWHT,STS
	CALL STSCHK
	RELEAS DWHT,
	JRST WA070
WA060:	CALL LISTE
WA070:	RETURN
	SUBTTL PEK
;
;	PEEK COMMAND
;	CALLING SEQUENCE:	*PEEK JOB<CR>
;	COMMAND SEQUENCE:	**E NNNNNN<CR>		OR
;				**D NNNNNN NNNNNN<CR>	OR
;				**E<CR>
;	EXIT SEQUENCE:		**<CR>
;
PEK:	CALL INJOB
	  JRST ER030
	CALL INCR
	JRST ER030
	CALL DOLOG
	SETZM ADDR
	TRZ SW,DEP
	MOVEI CHAN,TTY
PK010:	MOVEI CHAR,"*"
	CALL OTCHAR
	CALL OTCHAR
	OUTPUT TTY,
	INPUT TTY,	;INPUT COMMAND
	CALL INSIX
	CALL NXCHAR
	JUMPN SIX,PK020
	JUMPN CHAR,PK070
	RETURN
PK020:	CAMN SIX,[SIXBIT /D/]
	JRST PK060
	CAME SIX,[SIXBIT /E/]
	JRST PK070
PK030:	JUMPN CHAR,PK040	;E COMMAND
	TRZN SW,DEP
	AOS ADDR
	JRST PK050
PK040:	CAIE CHAR," "
	JRST PK070
	CALL INOCT
	CALL NXCHAR
	JUMPN CHAR,PK070
	MOVEM OCT,ADDR
PK050:	HRL 16,JOB
	HRRI 16,1
	HRL 17,ADDR
	HRRI 17,VALUE
	CALL PK500
	HRRZ OCT,ADDR
	CALL PK600
	MOVEI ADR,[ASCIZ ./ .]
	CALL OUTASC
	HLRZ OCT,VALUE
	CALL PK600
	MOVEI CHAR," "
	CALL OTCHAR
	HRRZ OCT,VALUE
	CALL PK600
	CALL OUTCR
	OUTPUT TTY,
	JRST PK010
PK060:	CAIE CHAR," "	;D COMMAND
	JRST PK070
	CALL INOCT
	HRLM OCT,VALUE
	CALL NXCHAR
	CAIE CHAR," "
	JRST PK070
	CALL INOCT
	HRRM OCT,VALUE
	CALL NXCHAR
	JUMPN CHAR,PK070
	TRO SW,DEP
	HRL 16,JOB
	HRRI 16,1
	TLO 16,400000
	HRLI 17,VALUE
	HRR 17,ADDR
	CALL PK500
	JRST PK010
PK070:	MOVEI ADR,[ASCIZ /EH?/]	;INVALID COMMAND
	JRST PK100
PK080:	MOVEI ADR,[ASCIZ /FAILED/]	;JOBPEK FAILED
	POP PDP,17
	JRST PK100
PK090:	MOVEI ADR,[ASCIZ /JOB NOT IN CORE/]	;JOB NOT IN CORE
	POP PDP,17
	JRST PK100
PK100:	TLZ SW,RRD	;ERROR RETURN
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST PK010
;
PK500:	MOVEI 15,^D20	;JOBPEK ROUTINE
PK510:	HRL 14,JOB
	HRRI 14,.GTSTS
	GETTAB 14,
	JRST PK520
	TLNN 14,SWP
	JRST PK520
	MOVEI 14,^D100
	HIBER 14,
	NOP
	SOJG 15,PK510
	JRST PK090
PK520:	MOVEI 15,16
	JOBPEK 15,
	JRST PK080
	RETURN
;
PK600:	MOVEI 17,6	;OUTPUT ROUTINE
	HRLZ 16,OCT
PK610:	SETZ 15,
	LSHC 15,3
	ADDI 15,"0"
	MOVE CHAR,15
	CALL OTCHAR
	SOJG 17,PK610
	RETURN
	SUBTTL HELP
;
;	HELP HOMMAND
;	CALLING SEQUENCE:	*HELP<CR>
;
HELP:	MOVE 17,PDP
	PUSH 17,1
	MOVE 1,[SIXBIT /OPR/]
	PUSHJ 17,.HELPR##
	POP 17,1
	RETURN
	SUBTTL WAT
;
;	WATCH COMMAND
;	CALLING SEQUENCE:	*WATCH<CR>
;
WAT:	CALL INCR
	JRST ER030
	RESET		;SETUP SPIRIT DATA AREA
	MOVEI 17,SPTTOP
	CORE 17,
	JRST ER130
	MOVEI 17,SPTTOP
	HRLM 17,.JBSA
	MOVEM 17,.JBFF
	TRO SW,SPT
	MOVE 17,[SIXBIT /SPIRIT/]
	SETNAM 17,
	TLNE SW,DB
	JRST WT005
	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /DETACHING FROM TERMINAL/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	MOVE 17,MYJOB
	TLO 17,AT.DET
	CALL PUTJOB
WT005:	MOVE 17,MYJOB
	MOVEM 17,JOB
	CALL CHKJOB
	MOVEM 17,MYLINE
WT010:	IFN SPTKJO,<	;SPIRIT KJOB CONDITIONAL
	MOVE 17,[SIXBIT /PTY/]
	SETO 16,
	REASSI 16,
	JUMPN 17,WT020
	MOVEI 17,^D60
	SLEEP 17,
	JRST WT010
	>
WT020:	MOVEI 17,200
	MSTIME 16,
WT030:	SETZM PPNS-1(17)
	SETZM RUNTIM-1(17)
	SETZM WARN-1(17)
	SETZM HUNG-1(17)
	MOVEM 16,TIME-1(17)
	SOJG 17,WT030
	MOVEI 17,20
WT040:	SETZM STRS-1(17)
	SETZM FCFS-1(17)
	SETZM LOW-1(17)
	SOJG 17,WT040
	MOVEI 17,SPTWRN
	MOVEM 17,WRNOUT
	SETZM REECNT
SPTREE:	AOS REECNT
	RESET
	CALL PRIO
	TLNN SW,DB
	JRST WT045
	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
WT045:	PUSH PDP,COMAND
	PUSH PDP,COMAND+1
	PUSH PDP,COMAND+2
	MOVE 17,[ASCII /SPIRI/]
	MOVEM 17,COMAND
	MOVE 17,[ASCII /T 000/]
	MOVEM 17,COMAND+1
	SETZM COMAND+2
	MOVE 15,REECNT
	IDIVI 15,^D100
	IDIVI 16,^D10
	DPB 15,[POINT 3,COMAND+1,20]
	DPB 16,[POINT 3,COMAND+1,27]
	DPB 17,[POINT 3,COMAND+1,34]
	SETZM JOB
	CALL DOLOG
	POP PDP,COMAND+2
	POP PDP,COMAND+1
	POP PDP,COMAND
WT050:	MOVE 17,TOPJOB
	MOVEM 17,JOB
WT060:	MOVE 17,JOB
	MSTIME 16,
	HRL 15,JOB	;TEST JOB
	HRRI 15,.GTSTS
	GETTAB 15,
	JRST WT080
	TLNN 15,JNA
	JRST WT080
	HRL 15,JOB
	HRRI 15,.GTPPN
	GETTAB 15,
	NOTDEF
	MOVEM 15,PPN
	CAME 15,PPNS(17)
	JRST WT090
	SKIPE HUNG(17)
	JRST WT110
	MOVE 15,PPN	;TEST PPN
	CAMN 15,HLPPPN
	JRST WT070
	HLRZ 15,PPN
	CAIG 15,10
	JRST WT110
	MOVE 14,SYSSER
	CAIE 14,TUFSER
	JRST WT070
	HLRZ 15,PPN
	CAIN 15,101
	JRST WT110
	LDB 15,[POINT 9,PPN,8]
	JUMPN 15,WT070
	LDB 15,[POINT 3,PPN,11]
	CAIN 15,0
	JRST WT110
	CAIN 15,5
	JRST WT110
WT070:	HRL 15,JOB
	HRRI 15,.GTKCT
	GETTAB 15,
	NOTDEF
	CAME 15,RUNTIM(17)
	JRST WT075
	IFE SPTKJD,<	;SPIRIT KJOB CONDITIONAL FOR DETACHED JOBS
	MOVE 14,JOB
	TRMNO. 14,
	JRST WT075
	>
	HRL 14,JOB
	HRRI 14,.GTLIM
	GETTAB 14,
	NOTDEF
	TLNN 14,(JB.LBT)
	JRST WT100
WT075:	MOVEM 16,TIME(17)
	MOVEM 15,RUNTIM(17)
	SETZM WARN(17)
	JRST WT110
WT080:	SETZM PPN
WT090:	MOVE 15,PPN
	MOVEM 15,PPNS(17)
	SETZM RUNTIM(17)
	SETZM WARN(17)
	SETZM HUNG(17)
	MOVEM 16,TIME(17)
	JRST WT110
WT100:	IFN SPTKJO,<	;SPIRIT KJOB CONDITIONAL
	MOVE 14,16
	SUB 14,TIME(17)
	IDIVI 14,^D<60*1000>
	CAMG 14,WRNOUT
	JRST WT110
	SKIPN WARN(17)
	JRST WT180
	MOVE 14,16
	SUB 14,WARN(17)
	IDIVI 14,^D<60*1000>
	CAMLE 14,^D15
	JRST WT200
	>
WT110:	SOSLE JOB
	JRST WT060
	SETZ 16,
WT120:	SYSSTR 16,
	NOTDEF
	JUMPE 16,WT170
	SETZ 17,
WT130:	SKIPN STRS(17)
	JRST WT140
	CAMN 16,STRS(17)
	JRST WT150
	AOJA 17,WT130
WT140:	MOVEM 16,STRS(17)
WT150:	MOVE 12,[XWD 3,13]
	MOVE 13,16
	DSKCHR 12,
	NOTDEF
	MOVEM 15,FCFS(17)
	IFN SPTDSK,<	;SPIRIT DSK CONDITIONAL
	CAIG 15,^D3000
	JRST WT160
	SETZM LOW(17)
	JRST WT120
WT160:	SKIPGE 14,LOW(17)
	JRST WT120
	JUMPE 14,WT250
	CAIG 15,^D1000
	JRST WT260
	>
	JRST WT120
WT170:	IFN SPTWHT,<		;SPIRIT WHAT CONDITIONAL
	MOVE 16,[%CVUPT]
	GETTAB 16,
	HRLOI 16,377777
	SUB 16,UTIME
	IDIV 16,JIFFY
	CAIL 16,^D<15*60>
	CALL WHAT
	>
	IFN SPTWHO,<CALL WHO>	;SPIRIT WHO CONDITIONAL
	IFN SPTTIM,<CALL TIMES>	;SPIRIT TIMES CONDITIONAL
	RESET
	CALL PRIO
	TLNN SW,DB
	JRST WT175
	OPEN TTY,OPENT
	JRST ER020
	OUTPUT TTY,
WT175:	MOVEI 17,^D60
	SLEEP 17,
	JRST WT050
	IFN SPTKJO,<	;SPIRIT KJOB CONDITIONAL
WT180:	MOVEM 16,WARN(17)
	CALL CHKJOB
	MOVEM 17,OLDLNE
	TLNE 17,AT.DET
	JRST WT190
	TLZ 17,AT.MON
	TLO 17,AT.USR
	HRR 17,MYJOB
	CALL PUTJOB
	TLNE SW,DB
	JRST WT183
	OPEN TTY,OPENT
	JRST WT185
	OUTPUT TTY,
WT183:	MOVEI 15,1000+.TOSTP
	HLRZ 16,OLDLNE
	TRZ 16,AT.MON+AT.USR+AT.DET
	TRO 16,.UXTRM
	SETZ 17,
	MOVE 14,[XWD 3,15]
	TRMOP. 14,
	  NOP
	CLRBFO
	MOVEI CHAN,TTY
	CALL OUTCR
	MOVEI ADR,[ASCIZ /;;SPIRIT: - RUN SOMETHING OR YOU'LL BE LOGGED OFF/]
	CALL OUTASC
	CALL OUTCR
	MOVEI CHAR,"."
	MOVE 17,OLDLNE
	TLNE 17,AT.MON
	CALL OTCHAR
	OUTPUT TTY,
	TLNN SW,DB
	RELEAS TTY,
WT185:	CALL RTMJOB
	MOVE 17,OLDLNE
	CALL PUTJOB
WT190:	JRST WT060
WT200:	CALL DOLOG
	CALL CHKJOB
	MOVEM 17,OLDLNE
	TLNE 17,AT.DET
	JRST WT230
	TLZ 17,AT.MON
	TLO 17,AT.USR
	HRR 17,MYJOB
	CALL PUTJOB
	TLNE SW,DB
	JRST WT203
	OPEN TTY,OPENT
	JRST WT205
	OUTPUT TTY,
WT203:	MOVEI 15,1000+.TOSTP
	HLRZ 16,OLDLNE
	TRZ 16,AT.MON+AT.USR+AT.DET
	TRO 16,.UXTRM
	SETZ 17,
	MOVE 14,[XWD 3,15]
	TRMOP. 14,
	  NOP
	CLRBFO
	MOVEI CHAN,TTY
	CALL OUTCR
	CALL OUTCR
	MOVEI ADR,[ASCIZ /;;SPIRIT: - BYE BYE/]
	CALL OUTASC
	CALL OUTCR
	CALL OUTCR
	MOVEI CHAR,"."
	CALL OTCHAR
	MOVEI ADR,KJOB1
	CALL OUTASC
	CALL OUTCR
	MOVE 17,SYSSER
	CAIN 17,TUFSER
	JRST WT204
	CALL OUTCR
	MOVEI CHAR,"."
	CALL OTCHAR
WT204:	OUTPUT TTY,
	TLNN SW,DB
	RELEAS TTY,
WT205:	CALL RTMJOB
	MOVE 17,OLDLNE
	CALL PUTJOB
WT230:	CALL KJOB
	  SKIPA
	JRST WT240
	MOVE 17,JOB
	SETOM HUNG(17)
WT240:	JRST WT060
	>
	IFN SPTDSK,<	;SPIRIT DSK CONDITIONAL
WT250:	AOS LOW(17)
	MOVE SIX,16
	OPEN PTY,OPENP
	JRST ER070
	MOVEI CHAN,PTY
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,[ASCIZ /SEND OPR WARNING: SYSTEM IS RUNNING OUT OF ROOM ON /]
	CALL OUTASC
	CALL OUTSIX
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	RELEAS PTY,
	JRST WT170
WT260:	SETOM LOW(17)
	MOVE SIX,16
	OPEN PTY,OPENP
	JRST ER070
	OUTPUT PTY,
	MOVEI CHAN,PTY
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,[ASCIZ .LOGIN 1,2.]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYUSR
	MOVEI ADR,[ASCIZ /SEND ALL WARNING: SYSTEM IS RUNNING OUT OF ROOM ON /]
	CALL OUTASC
	CALL OUTSIX
	MOVEI ADR,[ASCIZ / - OPR NOTIFIED/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,KJOB2
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYUSR
	RELEAS PTY,
	JRST WT170
	>
	SUBTTL TIMES
;
;	TIMES SPIRIT SUBFUNCTION
;	CALLING SEQUENCE:	CALL TIMES
;
TIMES:	MOVE 17,[%CNDTM]	;GET DAY TIME
	GETTAB 17,
	NOTDEF
	MOVEM 17,NOW
	OPEN TMS,OPENS	;TEST TIMES.SYS
	CALL OPCHK
TS010:	TRO SW,ERI
	SETZM LOOKS+3
	LOOKUP TMS,LOOKS
	CALL LKCHK
	TRZA SW,ERI
	JRST TS080
	LDB 17,[POINT 11,LOOKS+2,23]
	LDB 16,[POINT 12,LOOKS+2,35]
	DPB 16,[POINT 12,17,24]
	LDB 16,[POINT 3,LOOKS+1,20]
	DPB 16,[POINT 3,17,12]
	CAMN 17,CRETIM
	JRST TS090
	MOVEM 17,CRETIM
	TLZ SW,RRD	;READ NEW TIMES.SYS
	TRO SW,FCM
	MOVEI CHAN,TMS
TS020:	CALL INSP
	CALL NXCHAR
	JUMPE CHAR,TS060
	TLO SW,RRD
	CAIL CHAR,"0"
	CAILE CHAR,"9"
	JRST TS030
	CALL INTIM
	HRLZ 16,TIM
	IDIVI 16,^D<24*60>
	HLL 16,NOW
	MOVEM 16,NXTTIM
	CAML 16,NOW
	JRST TS070
TS030:	CALL NXCHAR
	JUMPE CHAR,TS060
	CAIE CHAR,012
	JRST TS030
	JRST TS020
TS060:	HLLZ 17,NOW
	ADD 17,[XWD 1,0]
	MOVEM 17,NXTTIM
TS070:	TRZ SW,FCM
TS080:	RELEAS TMS,
	RETURN
TS090:	MOVE 17,NOW	;TEST FOR NEXT TIME
	CAMGE 17,NXTTIM
	JRST TS280
	TLZ SW,RRD	;FETCH NEXT TIME
	TRO SW,FCM
	HRRZ 17,NXTTIM
	JUMPE 17,TS150
	MOVEI CHAN,TMS
TS100:	CALL INSP
	CALL NXCHAR
	JUMPE CHAR,TS290
	TLO SW,RRD
	CAIL CHAR,"0"
	CAILE CHAR,"9"
	JRST TS110
	CALL INTIM
	HRLZ 16,TIM
	IDIVI 16,^D<24*60>
	HLL 16,NOW
	CAMN 16,NXTTIM
	JRST TS150
TS110:	CALL NXCHAR
	JUMPE CHAR,TS290
	CAIE CHAR,012
	JRST TS110
	JRST TS100
TS150:	TLZ SW,RRD	;DO NEXT TIME
	TRZ SW,TOPN+TLGN
TS155:	SETZM TIMSTS
TS160:	MOVEI CHAN,TMS	;PROCESS NEXT FIELD
	CALL INSP
	CALL NXCHAR
	JUMPE CHAR,TS260
	CAIN CHAR,"*"
	JRST TS180
	CAIN CHAR,"@"
	JRST TS180
	CAIN CHAR,";"
	JRST TS250
	TLO SW,RRD
	CAIL CHAR,"0"
	CAILE CHAR,"9"
	JRST TS170
	CALL INTIM
	HRLZ 16,TIM
	IDIVI 16,^D<24*60>
	HLL 16,NOW
	CAMN 16,NXTTIM
	JRST TS160
	MOVEM 16,NXTTIM
	JRST TS270
TS170:	CALL INSIX
	JUMPE SIX,TS250
	MOVEI ADR,STAB1
	CALL DSPTCH
	JUMPL 17,TS250
	JRST @DTAB1(17)
TS180:	MOVEM CHAR,BREAK	;SETUP SUBJOB
	TROE SW,TOPN
	JRST TS200
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	OPEN TMSL,OPENM	;OPEN UP LOG
	CALL OPCHK
TS182:	TRO SW,NFL
	MOVE 17,QUEPPN
	MOVEM 17,LOOKM+3
	TRO SW,ERI
	LOOKUP TMSL,LOOKM
	CALL LKCHK
	TRZA SW,ERI
	JRST TS192
	TRZ SW,NFL
	MOVN 17,LOOKM+3
	HLRZ 16,17
	IDIVI 16,200
	CAIGE 16,SPTSIZ
	JRST TS192
	OPEN TMSR,OPENR
	CALL OPCHK
	MOVE 17,QUEPPN
	MOVEM 17,LOOKR+3
	ENTER TMSR,LOOKR
	CALL LKCHK
	OUTPUT TMSR,
	USETI TMSL,SPTSIZ/2
TS184:	SKIPLE MRNG+5
	JRST TS186
	INPUT TMSL,
	GETSTS TMSL,STS
	CALL STSCHK
	TRNE STS,IO.EOF
	JRST TS190
TS186:	ILDB CHAR,MRNG+4
	SOS MRNG+5
	JUMPE CHAR,TS184
	IDPB CHAR,RRNG+1
	SOSLE RRNG+2
	JRST TS188
	OUTPUT TMSR,
	GETSTS TMSR,STS
	CALL STSCHK
TS188:	JRST TS184
TS190:	OUTPUT TMSR,
	GETSTS TMSR,STS
	CALL STSCHK
	CLOSE TMSL,
	RELEAS TMSR,
	JRST TS182
TS192:	MOVE 17,QUEPPN
	MOVEM 17,LOOKM+3
	ENTER TMSL,LOOKM
	CALL LKCHK
	OUTPUT TMSL,
	TRNN SW,NFL
	USETI TMSL,-1
	MOVEI CHAN,TMSL	;WRITE HEADER INTO LOG
	CALL OUTCR
	MOVEI ADR,[ASCIZ /*************************  /]
	CALL OUTASC
	DATE DAT,
	CALL OUTDAT
	MOVEI ADR,[ASCIZ /  /]
	CALL OUTASC
	HRRZ 17,NXTTIM
	IMULI 17,^D<24*60>
	ADDI 17,^D<24*60>-1
	HLRZ TIM,17
	CALL OUTTIM
	MOVEI ADR,[ASCIZ /  ************************/]
	CALL OUTASC
	CALL OUTCR
	CALL OUTCR
	>
	OPEN PTY,OPENP	;OPEN UP PTY
	JRST ER070
	OUTPUT PTY,
	MOVEI CHAN,PTY
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	MOVEI 17,TMSL	;START UP LOGGING
	MOVEM 17,LOGDEV
	TRO SW,PLG
	>
TS200:	MOVE 17,TIMSTS	;LOGIN SUBJOB
	TRNN 17,T.NLG
	TROE SW,TLGN
	JRST TS210
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	SETZM LOGDEV	;TURN OFF LOGGING
	TRZ SW,PLG
	>
	MOVEI CHAN,PTY
	MOVEI ADR,[ASCIZ /LOGIN 1,2/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYUSR
	MOVEI 17,PTY
	JOBSTS 17,
	NOTDEF
	TLNN 17,(JB.ULI)
	JRST TS265
	MOVEI ADR,[ASCIZ /SET HPQ 1/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,[ASCIZ /SET DSKPRI 3/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,[ASCIZ /SET WATCH DAY/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	MOVEI 17,TMSL	;TURN ON LOGGING
	MOVEM 17,LOGDEV
	TRO SW,PLG
	>
TS210:	MOVE 17,BREAK	;SEND THE REST OF THE LINE
	CAIE 17,"*"
	JRST TS220
	MOVEI CHAN,TMS
	CALL NXCHAR
	JUMPE CHAR,TS260
	MOVEI CHAN,PTY
	CALL OTCHAR
	CAIE CHAR,012
	JRST TS210
	OUTPUT PTY,
	CALL PTYUSR
	JRST TS155
TS220:	MOVEI CHAN,TMS	;SEND BRACKETED MESSAGE
	CALL NXCHAR
	JUMPE CHAR,TS260
	CAIG CHAR,040
	JRST TS220
	MOVEM CHAR,BREAK
TS230:	MOVEI CHAN,TMS
	CALL NXCHAR
	JUMPE CHAR,TS260
	CAMN CHAR,BREAK
	JRST TS240
	MOVEI CHAN,PTY
	CALL OTCHAR
	JRST TS230
TS240:	OUTPUT PTY,
	CALL PTYUSR
	MOVEI CHAN,TMS
	JRST TS250
TS250:	CALL NXCHAR	;EAT THE REST OF THE LINE
	JUMPE CHAR,TS260
	CAIE CHAR,012
	JRST TS250
	JRST TS155
TS260:	HLLZ 17,NOW	;EOF, START AT TOP OF FILE
	ADD 17,[XWD 1,0]
	MOVEM 17,NXTTIM
	JRST TS270
TS265:	TRZ SW,TLGN	;CAN'T LOG IN
TS270:	TRZN SW,TLGN	;FINISH UP SUBJOB
	JRST TS275
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	SETZM LOGDEV	;TURN OFF LOGGING
	TRZ SW,PLG
	>
	MOVEI CHAN,PTY	;LOGOUT SUBJOB
	MOVEI CHAR,003
	CALL OTCHAR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,KJOB2
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYUSR
TS275:	TRZN SW,TOPN
	JRST TS280
	IFN SPTTLG,<	;TIMES LOG CONDITIONAL
	SETZM LOGDEV	;CLOSE DOWN LOG
	TRZ SW,PLG
	OUTPUT TMSL,
	GETSTS TMSL,STS
	CALL STSCHK
	RELEAS TMSL,
	>
	RELEAS PTY,
TS280:	TRZ SW,FCM
	RELEAS TMS,
	RETURN
TS290:	TRZ SW,FCM	;NEXT TIME NOT FOUND
	SETZM CRETIM
	RELEAS TMS,
	RETURN
;
TS400:	CALL TS800	;ONLY ON WEEKDAY
	CAIN 17,0
	JRST TS250
	CAIN 17,6
	JRST TS250
	JRST TS160
TS410:	CALL TS800	;NOT ON SUNDAY
	CAIN 17,0
	JRST TS250
	JRST TS160
TS420:	MOVE 17,SYSFEA	;ONLY IF OPR ON DUTY
	TRNE 17,400
	JRST TS250
	JRST TS160
TS430:	CALL TS800	;ONLY ON SATURDAY
	CAIE 17,6
	JRST TS250
	JRST TS160
TS440:	CALL TS800	;ONLY ON SUNDAY
	CAIE 17,0
	JRST TS250
	JRST TS160
TS450:	CALL TS800	;ONLY ON WEEKEND
	CAIN 17,0
	JRST TS160
	CAIN 17,6
	JRST TS160
	JRST TS250
TS460:	CALL TS800	;ONLY ON THURSDAY
	CAIE 17,4
	JRST TS250
	JRST TS160
TS470:	CALL NXCHAR	;ONLY ON A PARTICULAR DATE OR DATES
	JUMPE CHAR,TS260
	CAIE CHAR,":"
	JRST TS250
	TRZ SW,FND
TS480:	CALL INDAT
	JUMPE DAT,TS250
	CALL NXCHAR
	JUMPE CHAR,TS260
	CAIN CHAR,":"
	JRST TS490
	TLO SW,RRD
	MOVE 17,DAT	;DATE:DD-MMM-YY
	JRST TS500
TS490:	PUSH PDP,DAT	;DATE:DD-MMM-YY:DD-MMM-YY
	CALL INDAT
	POP PDP,17
	JUMPE DAT,TS250
TS500:	DATE 16,
	CAML 16,17
	CAMLE 16,DAT
	SKIPA
	TRO SW,FND
	CALL NXCHAR
	JUMPE CHAR,TS260
	CAIN CHAR,","
	JRST TS480
	TLO SW,RRD
	TRNN SW,FND
	JRST TS250
	JRST TS160
TS510:	MOVEI 17,T.NLG	;NO LOGIN NECESSARY
	IORM 17,TIMSTS
	JRST TS160
TS520:	CALL TS800	;ONLY ON MONDAY
	CAIE 17,1
	JRST TS250
	JRST TS160
;
TS800:	DATE 15,	;CALCULATE DAY OF THE WEEK
	IDIVI 15,^D<12*31>
	IDIVI 16,^D31
	ADDI 17,3
	ADD 17,[EXP 0,3,3,6,1,4,6,2,5,0,3,5](16)
	TRNN 15,3
	CAIG 16,1
	SKIPA
	ADDI 17,1
	ADD 17,15
	ADDI 15,3
	IDIVI 15,4
	ADD 17,15
	MOVE 16,17
	IDIVI 16,7
	RETURN
;
STAB1:	SIXBIT /WEEKDA/
	SIXBIT /NOTSUN/
	SIXBIT /OPR/
	SIXBIT /SATURD/
	SIXBIT /SUNDAY/
	SIXBIT /WEEKEN/
	SIXBIT /THURSD/
	SIXBIT /NEVER/
	SIXBIT /ALWAYS/
	SIXBIT /SPECIA/
	SIXBIT /DATE/
	SIXBIT /NOLOGI/
	SIXBIT /MONDAY/
	0
;
DTAB1:	TS400
	TS410
	TS420
	TS430
	TS440
	TS450
	TS460
	TS250
	TS160
	TS160
	TS470
	TS510
	TS520
	SUBTTL ATT
;
;	ATTACH COMMAND
;	CALLING SEQUENCE:	*ATTACH JOB DEVICE:<CR>
;
ATT:	CALL INJOB
	  JRST ER030
	CALL INSP
	JUMPE 17,ER030
	CALL NXCHAR
	SETO OCT,
	CAIN CHAR,"T"
	SETZ OCT,
	CAIN CHAR,"C"
	MOVE OCT,CTYLNE
	JUMPL OCT,ER030
	CALL NXCHAR
	CAIE CHAR,"T"
	JRST ER030
	CALL NXCHAR
	CAIE CHAR,"Y"
	JRST ER030
	SKIPG OCT
	CALL INOCT
	PUSH PDP,OCT
	CALL NXCHAR
	CAIE CHAR,":"
	TLO SW,RRD
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL DOLOG
	CALL CHKJOB
	POP PDP,16
	DPB 16,[POINT 7,17,17]
	TLZ 17,AT.DET
	CALL PUTJOB
	RETURN
	SUBTTL DBUG
;
;	DEBUG COMMAND
;	CALLING SEQUENCE:	*DEBUG<CR>
;
DBUG:	CALL INCR
	JRST ER030
	TLC SW,DB
	RETURN
	SUBTTL KSYS
;
;	KSYS COMMAND
;	CALLING SEQUENCE:	*KSYS HHMM<CR>		OR
;				*KSYS +HHMM<CR>		OR
;				*KSYS<CR>
;
KSYS:	CALL INCR
	JRST KS010
	SETZ 17,	;WITHOUT TIME
	PUSH PDP,17
	JRST KS020
KS010:	CALL INAFT	;WITH TIME
	CAIG 17,5
	MOVEI 17,5
	PUSH PDP,17
	CALL INCR
	JRST ER030
KS020:	SETZM JOB	;LOG IT
	CALL DOLOG
	POP PDP,17
	HRLI 17,.STKSY	;SET KSYS
	SETUUO 17,
	NOTDEF
	RETURN
	SUBTTL BOMB
;
;	BOMB COMMAND
;	CALLING SEQUENCE:	*BOMB NNNNNNNNNNNN<CR>
;	COMMAND SEQUENCE:	ARE YOU SURE? YES<CR>	OR
;				ARE YOU SURE? NO<CR>
;
BOMB:	CALL INCR
	JRST BM010
	MOVEI 17,2	;WITHOUT NUMBER
	PUSH PDP,17
	JRST BM020
BM010:	CALL INOCT	;WITH NUMBER
	PUSH PDP,OCT
	CALL INCR
	JRST ER030
BM020:	MOVE 17,[%NSKTM]	;TEST KSYS
	GETTAB 17,
	NOTDEF
	JUMPE 17,BM030
	JUMPL 17,BM040
	MOVEI 17,1
	SLEEP 17,
	JRST BM020
BM030:	CALL SURE	;CONFIRM
BM040:	SETZM JOB	;LOG IT
	CALL DOLOG
	MOVEI 17,^D10	;COUNT DOWN
BM050:	LIGHTS 17,
	MOVEI 16,1
	SLEEP 16,
	SOJGE 17,BM050
	MOVEI 16,CRSHWD	;DO IT
	POP PDP,17
	CALL POKE
	RETURN
	SUBTTL PRIV
;
;	PRIVILEGE COMMAND
;	CALLING SEQUENCE:	*PRIVILEGE JOB NNNNNNNNNNNN<CR>   OR
;				*PRIVILEGE JOB +NNNNNNNNNNNN<CR>  OR
;				*PRIVILEGE JOB -NNNNNNNNNNNN<CR>
;
PRIV:	CALL INJOB
	  JRST ER030
	CALL INSP
	JUMPE 17,ER030
	CALL NXCHAR
	SETZ 17,
	CAIN CHAR,"+"
	MOVE 17,[IOR 17,15]
	CAIN CHAR,"-"
	MOVE 17,[ANDCM 17,15]
	JUMPN 17,PV010
	TLO SW,RRD
	MOVE 17,[MOVE 17,15]
PV010:	PUSH PDP,17
	CALL INOCT
	PUSH PDP,OCT
	CALL INCR
	JRST ER030
	CALL DOLOG
	MOVE 17,[XWD .GTPRV,.GTSLF]
	GETTAB 17,
	NOTDEF
	HRRZ 16,17
	ADD 16,JOB
	HRL 17,JOB
	HRRI 17,.GTPRV
	GETTAB 17,
	NOTDEF
	POP PDP,15
	POP PDP,14
	XCT 14
	CALL POKE
	MOVEI CHAN,TTY
	MOVE OCT,17
	MOVEI ADR,[ASCIZ /OLD VALUE: /]
	CALL OUTASC
	CALL OUTOCT
	CALL OUTCR
	OUTPUT TTY,
	RETURN
	SUBTTL VM
;
;	VM COMMAND
;	CALLING SEQUENCE:	*VM JOB VIRTUAL,PHYSICAL<CR>
;
VM:	CALL INJOB		;GET JOB NUMBER
	JRST ER030
	CALL INSP		;GET VIRTUAL LIMIT
	JUMPE 17,ER030
	CALL NXCHAR
	JUMPE CHAR,ER030
	TLO SW,RRD
	CALL INDEC
	CAILE DEC,^D512
	MOVEI DEC,^D512
	HRLS DEC
	PUSH PDP,DEC
	CALL NXCHAR		;GET PHYSICAL LIMIT
	CAIE CHAR,","
	JRST ER030
	CALL NXCHAR
	JUMPE CHAR,ER030
	TLO SW,RRD
	CALL INDEC
	CAILE DEC,^D512
	MOVEI DEC,^D512
	HRRM DEC,(PDP)
	CALL INCR
	JRST ER030
	CALL DOLOG		;LOG IT
	HRL 17,JOB		;GET OLD LIMIT
	HRRI 17,.GTMVL
	GETTAB 17,
	NOTDEF
	EXCH 17,(PDP)		;SET IT
	HRRZ 15,JOB
	MOVE 16,[XWD .STUVM,17]
	MOVE 14,[XWD 2,15]
	JBSET. 14,
	NOTDEF
	MOVEI CHAN,TTY		;REPORT
	MOVEI ADR,[ASCIZ /OLD VALUE: /]
	CALL OUTASC
	HLRZ DEC,(PDP)
	CALL OUTDEC
	MOVEI CHAR,","
	CALL OTCHAR
	POP PDP,17
	HRRZ DEC,17
	CALL OUTDEC
	CALL OUTCR
	OUTPUT TTY,
	RETURN
	SUBTTL LIM
;
;	LIMIT COMMAND
;	CALLING SEQUENCE:	*LIMIT JOB TIME<CR>
;
LIM:	CALL INJOB
	  JRST ER030
	CALL INSP
	JUMPE 17,ER030
	CALL INTIM
	PUSH PDP,TIM
	CALL INCR
	JRST ER030
	CALL DOLOG
	HRL 17,JOB
	HRRI 17,.GTLIM
	GETTAB 17,
	NOTDEF
	LDB 16,[POINT 24,17,35]
	IDIV 16,JIFFY
	EXCH 16,(PDP)
	HRRZ 15,JOB
	HRLI 16,.STTLM
	MOVE 17,[XWD 2,15]
	JBSET. 17,
	NOTDEF
	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /OLD LIMIT: /]
	CALL OUTASC
	POP PDP,TIM
	MOVEI ADR,[ASCIZ /NONE/]
	SKIPN TIM
	CALL OUTASC
	SKIPE TIM
	CALL OUTTIM
	CALL OUTCR
	OUTPUT TTY,
	RETURN
	SUBTTL FOR
;
;	FORCE COMMAND
;	CALLING SEQUENCE:	*FORCE JOB NAME<CR>
;
FOR:	CALL INJOB
	  JRST ER030
	CALL INSP
	JUMPE 17,ER030
	CALL INFSX
	JUMPE SIX,ER030
	PUSH PDP,SIX
	CALL INCR
	JRST ER030
	CALL CHKBAT
	CALL DOLOG
	MOVE 15,[XWD 2,16]
	POP PDP,16
	MOVE 17,JOB
	FRCUUO 15,
	NOTDEF
	RETURN
	SUBTTL EX
;
;	EXIT COMMAND
;	CALLING SEQUENCE:	*EXIT<CR>
;	EXIT SEQUENCE:		.CONTINUE
;
EX:	CALL INCR
	JRST ER030
EXIT1:	SKPINC		;FAST EXIT WITH MESSAGE
	NOP
	OUTSTR EX900
EXIT2:	TLNN SW,JLG	;FAST EXIT
	JRST EXIT3
	EXIT 1,
	RETURN
;
EXIT0:	TLNN SW,JLG	;FULL EXIT
	JRST EXIT3
	EXIT
;
EXIT3:	SKPINC		;LOGOUT
	NOP
	OUTSTR EX910
	LOGOUT
;
EX900:	BYTE (7) 7,1,1,7,1,1,7,0
EX910:	ASCIZ /
.KJOB
./
	SUBTTL PRIO AND LOCKS
;
;	ROUTINE TO SET JOB IN HPQ
;	CALLING SEQUENCE:	CALL PRIO
;
PRIO:	TLNN SW,PRV+DB
	RETURN
	MOVEI 17,1
	HPQ 17,
	NOP
	MOVE 17,[XWD .DUPRI,[XWD -1,1]]
	DISK. 17,
	NOP
	RETURN
;
;	ROUTINE TO LOCK JOB IN CORE
;	CALLING SEQUENCE:	CALL LOCKS
;
LOCKS:	TLNE SW,PRV+DB
	TLNE SW,LCK
	RETURN
	MOVE 17,[XWD 7,7]	;LOCK IT
	LOCK 17,
	JRST LR010
	TLO SW,LCK
	PUSH PDP,CHAN	;TYPE MESSAGE
	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /[LOCKED]/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	POP PDP,CHAN
LR010:	RETURN
;
;	ROUTINE TO UNLOCK JOB FROM CORE
;	CALLING SEQUENCE:	CALL LOCKE
;
LOCKE:	TLNN SW,LCK
	RETURN
	MOVE 17,[XWD 1,1]	;UNLOCK IT
	UNLOK. 17,
	JRST LR020
	TLZ SW,LCK
	PUSH PDP,CHAN	;TYPE MESSAGE
	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /[UNLOCKED]/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	POP PDP,CHAN
LR020:	RETURN
	SUBTTL DOLOG
;
;	ROUTINE TO LOG OPR ACTION IN QUE:OPR.LOG
;	CALLING SEQUENCE:	CALL DOLOG
;	INPUT PARAMETERS:	JOB
;	AC'S USED:		ALL
;
DOLOG:	SKIPN JOB
	JRST DL010
	HRL 17,JOB
	HRRI 17,.GTSTS
	GETTAB 17,
	NOTDEF
	TLNN 17,JNA
	JRST ER060
DL010:	IFN OPRLOG,<	;OPR LOG CONDITIONAL
	TLNN SW,PRV
	RETURN
	PUSH PDP,CHAN
	SETZM REPLY		;ASK WHY?
	TRNE SW,WHY
	TRNE SW,SPT
	JRST DL050
	TRZ SW,WHY
	MOVSI 17,WHY
	ANDCAM 17,CMDADR
	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /WHY: /]
	CALL OUTASC
	OUTPUT TTY,
	TLZ SW,RRD
	INPUT TTY,
	MOVEI 17,^D80
	MOVE 16,[POINT 7,REPLY]
DL030:	CALL NXCHAR
	JUMPE CHAR,DL040
	IDPB CHAR,16
	SOJG 17,DL030
DL040:	SETZ 17,
	IDPB 17,16
DL050:	MOVEI CHAN,LOG
	OPEN LOG,OPENL
	CALL OPCHK
	TRO SW,NFL
	MOVE 17,QUEPPN
	MOVEM 17,LOOKL+3
	TRO SW,ERI
	LOOKUP LOG,LOOKL
	CALL LKCHK
	TRZ SW,ERI+NFL
	MOVE 17,QUEPPN
	MOVEM 17,LOOKL+3
	ENTER LOG,LOOKL
	CALL LKCHK
	OUTPUT LOG,
	TRNN SW,NFL
	USETI LOG,-1
	DATE DAT,
	CALL OUTDAT
	MOVEI CHAR," "
	CALL OTCHAR
	MSTIME 16,
	IDIVI 16,^D1000
	MOVE TIM,16
	CALL OUTTIM
	MOVEI CHAR," "
	CALL OTCHAR
	TLNN SW,DB
	JRST DL060
	MOVEI ADR,[ASCIZ /DEBUG /]
	CALL OUTASC
DL060:	MOVEI ADR,COMAND
	CALL OUTASC
	SKIPN REPLY
	JRST DL070
	MOVEI ADR,[ASCIZ / ;/]
	CALL OUTASC
	MOVEI ADR,REPLY
	CALL OUTASC
DL070:	SKIPN JOB
	JRST DL080
	MOVEI ADR,[ASCIZ / - /]
	CALL OUTASC
	TDZ SW,[XWD FST+PRF,FND]
	TLO SW,SLW
	CALL WHO2
	TRNE SW,FND
	JRST DL090
	MOVEI ADR,[ASCIZ /NO ONE/]
	CALL OUTASC
DL080:	CALL OUTCR
DL090:	OUTPUT LOG,
	GETSTS LOG,STS
	CALL STSCHK
	RELEAS LOG,
	POP PDP,CHAN
	>
	RETURN
	SUBTTL CHKBAT
;
;	ROUTINE TO CHECK FOR MEDDLING WITH BATCH OR CONTROLLED JOBS
;	CALLING SEQUENCE:	CALL CHKBAT
;	INPUT PARAMETERS:	JOB
;	AC'S USED:		ALL
;
CHKBAT:	SKIPN 17,JOB		;IS JOB CONTROLLED?
	JRST CB020
	CTLJOB 17,
	  JRST CB020
	JUMPLE 17,CB020
	EXCH 17,JOB		;YES, SAVE JOB
	PUSH PDP,17
	PUSH PDP,CHAN		;TELL USER
	MOVEI CHAN,TTY
	CALL OUTCR
	MOVEI ADR,[ASCIZ /% WARNING: THIS JOB IS CONTROLLED BY:/]
	CALL OUTASC
	CALL OUTCR
	CALL OUTCR
	TDZ SW,[FST+SLW+PRF,FND]	;DO A WHO
	CALL WHO2
	TRNE SW,FND
	JRST CB010
	MOVEI ADR,[ASCIZ /NO ONE/]
	CALL OUTASC
	CALL OUTCR
CB010:	CALL OUTCR
	CALL SURE	;ASK FOR CONFIRMATION
	POP PDP,CHAN
	POP PDP,JOB
CB020:	RETURN
	SUBTTL KJOB
;
;	ROUTINE TO KILL A JOB
;	CALLING SEQUENCE:	CALL KJOB
;				ERROR RETURN
;	INPUT PARAMETERS:	JOB
;	AC'S USED:		ALL
;
KJOB:	MOVE 17,SYSSER		;TUFTS?
	CAIE 17,TUFSER
	JRST KJ050		;NO
	MOVE 17,JOB		;DETACHED JOB?
	TRMNO. 17,
	  JRST KJ050		;NO
KJ010:	HRLI 17,AT.MON		;YES, USE FORCED COMMAND
	CALL GETJOB
	MOVEI ADR,[ASCIZ /HALT/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	CALL RETJOB
KJ030:	MOVE 15,[XWD 2,16]
	MOVE 16,[SIXBIT /KJOB/]
	MOVE 17,JOB
	FRCUUO 15,
	  JRST KJ070
	MOVEI 17,^D60
KJ040:	HRL 16,JOB
	HRRI 16,.GTSTS
	GETTAB 16,
	  JRST KJ070
	TLNN 16,JRUN+JLOG
	JRST KJ060
	MOVEI 16,1
	SLEEP 16,
	SOJG 17,KJ040
	JRST KJ070
KJ050:	HRLI 17,AT.MON	;USE PTY
	CALL GETJOB
	MOVEI ADR,[ASCIZ /HALT/]
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	MOVEI ADR,KJOB1
	CALL OUTASC
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYUSR
	RELEAS PTY,
	HRL 17,JOB
	HRRI 17,.GTSTS
	GETTAB 17,
	  JRST KJ070
	TLNE 17,JNA
	  JRST KJ070
KJ060:	AOS (PDP)		;SUCCESS
KJ070:	RETURN			;RETURN
	SUBTTL JOB
;
;	ROUTINE TO CHECK A JOBS LINE STATUS
;	CALLING SEQUENCE:	CALL CHKJOB
;	INPUT PARAMETERS:	JOB
;	OUTPUT PARAMETERS:	AC 17 HOLDS ATTACH UUO DATA
;
CHKJOB:	MOVE 17,JOB
	TLO 17,AT.USR
	MOVN 16,JOB
	JOBSTS 16,
	NOTDEF
	TLNE 16,(JB.UML)
	TLC 17,AT.MON+AT.USR
	MOVE 16,JOB
	TRMNO. 16,
	JRST CJ010
	DPB 16,[POINT 7,17,17]
	JRST CJ020
CJ010:	SKIPE 16
	NOTDEF
	TLC 17,AT.MON+AT.USR
	TLO 17,AT.DET
CJ020:	RETURN
;
;	ROUTINE TO ATTACH A JOB TO A PTY
;	CALLING SEQUENCE:	CALL GETJOB
;	INPUT PARAMETERS:	JOB
;				AC 17 HOLDS ATTACH UUO DATA OR ZERO
;	OUTPUT PARAMETRS:	OLDLNE
;
GETJOB:	PUSH PDP,17
	OPEN PTY,OPENP
	JRST ER070
	OUTPUT PTY,
	MOVEI CHAN,PTY
	CALL OUTCR
	OUTPUT PTY,
	CALL PTYMON
	CALL CHKJOB
	MOVEM 17,OLDLNE
	MOVEI 17,PTY
	DEVNAM 17,
	NOTDEF
	LDB 16,[POINT 3,17,23]
	LDB 15,[POINT 6,17,29]
	JUMPE 15,GJ010
	ANDI 15,7
	LSH 16,3
	ADD 16,15
	LDB 15,[POINT 6,17,35]
	JUMPE 15,GJ010
	ANDI 15,7
	LSH 16,3
	ADD 16,15
GJ010:	ADD 16,PTYDSP
	MOVE 17,JOB
	HRL 17,16
	POP PDP,16
	TLNN 16,AT.MON+AT.USR
	MOVE 16,OLDLNE
	TLO 17,AT.MON
	TLNE 16,AT.USR
	TLC 17,AT.MON+AT.USR
	ATTACH 17,
	NOTDEF
	RETURN
;
;	ROUTINE TO ATTACH A JOB TO A LINE
;	CALLING SEQUENCE:	CALL PUTJOB
;	INPUT PARAMETERS:	AC 17 HOLDS ATTACH UUO DATA
;
PUTJOB:	TLNN 17,AT.DET
	JRST PJ010
	HRRZ 16,17
	TRMNO. 16,
	JRST PJ020
	HRLZ 17,16
PJ010:	ATTACH 17,
	NOTDEF
	RETURN
PJ020:	SKIPE 16
	NOTDEF
	RETURN
;
;	ROUTINE TO RETURN A JOB FROM A PTY
;	CALLING SEQUENCE:	CALL RETJOB
;	INPUT PARAMETERS:	JOB
;				OLDLNE
;
RETJOB:	CALL CHKJOB
	MOVE 16,OLDLNE
	TLZ 16,AT.USR
	TLO 16,AT.MON
	TLNE 17,AT.USR
	TLC 16,AT.MON+AT.USR
	MOVE 17,16
	CALL PUTJOB
	RELEAS PTY,
	RETURN
;
;	ROUTINE TO RETURN SPIRIT TO IT'S TTY
;	CALLING SEQUENCE:	CALL RTMJOB
;	INPUT PARAMETERS:	MYLINE
;
RTMJOB:	MOVE 17,MYLINE
	CALL PUTJOB
	RETURN
	SUBTTL PTY
;
;	ROUTINE TO WAIT FOR PTY JOB TO READ INPUT
;	CALL SEQUENCE:	CALL PTYWAT
;			ERROR RETURN
;
PTYWAT:	WAIT PTY,
	SETZM HBCNT
PW010:	MOVE 14,[XWD 3,15]
	MOVEI 15,.TOSIP
	MOVE 16,JOB
	TRMNO. 16,
	JRST PW030
	TRMOP. 14,
	JRST PW020
	CALL PTYHIB
	JRST PW030
	JRST PW010
PW020:	AOS (PDP)
PW030:	RETURN
;
;	ROUTINE TO READ OUTPUT FROM A PTY IN USER MODE
;	CALLING SEQUENCE:	CALL PTYUSR
;
PTYUSR:	SETZM HBCNT
PU010:	CALL PTYOUT
	TLNE 17,(JB.UDI)
	JRST PU020
	CALL PTYHIB
	JRST PU020
	JRST PU010
PU020:	RETURN
;
;	ROUTINE TO READ FROM A PTY IN MONITOR MODE
;	CALLING SEQUENCE:	CALL  PTYMON
;
PTYMON:	SETZM HBCNT
	TRO SW,POUT+PTL
	CALL PTYOUT
	TRZ SW,POUT+PTL
	RETURN
;
;	ROUTINE TO READ FROM A PTY IN ANY MODE (NOT AS FAILSAFE)
;	CALLING SEQUENCE:	CALL PTYALL
;
PTYALL:	SETZM HBCNT
	CALL PTYOUT
	RETURN
;
;	ROUTINE TO READ FROM A PTY
;	CALLING SEQUENCE:	CALL PTYOUT
;	INPUT PARAMETERS:	HBCNT
;				LOGDEV (IF LOGGING)
;				POUT (SW BIT)
;				PTL (SW BIT)
;	AC'S USED:		CHAN
;
PTYOUT:	MOVEI 17,PTY
	JOBSTS 17,
	NOTDEF
	TLNN 17,(JB.UOA)
	JRST PT020
	INPUT PTY,
	TRZ SW,POUT
	TDNN SW,[XWD DB,PLG]
	JRST PTYOUT
	PUSH PDP,CHAN
	SKIPN CHAN,LOGDEV
	MOVEI CHAN,TTY
PT010:	ILDB CHAR,PRNG+4
	CALL OTCHAR
	SOSLE PRNG+5
	JRST PT010
	CAIN CHAN,TTY
	OUTPUT TTY,
	POP PDP,CHAN
	JRST PTYOUT
PT020:	TRNN SW,POUT
	JRST PT030
	CALL PTYHIB
	JRST PT030
	JRST PTYOUT
PT030:	RETURN
;
;	ROUTINE TO HIBERNATE FOR PTY ACTIVITY
;	CALLING SEQUENCE:	CALL PTYHIB
;				ERROR RETURN
;	INPUT PARAMETERS:	HBCNT
;				PTL (SW BIT)
;
PTYHIB:	MOVE 16,[HB.RPT+^D1000]
	HIBER 16,
	NOTDEF
PH010:	AOS 16,HBCNT
	TRNE SW,PTL
	CAIG 16,^D60
	AOS (PDP)
	RETURN
	SUBTTL POKE
;
;	ROUTINE TO CHANGE A WORD IN THE MONITOR
;	CALLING SEQUENCE:	CALL POKE
;	INPUT PARAMETERS:	AC 16 HOLDS THE EXECUTIVE ADDRESS
;				AC 17 HOLDS THE NEW VALUE
;	OUTPUT PARAMETERS:	AC 17 HOLDS THE OLD VALUE
;
POKE:	MOVE 14,[XWD 3,15]
	MOVE 15,16
	PEEK 16,
	PUSH PDP,16
	POKE. 14,
	NOTDEF
	POP PDP,17
	RETURN
	SUBTTL DSPTCH
;
;	ROUTINE TO LOCATE SIXBIT ENTRY IN DISPATCH TABLE
;	CALLING SEQUENCE:	CALL DSPTCH
;	INPUT PARAMETERS:	SIX
;				ADR
;	OUTPUT PARAMETERS:	17 (-1 INDICATES ERROR)
;
DSPTCH:	SETZ 17,
	MOVE 16,ADR
DP010:	SKIPN (16)
	JRST DP050
	CAMN SIX,(16)
	JRST DP040
	MOVEI 15,6
	MOVE 14,[POINT 6,SIX]
	MOVE 13,[POINT 6,(16)]
DP020:	ILDB 12,14
	JUMPE 12,DP030
	ILDB 11,13
	CAME 11,12
	AOJA 16,DP010
	SOJG 15,DP020
DP030:	JUMPG 17,DP060
	MOVE 17,16
	AOJA 16,DP010
DP040:	MOVE 17,16
DP050:	JUMPE 17,DP060
	SUB 17,ADR
	RETURN
DP060:	SETO 17,	;ERROR
	RETURN
	SUBTTL SURE
;
;	ROUTINE TO ASK FOR CONFIRMATION
;	CALLING SEQUENCE:	CALL SURE
;	COMMAND SEQUENCE:	ARE YOU SURE? YES<CR>	OR
;				ARE YOU SURE? NO<CR>
;	AC'S USED:		ALL
;
SURE:	MOVEI CHAN,TTY
	MOVEI ADR,[ASCIZ /ARE YOU SURE? /]
	CALL OUTASC
	OUTPUT TTY,
	TLZ SW,RRD
	INPUT TTY,
	CALL INSIX
	JUMPE SIX,SURE
	CALL NXCHAR
	JUMPN CHAR,SURE
	LDB 17,[POINT 6,SIX,5]
	CAIE 17,'Y'
	JRST ERROR
	RETURN
	SUBTTL LIST
;
;	ROUTINE TO READ A FOO AND OPEN FOR LISTING
;	CALLING SEQUENCE:	CALL LIST
;				ERROR RETURN
;	OUTPUT PARAMETERS:	LST
;
LIST:	CALL INFOO	;READ A FOO
	JRST LT090
	MOVEM 17,LOOKF+3	;SET DEFAULTS
	MOVEM 16,LOOKF+2
	MOVEM 15,LOOKF+1
	MOVSI 17,'TTY'
	SKIPE 14
	MOVSI 17,'DSK'
	SKIPN 13
	MOVE 13,17
	MOVEM 13,OPENF+1
	SKIPN 14
	MOVSI 14,'OPR'
	MOVEM 14,LOOKF
	MOVE 17,OPENF+1	;TEST FOR TTY
	CAME 17,[SIXBIT /TTY/]
	JRST LT070
	MOVEI 17,TTY	;TTY
	JRST LT080
LT070:	TLNN SW,JLG	;NOT TTY
	JRST ER120
	OPEN LPT,OPENF
	CALL OPCHK
	ENTER LPT,LOOKF
	CALL LKCHK
	OUTPUT LPT,
	MOVEI 17,LPT
LT080:	MOVEM 17,LST	;REMEMBER CHANNEL
	AOS (PDP)	;SKIP RETURN
LT090:	RETURN		;FINISHED
;
;	ROUTINE TO CLOSE FOO
;	CALLING SEQUENCE:	CALL LISTE
;	INPUT PARAMETERS:	LST
;
LISTE:	MOVE 17,LST	;TEST FOR TTY
	CAIE 17,TTY
	JRST LT100
	OUTPUT TTY,	;TTY
	JRST LT110
LT100:	OUTPUT LPT,	;NOT TTY
	GETSTS LPT,STS
	CALL STSCHK
	RELEAS LPT,
LT110:	RETURN
	SUBTTL SAVACS
;
;	ROUTINE TO SAVE/RESTORE ALL AC'S (EXCEPT PDP)
;	CALLING SEQUENCE:	CALL SAVACS
;	AC'S USED:		NONE
;
SAVACS:	ADD PDP,[XWD 21,21]
	SKIPL PDP
	HALT ERROR
	EXCH 0,-21(PDP)
	MOVEM 0,(PDP)
	HRLI 0,1
	HRRI 0,-20(PDP)
	BLT 0,-2(PDP)
	MOVEI 0,SV010
	MOVEM 0,-1(PDP)
	MOVE 0,-21(PDP)
	RETURN
SV010:	HRLI 0,-16(PDP)
	HRRI 0,1
	BLT 0,17
	MOVE 0,-21(PDP)
	SUB PDP,[XWD 22,22]
	RETURN
	SUBTTL NXCHAR
;
;	ROUTINE TO FETCH A CHARACTOR FROM AN INPUT CHANNEL
;	CALLING SEQUENCE:	CALL NXCHAR
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	CHAR (ZERO INDICATES EOR OR EOF)
;	AC'S USED:		RNG ONLY
;
NXCHAR:	TLZE SW,RRD
	RETURN
	TRNE SW,FCM
	JRST NX010
	MOVE RNG,RNGTAB(CHAN)	;LINE MODE
	SKIPG 5(RNG)
	JRST NX030
	ILDB CHAR,4(RNG)
	SOS 5(RNG)
	CAIL CHAR,"a"
	CAILE CHAR,"z"
	SKIPA
	SUBI CHAR,"a"-"A"
	CAIN CHAR,33
	JRST NX030
	CAIN CHAR,15
	JRST NXCHAR
	CAIN CHAR,12
	JRST NX030
	CAIN CHAR,14
	JRST NX030
	CAIE CHAR,03
	JRST NX040
	CALL EXIT1
	JRST ERROR
NX010:	MOVE RNG,RNGTAB(CHAN)	;FULL CHARACTER MODE
	SKIPLE 5(RNG)
	JRST NX020
	CALL SCHAN
	INPUT 0,
	XCT INS
	CALL SCHAN
	GETSTS 0,STS
	XCT INS
	CALL STSCHK
	TRNE STS,IO.EOF
	JRST NX030
NX020:	ILDB CHAR,4(RNG)
	SOS 5(RNG)
	JUMPE CHAR,NX010
	JRST NX040
NX030:	SETZ CHAR,	;EOR OR EOF
NX040:	RETURN
	SUBTTL OTCHAR
;
;	ROUTINE TO OUTPUT A CHARACTOR TO AN OUTPUT CHANNEL
;	CALLING SEQUENCE:	CALL OTCHAR
;	INPUT PARAMETERS:	CHAN
;				CHAR
;				LOGDEV (IF PTY LOGGING)
;	AC'S USED:		RNG
;				STS
;				INS
;
OTCHAR:	CAIE CHAN,PTY	;TEST FOR PTY
	JRST OT010
	TDNN SW,[XWD DB,PLG]
	JRST OT030
	PUSH PDP,CHAN
	SKIPN CHAN,LOGDEV
	MOVEI CHAN,TTY
	CALL OT010
	POP PDP,CHAN
	JRST OT030
OT010:	TRNE CHAR,140	;TEST FOR CTRL CHAR
	JRST OT030
	JUMPE CHAR,OT030	;<NULL>
	CAIGE CHAR,007	;<BELL>
	JRST OT020
	CAIG CHAR,015	;<CR>
	JRST OT030
OT020:	PUSH PDP,CHAR	;ARROW MODE
	MOVEI CHAR,"^"
	CALL OT030
	MOVE CHAR,(PDP)
	TRO CHAR,100
	CALL OT030
	POP PDP,CHAR
	RETURN
OT030:	MOVE RNG,RNGTAB(CHAN)	;OUTPUT CHAR
	IDPB CHAR,1(RNG)
	AOS TABPOS
	SOSLE 2(RNG)
	RETURN
	CALL SCHAN
	OUTPUT 0,
	XCT INS
	CALL SCHAN
	GETSTS 0,STS
	XCT INS
	CALL STSCHK
	RETURN
	SUBTTL SCHAN
;
;	ROUTINE TO SET UP AN INSTRUCTION FOR A CHANNEL
;	CALLING SEQUENCE:	CALL SCHAN
;				INSTRUCTION
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	INS
;	AC'S USED:		NONE
;
SCHAN:	MOVE INS,@(PDP)
	DPB CHAN,SH900
	AOS (PDP)
	RETURN
;
SH900:	POINT 4,INS,12
	SUBTTL TAB
;
;	ROUTINE TO TAB ON AN OUTPUT CHANNEL
;	CALLING SEQUENCE:	CALL TAB
;				^DNN
;	INPUT PARAMETERS:	CHAN
;				TABPOS (ZEROED AT BEGINNING OF LINE)
;
TAB:	MOVE 17,@(PDP)	;SETUP
	SUB 17,TABPOS
	SUBI 17,1
	MOVEI CHAR," "
	CALL OTCHAR
	SOJG 17,.-1
	AOS (PDP)
	RETURN
;
;	ROUTINE TO SPACE OR GO TO THE NEXT LINE ON AN OUTPUT CHANNEL
;	CALLING SEQUENCE:	CALL TABW
;	INPUT PARAMETERS:	CHAN
;				TABPOS (ZEROED AT BEGINNING OF LINE)
;
TABW:	MOVE 17,TABPOS		;DISPATCH
	CAIL 17,^D<80-20>
	JRST TB010
	MOVEI CHAR," "
	CALL OTCHAR
	JRST TB020
TB010:	CALL OUTCR
	SETZM TABPOS
	MOVEI ADR,[ASCIZ /     /]
	CALL OUTASC
TB020:	RETURN
	SUBTTL INSP
;
;	ROUTINE TO SKIP TO THE NEXT NON-BLANK CHARACTOR
;	CALLING SEQUENCE:	CALL INSP
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	AC 17 HOLDS LAST BLANK OR ZERO
;
INSP:	SETZ 17,
	SKIPA
IB010:	MOVE 17,CHAR
	CALL NXCHAR
	CAIN CHAR," "
	JRST IB010
	CAIN CHAR,"	"
	JRST IB010
	TLO SW,RRD
	RETURN
	SUBTTL INOCT
;
;	ROUTINE TO INPUT AN OCTAL NUMBER
;	CALLING SEQUENCE:	CALL INOCT
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	OCT
;
INOCT:	SETZ 16,	;SETUP
IN010:	CALL NXCHAR	;TEST CHAR
	CAIGE CHAR,"0"
	JRST IN020
	CAILE CHAR,"7"
	JRST IN020
	SUBI CHAR,"0"
	MOVE 17,CHAR
	LSH 17,^D33
	LSHC 16,3
	JRST IN010
IN020:	MOVE OCT,16	;EOF
	TLO SW,RRD
	RETURN
	SUBTTL INSIX
;
;	ROUTINE TO INPUT A SIXBIT WORD (ALPHANUMERIC CHARACTER SET ONLY)
;	CALLING SEQUENCE:	CALL INSIX
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	SIX
;
INSIX:	SETZ SIX,	;SETUP
	MOVEI 17,6
	MOVE 16,[POINT 6,SIX]
IS010:	CALL NXCHAR	;TEST CHAR
	CAIGE CHAR,"A"
	JRST IS020
	CAIG CHAR,"Z"
	JRST IS030
IS020:	CAIGE CHAR,"0"
	JRST IS040
	CAILE CHAR,"9"
	JRST IS040
IS030:	JUMPE 17,IS010	;GOOD CHAR
	SUBI CHAR,40
	IDPB CHAR,16
	SOJA 17,IS010
IS040:	TLO SW,RRD	;EOF
	RETURN
	SUBTTL INFSX
;
;	ROUTINE TO INPUT A SIXBIT WORD (FULL SIXBIT CHARACTER SET)
;	CALLING SEQUENCE:	CALL INFSX
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	SIX
;
INFSX:	SETZ SIX,	;SETUP
	MOVEI 17,6
	MOVE 16,[POINT 6,SIX]
IF010:	CALL NXCHAR	;TEST CHAR
	CAIL CHAR,40
	CAILE CHAR,137
	JRST IF030
	CAIN CHAR,","
	JRST IF030
	CAIN CHAR," "
	JRST IF030
	CAIN CHAR,"/"
	JRST IF030
IF020:	JUMPE 17,IF010	;GOOD CHAR
	SUBI CHAR,40
	IDPB CHAR,16
	SOJA 17,IF010
IF030:	TLO SW,RRD	;EOF
	RETURN
	SUBTTL INDEC
;
;	ROUTINE TO INPUT A DECIMAL NUMBER
;	CALLING SEQUENCE:	CALL INDEC
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	DEC
;
INDEC:	MOVEI 17,^D11	;SETUP
	SETZ DEC,
ID010:	CALL NXCHAR	;TEST CHAR
	CAIGE CHAR,"0"
	JRST ID020
	CAILE CHAR,"9"
	JRST ID020
	SUBI CHAR,"0"
	IMULI DEC,^D10
	ADD DEC,CHAR
	SOJG 17,ID010
ID020:	TLO SW,RRD	;EOF
	RETURN
	SUBTTL INJOB
;
;	ROUTINE TO INPUT A JOB NUMBER
;	CALLING SEQUENCE:	CALL INJOB
;				ERROR RETURN
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	JOB
;				LSTJOB
;
INJOB:	CALL NXCHAR
	CAIN CHAR,"."
	JRST IJ010
	TLO SW,RRD
	CALL INDEC
	JUMPE DEC,IJ030
	MOVEM DEC,JOB
	MOVEM DEC,LSTJOB
	JRST IJ020
IJ010:	SKIPN 17,LSTJOB
	JRST ER170
	MOVEM 17,JOB
IJ020:	AOS (PDP)			;SKIP RETURN
IJ030:	RETURN
	SUBTTL INDAT
;
;	ROUTINE TO INPUT A DATE (DD-MMM-YY)
;	CALLING SEQUENCE:	CALL INDAT
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	DAT (ZERO INDICATES ERROR)
;	AC'S USED:		DEC
;
INDAT:	CALL INDEC
	JUMPE DEC,IY070
	CAILE DEC,^D31
	JRST IY070
	SUBI DEC,1
	PUSH PDP,DEC
	CALL NXCHAR
	CAIN CHAR,"-"
	JRST IY010
	CAIE CHAR," "
	JRST IY060
IY010:	CALL INSIX
	MOVEI 17,^D12
IY020:	MOVE 16,IY900-1(17)
	CAMN SIX,16
	JRST IY030
	SOJG 17,IY020
	JRST IY060
IY030:	SUBI 17,1
	PUSH PDP,17
	CALL NXCHAR
	CAIN CHAR,"-"
	JRST IY040
	CAIE CHAR," "
	JRST IY050
IY040:	CALL INDEC
	JUMPE DEC,IY050
	CAILE DEC,^D99
	JRST IY050
	SUBI DEC,^D64
	MOVE 17,DEC
	IMULI 17,^D12
	POP PDP,16
	ADD 17,16
	IMULI 17,^D31
	POP PDP,16
	ADD 17,16
	MOVE DAT,17
	RETURN
IY050:	POP PDP,17
IY060:	POP PDP,17
IY070:	SETZ DAT,
	RETURN
;
IY900:	SIXBIT /JAN/
	SIXBIT /FEB/
	SIXBIT /MAR/
	SIXBIT /APR/
	SIXBIT /MAY/
	SIXBIT /JUN/
	SIXBIT /JUL/
	SIXBIT /AUG/
	SIXBIT /SEP/
	SIXBIT /OCT/
	SIXBIT /NOV/
	SIXBIT /DEC/
	SUBTTL INTIM
;
;	ROUTINE TO INPUT A TIME (HHMMSS OR HH:MM:SS)
;	CALLING SEQUENCE:	CALL INTIM
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	TIM (SECONDS)
;	AC'S USED:		DEC
;
INTIM:	CALL INDEC
	CALL NXCHAR
	CAIE CHAR,":"
	JRST IT020
	PUSH PDP,DEC	;WITH COLONS
	CALL INDEC
	CALL NXCHAR
	CAIN CHAR,":"
	JRST IT010
	TLO SW,RRD	;MM:SS
	SETZ 15,
	POP PDP,16
	MOVE 17,DEC
	JRST IT030
IT010:	PUSH PDP,DEC	;HH:MM:SS
	CALL INDEC
	MOVE 17,DEC
	POP PDP,16
	POP PDP,15
	JRST IT030
IT020:	TLO SW,RRD	;WITHOUT COLONS
	MOVE 15,DEC
	IDIVI 15,^D<100*100>
	IDIVI 16,^D100
IT030:	IMULI 15,^D<60*60>
	IMULI 16,^D60
	ADD 17,15
	ADD 17,16
	MOVE TIM,17
	RETURN
	SUBTTL INAFT
;
;	ROUTINE TO INPUT AFTER TIME (+HHMM OR HHMM)
;	CALLING SEQUENCE:	CALL INAFT
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	17 (PLUS MINUTES)
;	AC'S USED:		DEC
;
INAFT:	CALL NXCHAR
	PUSH PDP,CHAR
	CAIE CHAR,"+"
	TLO SW,RRD
	CALL INDEC
	CALL NXCHAR
	CAIN CHAR,":"
	JRST IA010
	TLO SW,RRD	;WITHOUT COLON
	MOVE 16,DEC
	IDIVI 16,^D100
	IMULI 16,^D60
	ADD 17,16
	JRST IA020
IA010:	PUSH PDP,DEC	;WITH COLON
	CALL INDEC
	POP PDP,17
	IMULI 17,^D60
	ADD 17,DEC
IA020:	POP PDP,16
	CAIN 16,"+"
	JRST IA030
	MSTIME 15,	;WITHOUT PLUS
	IDIVI 15,^D<60*1000>
	SUB 17,15
	SKIPG 17
	ADDI 17,^D<24*60>
IA030:	RETURN
	SUBTTL INFOO
;
;	ROUTINE TO INPUT A FOO (DEV:FILE.EXT<PROT>[P,PN])
;	CALLING SEQUENCE:	CALL INFOO
;				ERROR RETURN (NOT A FOO)
;	INPUT PARAMETERS:	CHAN
;	OUTPUT PARAMETERS:	13 (DEVICE)
;				14 (FILE)
;				15 (EXT)
;				16 (PROT)
;				17 (PPN)
;	AC'S USED:		OCT
;				SIX
;
INFOO:	SETZ 17,	;SETUP
	PUSH PDP,17
	PUSH PDP,17
	PUSH PDP,17
	PUSH PDP,17
	PUSH PDP,17
IO010:	CALL INSP	;SEARCH FOR FILES
	CALL NXCHAR
	CAIN CHAR,":"
	JRST IO020
	CAIN CHAR,"."
	JRST IO030
	CAIN CHAR,"<"
	JRST IO040
	CAIN CHAR,"["
	JRST IO050
	TLO SW,RRD	;FILE
	CALL INSIX
	JUMPE SIX,IO060
	SKIPE -1(PDP)
	JRST IO070
	MOVEM SIX,-1(PDP)
	JRST IO010
IO020:	SKIPE SIX,-1(PDP)	;DEVICE
	SKIPE 0(PDP)
	JRST IO070
	MOVEM SIX,0(PDP)
	SETZM -1(PDP)
	JRST IO010
IO030:	SKIPE -2(PDP)	;EXTENSION
	JRST IO070
	CALL INSIX
	JUMPE SIX,IO070
	HLLZM SIX,-2(PDP)
	JRST IO010
IO040:	SKIPE -3(PDP)	;PROTECTION
	JRST IO070
	CALL INOCT
	CALL NXCHAR
	CAIE CHAR,">"
	JRST IO070
	DPB OCT,[POINT 9,-3(PDP),8]
	JRST IO010
IO050:	SKIPE -4(PDP)	;PPN
	JRST IO070
	CALL INOCT
	JUMPE OCT,IO070
	HRLM OCT,-4(PDP)
	CALL NXCHAR
	CAIE CHAR,","
	JRST IO070
	CALL INOCT
	JUMPE OCT,IO070
	HRRM OCT,-4(PDP)
	CALL NXCHAR
	CAIE CHAR,"]"
	JRST IO070
	JRST IO010
IO060:	TLO SW,RRD	;EOF
	AOS -5(PDP)	;SKIP RETURN
IO070:	POP PDP,13	;RETURN FOO
	POP PDP,14
	POP PDP,15
	POP PDP,16
	POP PDP,17
	RETURN
	SUBTTL INCR
;
;	ROUTINE TO INPUT AN END OF LINE SEQUENCE
;	CALLING SEQUENCE:	CALL INCR
;				ERROR RETURN (NOT EOL)
;	INPUT PARAMETERS:	CHAN
;	AC'S USED:		CHAR
;
INCR:	CALL INSP
	CALL NXCHAR
	JUMPE CHAR,IC040
	CAIN CHAR,";"
	JRST IC020
	CAIN CHAR,","
	JRST IC030
IC010:	TLO SW,RRD	;NOT AN EOL
	RETURN
IC020:	CALL NXCHAR	;A COMMENT
	JUMPN CHAR,IC020
	TRZ SW,WHY
	JRST IC040
IC030:	TRO SW,AGN	;A COMMA
IC040:	AOS (PDP)	;AN EOL
	RETURN
	SUBTTL OUTASC
;
;	ROUTINE TO OUTPUT AN ASCIZ STRING
;	CALLING SEQUENCE:	CALL OUTASC
;	INPUT PARAMETERS:	CHAN
;				ADR
;
OUTASC:	MOVE 17,ADR
	HLL 17,OA900
OA010:	ILDB CHAR,17
	JUMPE CHAR,OA020
	CALL OTCHAR
	JRST OA010
OA020:	RETURN
;
OA900:	POINT 7,0
	SUBTTL OUTOCT
;
;	ROUTINE TO OUTPUT AN OCTAL NUMBER
;	CALLING SEQUENCE:	CALL OUTOCT
;	INPUT PARAMETERS:	CHAN
;				OCT
;
OUTOCT:	JUMPE OCT,ON040
	SETZ 17,	;SETUP
	MOVEI 16,^D12
	MOVE 15,OCT
ON010:	SETZ 14,	;OUTPUT CHAR
	LSHC 14,3
	JUMPN 14,ON020
	JUMPE 17,ON030
ON020:	SETO 17,
	ADDI 14,"0"
	MOVE CHAR,14
	CALL OTCHAR
ON030:	SOJG 16,ON010
	RETURN
ON040:	MOVEI CHAR,"0"
	CALL OTCHAR
	RETURN
	SUBTTL OUTSIX
;
;	ROUTINE TO OUTPUT A SIXBIT WORD
;	CALLING SEQUENCE:	CALL OUTSIX
;	INPUT PARAMETERS:	CHAN
;				SIX
;
OUTSIX:	MOVEI 17,6	;SETUP
	MOVE 16,[POINT 6,SIX]
	SETZ 15,
OS010:	ILDB CHAR,16	;OUTPUT CHAR
	CAIN CHAR,' '
	AOJA 15,OS040
	JUMPLE 15,OS030
	PUSH PDP,CHAR
OS020:	MOVEI CHAR," "
	CALL OTCHAR
	SOJG 15,OS020
	POP PDP,CHAR
OS030:	ADDI CHAR,40
	CALL OTCHAR
OS040:	SOJG 17,OS010
	RETURN
	SUBTTL OUTPUT DECIMAL ROUTINES
;
;	ROUTINE TO OUTPUT A DECIMAL NUMBER
;	CALLING SEQUENCE:	CALL OUTDEC
;	INPUT PARAMETERS:	CHAN
;				DEC
;
OUTDEC:	JUMPE DEC,OD050	;SETUP
	SETZ 17,
	MOVE 15,DEC
OD010:	IDIVI 15,^D10	;PUSH DOWN CHARS
	PUSH PDP,16
	JUMPE 15,OD020
	AOJA 17,OD010
OD020:	SETZ 16,
OD030:	POP PDP,CHAR	;POP AND OUTPUT CHARS
	SKIPN 16
	JUMPE CHAR,OD040
	SETO 16,
	ADDI CHAR,"0"
	CALL OTCHAR
OD040:	SOJGE 17,OD030
	RETURN
OD050:	MOVEI CHAR,"0"
	CALL OTCHAR
	RETURN
;
;	ROUTINE TO OUTPUT A TWO DIGIT DECIMAL NUMBER
;	CALLING SEQUENCE:	CALL OUTTDC
;	INPUT PARAMETERS:	CHAN
;				DEC
;
OUTTDC:	MOVE 16,DEC
	IDIVI 16,^D10
	ADDI 16,"0"
	MOVE CHAR,16
	CALL OTCHAR
	ADDI 17,"0"
	MOVE CHAR,17
	CALL OTCHAR
	RETURN
;
;	ROUTINE TO OUTPUT A DECIMAL NUMBER SCALED BY ONE HUNDRED
;				WITH TWO DECIMAL PLACES
;	CALLING SEQUENCE:	CALL OUTPDC
;	INPUT PARAMETERS:	CHAN
;				DEC
;
OUTPDC:	MOVE 16,DEC
	IDIVI 16,^D100
	PUSH PDP,17
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,"."
	CALL OTCHAR
	POP PDP,DEC
	CALL OUTTDC
	RETURN
	SUBTTL OUTDAT
;
;	ROUTINE TO OUTPUT A DATE
;	CALLING SEQUENCE:	CALL OUTDAT
;	INPUT PARAMETERS:	CHAN
;				DAT
;	AC'S USED:		DEC
;				ADR
;
OUTDAT:	MOVE 16,DAT
	IDIVI 16,^D31
	ADDI 17,1
	MOVEM 17,DEC
	IDIVI 16,^D12
	ADDI 16,^D64
	PUSH PDP,16
	PUSH PDP,17
	CALL OUTDEC
	MOVEI CHAR,"-"
	CALL OTCHAR
	POP PDP,17
	MOVEI ADR,OY900(17)
	CALL OUTASC
	MOVEI CHAR,"-"
	CALL OTCHAR
	POP PDP,DEC
	CALL OUTDEC
	RETURN
;
OY900:	ASCII /JAN/
	ASCII /FEB/
	ASCII /MAR/
	ASCII /APR/
	ASCII /MAY/
	ASCII /JUN/
	ASCII /JUL/
	ASCII /AUG/
	ASCII /SEP/
	ASCII /OCT/
	ASCII /NOV/
	ASCII /DEC/
	SUBTTL OUTTIM
;
;	ROUTINE TO OUTPUT A TIME
;	CALLING SEQUENCE:	CALL OUTTIM
;	INPUT PARAMETERS:	CHAN
;				TIM (IN SECONDS)
;	AC'S USED:		DEC
;
OUTTIM:	MOVE 16,TIM
	IDIVI 16,^D60
	PUSH PDP,17
	IDIVI 16,^D60
	PUSH PDP,17
	MOVE DEC,16
	CALL OUTDEC
	MOVEI CHAR,":"
	CALL OTCHAR
	POP PDP,DEC
	CALL OUTTDC
	MOVEI CHAR,":"
	CALL OTCHAR
	POP PDP,DEC
	CALL OUTTDC
	RETURN
	SUBTTL OUTLNE
;
;	ROUTINE TO OUTPUT A LINE NAME
;	CALLING SEQUENCE:	CALL OUTLNE
;	INPUT PARAMETERS:	CHAN
;				LINE
;	AC'S USED:		ADR
;				OCT
;
OUTLNE:	MOVE 17,LINE
	JUMPL 17,OL020
	TRZ 17,600000
	CAMN 17,CTYLNE
	JRST OL010
	CAML 17,PTYDSP
	JRST OL030
	MOVEM 17,OCT
	MOVEI ADR,[ASCIZ /TTY/]
	CALL OUTASC
	CALL OUTOCT
	RETURN
OL010:	MOVEI ADR,[ASCIZ /CTY/]
	CALL OUTASC
	RETURN
OL020:	MOVEI ADR,[ASCIZ /DET/]
	CALL OUTASC
	RETURN
OL030:	SUB 17,PTYDSP
	MOVEM 17,OCT
	MOVEI ADR,[ASCIZ /PTY/]
	CALL OUTASC
	CALL OUTOCT
	RETURN
	SUBTTL OUTCR
;
;	ROUTINE TO OUTPUT A <CR><LF>
;	CALLING SEQUENCE:	CALL OUTCR
;	INPUT PARAMETERS:	CHAN
;	AC'S USED:		ADR
;
OUTCR:	MOVEI ADR,OR900
	CALL OUTASC
	RETURN
;
OR900:	BYTE (7) 15,12
	SUBTTL OPCHK
;
;	ROUTINE TO PROCESS OPEN FAILURE
;	CALLING SEQUENCE:	OPEN CHAN,SPEC
;				CALL OPCHK
;
OPCHK:	CALL CSET	;DEV NOT AVAIL
	MOVEI ADR,OP900
	CALL OUTASC
	MOVE 17,(PDP)
	MOVE 16,-2(17)
	MOVE SIX,1(16)
	CALL OUTSIX
	MOVEI ADR,OP910
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST ERROR
;
OP900:	ASCIZ /? /
OP910:	ASCIZ /: NOT AVAILABLE/
	SUBTTL LKCHK
;
;	ROUTINE TO PROCESS LOOKUP OR ENTER FAILURE
;	CALLING SEQUENCE:	LOOKUP CHAN,SPEC
;				CALL LKCHK		OR
;				ENTER CHAN,SPEC
;				CALL LKCHK
;	OUTPUT PARAMETERS:	LERR
;	AC'S USED:		RNG
;
LKCHK:	MOVE RNG,(PDP)
	MOVE RNG,-2(RNG)
	HRRZ 17,1(RNG)
	MOVEM 17,LERR
	CAIN 17,3
	JRST LK040
	CAIN 17,16
	JRST LK040
	TRZE SW,ERI
	JUMPE 17,LK050
LK010:	TRNE SW,SPT
	TLNE SW,DB
	SKIPA
	JRST SPTREE
	CALL CSET
	MOVEI ADR,LK900
	CALL OUTASC
	MOVE OCT,LERR
	CALL OUTOCT
	MOVEI ADR,LK910
	CALL OUTASC
	MOVE 17,(PDP)
	LDB SIX,LK990
	DEVNAM SIX,
	MOVE SIX,LK920
	CALL OUTSIX
	MOVE 17,LERR
	CAIN 17,6
	JRST LK060
	CAIN 17,14
	JRST LK070
LK020:	MOVEI CHAR,":"
	CALL OTCHAR
	MOVE 17,(PDP)
	MOVE 16,-2(17)
	MOVE SIX,0(16)
	CALL OUTSIX
	MOVE 17,(PDP)
	MOVE 16,-2(17)
	HLLZ SIX,1(16)
	JUMPE SIX,LK030
	MOVEI CHAR,"."
	CALL OTCHAR
	CALL OUTSIX
LK030:	SETZ 17,
	MOVE 16,LERR
	CAIN 16,0
	MOVEI 17,1
	CAIN 16,1
	MOVEI 17,1
	CAIN 16,24
	MOVEI 17,1
	CAIN 16,26
	MOVEI 17,1
	CAIN 16,2
	MOVEI 17,2
	CAIN 16,15
	MOVEI 17,2
	MOVE ADR,LK930(17)
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST ERROR
LK040:	MOVEI RNG,1	;RETRY
	SLEEP RNG,
	SOS (PDP)
	SOS (PDP)
	RETURN
LK050:	AOS (PDP)	;SKIP RETURN
	RETURN
LK060:	MOVEI ADR,LK970	;DATA ERROR ON RIB OR UFD
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST ERROR
LK070:	MOVEI ADR,LK980	;QUOTA EXCEEDED
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST ERROR
;
LK900:	ASCIZ /? (/
LK910:	ASCIZ /) /
LK920:	SIXBIT /DSK/
LK930:	LK940
	LK950
	LK960
LK940:	ASCIZ / LOOKUP FAILURE/
LK950:	ASCIZ / NOT FOUND/
LK960:	ASCIZ / PROTECTION FAILURE/
LK970:	ASCIZ /: DATA ERROR ON RIB OR UFD/
LK980:	ASCIZ /: QUOTA EXCEEDED/
LK990:	POINT 4,-2(17),12
	SUBTTL STSCHK
;
;	ROUTINE TO TEST STATUS BITS
;	CALLING SEQUENCE:	GETSTS CHAN,STS
;				CALL STSCHK
;
STSCHK:	TRNN STS,740000	;IN/OUT CHECK
	RETURN
ST010:	TRNE SW,SPT
	TLNE SW,DB
	SKIPA
	JRST SPTREE
	CALL CSET
	MOVEI ADR,ST900
	CALL OUTASC
	MOVE OCT,STS
	CALL OUTOCT
	MOVEI ADR,ST910
	CALL OUTASC
	MOVE 17,(PDP)
	LDB SIX,ST950
	DEVNAM SIX,
	MOVE SIX,ST920
	CALL OUTSIX
	TRNE STS,040000
	JRST ST030
ST020:	MOVEI ADR,ST930	;IN-OUT ERROR
	SKIPA
ST030:	MOVEI ADR,ST940	;QUOTA EXCEEDED
	CALL OUTASC
	CALL OUTCR
	OUTPUT TTY,
	JRST EXIT0
;
ST900:	ASCIZ /? (/
ST910:	ASCIZ /) /
ST920:	SIXBIT /DSK/
ST930:	ASCIZ /: IN-OUT ERROR/
ST940:	ASCIZ /: QUOTA EXCEEDED/
ST950:	POINT 4,-2(17),12
	SUBTTL END
;
	END INITL