Google
 

Trailing-Edge - PDP-10 Archives - BB-D348F-SM - exec/exec0.mac
There are 47 other files named exec0.mac in the archive. Click here to see a list.
;<4.EXEC>EXEC0.MAC.257,  3-Jan-80 16:09:00, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<4.EXEC>EXEC0.MAC.255,  9-Oct-79 15:34:37, Edit by LCAMPBELL
; Cosmetic fix to "foreign host" typeout in SYSTAT
;<4.EXEC>EXEC0.MAC.254,  9-Oct-79 15:26:36, EDIT BY OSMAN
;MORE 4.2500 - FIX COMND INSTEAD OF EXEC!
;<4.EXEC>EXEC0.MAC.253,  8-Oct-79 15:29:36, EDIT BY OSMAN
;REMOVE LIST COMMAND
;<4.EXEC>EXEC0.MAC.252, 28-Sep-79 08:47:50, EDIT BY OSMAN
;tco 4.2500 - Fix "DEFINE DBELL: DSK:" , "SYSTAT DBELL:" (when user DBELL
;exists)
;<4.EXEC>EXEC0.MAC.251, 14-Sep-79 17:12:51, Edit by HESS
; Make program name print for Infor Version (XTND only)
;<4.EXEC>EXEC0.MAC.250, 14-Sep-79 08:53:02, EDIT BY OSMAN
;No need for JFNSTK at CIN3 anymore, since done in FIELD
;<4.EXEC>EXEC0.MAC.249, 13-Sep-79 18:41:41, Edit by LCAMPBELL
; Correct output of host numbers when no name exists in SYSTAT
;<4.EXEC>EXEC0.MAC.248, 12-Sep-79 15:36:11, Edit by HESS
; Re-arrange invocation of MESMES for "set no login-mail" (XTND only)
;<4.EXEC>EXEC0.MAC.246, 10-Sep-79 14:36:11, EDIT BY OSMAN
;more of 4.2401 - Make sure that if not printing herald, CINITF and DOATI still happen
;<4.EXEC>EXEC0.MAC.244,  6-Sep-79 11:06:17, EDIT BY OSMAN
;tco 4.2444 - Make TERM INDICATE and TERM FORM be independent!!
;<4.EXEC>EXEC0.MAC.243, 31-Aug-79 14:28:27, Edit by LCAMPBELL
;<4.EXEC>EXEC0.MAC.242, 31-Aug-79 11:07:16, Edit by LCAMPBELL
; Get columns to line up when typing foreign host name
;<4.EXEC>EXEC0.MAC.241, 30-Aug-79 18:12:45, Edit by LCAMPBELL
;<4.EXEC>EXEC0.MAC.240, 30-Aug-79 17:56:06, Edit by LCAMPBELL
;<4.EXEC>EXEC0.MAC.239, 30-Aug-79 16:45:02, Edit by LCAMPBELL
;<4.EXEC>EXEC0.MAC.238, 30-Aug-79 16:12:07, Edit by LCAMPBELL
;<4.EXEC>EXEC0.MAC.237, 30-Aug-79 15:00:48, Edit by LCAMPBELL
; Type foreign host on SYSTAT line for ARPANET systems
;<4.EXEC>EXEC0.MAC.236, 28-Aug-79 17:44:49, Edit by HESS
;<4.EXEC>EXEC0.MAC.235, 28-Aug-79 15:53:26, Edit by HESS
;<HESS.E>EXEC0.MAC.31, 19-Aug-79 23:02:09, Edit by HESS
; Added extended features
;<4.EXEC>EXEC0.MAC.233, 15-Aug-79 16:37:45, EDIT BY OSMAN
;tco 4.2401 - Enable ^C later
;<4.EXEC>EXEC0.MAC.232, 15-Aug-79 11:07:42, EDIT BY OSMAN
;tco 4.2399 - Use CMERRX instead of ERROR on "Unrecognized command"
;<4.EXEC>EXEC0.MAC.227, 24-Jul-79 13:39:37, EDIT BY OSMAN
;tco 4.2338 - print 0.00 instead of .00 for tiny numbers
;tco 4.2317 - Don't lose ^T or IPCF interrupts
;<4.EXEC>EXEC0.MAC.226, 29-Jun-79 13:48:53, EDIT BY OSMAN
;DON'T LOSE IPCF INTERRUPT
;<4.EXEC>EXEC0.MAC.225, 29-Jun-79 12:44:47, EDIT BY OSMAN
;tco 4.2315 - Call LTTYMD at cold start in order to make ^V invisible
;<4.EXEC>EXEC0.MAC.224, 14-Jun-79 10:45:58, EDIT BY OSMAN
;tco 4.2286 - Use ETYPE instead of TYPE for failing system message lookup
;<4.EXEC>EXEC0.MAC.223,  6-Jun-79 10:46:54, EDIT BY HELLIWELL
;REMOVE NOSHIP VERSION OF "PUNCH" COMMAND
;<4.EXEC>EXEC0.MAC.222,  6-Jun-79 10:41:01, EDIT BY HELLIWELL
;REMOVE "UNMOUNT" COMMAND (NOSHIP)
;<4.EXEC>EXEC0.MAC.221,  1-Jun-79 13:44:17, Edit by OSMAN
;tco 4.2267 - prevent "COPY TTY:$" from typing "MAIL"
;<4.EXEC>EXEC0.MAC.220, 15-May-79 13:23:19, EDIT BY OSMAN
;DO GODDAM EPCAP AT COLD START SINCE MONITOR LEAVES UNLOGGED IN JOB AS WHEEL!!
;<4.EXEC>EXEC0.MAC.219, 15-May-79 09:10:22, EDIT BY OSMAN
;CALL LTTYMD ON WARM START
;<4.EXEC>EXEC0.MAC.217,  4-May-79 15:36:04, EDIT BY OSMAN
;GET RID OF SETNM AT CMDIN3, SETSN AT CMDIN4 IS SUFFICIENT
;<4.EXEC>EXEC0.MAC.216,  4-May-79 10:50:49, EDIT BY OSMAN
;MOVE BLECCH CODE INTO DOATI
;<4.EXEC>EXEC0.MAC.213,  2-May-79 10:17:48, EDIT BY OSMAN
;GET RID OF CJFN1
;<4.EXEC>EXEC0.MAC.212,  1-May-79 15:03:59, EDIT BY OSMAN
;<4.EXEC>EXEC0.MAC.209,  1-May-79 10:13:47, EDIT BY OSMAN
;ONLY DO ATI FOR ^E IN ADVISE, DO DTI TO CLEAN UP FROM ADVISE
;<4.EXEC>EXEC0.MAC.206, 30-Apr-79 16:53:22, EDIT BY OSMAN
;ADD BLECCH
;<4.EXEC>EXEC0.MAC.204, 30-Apr-79 14:43:31, EDIT BY OSMAN
;DON'T CALL LTTYMD (SET UP TTY) AFTER ^C AND ERRORS, COMND WILL DO IT
;<4.EXEC>EXEC0.MAC.201, 30-Apr-79 13:35:02, EDIT BY OSMAN
;MOVE EPCAP, ATI STUFF INTO INITIALIZATION TO AVOID DOING IT EVERY ^C!
;<4.EXEC>EXEC0.MAC.200, 20-Apr-79 10:17:07, EDIT BY OSMAN
;PUT ERCAL AFTER MTOPR FOR SPEED SETTING, SO IF ACJ REJECTS IT, WE'LL HANDLE IT
;<4.EXEC>EXEC0.MAC.199, 28-Mar-79 13:36:43, EDIT BY OSMAN
;tco 4.2225 - Better error when operator does ^EEDDT etc. and he isn't a wheel
;<4.EXEC>EXEC0.MAC.198, 20-Mar-79 10:46:50, EDIT BY OSMAN
;Be more clear as to why reading system mail fails (better error message)
;<4.EXEC>EXEC0.MAC.197, 12-Mar-79 17:46:09, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.EXEC>EXEC0.MAC.164,  2-Mar-79 15:46:30, EDIT BY OSMAN
;PRINT BETTER ERRORS WHEN TIMER FAILS
;<4.EXEC>EXEC0.MAC.158,  1-Mar-79 15:10:09, EDIT BY OSMAN
;implement CLASS arg to SYSTAT
;<4.EXEC>EXEC0.MAC.150, 27-Feb-79 09:45:47, EDIT BY OSMAN
;PUT IN CLASS PARAMETER TABLE
;<4.EXEC>EXEC0.MAC.149, 23-Feb-79 15:01:57, EDIT BY OSMAN
;REMOVE QUEUE COMMAND
;<4.EXEC>EXEC0.MAC.148, 19-Feb-79 14:42:52, EDIT BY OSMAN
;SET CLF BEFORE CALLING READY
;<4.EXEC>EXEC0.MAC.147, 14-Feb-79 15:40:50, EDIT BY OSMAN
;MAKE CCHKPT AND CBACK GLOBAL
;<4.EXEC>EXEC0.MAC.146,  7-Feb-79 15:19:44, EDIT BY OSMAN
;LINE UP COMMENTS IN CTBL1
;<4.EXEC>EXEC0.MAC.144,  7-Feb-79 14:55:44, EDIT BY OSMAN
;ADD PLOT
;<4.EXEC>EXEC0.MAC.143,  1-Feb-79 17:38:15, EDIT BY OSMAN
;remove SREMOVE
;<4.EXEC>EXEC0.MAC.142,  1-Feb-79 17:16:53, EDIT BY OSMAN
;CALL IPCHEK INSTEAD OF CHECKM
;<4.EXEC>EXEC0.MAC.141,  1-Feb-79 17:10:20, EDIT BY OSMAN
;SET UP IINTDF AT COMMAND LEVEL
;<4.EXEC>EXEC0.MAC.140, 30-Jan-79 16:34:06, EDIT BY OSMAN
;ADD LA38, LA120
;<4.EXEC>EXEC0.MAC.139, 25-Jan-79 13:26:53, EDIT BY OSMAN
;CALL FIXIO BEFORE INPUTTING COMMAND
;<4.EXEC>EXEC0.MAC.138, 18-Jan-79 11:36:21, EDIT BY OSMAN
;MAKE PION/PIOFF NESTABLE
;<4.EXEC>EXEC0.MAC.137, 17-Jan-79 12:31:33, EDIT BY DNEFF
;Make VERGET check B for page access so I VER types user program version.
;<4.EXEC>EXEC0.MAC.136, 16-Jan-79 12:58:42, EDIT BY OSMAN
;CLEAR .JBUFP AT CMDIN4 TO ALLOW ALL JFNS TO BE CLEARED
;<4.EXEC>EXEC0.MAC.135, 15-Jan-79 18:22:02, EDIT BY HEMPHILL
;Make "EXAMINE<CR><LF>" work by setting default string to octal number
; instead of m,,n
;<4.EXEC>EXEC0.MAC.134, 15-Jan-79 02:37:12, EDIT BY HEMPHILL
;MAKE EXEC HANDLE USER EXTENDED ADDRESSING FOR "EXAMINE", "DEPOSIT"
;<4.EXEC>EXEC0.MAC.132, 13-Jan-79 15:33:40, EDIT BY OSMAN
;CALL RLJFNS AT CMDIN4 SO EACH COMMAND USING JFN'S NEEDN'T CALL RLJFNS
;<4.EXEC>EXEC0.MAC.130, 12-Jan-79 17:31:50, EDIT BY OSMAN
;REMOVE REFS TO RUNFK
;<4.EXEC>EXEC0.MAC.129,  5-Jan-79 10:34:54, EDIT BY OSMAN
;move FREINI to EXECSU
;<4.EXEC>EXEC0.MAC.128,  8-Dec-78 16:38:41, EDIT BY OSMAN
;remove psave (there's now "preserve" subcommand on "save") instead
;<4.EXEC>EXEC0.MAC.127,  6-Dec-89 10:46:47, EDIT BY OSMAN
;REMOVE REF TO BFP
;<4.EXEC>EXEC0.MAC.126,  5-Dec-78 13:23:31, EDIT BY R.ACE
;ADD DISMOUNT COMMAND
;<4.EXEC>EXEC0.MAC.123, 10-Nov-78 14:38:44, EDIT BY OSMAN
;make SDISMOUNT, TMOUNT, SMOUNT, SREMOVE invisible (MOUNT and DISMOUNT are the latest)
;<4.EXEC>EXEC0.MAC.122, 26-Oct-78 16:08:43, EDIT BY OSMAN
;PUT SEMI-COLON ON LINE THAT MAKES "DIS" MEAN DISCARD
;<4.EXEC>EXEC0.MAC.121, 26-Oct-78 14:44:20, EDIT BY OSMAN
;MOVE "CALL ICLEAR" SO ISN'T DONE ON EVERY ^C
;<3-ARC-EXEC>EXEC0.MAC.1, 14-May-78 14:59:25, Edit by MTRAVERS
; Put ARCHIVE, FLUSH, and RETRIEVE in command table
;<4.EXEC>EXEC0.MAC.119, 13-Oct-78 10:10:06, EDIT BY OSMAN
;ALLOW "TERMINAL TYPE VT100"
;<4.EXEC>EXEC0.MAC.116,  8-Oct-78 14:56:42, EDIT BY OSMAN
;FLUSH NERET, CHANGE REFS TO RERET, SINCE THAT'S ALL NERET EVER HAD IN IT!
;<4.EXEC>EXEC0.MAC.104, 28-Sep-78 17:27:34, EDIT BY OSMAN
;<4.EXEC>EXEC0.MAC.99, 21-Sep-78 15:00:41, EDIT BY OSMAN
;CHANGE DEFS OF ONEWD, NOLOG TO ASSUME FULL WORD DEFINITIONS
;ADD MOUNT COMMAND (REMOVE NOSHIP)
;<4.EXEC>EXEC0.MAC.94, 17-Sep-78 17:34:10, EDIT BY OSMAN
;ALLOCATE SOME FREE SPACE FOR STRING STORAGE.  PUT POINTER TO STORAGE IN CSBUFP
;<4.EXEC>EXEC0.MAC.87, 15-Sep-78 15:37:06, EDIT BY OSMAN
;USE STANDARD FREE SPACE ALLOCATOR (SEE FREINI)
;<4.EXEC>EXEC0.MAC.86, 14-Sep-78 15:38:10, EDIT BY OSMAN
;tco 4.2006 - change user core to user memory
;<4.EXEC>EXEC0.MAC.85, 14-Sep-78 14:06:57, EDIT BY OSMAN
;USE SYMBOL "OURNAM" INSTEAD OF SIXBIT /EXEC/
;<4.EXEC>EXEC0.MAC.83, 14-Sep-78 11:37:19, EDIT BY OSMAN
;REMOVE SEARCH
;<4.EXEC>EXEC0.MAC.82, 12-Sep-78 17:52:13, EDIT BY OSMAN
;PUT IN TEMPORARY LOGIN MESSAGE
;<4.EXEC>EXEC0.MAC.81, 12-Sep-78 15:31:50, EDIT BY OSMAN
;REMOVE REFS TO WAKE AND NOWAKE
;<4.EXEC>EXEC0.MAC.80, 11-Sep-78 16:58:41, EDIT BY HEMPHILL
;CALL PIOFF to guarantee auto-logout TIMER call succeeds
;<4.EXEC>EXEC0.MAC.79,  1-Sep-78 22:19:07, EDIT BY OSMAN
;ADD VT100 STUFF
;<4.EXEC>EXEC0.MAC.78, 28-Aug-78 19:03:52, EDIT BY HELLIWELL
;<4.EXEC>EXEC0.MAC.77, 28-Aug-78 19:00:16, EDIT BY HELLIWELL
;<4.EXEC>EXEC0.MAC.76, 28-Aug-78 18:58:50, EDIT BY HELLIWELL
;<4.EXEC>EXEC0.MAC.75, 28-Aug-78 18:56:38, EDIT BY HELLIWELL
;<4.EXEC>EXEC0.MAC.74, 28-Aug-78 18:54:21, EDIT BY HELLIWELL
;<4.EXEC>EXEC0.MAC.73, 28-Aug-78 18:48:15, EDIT BY HELLIWELL
;ADD "TERMINAL PAUSE" MAKE "TERMINAL PAGE" DO BOTH PAUSES
;<4.EXEC>EXEC0.MAC.72, 21-Aug-78 16:50:13, EDIT BY HELLIWELL
;REMOVE "SET EDITOR" INITIALIZATION
;<4.EXEC>EXEC0.MAC.68, 14-Aug-78 08:39:50, EDIT BY OSMAN
;DON'T SET UP RSPTR UNTIL COMMAND IS CONFIRMED
;<4.EXEC>EXEC0.MAC.67, 13-Aug-78 15:20:40, Edit by HELLIWELL
;INITIALIZE TO "SET EDITOR (TO) EDIT"
;REMOVE "TV" COMMAND
;<4.EXEC>EXEC0.MAC.66, 11-Aug-78 10:33:15, EDIT BY OSMAN
;TCO 4.1979 - MAKE "SYSTAT D.SCHEIFLER" WORK
;<4.EXEC>EXEC0.MAC.62, 10-Aug-78 08:48:36, EDIT BY OSMAN
;FIX ^T DURING PRIV COMMANDS
;<4.EXEC>EXEC0.MAC.61,  9-Aug-78 13:40:39, EDIT BY OSMAN
;MAKE ^T SHOW SOMETHING REASONABLE AFTER "PROG MUMBLE" BEFORE PROG GETS LOADED
;<4.EXEC>EXEC0.MAC.59,  9-Aug-78 11:36:02, EDIT BY OSMAN
;<4.EXEC>EXEC0.MAC.57,  3-Aug-78 17:22:09, EDIT BY OSMAN
;STORE JOB NUMBER IN JOBNO
;<4.EXEC>EXEC0.MAC.56,  2-Aug-78 10:15:54, EDIT BY OSMAN
;CHANGE CHNTAB TO POINT AT PDLOV FOR PUSHDOWN OVERFLOW
;<4.EXEC>EXEC0.MAC.55,  2-Aug-78 10:07:38, EDIT BY OSMAN
;MAKE COMMON INSTRUCTION FOR INITIALIZING P
;<4.EXEC>EXEC0.MAC.54, 25-Jul-78 14:29:17, EDIT BY OSMAN
;DON'T SHOW SYSTEM STUFF BY DEFAULT IF "PROGRAM FOO" TYPED TO SYSAT
;<4.EXEC>EXEC0.MAC.52, 21-Jul-78 15:29:57, EDIT BY OSMAN
;SAVE NAME AT STARTUP
;<4.EXEC>EXEC0.MAC.51, 21-Jul-78 09:00:57, EDIT BY OSMAN
;SET UP P AT EXEC0, RATHER THAN A FEW INSTRUCTIONS LATER
;<4.EXEC>EXEC0.MAC.49, 20-Jul-78 15:25:19, EDIT BY OSMAN
;SAVE STATE OF .JIT20 UPON STARTUP
;<4.EXEC>EXEC0.MAC.42, 11-Jul-78 15:08:44, EDIT BY OSMAN
;MAKE SYSTAT CELLS LOCAL
;MAKE SYSTAT CELLS BE LOCAL
;<4.EXEC>EXEC0.MAC.40, 29-Jun-78 13:55:08, EDIT BY OSMAN
;CALL SETT20 AT STARTUP
;<4.EXEC>EXEC0.MAC.39, 27-Jun-78 16:21:03, EDIT BY OSMAN
;PUT SYSGT INI LOOP BACK BUT DO MANY FEWER SYMS THAN BEFORE
;<4.EXEC>EXEC0.MAC.38, 27-Jun-78 16:07:03, EDIT BY OSMAN
;CHANGE ALL THE GTB'S TO USE MONSYM SYMBOL
;<4.EXEC>EXEC0.MAC.37, 27-Jun-78 15:57:21, EDIT BY OSMAN
;REMOVE SYSGT INITIALIZATION LOOP FROM STARTUP (USE MONSYM SYMBOLS INSTEAD)
;<4.EXEC>EXEC0.MAC.35, 27-Jun-78 14:29:36, EDIT BY OSMAN
;CALL PION BEFORE COMMAND TO GUARANTEE THAT ^C ALLOWED
;<4.EXEC>EXEC0.MAC.34, 26-Jun-78 13:58:12, EDIT BY OSMAN
;<4.EXEC>EXEC0.MAC.33, 26-Jun-78 13:32:08, EDIT BY OSMAN
;DON'T SETNM TO COMMAND NAME UNTIL CONFIRMATION (SEE CIPF)
;<4.EXEC>EXEC0.MAC.32, 23-Jun-78 21:55:18, EDIT BY OSMAN
;REMOVE .JBUSY (UNREFERENCED)
;<4.EXEC>EXEC0.MAC.30, 23-Jun-78 18:52:27, EDIT BY OSMAN
;REMOVE UNREFERENCED SYMBOLS: CIN0, CIN3C, CMDN2C, FORMF1, JOBOPC,
;JOBREN, NPAGEL, TEXTIA-C-D
;REMOVE "DIC" AT EXEC0 AND REENTE THAT WAS TURNING OFF MAIL CHANNEL!
;<4.EXEC>EXEC0.MAC.28, 22-Jun-78 17:15:32, EDIT BY OSMAN
;SET UP SYSTEM NAME AS "EXEC" BEFORE COMMAND INPUT
;<4.EXEC>EXEC0.MAC.23, 22-Jun-78 15:34:17, EDIT BY OSMAN
;USE MORE SYMBOLS IN CHNTAB
;<4.EXEC>EXEC0.MAC.22, 21-Jun-78 16:13:20, EDIT BY OSMAN
;TEST PRVENF AT CIN0 (PREVENTS DOING RPCAP BEFORE EVERY COMMAND)
;<4.EXEC>EXEC0.MAC.21, 21-Jun-78 15:55:08, EDIT BY OSMAN
;DON'T CALL LTTYMD BEFORE EVERY COMMAND (AVOIDS ABOUT 6 JSYSES PER COMMAND!)
;<4.EXEC>EXEC0.MAC.20, 19-Jun-78 14:54:07, EDIT BY OSMAN
;USE SETNM SO SYSTAT SHOWS WHAT COMMAND'S BEING EXECUTED
;<4.EXEC>EXEC0.MAC.19, 19-Jun-78 14:06:41, EDIT BY OSMAN
;DON'T CALL "DOECHO" IN COMSET;  WAS CAUSING EXTRA JSYS'S PER COMMAND
;<4.EXEC>EXEC0.MAC.16, 19-Jun-78 11:14:14, EDIT BY OSMAN
;ADD "PROGRAM" ARG TO SYSTAT
;<4.EXEC>EXEC0.MAC.15, 13-Jun-78 11:30:52, EDIT BY OSMAN
;ADD DOCC2
;<4.EXEC>EXEC0.MAC.14, 12-Jun-78 10:42:52, EDIT BY OSMAN
;INITIALIZE DEXTBL AT STARTUP
;<4.EXEC>EXEC0.MAC.13,  9-Jun-78 18:03:13, EDIT BY OSMAN
;CHANGE CALLS TO FIELD TO FLDSKP
;<4.EXEC>EXEC0.MAC.12,  8-Jun-78 14:33:57, EDIT BY OSMAN
;CHANGE CPUNCH/TPUNCH TO PUNCH TAPE/CARDS
;<4.EXEC>EXEC0.MAC.11, 26-May-78 14:15:39, EDIT BY OSMAN
;ADD CPUNCH, TPUNCH
;<4.EXEC>EXEC0.MAC.10, 22-Apr-78 17:54:27, Edit by BORCHEK
;DON'T PRINT MAIL CHECKS FOR CRJOB LOGINS
;<4.EXEC>EXEC0.MAC.9, 10-Mar-78 16:35:34, Edit by PORCHER
;Fix AC check in DEPOSIT
;<4.EXEC>EXEC0.MAC.8, 31-Jan-78 16:28:52, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.7, 31-Jan-78 15:30:02, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.6, 31-Jan-78 15:14:18, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.5, 31-Jan-78 13:49:39, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.4, 31-Jan-78 12:00:20, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.3, 31-Jan-78 11:35:49, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.2, 31-Jan-78 09:10:48, Edit by PORCHER
;<4.EXEC>EXEC0.MAC.1, 30-Jan-78 17:37:50, Edit by PORCHER
;Add stuff for execute-only
;TOPS20 'EXECUTIVE' COMMAND LANGUAGE


;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979,1980 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH XDEF
	TTITLE EXEC0

;THIS FILE CONTAINS
; START AND REENTER INITIALIZATION
; MAIN LOOP TO READ FIRST WORD OF COMMAND AND DISPATCH
; COMMAND TABLES AND OTHER MISC TABLES
; STATUS AND TERMINAL CHARACTERISTICS COMMANDS

; TOPS10 JOB DATA AREA

JOBSA==:120
JOBSYM==:116
JOBDDT==:74
JOBVER==:137
;TOPS20 ENTRY VECTOR
; NOTE: "EXEC" IS ASSUMED TO BE FIRST SYMBOL IN EXEC.REL, AND AT A
; PAGE BOUNDARY, BY PAGE BOUNDARY CHECK IN "ALOFRK" AT END OF THIS FILE.

EXEC::	JRST REENTE		;START ENTRY
	JRST REENTE		;REENTER ENTRY
	%%LVER,,%%RVER		;VERSION NUMBER

;POINTER TO SYMBOL TABLE
;SAVED HERE FROM JOBSYM WHEN THAT PAGE REMOVED FOR SHARABLE SUBSYSTEM

.JOBSYM::0
.NPAGS::0			;SIZE OF EXEC IN PAGES

 EVLEN==:3		;ENTRY VECTOR LENGTH (STARTING AT "EXEC")

;PATCH AREA
;ALSO THERE'S A WRITEABLE PATCH AREA (PPAT) IN EXECPR.MAC.

PATS::
PAT:: BLOCK 200
;SUBROUTINE TO "AUTOLOGOUT" THIS JOB IF NOT LOGGED IN AND MORE
; THAN "AUTOL1" SECONDS HAVE ELAPSED SINCE STARTUP.
;ONE CALL IN CMDIN4 AREA.

ALOTST:	PUSH P,A
	GTAD
	SUB A,STRTIM
	SUB A,[AUTOL1]
	JUMPG A,AUTOLO		;DO AUTOLOGOUT (XSUBRS.MAC)
	POP P,A
	RET


CHNMSK:	CHNS			;MASK FOR ACTIVE CHANNELS

; Routine to clear CRJOB/PRARG start up block

CLPRA:	SETZM CRPRA
	MOVE A,[XWD CRPRA,CRPRA+1]
	BLT A,CRPRA+17
	RET
;SUBROUTINE TO TYPE SYSTEM AND EXEC VERSIONS.
;USED AT STARTUP TO PRINT SIGN-ON MESSAGE; THIS IS ALSO THE
; EXECUTION ROUTINE FOR "VERSION" COMMAND.
;HERE TO MINIMIZE PAGE-FAULTS DURING STARTUP.

.VERSI::CALL %VERSI		;PRINT MONITOR VERSION
	CALL EXECV		;PRINT EXEC VERSION
	SKIPG A,FORK		;ANY INFERIOR FORK?
	RET			;NO
	GEVEC			;GET ENTRY VECTOR
	HLRZ A,B
	CAIE A,(<JRST>)		;COMPATIBLE?
	JRST [	CAIGE A,3	;NO, DOES +2 EXIST?
		JRST NOVERS	;NO, NO VERSION
		MOVEI A,2(B)	;YES, LOOK THERE
		JRST ISVER1]
	MOVEI A,JOBVER		;READ VERSION WORD
ISVER1:	CALL VERGET
NOVERS:	 SETZ Q1,		;NO VERSION
NOXTND,<
	SKIPN A,PTTYMD+TTWPNM
	JRST [	JUMPE Q1,VERSI2
		TYPE < Version is >
		JRST VERSI0]
>
XTND,<
	MOVE A,FORK
	SKIPE A,SLFTAB(A)	; GET FRKTBL PNTR
	 SKIPN A,.FKPTM+TTWPNM(A) ; NAME ENTRY
	  JRST [JUMPE Q1,VERSI2
		TYPE < Version is >
		JRST VERSI0]
>
	TYPE < Program is >
	PUSHJ P,SIXPRT
	JUMPE Q1,VERSI2		;DONE IF NO VERSION
	TYPE <, version is >
VERSI0:	CALL VERPNT		;PRINT VERSION
	MOVE A,FORK
	GCVEC			;GET COMPATIBILITY ENTRY VECTOR
	JUMPLE B,[RET]		;RETURN IF COMPATIBILITY DISABLED OR NOT THERE
	HLRZ A,B
	CAIGE A,2		;DOES VERSION ENTRY EXIST?
	RET			;NO
	MOVEI A,2(B)		;GET ADDR
	CALL VERGET		;GET VERSION
	 RET			;LEAVE IF NONE
	TYPE < UUO simulation in use, version is >
	CALLRET VERPNT		;PRINT VERSION AND LEAVE

VERGET:	PUSH P,A
	CALL MAPPF
	 JRST [	POP P,A			;Failed to MAP-- no
		RET]			; version-- return +1 from VERGET
	POP P,Q1
	TXNN B,PA%PEX
	RET			;NO PAGE
	TXNN B,PA%RD
	RET			;CAN'T READ IT
	ANDI Q1,777
	MOVE Q1,PAGEN(Q1)	;LOAD VERSION INTO Q1
	JUMPE Q1,[RET]
	RETSKP

VERPNT:	LDB A,[POINT 9,Q1,11]	;GET MAJOR VERSION
	SKIPE A
	ETYPE <%1O>		;PRINT IF NON-ZERO
	LDB A,[POINT 6,Q1,17]	;GET MINOR VERSION
	JUMPE A,VERSI1		;SKIP IF 0
	SUBI A,1
	IDIVI A,^D26		;MAKE 2 LETTERS
	SKIPE A			;ANY FIRST LETTER?
	PRINT "A"-1(A)		;YES, PRINT
	PRINT "A"(B)		;PRINT SECOND LETTER
VERSI1:	HRRZ A,Q1		;GET EDIT NUMBER
	SKIPE A
	ETYPE <(%1O)>		;PRINT IF NON-ZERO
	LDB A,[POINT 3,Q1,2]	;GET GROUP CODE
	SKIPE A
	ETYPE <-%1O>		;PRINT IF NON-ZERO
VERSI2:	ETYPE<%_>
	RET

$VERSI:	GJINF
	JUMPN A,EXECV		;EXEC VERSION ONLY IF LOGGED IN
%VERSI:	PRINT " "
	HLLZ D,SYSVER		;XWD LENGTH, INDEX
%VERS1:	GTB .SYSVE		;GET A DATA WORD FROM TABLE (USES D)
	MOVE B,A
	MOVEI C,5		;PRINT 5 CHARS FROM EACH WORD
%VERS2:	SETZ A,
	LSHC A,7
	JUMPE A,%VERS3		;END ON NULL
	PRINT (A)
	SOJG C,%VERS2
	AOBJN D,%VERS1		;ALSO END ON END OF TABLE
%VERS3:	ETYPE<%_>
	RET

;"EXEC" AND ITS VERSION

EXECV::	TYPE < TOPS-20 Command processor >
	MOVE Q1,EXEC+2		;GET VERSION #
	CALLRET VERPNT		;PRINT IT

;ROUTINE TO INITIALIZE COMND JSYS.  ITEMS INITIALIZED IN THIS ROUTINE
;ARE ONES NOT NECESSARY TO REINITIALIZE FOR EACH COMMAND.

CMDINI:	MOVEI A,REPARS		;SET UP REPARSE HANDLER ADDRESS
	MOVEM A,CMFLG
	HRROI A,CBUF		;POINTER TO COMMAND BUFFER
	MOVEM A,CMBFP
	MOVEM A,CMPTR		;NO "NEXT FIELD" YET
	MOVEI B,CBUFL*5	;ANNOUNCE HOW MUCH ROOM FOR TYPEIN THERE IS
	MOVEM B,CMCNT
	SETZM CMINC		;NO UNPARSED CHARACTERS YET
	HRROI A,ATMBUF		;POINTER TO ATOM BUFFER
	MOVEM A,CMABP
	MOVEI A,ATMLEN*5	;LENGTH OF ATOM BUFFER
	MOVEM A,CMABC
	MOVEI A,CJFNBK		;ADDRESS OF GTJFN BLOCK
	MOVEM A,CMGJB
	RET
;REENTER ENTRY

REENTE::
REE::	SKIPN CINITF		;IS EXEC INITIALIZED?
	JRST EXEC0		;NO, "REENTER" GIVEN BEFORE "START",
				;FULL INITIALIZATION REQUIRED.

;THE FOLLOWING CODE IS EXECUTED ON "REENTER" ONLY.

;RE-INITIALIZE PSI SYSTEM
; (^C OUT OF EXEC DDT TO SUPERIOR EXEC LEAVES IT WRONG).

	CALL ICLEAR		;CLEAR INTERRUPT WE MAY HAVE RESTARTED OUT OF, DONE HERE TO AVOID TWO FOR EVERY ^C!
	MOVEI A,.FHSLF
	MOVE B,CHNMSK		;GET ACTIVE CHANNEL MASK
	AIC			;ACTIVATE CHANNELS SPECIFIED BY MASK
	EIR			;ENABLE PROCESS PSEUDOINTERRUPT SYSTEM
	CALL CPULIM		;GET AND SET CPU TIME LIMIT
	TXO Z,NECHOF		;PRETEND ECHOING OFF
	CALL DOECHO		;FORCE ECHOING (IN CASE WARM START AFTER INTERRUPT OUT OF A NOECHO PLACE!)
	CALL DOATI		;TERMINAL INTERRUPTS (ON ^EQ, MINI-EXEC CLEARS THEM)
	MOVEI Q1,ETTYMD
	CALL LTTYMD		;INIT TTY STATE IN CASE INTERRUPTED OUT OF COMND
	JRST CMDIN2		;JOIN STARTUP CASE

;INSTRUCTION TO INITIALIZE STACK

INISTK::MOVE P,[IOWD PDL,PD]

;FIRST STARTUP INITIALIZATION

EXEC0::	XCT INISTK		;INITIALIZE THE STACK
	MOVEI A,.FHSLF
	RPCAP			;GET CURRENT CAPABILITIES
	HLLZ C,C		;PREVENT "ATTACH" WITHOUT PASSWORD
	EPCAP			;(MONITOR MAKES VIRGIN JOB BE WHEEL!)
	SETZM CSZ1
        MOVE A,[XWD CSZ1,CSZ1+1]
        BLT A,CSZ4
	GETNM			;GET PROGRAM NAME
	MOVEM A,SAVNAM		;REMEMBER NAME
	CALL GETMOD		;SEE WHETHER WE'RE COMING FROM EXEC OR USER MODE
	MOVEM A,SAVT20		;REMEMBER FOR WHEN WE POP

;SET UP 41 FOR UUO'S, P=17 FOR PUSHDOWN POINTER

        MOVE A,[CALL CUUO]
        MOVEM A,41
	MOVE A,[IOWD JBUFL,JBUF] ;INIT PTR INTO JFN BUFFER
	MOVEM A,JBUFP		;..
	SETOM 1(A)		;INIT JFN BUFFER TO -1'S: 0 IS A JFN.
	AOBJN A,.-1		;..
	CALL XFRINI		;INITIALIZE PERMANENT FREE SPACE

;CLEAR FLAGS

	SETZ Z,

;RANDOM THINGS

	CALL CLPRA		; Clear CRJOB/PRARG area
	MOVE A,[.PRARD,,.FHSLF]	; Read our blk if there
	MOVEI B,CRPRA
	MOVEI C,20		; Length of our blk
	PRARG
	JUMPE C,EXEC01		; Nothing waiting for us
	MOVE A,CRPRA+.CJPHD	; Pick up ID that identifies CRJOB-PRARG
	CAME A,[1B0+3B6+2B12+CR%PRA] ; PRARG from CRJOB?
	 JRST [ CALL CLPRA	; No, who knows what, ditch it
		JRST EXEC01]
	SETO A,			; This job
	HRROI B,CJPTIM		; 1 word into our flag word
	MOVEI C,.JIRTL		; Get job runtime limit (if set)
	GETJI
	 SETZM CJPTIM		; Failed, flag as none present
	HRRZ A,CRPRA+.CJPLP	; Get ptr to flags
	MOVE B,CRPRA(A)		; Pick up flags
	TLNN B,(1B1+1B2)	; A fork handle given to us?
	 JRST EXEC01		; No, continue
	HRRZ A,CRPRA+.CJPKP	; Get ptr to FORK,,SFRKV offset
	MOVE B,CRPRA(A)
	HLRZM B,FORK		; Set it as current lower fork
	JRST EXEC02
EXEC01:	SETOM FORK		;SAY NO INFERIOR FORK
XTND,<
	SETOM RUNFK		; NO RUNNING FORK
	SETOM EDFORK		; NO EDITOR FORK
	SETOM IDFORK		; NO IDDT FORK
	SETOM EFORK		; NO EPHERMERAL FORK
>
MIC,<
	SETOM MICFRK		; NO MIC FORK
>
EXEC02:	SETOM NPAGE		;SAY NO PAGE OF INFERIOR IS MAPPED
	SETOM EXDPLC		;Say no examine/deposit yet
	MOVEI A,NEXTS		;INITIALIZE EXTENSION TABLE
	MOVEM A,DEXTBL
;INITIALIZE PROCESS PSI SYSTEM,
; DONE EARLY SO ERRORS IN REST OF INITIALIZATION WILL BE HANDLED.
;ENABLE ALL ERROR CHANNELS BUT OVERFLOW,
; ALSO CHANNEL 1 FOR ASSIGNMENT TO ^C BELOW,
; AND 2 FOR AUTOLOGOUT.

	MOVEI A,.FHSLF		;SAY THIS FORK
	MOVE B,[XWD LEVTAB,CHNTAB]
	SIR			;SET UP TABLE ADDRESSES
	MOVE B,CHNMSK		;GET ACTIVE CHANNEL MASK
	AIC			;ACTIVATE SPECIFIED CHANNELS
	EIR			;ENABLE PROCESS PSI SYSTEM
	CALL CPULIM		;GET AND SET CPU TIME LIMIT
	CALL CMDINI		;INITALIZE ALL COMND PARAMETERS
	MOVE A,IOPTB		;GET INITIAL COMMAND JFN BUFFER POINTER
	MOVEM A,IOPT		;INITIALIZE COMMAND JFNS
	MOVE A,[100,,101]
	CALL PUSHIO		;START FIRST COMMAND STREAM
	CALL STSYST		;INIT GETAB NUMBERS

;INITIALIZE TELETYPE MODE, TABS, CONTROL CHARACTER OUTPUT (CCOC).
; INITIALIZE MODES FOR USE IN RUNNING PROGRAM FROM PRESENT MODES.

	MOVEI Q1,ITTYMD		;INITIAL MODES FOR "START"
	CALL RTTYMD		;THIS SUBR SAVES MODE WORD, TABS, CCOC.
	MOVE A,[SIXBIT /(PRIV)/]
	MOVEM A,ITTYMD+TTWSNM	;SUBSYSTEM NAME UNLESS OTHERWISE SPEC
NOXTND,<
	MOVE A,[XWD ITTYMD,PTTYMD]
	BLT A,PTTYMD+NTTYMD-1	;MOVE INITIAL TO ACTIVE PGM BLOCK
>
; INITIALIZE MODES FOR USE WHEN EXEC IS RUNNING:
;  ASSUME ITS ALREADY CORRECT WITH REGARD TO HARDWARE FEATURES; 

	MOVEI Q1,ETTYMD		;KEEP EXEC MODES UP TO DATE IN STORAGE
	CALL RTTYMD		;...FOR ^C.
	MOVEI A,2		;CODE SAYING "TYPE LITERAL CONTROL CHARACTER"
	DPB A,[POINT 2,ETTYMD+TTWCOC+""*2/^D36,""*2+1-""*2/^D36*^D36]
				;MAKE CONTROL-V ECHO LITERALLY AS IN FILENAMES
	MOVEI A,3		;FORMAT LINEFEED (MAKE IT ECHO AS CRLF)
	DPB A,[POINT 2,ETTYMD+TTWCOC+<"J"-100>*2/^D36,<"J"-100>*2+1-<"J"-100>*2/^D36*^D36]

;DISABLE COMPAT FOR EXEC

	MOVEI	A,.FHSLF	;FOR SELF
	MOVNI	B,1		;SET TO -1
	MOVEI	C,0		;...
	SCVEC			;BYE
;DETERMINE HERE IF BATCH MODE

	SETZM BATCHF		;ASSUME NOT BATCH JOB
	MOVNI A,1
	MOVE B,[-1,,A]
	MOVEI C,.JIBAT		;GET BATCH FLAG
	GETJI
	 CALL JERR
	JUMPE A,NOBTCH		;0 := NOT BATCH
	SETOM	BATCHF		;SET BATCH FLAG
	SETOM	CCFLAG		;NO CTRL-C CAPABILITY
NOBTCH:
STAT,<	HRROI B,[ASCIZ /PS:<QUEUES>COMMANDS-USAGE.THAW;0/]
	CALL TRYGTJ
	JRST STLOSE		;GIVE UP IF NO FILE
	MOVEI B,OF%RD!OF%WR!OF%THW
	OPENF
	JRST STLOSE
	HRLZ A,A
	MOVE B,[.FHSLF,,<STBUF>B44]
	LDF C,PM%RD!PM%WT
	PMAP
STLOSE:
>;STAT

;FIND OUT IF THIS JOB IS LOGGED IN. (MIGHT BE AT STARTUP IF SUBSIDIARY.
;  OR A SUBSYSTEM COULD LOG JOB IN.)

	GJINF			;USER # IN A, 0 IF NOT LOGGED
	MOVEM A,CUSRNO		;SAVE USER # OR 0
	MOVEM A,LIDNO		;SAVE AS LOGGED-IN DIR NUMBER IN CASE OLD MONITOR AND GETJI FAILS
	MOVEM C,JOBNO		;REMEMBER JOB NUMBER
	MOVE A,C		;GET THE JOB NUMBER
	HRROI B,LIDNO		;READ LOGGED-IN DIRECTORY NUMBER INTO LIDNO
	MOVEI C,.JILNO		;ASK FOR ONLY THIS ONE.
	GETJI			;DO IT.
	 JFCL			;IGNORE FAILURE, SEE LIDNO REF. ABOVE.
	MOVEI A,.FHJOB
	RTIW			;UPDATED JOB TIW FOR EXEC
	MOVEM B,ETTYMD+TTWJTI
	MOVEM B,ITTYMD+TTWJTI	;INITIALLY, SAME FOR PGM
	MOVEI Q1,ETTYMD		;INITIALIZE TTY, SO ^V DOESN'T APPEAR IN FILENAMES
	CALL LTTYMD

;SAY INITIALIZATION HAS COMPLETED SUCCESSFULLY.
;UNTIL CINITF><0, ERROR ROUTINES HALT RATHER HAN TYPE MESSAGES.
; AND "REENTER" DOES A "START".

	SETOM CINITF
	CALL DOATI		;ASSIGN TERMINAL INTERRUPTS (DON'T ALLOW ^C EARLIER !)
	TLZ Z,F1		;FIRST ASSUME WE WANT HERALD
	SKIPE CRPRA		; CRJOB startup?
	 JRST [ HRRZ A,CRPRA+.CJPLP ; Yes, get flags ptr
		MOVE B,CRPRA(A)	; Now get flags
		TLNE B,(1B0)	; Suppress herald?
		TLO Z,F1	;YES, REMEMBER
		JRST .+1]
	TLNN Z,F1		;SUPPRESS HERALD?
	JRST [	ETYPE <%_>	;NO, PRINT IT.  CR FIRST.
		CALL $VERSI	;PRINT VERSION
		CALL DWNTYP	;ANNOUNCE IF SYSTEM GOING DOWN
		JRST .+1]

;COMMANDS THAT RUN PROGRAM RETURN HERE WHEN IT STOPS.
;START, CONT, REENTER, RUN, <SUBSYSTEM NAME>, GOTO.
;RE-ENTRY JOINS MAIN FLOW HERE

CMDIN2::	CALL SETT20		;SAY TOPS20 COMMAND LEVEL (PLACED HERE TO MINIMIZE JSYS'S PER COMMAND)
	JRST CMDIN3

;ROUTINE TO ENABLE TERMINAL INTERRUPTS

DOATI::	MOVEI A,.FHSLF
	RPCAP			;SEE IF WE'RE ALLOWED TO ENABLE ^C
	TXNN B,SC%CTC		;TEST SPEC CAP BIT 0
	JRST DOAT0		;NOT ALLOWED TO ENABLE ^C
	TXO C,SC%CTC
	EPCAP			;ENABLE FOR ^C CAPABILITY
	MOVE A,[XWD CTRLC,1]
	ATI
	MOVEI A,.FHJOB		;SET TERMINAL MASK FOR JOB
	MOVE B,ETTYMD+TTWJTI	;GET CORRECT MASK
	STIW			;SET UP CORRECT MASK
	MOVX A,ST%DIM!.FHSLF	;OURSELF, GET DEFERREDS IN AC3
	RTIW			;GET DEFERRED MASK
	TXO C,1B<CTRLC>
	STIW			;MAKE SO PROGRAM BUFFERED INPUT GETS READ BEFORE ^C

;ASSIGN CHAR TO PRINT TIME USED (^T) TO PSI CHANNEL 3

DOAT0:	MOVEI A,ADVESC		;MAKE SURE ADVICE CHARACTER NO LONGER SPECIAL
	DTI
	MOVE A,[XWD CTCODE,3]
	ATI

;ASSIGN CHARACTER TO CLEAR OUTPUT BUFFER

	MOVE A,[CTRLO,,5]	;CONTROL-O IS USED
	ATI
	RET

;THIS ROUTINE GET TIME LIMIT WHICH WAS POSSIBLY SET BY ANOTHER
;PROCESS AND SETS IT ON THE CORRECT CHANNEL
CPULIM:	MOVNI A,1
	MOVE B,[-1,,D]		;GET CURRENT LIMIT INTO D
	MOVEI C,.JIRTL
	GETJI
	 CALL JERR
	MOVE A,[.FHJOB,,.TIMRT]	;SET TIME LIMIT CODE
	SETZB B,C		;CLEAR LIMIT
	TIMER
	 CALL [	CAIE A,TIMX4	;NOT SET BY THIS FORK?
		JRST JERR	;NOPE, PRINT IT
		POP P,(P)
		RET]		;RETURN HAVING DONE NOTHING
	MOVE A,[.FHJOB,,.TIMRT]	;SET TIME LIMIT CODE
	MOVE B,D		;GET TIME TO SET
	MOVEI C,4		;CHANNEL
	TIMER
TIMERR:	 ERROR <Couldn't set time limit - %?>
	RET

;SUBROUTINE TO INIT GTTAB NUMBERS - USED AT STARTUP ONLY
;NOTE:  THE ONLY ONES THAT SHOULD BE INITED HERE ARE ONES TO BE
;USED FOR *OTHER* THAN GETAB JSYS.  FOR GETAB JSYS, USE MONITOR
;SYMBOLS.

STSYST:	MOVSI D,-NGTTBS		;NUMBER OF TABLES
STSYS1:	MOVE A,GTTBS(D)		;GET THE SIXBIT NAME OF THE TABLE
	SYSGT			;GET ITS NUMBER
	JUMPN B,STSYS2		;JUMP UNLESS NO SUCH TABLE
	TYPE <%No system table named: >
	MOVE A,GTTBS(D)
	CALL SIXPRT
	SETZ B,
STSYS2:	MOVEM B,@GTTBS+1(D)	;PUT NUMBER IN VARIABLE
	AOBJN D,.+1
	AOBJN D,STSYS1		;DO ALL TABLES
	RET

;LIST OF GTTAB TABLES KNOWN TO EXEC

DEFINE XX (NAMS)<
	IRP NAMS,<
	SIXBIT /NAMS/
	Z NAMS>>

GTTBS:	XX <QTIMES,SNAMES,SYSVER,JOBRT,TTYJOB>
NGTTBS==.-GTTBS

;^C AND COMMAND ERRORS COME BACK HERE.
;AFTER ^C IT IS NECESSARY TO EXECUTE CODE TO FIND OUT WHETHER LOGGED IN,
; HAVE INFERIOR FORK, UPDATE CAPABILITIES, KILL AUTOLOGOUT FORK,
; ETC IN CASE INTERRUPTED COMMAND WAS LOGIN, RUN, ETC.

ERRET::
;INDICATE NOT IN ADVISE CODE

	SKIPN ADVFLG
	JRST CMDIN3		;NO CLEANUP NECESSARY
	TYPE <
?Error while giving advice - ADVICE terminated
>
	CALL DOATI		;MAKE SO ^E AND ^C WORK AS NORMAL AGAIN
	SETZM ADVFLG

CMDIN3:
	MOVEI A,1
	MOVEM A,INTDF
	MOVEM A,IINTDF		;MAKE SURE IPCF INTERRUPTS ALLOWED
	CALL PION		;MAKE SURE ^C ALLOWED
	CALL IPCON		;MAKE SURE IPCF INTERRUPTS ALLOWED

;MISCELLANEOUS INITIALIZATION

	MOVEI A,RERET		;SAY WHERE TO GO ON ERROR WHILE TYPING
	MOVEM A,CERET		; ...LOGIN MESSAGE

;PRINT "YOU HAVE A MESSAGE" IF APPROPRIATE
;HERE SO DONE EVEN AFTER ^C DURING LOGIN MESSAGE

	SKIPE CRPRA		; In CRJOB start up?
	 JRST [ HRRZ A,CRPRA+.CJPLP ; Get flags ptr
		MOVE B,CRPRA(A)
		TLNN B,(1B3)	; Creator want system messages etc?
		 JRST [ SETZM MESMSF ; NO LOGIN CHECK
			SETZM MWATCF ; NO MAIL WATCH
			JRST CMDIN4] ; BYPASS
		ETYPE < Job %J on %L %D %E
>
		SETO A,		; This job
		HRROI B,LOGDAT
		MOVEI C,.JILLN	; Get last login D&T
		GETJI
		 SETZ A,	; Fails, used never logged in
		SETOM SYSMF	; Init guy so it works...
		CALL FREINI	;INITIALIZE FREE SPACE
		CALL PNTMES	; Print system message(s)
		JRST .+1]
NOXTND,<
	SKIPE MESMSF		;SKIP IF WE NEEDN'T CHECK FOR A MESSAGE
				;(NON-0 FROM LOGIN TO SUCCESSFUL
				;COMPLETION OF "MESMES")
	CALL MESMES		;SUBROUTINE NEAR "LOGIN"
>
;HERE WHEN READY TO INPUT A COMMAND.
;ALL COMMANDS RETURN HERE OR ABOVE HERE WHEN DONE.

CMDIN4::

	SETZM .JBUFP		;ALLOW ALL JFNS TO BE RELEASED
	CALL FIXIO		;MAKE SURE REAL STREAM USED FOR COMMAND

;SET SUBSYSTEM NAME TO "EXEC".
;THIS UPDATES MONITOR TABLES USED BY "SYSTAT".

	MOVX A,OURNAM
	MOVEM A,ETTYMD+TTWSNM
	MOVEM A,ETTYMD+TTWPNM	;PROGRAM NAME TOO
	MOVX B,OURNAM		;SET UP PRIVATE NAME AS SAME
	SETSN			;SET UP SYSTEM NAME AS EXEC
	 JFCL
	SETO A,
	CAME A,NPAGE
	CALL MAPPF		;DON'T LEAVE FORK PAGES MAPPED
	 JFCL			;Unmap shouldn't fail
	SETZM CSZ1		;ZERO STORAGE
	MOVE A,[XWD CSZ1,CSZ1+1]
        BLT A,CSZ2

;INITIALIZE WHAT NEEDS INITIALIZING

        MOVE A,[POINT 7,CBUF,-1] ;BYTE POINTER INTO COMMAND BUFFER,
				;IN WHICH ENTIRE LINE IS ACCUMULATED.
	MOVEM A,BEGINP		;REMEMBER WHERE INPUT LINE BEGINS (FOR REPARSES)
	XCT INISTK		;INITIALIZE STACK
	CALL FREINI		;INITIALIZE FREE SPACE
;INITIALIZE AUTOLOGOUT STUFF IF NECESSARY

	SKIPE CUSRNO
	JRST CMDN5E		;LOGGED IN, NOT RELEVANT.
	IFNBATCH (CMDN5E)	;NO ALO STUFF IF IN BATCH
	SKIPE ALOST		; Have we started the autologout stuff up?
	 JRST CMDN5D		; Yes, the following already done
	GTAD			;SAVE STARTUP TIME FOR USE IN
	MOVEM A,STRTIM		;"ALOTST" SUBR

; Setup a pending TIMER interrupt for AUTO-LOGOUT if job is inactive

	MOVE A,[.FHSLF,,.TIMEL]	; Set an elapsed timer for self
	MOVE B,[AUTOL2*^D1000]	; For that far in future
	MOVEI C,2		; On channel 2
	CALL PIOFF		; Disable control-C's
	SETOM ALOST		; Say autologout stuff started
	TIMER
	 ERROR <Couldn't initialize auto-logout timer - %?>
	CALL PION		; Enable control-C's

;JOB ISN'T LOGGED IN, SEE IF ITS TIME TO AUTO-LOGOUT IT.

CMDN5D:	CALL ALOTST
;PRINT READY CHARACTER

CMDN5E:
; Check to see if CRJOB/PRARG start up & if so, a program to run

	SKIPE CRPRA		; CRJOB start up?
	 JRST [ HRRZ A,CRPRA+.CJPLP ; Yes, get flags ptr
		MOVE B,CRPRA(A)	; then flags
		TLNN B,(1B2)	; Want fork started?
		 JRST .+1	; No
		HRRZ A,CRPRA+.CJPKP ; Get ptr to fork & SFRKV offset
		HRRZ B,CRPRA(A)
		CALL CLPRA	; Clear CRJOB/PRARG area
		PUSH P,[CMDIN4] ; Where to return when done
		JRST ..STCR]	; Run it
	CALL CLPRA

;CHECK FOR DEFAULT "TAKE" COMMANDS

	MOVE A,CIJFN
	CAIE A,.PRIIN		;IF INPUT NOT FROM PRIMARY
	JRST NLGINI		;THEN NO CHANGE OF INPUT NOW
	SKIPE CUSRNO		;IF NOT LOGGED IN,
	SKIPE FILINI		;OR INITIALIZATION DONE,
	JRST NEXINI		;THEN SKIP FOR NOW
	SETOM FILINI		;DON'T COME BACK HERE AGAIN
	HRROI B,[ASCIZ "COMAND.CMD"]
	CALL TAKEIN
	CAIA			;DON'T RESET ANYTHING UNLESS WE'RE REALLY DOING "TAKE" NOW
	JRST CMDIN4		;RESET ALL COMMAND INFO AFTER TAKEIN ATTEMPT

NEXINI:	SKIPN LOGINI		;LOGIN JUST DONE?
	JRST NLGINI		;NO, SKIP THIS
	SETZM LOGINI		;CLEAR FLAG
	HRROI B,[ASCIZ "LOGIN.CMD"]
	SKIPE	BATCHF		;UNDER BATCH?
	HRROI	B,[ASCIZ "BATCH.CMD"] ;YES - USER OTHER FILE
	CALL TAKEIN		;SETUP EXEC INPUT
	CAIA			;DON'T RESET ANYTHING IF NOTHING GOT TAKEN
	JRST CMDIN4		;RESET ALL COMMAND INFO AFTER TAKEIN ATTEMPT

NLGINI:	MOVE A,CIJFN		;SEE WHERE INPUT IS COMING FROM
	CAIN A,.PRIIN		;INPUTTING FROM TERMINAL?
	CALL PNTMES		;YES, SO DONE WITH INITIALIZATION, TYPE SYSTEM MESSAGES

;PREFORM MAIL WATCH FUNCTION, IF REQUESTED BY SET MAIL-WATCH

	CALL IPCOFF		;DON'T ALLOW IPCF INTERRUPTS
	SKIPE IPCRCF		;WERE THERE SOME?
	CALL IPCHEK		;YES, CHECK FOR MESSAGES RECEIVED
	SETZM IPCRCF		;THIS FLAG WILL BE SET NEXT TIME AN INTERRUPT HAPPENS
	CALL IPCON		;...WHICH COULD BE RIGHT NOW OR LATER
NOXTND,<
	SKIPE MWATCF		;MAIL WATCH ON?
	CALL MWATCH		;YES.  SEE IF ANY NEW MAIL.
>
XTND,<
	SETZM TYPING		; NO TYPEOUT IN PROGRESS
	SETZM AUTOF		; NO INTERUPT IN PROGRESS
	CALL MWATCH		; DO MAIL WATCH
	CALL ALRCHK		;  AND ALERT CHECK
>
	CALL RLJFNS		;RELEASE ANY JFNS USED IN PREVIOUS COMMAND
				;NOTE:  RLJFNS CALLED HERE RATHER THAN EARLIER
				;TO FLUSH JFN USED BY MWATCH.  THIS IS NECESSARY
				;SO THAT "COPY TTY:$" DOESN'T TYPE "MAIL"!
	SETZM CIPF		;SAY NO COMMAND IN PROGRESS
	SETOM CLF		;SAY WE'RE AT COMMAND LEVEL
	CALL READY		;INITIALIZE FOR COMND JSYS
	MOVEI A,RERET		;REGULAR ERROR RETURN ADDRESS
	MOVEM A,CERET		;SAY WHERE TO GO AFTER PRINTING ERR MSG

;CLEAR SOME FLAGS

	MOVEI Z,0		;CLEAR FLAGS

;BEGIN INPUTTING AND DECODING A COMMAND

	CALL COMSET		;SET UP THINGS FOR COMMAND INPUT
	MOVX B,WHLU+OPRU+ERRU
	SKIPE PRVENF		;USER "ENABLE"D?
	CALL PRVCK	;CHECK FOR PRIVILEGED USER
	 JRST CIN9		;NOT PRIVILEGED, SO ^E NO POSSIBILITY
NOXTND,<
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>,,[
		FLDDB. .CMTOK,,<-1,,[ASCIZ //]>,,,[
		FLDDB. .CMFIL,CM%SDH,,<system program name>,,]]]
>
XTND,<
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>,,[
		FLDDB. .CMTOK,,<-1,,[ASCIZ //]>,,,[
		FLDDB. .CMTOK,,<-1,,[BYTE (7)14]>,,,[
		FLDDB. .CMFIL,CM%SDH,,<system program name>,,]]]]
>
	JRST CIN10		;GO INPUT FIELD
CIN9:
NOXTND,<
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>,,[
		FLDDB. .CMFIL,CM%SDH,,<system program name>,,]]
>
XTND,<
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>,,[
		FLDDB. .CMTOK,,<-1,,[BYTE (7)14]>,,,[
		FLDDB. .CMFIL,CM%SDH,,<system program name>,,]]]
>
NOXTND,<
	SKIPN CUSRNO		;IF NOT LOGGED IN, CAN'T RUN PROGRAMS
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>]
>
XTND,<
	SKIPN CUSRNO		;IF NOT LOGGED IN, CAN'T RUN PROGRAMS
	MOVEI B,[FLDDB. .CMTOK,,<-1,,[BYTE (7)14]>,,,[
		 FLDDB. .CMKEY,,CTBL1,<Command,>]]
>
CIN10:	CALL FLDSKP		;TRY TO READ COMMAND NAME
	 JRST CIN4		;NO
	MOVEM B,COMAND		;SAVE COMMAND INFO
	LDB D,[331100,,(C)]	;GOOD PARSE,  SEE WHAT GOT TYPED
	CAIN D,.CMFIL		;FILESPEC?
	JRST CIN3		;YES, GO RUN PROGRAM
	CAIN D,.CMTOK		;^E?
	JRST CINE		;YES
	JRST CIN2		; MUST BE COMMAND

;ROUTINE TO SET UP DEFAULTS FOR COMMAND INPUT
;PLEASE BE CAREFUL ABOUT CAUSING JSYS'S TO BE EXECUTED IN THIS ROUTINE,
;SINCE THIS ROUTINE GETS CALLED FOR EVERY COMMAND, AND WE WANT TO
;MINIMIZE NUMBER OF SYSTEM CALLS.  THANKS.

COMSET:	DEXTX <EXE>		;DEFAULT PROGRAM EXTENSION IS "EXE"
	HRROI A,[ASCIZ /SYS/]	;DEFAULT DEVICE FOR PROGRAMS IS SYS:
	MOVEM A,CJFNBK+.GJDEV
	MOVX A,GJ%OLD		;PROGRAM MUST EXIST
	MOVEM A,CJFNBK+.GJGEN
	RET

;PRIVILEGED, AND ^E TYPED

CINE:
XTND,<
	MOVSI A,(<BYTE (7)14>)	; FF
	HRRZ D,1(C)		; GET TOKEN PARSED
	CAME A,0(D)		; IS IT ^E OR ^L
	 JRST CINE2		; ^E - SEE IF SPECIAL COMMAND
	ETYPE <%_>		; ^L
	CALL BLANK1
	JRST CMDIN4		; CLEAR SCREEN
>
CINE2:	MOVEI B,[FLDDB. .CMKEY,,CTBL2]
	CALL FLDSKP
	 CMERRX			;NO SUCH ^E COMMAND
	MOVEM B,COMAND
;HAVE VALID FIRST KEYWORD IN COMMAND
;MAKE PRE-DISPATCH CHECKS

CIN2:	MOVE B,COMAND		;GET WHICH COMMAND WE'RE DOING
	CALL GETKEY
	MOVE P4,P3		;1ST KW'S VALUE WD STAYS IN P4.
	TXNE P4,NOLG
	JRST .+3
	SKIPN CUSRNO		;SKIP IF LOGGED IN
	ERROR <LOGIN please>
	MOVE B,P3		;FOUND PRIVILEGED COMMAND, MAKE SURE PRIVILEGES
	CALL PRVCK
	 ERROR <Insufficient privileges>
	TXNE P4,ONEWRD		;IS IT A ONE-WORD COMMAND?
        CONFIRM			;YES, HANDLE CONFIRMATION NOW.
	CALL (P4)		;DISPATCH WITH PUSHJ,
				;CAN RETURN WITH POPJ
				;OR JRST CMDIN2,3,4.
	JRST CMDIN4		;WHERE MOST COMMANDS SHOULD RETURN.

;COMMANDS WHICH CLANK QUEUE SYSTEM

QCM:	HRROI B,[GETSAVE (SYS:QUENCH.)]
	JRST DOCC1

DEFINE PRGSTG			;STORAGE NEEDED FOR PROGRAM COMMANDS
<	TRVAR <PNAMP,PJFN,PTBLP>
>

;DO CCL COMMAND - RUN SYS:COMPILE AND PASS INPUT LINE

   NOSHIP,<
DOCCL::	HRROI B,[GETSAVE(SYS:COMPIL.)]
   >;NOSHIP
DOCC1::	PRGSTG
	CALL TRYGTJ		;CCL COMMAND, BEGIN GET OF COMPIL
	 JRST CIN4E		;NO COMPIL THEREFORE NO CCL COMMANDS...
	MOVEM A,PJFN		;REMEMBER PROGRAM JFN
	LINEX <Data line to be sent to program>
	 CMERRX
	confirm
	JRST RSUBS4		;CONTINUE WITH RUN OF PROGRAM

;ENTRY FOR PRARG...

DOCC2::	PRGSTG			;ALLOCATE STORAGE
	CALL TRYGTJ		;GET JFN ON FILESPEC
	 CMERRX <Can't run program>
	MOVEM A,PJFN		;REMEMBER JFN OF PROGRAM
	JRST RSUBS4		;GO RUN PROGRAM
;FIRST KEYWORD IS NOT A COMMAND NAME,
; SEE IF ITS A SUBSYSTEM NAME

CIN3:	PRGSTG			;ALLOCATE TEMPORARY STORAGE
	MOVE A,B
	MOVEM A,PJFN		;REMEMBER JFN
	MOVEI A,EXTSIZ		;GET ROOM FOR FILENAME
	CALL GETBUF		;GET BUFFER FOR IT
	HRRO A,A		;MAKE POINTER TO THE SPACE
	MOVEM A,PNAMP		;REMEMBER POINTER TO PROGRAM NAME
	HRLM A,PRGCEL		;SET UP POINTER TO PROG NAME FOR ^T
	MOVE B,PJFN		;GET PROGRAM NAME
	MOVX C,1B8		;WE WANT JUST THE NAME FIELD
	JFNS			;GET FILE NAME
	MOVEI B,PRGCEL
	MOVEM B,COMAND
NOXTND,<
	CALL CIN3D		; GET REST OF COMMAND LINE
	JRST RSUBS4		; START PROCESS
>
XTND,<
	MOVEI A,FRKNMS		; SEE IF WE KNOW ABOUT THIS FORK
	MOVE B,PNAMP
	TBLUK
	TXNE B,TL%EXM		; EXACT MATCH OF NAME?
	 TLOA Z,F1		; YES - REMEMBER IT
	  TLZA Z,F1		; NO - GO ON
	   MOVEM A,PTBLP	; SAVE TABLE POINTER
	MOVE A,PJFN
	DVCHR			; GET DEVICE CHARACTERISTICS
	TLNE A,177777		; IS IT A DISK?
	 JRST RSUBS3		; NO - GO ON
	MOVE A,PJFN
	MOVE B,[1,,.FBCTL]	; GET FILE FLAGS
	MOVEI C,C		; INTO C
	CALL $GTFDB
	 JRST CERR
	LDB C,[POINTR C,FB%FCF]
	CAIN C,.FBKEP		; KEPT PROGRAM?
	 TLO Z,F2		; YES , REMEMBER THAT
	CAIE C,.FBEPH		; EPHEMERAL?
	 JRST RSUBS3		; NO - GO ON
	NOISE <;E>		; YES - HANDLE SPECIAL
	CALL CIN3D		; GATHER REST OF COMMAND LINE
	MOVEI Q1,ETTYMD		; SET TTY MODES
	CALL LTTYMD
	MOVE A,PJFN		; PASS ON JFN
	JRST REPH		; GO RUN EPHEMERAL
>
CIN3D:	LINEX <Data line to be sent to program>
	 CMERRX
	MOVE B,CMABP		;GET POINTER TO BEGINNING OF END OF LINE
	ILDB D,B		;GET FIRST CHARACTER OF REST OF LINE
	MOVE A,CSBUFP		;POINTER TO COMMAND LINE
	MOVE B,PNAMP		;GET POINTER TO PROGRAM NAME
	MOVEI C,0		;END ON NULL
	SOUT			;START COMMAND LINE WITH PROGRAM NAME
	MOVEI B,40		;SPACE TO SEPERATE FILENAME FROM REST OF LINE
	CAIE D,0		;IS THERE ANY MORE TO THE LINE?
	 TLOA Z,F3		; YES - LITE FLAG
	  TLZA Z,F3		; NO - CLEAR FLAG
	   BOUT			;  AND PUT THE SPACE IN
	MOVE B,CMABP		;GET POINTER TO ATOM BUFFER (REST OF LINE)
	SOUT			;COPY REST OF LINE FOR RSCAN
	HRROI B,[BYTE (7)12,0]	;LINEFEED TO END RSCAN BUFFER
	SOUT			;FINISH LINE WITH LF
	CONFIRM			;GET CONFIRMATION AFTER DATA LINE
	MOVE A,CSBUFP		;GET RESCAN POINTER
	CALL BUFFS		;SAVE THE STRING
	MOVEM A,RSPTR		;SET UP FINAL ONE, NOW THAT COMMAND IS CONFIRMED
	RET			; RETURN

XTND,<
RSUBS3:	CALL CIN3D		; GATHER COMMAND LINE
	TLZe Z,F1		; DO WE KNOW THIS FORK?
	 TLZe Z,F3		; HAVE COMMAND ARGS?
	  JRST RSUBS4		;   TREAT AS NEW instance
	MOVE B,PTBLP		; GET TABLE PNTR
	hrrz a,0(b)		; fork handle
	move a,slftab(a)	; fork flags from table
 	SKIPN CCKEEP		; CARE IF FORK INTERRUPTED?
	 TXNE A,FK%KPT		; NO - IS IT KEPT
	  CAIA			; YES - CHECK CTRL-C FLAG
	   JRST RSUBS4		; NO - MAKE NEW ONE
	txnn a,fk%int		; involuntary termination?
	 JRST CONTFK		; NO - JUST RESUME FORK
>
RSUBS4:	MOVEI Q1,ETTYMD		;MAKE SURE NORMAL TTY MODE RESTORED
	CALL LTTYMD
	CALL ERESET		;PREPARE TO LOAD AND RUN PGM
	MOVE A,PJFN		;SAY WHICH PROGRAM TO GET
	CALL $GET2		; GET PROGRAM
XTND,<
	TLZN Z,F2		; KEEP THIS ONE?
	 JRST ..STRT		; NO - START IT NOW
	MOVE A,FORK		; YES - MARK IT
	MOVX B,FK%KPT
	IORM B,SLFTAB(A)	; IN FORK TABLE
	TYPE <[Keeping]
>
>
	JRST ..STRT		;START PROGRAM

;NOT A SUBSYSTEM NAME,
; GO TO SPECIAL ERROR PROCESSOR IF THIS USER HAS ONE
;4/30/70: AT THIS POINT WE DON'T KNOW THE WHOLE INPUT TEXT
;	BECAUSE WE HAVEN'T CAPTURED CHARACTERS READ BY GTJFN.

CIN4:
NOXTND,<
CIN4E:	CMERRX <Unrecognized command>
>
XTND,<
	MOVEI B,[FLDDB. .CMKEY,,FRKNMS]	; TRY LOOKING UP COMMAND
	CALL FLDSKP		; IN FORK NAME TABLE
CIN4E:	 CMERRX <Unrecognized command>
	CONFIRM			; MUST HAVE CR
	JRST CONTFK		; GOT IT - NOW CONTINUE
>
;EXAMINE (MEMORY LOCATION) N

.EXAMI:	NOISE <MEMORY LOCATION>
	SETZ A,			;Say examine
	CALL EXDPDF		;Set default address, if any
	MOVEI A,[ASCIZ /Address to examine/]
	MOVEI B,[ASCIZ /Confirm with carriage return/]
	CALL OCTCOM		;Read general octal number
	CONFIRM
	TLNE A,777740		;This command only allows 32 sections
	ERROR <Memory address not between 0 and 37,,777777>
	CALL MAPPF		;MAP THAT PAGE & GET ACCESS INFO
	 JRST CJERRE		;Failed-- type JSYS error
	TXNN B,PA%PEX
	ERROR <No such page>
	TXNN B,PA%RD
	ERROR <Can't read that page>
	MOVEM A,EXDPLC		;Save this location as last one examined
	SETZM EXDPF		;Indicate last was examine
	MOVE C,A		;Fetch contents
	ANDI C,777
	MOVE C,PAGEN(C)		;RH
	ETYPE<%1Y/ %3Y%%_>		;TYPE CARRIAGE RETURN
	JRST CMDIN4		;DONE, GET NEXT COMMAND
;DEPOSIT (MEMORY LOCATION) N (CONTENTS) M

.DEPOS:	NOISE <MEMORY LOCATION>
	SETO A,			;Indicate deposit
	CALL EXDPDF		;Set default address
	MOVEI A,[ASCIZ /Address in which to deposit/]
	MOVEI B,[ASCIZ /Value to deposit/]
	CALL OCTCOM		;Read general octal number
	TLNE A,777740		;This command only allows 32 sections
	ERROR <Memory address not between 0 and 37,,777777>
	PUSH P,A		;SAVE ADDRESS
	NOISE <CONTENTS>
	MOVEI A,[ASCIZ /Value to deposit/]
	MOVEI B,[ASCIZ /Confirm with carriage return/]
	CALL OCTCOM		;INPUT VALUE, ACCEPTING LH,,RH ETC,
	PUSH P,A		;SAVE DATA FOR DEPOSITING
	CONFIRM
	SKIPG FORK		;FORK EXISTS?
	CALL ECFORK		;NO, CREATE ONE
	MOVE A,-1(P)		;GET LOCATION BEING WRITTEN INTO
	CALL MAPPF		;MAP THAT PAGE AND GET ACCESS INFO
	 JRST CJERRE		;Failed-- type JSYS error
	TXNN B,PA%WT
	JRST [	TXNN B,PA%CPY	;COPY-ON-WRITE BIT
		ERROR <Can't write that page>
		TYPE < [Shared] >
		JRST .+1]
	TXNN B,PA%PEX
	JRST [	TYPE < [New] > ;ADVISORY MESSAGE
		JRST .+1]

;GET VALUE

	POP P,A		;RESTORE DATA TO BE WRITTEN
	POP P,B		;GET LOCATION BEING WRITTEN INTO
	MOVEM B,EXDPLC		;Save last location examined/deposited
	SETOM EXDPF		;Indicate deposit last

;STORE A AT B IN FORK. ASSUME WE STILL HAVE THE PAGE.

	MOVE C,B		;Remember address
	ANDI B,777		;MASK OFF PAGE # PART OF ADDRESS
	MOVEM A,PAGEN(B)	;STORE INTO PAGE BUFFER

;EXECUTION OF DEPOSIT COMMAND...
;IF ADDRESS < 20, SET FORK AC'S. NON-AC PAGES HANDLE THEMSELVES.

	TDNE C,[777776,,777760]	;ACs are also in section 1
	JRST CMDIN4
	MOVE A,FORK
	MOVEI B,PAGEN
	SFACS
	 ERJMP CJERRE		;Failed-- type JSYS error
	JRST CMDIN4

; EXDPDF - Set default address for examine or deposit
; 	A/	0 for examine, -1 for deposit
;
EXDPDF:	STKVAR <EAM>
	SKIPGE B,EXDPLC		;Any previous examine/deposit?
	 RET			;No-- don't set default
	CAMN A,EXDPF		;Flag same as last operation?
	 ADDI B,1		;Yes-- bump to next location
	MOVEM B,EAM
	MOVEI A,3		;ENOUGH ROOM FOR NUMBER
	CALL GETBUF		;GET BUFFER ON WORD BOUNDARY
	MOVE D,A		;REMEMBER WHERE BUFFER STARTS
	HRLI A,440700		;MAKE BYTE POINTER
	MOVX C,^D8		;Get old value
	MOVE B,EAM

;Would like to set default string to m,,n instead of large octal number
;This requires m,,n to be an atom for some type of COMND JSYS field

REPEAT 0,<
	TLNN B,-1		;Any significance in left half?
	JRST EXDPRH		;No--just do right half
	PUSH P,B		;Save number for right half later
	HLRZS B			;Set to print left half now
	NOUT			; in octal
	 JRST [	POP P,(P)	;Can't--don't default
		RET]
	MOVEI B,","		;Separate halves with ",,"
	IDPB B,A
	IDPB B,A
	POP P,B			;Get back number
EXDPRH:	HRRZS B			;Print just right half now
>				;END OF REPEAT 0

	NOUT			; in octal
	 RET			;Can't-- don't default
	UDEF @D		;Set default to text number
	RET			;Return from EXDPDF

;	READ ONLY STORAGE AREA

;EXTERNS FOR CELLS REFERENCED IN THIS AREA ONLY
; SPECIAL CHARACTER ROUTINES:

;COMMAND TABLES

;FORM:
;       LABEL:  NUMBER OF ENTRIES
;               XWD [VALUE],[ASCIZ @TEXT@]  FOR EACH ENTRY, ALPH ORDER
;   VALUE IS GENERALLY  XWD BITS,ADDRESS
;       SEE "DEFINITIONS" FILE FOR BIT SYMBOLS AND MACRO DEFINITIONS

;MACROS USED TO GENERATE TABLES (DEFINED IN "DEFINITIONS" FILE)
;
;	T TEXT[,BITS[,ADDRESS]]		;HERE []'S MEAN OPTIONAL
;		SETS UP ENTRY. DEFAULTS ADDRESS TO ".TEXT", OR IF
;		THAT IS UNDEFINED, TO "NOT IMPLEMENTED" ERROR ROUTINE
;
;	X TEXT
;		CREATES A SPECIAL FAKE ENTRY, TO MAKE AN OTHERWISE
;		UNIQUE SUBSET AMBIGUOUS (EVEN THE EXACT TEXT GIVEN TO X 
;		MACRO WILL BE TREATED AS AMBIGUOUS).  USED WHERE ACTUAL
;		AMBIGUITY IS WITH AN ENTRY IN ANOTHER TABLE SEARCHED
;		LATER.
;
;	TABLE	RESERVES WD FOR # ENTRIES AT TOP OF TABLE
;
;	TEND	FILLS IN # OF ENTRIES SINCE LAST "TABLE" MACRO
;		IN LOCATION RESERVED BY THAT "TABLE" MACRO
;COMMANDS NOT PREFIXED BY ^E.
;CCL COMMANDS ALL DISPATCH TO DOCCL, QUEUE COMMANDS DISPATCH
;TO QCM

CTBL1:  TABLE

T ACCESS			;ACCESS (TO DIRECTORY) <NAME>
T ADVISE			;ADVISE USER/TTY
T APPEND			;APPEND <FILE> (TO) <FILE>
T ARCHIVE			; ARCHIVE (files), keyword
T ASSIGN			;ASSIGN <DEVICE> (AS) <NAME>
T ATTACH,NOLG			;ATTACH (TO JOB) <JOBNO>
T BACKSPACE			;BACKSPACE
   XTND,<
T BLANK,NOLG			; CLEAR SCREEN
   >
T BREAK,NOLG			;BREAK (LINKS)
T BUILD,,.CREAT			;BUILD OR MODIFY DIRECTORY
T CANCEL			;KILL QUEUE REQUEST
   XTND,<
T CD,,.CONNE			; ABBREV FOR CONNECT
   >
   NOSHIP,<
T CLEAR				;CLEAR DEVICE DIRECTORY
   >;NOSHIP
T CLOSE				;CLOSE (JFN) <JFN NUMBER>
T COMPILE			;COMPILE (FROM
TA CON				;"con" means continue
T CONNECT			;CONNECT (TO DIRECTORY) <NAME>
.CON:	T CONTINUE		;CONTINUE
T COPY				;COPY (FROM) <FILE> (TO) <FILE>
T CREATE,,.EDITC		;CREATE (FILE) <FILE>
T CREF				;CREF (FILE)
T CSAVE,EASB			;SAVE ... (ON) <FILE>.
TA D				;"D" IS DEPOSIT
T DAYTIME,ONEWRD+NOLG		;DAYTIME
T DDT,ONEWRD+EASB		;START DDT
T DEASSIGN			;DEASSIGN (DEVICE)
T DEBUG				;DEBUG (FROM)
T DEFINE			;DEFINE (LOGICAL NAME)--(AS)--
T DELETE			;DELETE <FILE>
.D:	T DEPOSIT		;DEPOSIT INTO MEMORY LOCATION
T DETACH			;DETACH JOB
T DIRECTORY			;DIRECTORY.
   XTND,<
TA DIS				; ABBREV FOR DISABLE
   >
.DIS:	T DISABLE		; DISABLE PRIV CMNDS
T DISCARD			; DISCARD tape information
T DISMOUNT			;DISMOUNT TAPE OR STRUCTURE
   NOSHIP,<
IT DMOUNT			;DMOUNT (TAPE) <LOGICAL> (VOLID) ...
   >;NOSHIP
   MIC,<
T DO				; DO (FILE)
   >
TA E				;"E" SAME AS "EXAMINE"
T EDIT				;EDIT (FILE) <FILE> (OUTPUT AS) <FILE>
T ENABLE			;ENABLE PRIV CMDS
T END-ACCESS,,.ENDAC		;END-ACCESS (TO DIRECTORY) <NAME>
T EOF				;END OF FILE
XTND,<
T ERUN				; ERUN (EPHERMERAL)
>
TA EX 				;SPECIAL ABBREV FOR EXECUTE
.E:	T EXAMINE		;EXAMINE MEMORY CONTENTS
.EX:	T EXECUTE		;EXECUTE (FROM)
T EXPUNGE			;EXPUNGE (DELETED FILES)
T FDIRECTORY 			;DIR, CRAM, EVERYTHING, NO HEADING
T FORK				;FORK <N>. AFFECTS /, \, ETC.
   XTND,<
T FREEZE			; FREEZE (FORK)
   >
T GET				;GET <FILE>
T HELP				;HELP COMMAND
T INFORMATION,NOLG		;INFORMATION COMMANDS
   XTND,<
T KEEP				; KEEP (FORK)
   >
   MIC,<
T KMIC
   >				; KILL MIC PROCESS
   NOSHIP,<
T LABEL,,DOCCL			;LABEL
   >				;NOSHIP
T LOAD				;LOAD (FROM)
TA LOG				;FUDGE TO RECOG "LOG" AS "LOGIN"
.LOG:	T LOGIN,NOLG		;LOGIN <USER> <PASSWD> <ACCT>
T LOGOUT,NOLG			;LOGOUT
   NOSHIP,<
T MAKE,,DOCCL			;MAKE (FILE)
   >				;NOSHIP
T MERGE,EASB			;MERGE <FILE>
T MODIFY			;MODIFY QUEUE REQUESTS
T MOUNT				;MOUNT TAPE OR STRUCTURE
   XTND,<
T NAME				; NAME (FORK AS)
   >
T PLOT				;PUT FILES INTO PLOTTER QUEUE
T POP				;POP EXEC LEVEL
T PRINT				;PRINT
T PUNCH				;PUNCH CARDS/PAPER-TAPE
T PUSH				;PUSH EXEC LEVEL
   XTND,<
T QD,				; QFD - DELETED FILES ONLY
   >
T R				;= RUN SYS:
   XTND,<
T RDIRECTORY,			; DIR, READ, SIZE, CHRON BY READ
   >
T RECEIVE			;RECEIVE (LINKS/ADVICE)
T REENTER			;REENTER
T REFUSE			;REFUSE (LINKS/ADVICE)
T REMARK			;ENTER REMARK MODE
T RENAME			;RENAME (...) -- (TO BE) --
   NOXTND,<
T RESET,ONEWRD			;RELEASES MEMORY & CLOSES FILES
   >
   XTND,<
T RESET				; RESET (FORK) NAME
   >
T RETRIEVE			;RETRIEVE <files>
T REWIND			;REWIND
T RUN				;RUN <FILE>. STARTS ENV FILE.
T SAVE,EASB			;SHARABLE SAVE
IT SDISMOUNT			;SDISMOUNT (FILE STRUCTURE) <NAME>
T SET,NOLG			;SET COMMAND
T SKIP				;SKIP
IT SMOUNT			;SMOUNT (FILE STRUCTURE) <NAME> ...
T START				;START PROGRAM
T SUBMIT			;SUBMIT
T SYSTAT,NOLG,.SISTA		;SYSTEM STATUS PRINTOUT
T TAKE				;TAKE (EXEC INPUT FROM) FILESPEC
T TALK				;TALK (TO)
T TDIRECTORY, 			;DIR, TIME W, CHRON W, REV
   NOSHIP,<
T TECO,,DOCCL			;TECO (FILE)
   >				;NOSHIP
T TERMINAL,NOLG			;TERMINAL TYPE IS N
IT TMOUNT			;TMOUNT (TAPE) <LOGICAL> (VOLID) ...
T TRANSLATE			;TRANSLATE BETWEEN DIRS AND PPNS
T TYPE				;LIST FILE TO TTY
T UNATTACH,NOLG			;DETACH REMOTE JOB
T UNDELETE			;UNDELETE <FILE>
   XTND,<
T UNKEEP			; UNKEEP (FORK)
   >
T UNLOAD			;UNLOAD
T VDIRECTORY, 			;DIR, PROT, SIZ, LEN, TIM W, USER W
   XTND,<
T WDIRECTORY,			; DIR, SIZE, USER W, USER CRE, CHRON BY WRITE
   >
        TEND

STAT,<IFG .-CTBL1-1000,<PRINTX COMMAND TABLE TO LARGE FOR STATISTICS>>
;PRIVILEGED COMMANDS PREFIXED WITH ^E
;ONLY LEGAL FOR PRIV USERS WHO HAVE "ENABLE"D PRIV COMMANDS

CTBL2:  TABLE

T CEASE,,ECEASE			;SYSTEM SHUTDOWN
T CREATE			;CREAT/MODIFY DIRECTORY
T DEFINE,,EDEFIN		;CREATE LOGICAL NAME
T EDDT,ONEWRD+WHLU		;GO TO DDT LOOKING AT EXEC
T PRINT,,EPRINT			;PRINT DIRECTORY INFORMATION
T QUIT,ONEWRD+WHLU		;QUIT: EXIT TO SUPERIOR EXEC
T SEND				;SEND (MESSAGE) TO ALL
T SET,,ESET			;SET DATE AND TIME
T SPEAK				;SPEAK (TO SYSJOB)

	TEND
;PSEUDO-INTERRUPT SYSTEM TABLES

; IN "SUBRS" ASSEMBLY:

;LEVEL TABLE: WHERE TO STORE PC'S FOR VARIOUS LEVELS

LEVTAB::LEV1PC
	LEV2PC
	LEV3PC

;CHANNEL TABLE
;INDEXED BY CHANNEL NUMBER. XWD LEVEL,ADDRESS FOR EACH.

DEFINE DEFCH (LEVEL,ROUTIN,CHANEL)
<
IFN CHNS&1B<CHANEL>,<PRINTX ?CHANNEL TABLE OVERLAPS ITSELF>
CHNS==CHNS!1B<CHANEL>
RELOC CHNTAB+CHANEL
	XWD LEVEL,ROUTIN
>
CHNS==0
CHNTAB:

NOXTND,<
 DEFCH 1,MALINT,MALCHN			;MAIL-WATCH INTERRUPT
>
XTND,<
 DEFCH 1,IITPSI,IITCHN		; AUTO MAIL-WATCH & ALERTS
>
 DEFCH LV.IPC,IPCINT,IPCCHN			;IPCF INTERRUPT
 DEFCH LV.IPC,CCPSI,1			;1: ASSIGNED BY PROGRAM TO ^C
			;^C INTERRUPT LEVEL MUST BE KEPT THE SAME AS
			;IPCF INTERRUPT LEVEL TO PREVENT ^C OUT OF IPCF
			;INTERRUPT, WHICH WOULD PREVENT FURTHER IPCF MESSAGES,
			;SINCE THE MONITOR ONLY GENERATES INTERRUPT WHEN NUMBER
			;OF MESSAGES GOES FROM 0 TO 1.
 DEFCH 1,ALOPSI,2			;2: ASSIGNED BY PROGRAM TO AUTO-LOGOUT
 DEFCH 3,USEPSI,3			;3: ASS BY PROG TO CHAR TO PRINT RUNTIME (^T)
 DEFCH 2,TLMPSI,4			;4: TIME LIMIT EXCEEDED TRAP
 DEFCH 2,COBPSI,5			;5: ASS BY PROG TO CLEAR OUTBUF ON ^O
 DEFCH LV.POV,PDLOV,.ICPOV		;PUSHDOWN OVERFLOW
 DEFCH LV.EOF,EOFPSI,.ICEOF		;END OF FILE
 DEFCH LV.DAT,DATPSI,.ICDAE		;FILE DATA ERROR
 DEFCH LV.QTA,QTAPSI,.ICQTA		;QUOTA EXCEEDED (OR DISK FULL)
 DEFCH LV.ILI,ILIPSI,.ICILI		;I>>, MR>>, MW>>, MX>>
 DEFCH 1,[TRAP (1,<Illegal memory READ>)],.ICIRD
 DEFCH 1,[TRAP (1,<Illegal memory WRITE>)],.ICIWR
 DEFCH 1,INFTRM,.ICIFT			;INFERIOR FORK TERMINATION
 DEFCH 1,[TRAP (1,<File or Swapping space exceeded>)],.ICMSE
				;MACHINE SIZE EXCEEDED
 DEFCH LV.ESC,ESCPSI,ADVCHN		;ESCAPE CHARACTER FOR ADVISE

RELOC CHNTAB+6*6		;LEAVE ROOM FOR CHANNEL TABLE

;INITIAL WORD FOR COMMAND STREAM JFN POINTER

IOPTB::	IOWD IOLEN,IOLST	;INITIAL POINTER FOR COMMAND STREAM

NOXTND,<
;EXEC INTERRUPTS TO HERE (CAUTION: FROM ANYWHERE!) WHEN MAIL
;HASN'T BEEN CHECKED FOR AWHILE.

MALINT:	SETOM MAILF		;SET FLAG TO SAY INTERRUPT HAPPENED
	DEBRK
>
;SYSTAT

;BITS IN Q1 USED FOR SYSTAT OUTPUT CONTROL

SYSIND==1

DEFINE SYSBIT(A)
<	IRP A,<
IFE SYSIND,<PRINTX SYSTAT CONTROL BITS EXHAUSTED
>
SY%'A==SYSIND
SYSIND==SYSIND+SYSIND
>>

SYSBIT <ALL,CLS,HED,NHD,TTY,USR,SUB,TIM,CON,LIM,CJB,JOB,NJB,STA,NOP,4NH>

SYSDEF==SY%TTY!SY%USR!SY%SUB!SY%4NH	;DEFAULT LISTING

SYSALL==SY%ALL!SY%CLS!SY%TTY!SY%USR!SY%SUB!SY%TIM!SY%CON!SY%LIM!SY%CJB!SY%STA!SY%4NH ;ALL (EVERYTHING)

;INDICES FOR STACK ARGS
SY$JOB==0	;JOB NUMBER
SY$TTY==1	;LINE NUMBER
SY$DIR==2	;DIRNUM
SY$USR==3	;USER NUMBER
SY$PRG==4	;PROGRAM NAME

JIBLN==.JILNO+1			;SIZE BLOCK NEEDED FOR JOB INFO
SYCLN==10			;SKED% BLOCK SIZE

.SISTA:	TRVAR <SYSJFN,JNX,<SYCLB,SYCLN>,<.JIBAS,JIBLN>,SFRAME,<SYSTAK,SYSTAL>,SYSDIR,SYSTNM,SISTAS,SISTAN,<HSTNAM,10>,HDRPOS>
	SETZM SYSJFN		;NO SPECIAL OUTPUT JFN YET
XTND,<
	SETOM TYPING		; SAY TYPEOUT IN PROGRESS
>
	MOVE Q1,[SYSDEF]
	HRLI A,-SYSTAL
	HRRI A,SYSTAK		;MAKE STACK POINTER
	MOVEM A,SFRAME		;SAVE ARG START
	TLZ Z,F3
	JRST SYSTK1		;GO READ THE LINE AFTER WORD "SYSTAT"

SYSTK.:	GJINF
	MOVEI A,SY$JOB
	CALL SSTACK		;PUT FLAVOR ON STACK
	MOVE A,C
	CALL SSTACK		;PUT ITEM ON STACK
	JRST SYST1J

SYSTK1:	MOVEI B,[
		FLDDB. .CMKEY,,$SESTA,,,[
		FLDDB. .CMUSR,,CM%DWC,,,[
		FLDDB. .CMDIR,,CM%DWC,,,[	;KEEP AFTER USER NAME TO ALLOW RECOGNITION ON USER NAME
		FLDDB. .CMNUM,CM%SDH,5+5,<Decimal job number>,,[
		FLDDB. .CMCMA,,,,,[
		FLDDB. .CMTOK,,<-1,,[ASCIZ /./]>,,,[
		FLDDB. .CMCFM,,,,,]]]]]]]
	CALL FLDSKP		;GET SOME INPUT
	 JRST SYSNX		;NO
	LDB D,[331100,,(C)]	;GET FUNCTION CODE
	CAIN D,.CMKEY		;KEYWORD?
	JRST SYSKEY		;YES
	CAIN D,.CMUSR		;USER NAME?
	JRST SYSTU		;YES
	CAIN D,.CMDIR		;DIRECTORY NAME?
	JRST SYSTD		;YES
	CAIN D,.CMNUM		;DECIMAL JOB NUMBER?
	JRST SYSTJ		;YES
	CAIN D,.CMCMA		;COMMA?
	JRST SYSSUB		;YES, MAYBE SUBCOMMANDS COMING
	CAIN D,.CMTOK		;DOT?
	JRST SYSTK.		;YES
	CAIN D,.CMCFM		;END OF LINE?
	JRST SYSTS0		;YES GO EXECUTE COMMAND
	CALL SCREWUP		;SHOULD NEVER GET HERE

;KEYWORD TYPED AFTER SYSTAT

SYSKEY:	CALL GETKEY		;CHANGE TABLE ADDRESS TO DISPATCH DATA
	CALL (P3)
	JRST SYSTK1

;COMMA TYPED..

SYSSUB:	CRRX <Carriage return to enter subcommands, or another SYSTAT argument>
	 JRST SYSTK1		;NO CR AFTER COMMA, NOT TIME FOR SUBCOMMANDS
	JRST SYSUB1		;COMMA CR, SO GO GET SUBCOMMANDS

SYSNX:	CMERRX <Invalid SYSTAT argument>

SYSUB1:	SUBCOM $SYSTB
SYSTS0:	TXNE Q1,SY%CLS		;USER ASKING FOR CLASS STUFF?
	JRST [	CALL CLSON	;YES, MAKE SURE CLASS SCHEDULING IS ON
		 CAIA		;NO!
		JRST .+1	;YES
		TXNN Q1,SY%ALL	;DON'T COMPLAIN IF HE SAID "ALL"
		ETYPE <%%Class-scheduling is off%_>
		TXZ Q1,SY%CLS	;PRETEND HE NEVER ASKED FOR CLASS STUFF
		JRST .+1]
	SKIPN A,SYSJFN		;SPECIAL OUTPUT JFN?
	JRST SYSNFL		;NO!
	LDF B,OF%WR		;WRITE
	CALL $OPEN7		;OPEN, 7 BIT BYTES, MODE 0.
	MOVE A,SYSJFN		;NOW REDIRECT COJFN
	MOVEM A,COJFN		;(MUST WAIT UNTIL AFTER $OPEN7 SINCE $IOCHK WOULD CIRCUMVENT THE OPENF!)
SYSNFL:	TXNN	Q1,SY%JOB!SY%NJB ;IF NEITHER JOB NOR NON-JOB NOR DEBUG
	TXO	Q1,SY%JOB!SY%NJB ;THEN DEFAULT TO JOB AND NON-JOB
	TXNN	Q1,SY%HED!SY%NHD ;IF HEADER NOT DECIDED,
	TXO	Q1,SY%HED		;DEFAULT TO HEADER
	TXNE	Q1,SY%NJB
	CALL SYPART		;TYPE SYSTEM PART
	TXNE	Q1,SY%JOB
	CALL JBPART		;TYPE JOB LINES
	RET

SYPART:	SAVEAC <Q1>		;DON'T CLOBBER Q1 (READT DOES SO)
	PRINT " "
	GTAD
	MOVE B,A
	CAMN B,[-1]
	MOVSI B,1		;DO SAME AS %A IF NO DATE
	MOVE A,COJFN
	MOVX C,OT%DAY!OT%SCL
	ODTIM			;CAN'T USE %D BECAUSE WE WANT DAY OF WEEK
	ETYPE <  Up %k%%_ %i Jobs   Load av >
	HRROI A,-1		;WE WANT LOADS FOR CURRENT JOB'S CLASS
	CALL GLOADS		;GET LOAD AVERAGES
	CAIL A,0		;CLASS SCHEDULING ON?
	ETYPE <(class %1q) >
	ETYPE <%2Q %3Q %4Q%%_%%_>
	MOVEI A,.SFOPR		;READ OPR STATUS
	TMON
	CAIN B,0
	ETYPE < No operator in attendance%_%%_>
	SETZ D,
	GTB .DBUGS		;READ DBUGSW
	JUMPE A,SYDBG1		;0=NORMAL, DON'T PRINT
	HRROI B,[ASCIZ/ System is stand-alone/]	;ASSUME THIS
	CAIN A,1		;1=REMEDIAL
	HRROI B,[ASCIZ / System is remedial/]
	ETYPE <%2m%%_%%_>
SYDBG1:	CALL SYSDWN		;PRINT DOWN-TIME INFO
	RET

SYSDWN::MOVEI D,0		;GET ITEM 0 FROM DWNTIM TABLE
	GTB .DWNTI
	JUMPE A,R		;DO NOTHING IF NOT SET
	ETYPE < System shutdown scheduled for %1D %E>
	MOVEI D,1		;GET ITEM 1
	GTB .DWNTI
	CAIE A,0
	ETYPE <,%_Up again at %1D %e>
	ETYPE <%_%%_>
	RET

;LOOP TO TYPE TSS JOB #, TTY #, USER  FOR EACH JOB

JBPART:	TLZ Z,F1+F2		;CLEAR LOCAL FLAGS
	MOVX A,.NULIO		; Toss away the host name
	SETO B,			; Get our host name
	CVHST			; To see if this is an ARPA system
	 ERJMP [TXZ Q1,SY%4NH		; It isn't, so don't do 4N host name
		JRST .+1]		; Rejoin main flow
	MOVSI A,(RC%EMO)	;EXACT MATCH ONLY
	HRROI B,[ASCIZ /OPERATOR/]
	RCUSR			;GET OPERATOR'S USER NUMBER
	TLNE A,(RC%NOM+RC%AMB)	;GOT IT?
	 MOVEI C,-1		;IF NO SUCH, USE -1
	MOVEM C,SYSDIR
	TLZ Z,F3		;NO JOBS PRINTED YET
SYST9A:	SETO D,
	GTB .JOBRT		;GET # POSSIBLE JOBS
	HRLZ D,A		;XWD AOBJN COUNT, JOB #

;TOP OF LOOP

SYST2:	MOVEM D,JNX		;REMEMBER JOB NUMBER COUNTER
	HRRZ A,JNX
	HRLI B,-JIBLN		;LENGTH OF JOB INFO BLOCK
	HRRI B,.JIBAS		;STORE INTO CORRECT BLOCK
	MOVEI C,0		;START WITH FIRST ENTRY
	GETJI
	 CALL [	CAIE A,GTJIX4	;NO SUCH JOB?
		JRST JERR	;NO, COMPLAIN
		POP P,(P)
		JRST SYST9]	;YES, SKIP IT
	HRROI B,.JILNO+.JIBAS	;PREPARE TO GET LOGGED-IN DIR NUMBER
	MOVEI C,.JILNO
	GETJI			;TRY TO GET LOGGED-IN DIR NUMBER
	JFCL			;FAILED, BUT SEE "MOVE C," ABOVE
	SKIPGE .JIRT+.JIBAS	;NEG RUN TIME MEANS NO JOB
	JRST SYST9		;SO SKIP IT

;CHECK FOR PASS 1 OR 2

	SETO B,			;ASSUME NOT OPR
	MOVE A,SYSDIR
	CAMN A,.JIUNO+.JIBAS
	SETZ B,			;FLAG OPR
	TLNE Z,F2
	SETCA B,		;REVERSE TEST FOR PASS 2
	JUMPE B,SYST9		;PASS 1, SKIP OPR. PASS 2, DO OPR

;CHECK IF REQUESTED JOB

	HRLI A,-SYSTAL
	HRRI A,SYSTAK
	CAMN A,SFRAME		;ANY ARGS?
	JRST SYST2Y
SYST2A:	MOVE B,(A)		;GET INDEX INTO FUNCTION TABLE
	MOVE C,1(A)		;GET ARG 
	XCT [	JRST SYST2D
		CAMN C,.JITNO+.JIBAS
		JRST SYST2C
		JRST SYS2U
		JRST SYSPRG](B)		;NOTE INDEX ***
	JRST SYST2Z		;MATCH
SYST2B:	ADD A,[2,,2]
	CAME A,SFRAME
	JRST SYST2A
	JRST SYST9		;NO MATCH

SYSPRG:	CAMN C,.JIPNM+.JIBAS	;CORRECT PROGRAM NAME?
	JRST SYST2Z		;YES
	JRST SYST2B

SYS2U:	CAMN C,.JIUNO+.JIBAS	;CORRECT USER NUMBER?
	JRST SYST2Z		;YES
	JRST SYST2B

SYST2C:	CAMN C,.JILNO+.JIBAS
	JRST SYST2Z
	TXNN	Q1,SY%CON	;SHOWING CONNECTED DIR'S?
	JRST SYST2B
	CAMN C,.JIDNO+.JIBAS
	JRST SYST2Z
	JRST SYST2B

SYST2D:	HRRZ D,JNX
	CAMN C,D		;CURRENT JOB?
	JRST SYST2Z
	TXNN	Q1,SY%CJB
	JRST SYST2B
	CAMN C,.JICPJ+.JIBAS
	JRST SYST2Z
	JRST SYST2B

SYST2Y:	MOVE D,JNX
	TRNE D,-1
	JRST SYST2Z
	SKIPGE .JITNO+.JIBAS
	JRST SYST9		;SKIP JOB 0 FOR NORMAL PRINT IF DETACHED
SYST2Z:

;HAVE A REAL JOB #. PRINT IT.

	TLOE Z,F1		;TYPE HEADER FIRST TIME.
	JRST SYSTS2
	TXNN	Q1,SY%HED
	JRST SYSTS2
	ETYPE < Job >
	TXNE	Q1,SY%CJB
	ETYPE < CJB>
	TXNE	Q1,SY%TTY
	ETYPE < Line>
	TXNE	Q1,SY%SUB
	ETYPE < Program>
	TXNE	Q1,SY%STA
	ETYPE < State>
	TXNE	Q1,SY%TIM
	ETYPE <  Time   >
	TXNE Q1,SY%CLS		;Class info requested?
	ETYPE < Cls   Shr   Use>
	TXNE	Q1,SY%LIM
	ETYPE <  Limit  >
	TXNN	Q1,SY%USR
	JRST SYST2U
	ETYPE <  User>
	TXNE	Q1,SY%CON
	UETYPE [ASCIZ /, <Directory>/]
	TXNN Q1,SY%4NH		; Doing foreign host?
	JRST SYST2U		; No, skip this then
	TXNN Q1,SY%CON		; If previous heading not typed,
	ETYPE <            >	; Columnize this better
	MOVE A,COJFN		; Get current column position
	RFPOS			;  ..
	 ERJMP [SETZ B,			; If not terminal, assume 0
		JRST .+2]		;  *** Note .+2, not .+1 ***
	ADDI B,2		; Account for leading spaces in next ETYPE
	HRRZM B,HDRPOS		; Save for later
	ETYPE <  Foreign host>
SYST2U:	ETYPE <%_>
	TLZ Z,F3		;NO NEW LINE AFTER TITLE
SYSTS2:	TLZE Z,F3		;SEPERATE USER FROM OPR?
	ETYPE <%_>
	HRRZ A,JNX
	CALL NUM4		;PRINT 4-COLUMN NUMBER
	GJINF
	MOVEI B," "		;ASSUME NOT CURRENT JOB
	HRRZ D,JNX
	CAMN C,D		;OUR JOB?
	MOVEI B,"*"		;YES, INDICATE
	PRINT @B		;SPACE OR STAR

;CONTROLLING JOB OF PTY

	TXNN	Q1,SY%CJB
	JRST SYST4A
	SKIPGE A,.JICPJ+.JIBAS
	JRST [	TYPE <    >
		JRST SYST4A]
	MOVX B,NO%LFL!FLD(4,NO%COL)!<5+5>	;LEADING FILLER, 4 COLUMNS, DECIMAL
	CALL SYNUM
SYST4A:

;"DET" OR "TTY N"

	TXNN	Q1,SY%TTY
	JRST SYST4
	SKIPGE A,.JITNO+.JIBAS
	JRST [	TYPE <  DET>
		JRST SYST4]
	MOVX B,NO%LFL!FLD(5,NO%COL)!8	;LEADING FILLER, 5 COLUMNS, OCTAL
	CALL SYNUM

SYST4:
;SYSTAT...
;SUBSYSTEM NAME

	TXNN	Q1,SY%SUB
	JRST SYST8
	SKIPN A,.JIPNM+.JIBAS
	MOVE A,.JISNM+.JIBAS	;IF NO PROGRAM NAME, USE SUBSYSTEM NAME
	ETYPE <  %1'>
	MOVEI B,0
	JUMPE A,[	TYPE <      >	;SIX SPACES IF 0 NAME
			JRST SYST8]
SYSSU:	LSHC A,-6		;PAD TO EXACTLY SIX CHARACTERS
	JUMPN B,SYST8		;LEAVE LOOP IF ENOUGH SPACES
	PRINT " "		;PRINT A SPACE
	JRST SYSSU
SYST8:	TXNN	Q1,SY%STA
	JRST SYST8A
	SKIPGE D,.JITNO+.JIBAS
	JRST SYST8B		;IF NO TERMINAL, SAY RUNNING
	GTB .TTYJO		;GET TERMINAL WORD
	HRRZ A,A
	CAIE A,-1		;OTHER THAN -1 MEANS FORK WAITING
	SKIPA B,[-1,,[ASCIZ/  TI  /]]
SYST8B:	HRROI B,[ASCIZ/  RUN /]
	ETYPE <%2m>
SYST8A:	TXNN	Q1,SY%TIM
	JRST SYSTS3
	MOVE A,.JIRT+.JIBAS
	ETYPE <  %1b>

SYSTS3:	TXNN Q1,SY%CLS		;PRINT CLASS STUFF?
	JRST SYSECL		;NO

;CLASS SCHEDULER INFO

	MOVE A,.JIJNO+.JIBAS	;GET JOB NUMBER
	MOVEM A,.SAJOB+SYCLB		;TELL MONITOR WHICH JOB TO INVESTIAGE
	MOVEI A,SYCLN		;SET UP BLOCK SIZE FOR SKED%
	MOVEM A,.SACNT+SYCLB
	MOVEI A,.SKRJP		;SAY READ JOB PARAMETERS
	MOVEI B,SYCLB		;POINT TO BLOCK
	SKED%			;READ THE INFO
	MOVE A,.SAJCL+SYCLB	;GET CLASS
	CALL NUM4		;PRINT AS FOUR COLUMNS
	DMOVE A,.SAJSH+SYCLB	;GET SHARE AND UTILIZATION
	ETYPE <%1=%%2=>
SYSECL:	TXNN	Q1,SY%LIM
	JRST SYSTS4

;LIMIT

	ETYPE <  >
	SKIPG A,.JIRTL+.JIBAS
	JRST [	ETYPE <       >
		JRST SYSTS4]
	ETYPE <%1b>

;USER NAME OR "?" IF CONVERSION FAILS.

SYSTS4:	TXNN	Q1,SY%USR
	JRST SYSTS5
	ETYPE <  >
	SKIPN B,.JIUNO+.JIBAS
	JRST [	ETYPE <Not logged in>
		JRST SYSTS5]
	ETYPE <%2r>
	TXNN	Q1,SY%CON
	JRST SYSTS5
	MOVE B,.JIDNO+.JIBAS
	CAMN B,.JILNO+.JIBAS
	JRST SYSTS5
	ETYPE <, >
	MOVE B,.JIDNO+.JIBAS
	ETYPE <%2r>
SYSTS5:	TXNN Q1,SY%4NH		; Doing foreign host name?
	JRST SYSTS6		; No, skip this stuff then
	MOVE A,[SIXBIT /PTYPAR/]
	SYSGT			; Get PTY numbers
	HLRZ B,A		; Get number of PTYs
	ADDI B,(A)		; Compute number of first NVT
	MOVE A,.JITNO+.JIBAS	; Controlling TTY number of job
	CAMGE A,B		; Is this an NVT?
	JRST SYSTS6		; No, no foreign host then
	MOVE B,A		; Copy terminal number to B
	MOVX A,.GTNNI		; Get NCP info for input connection
	MOVEI C,C		; Get foreign host number into C
	HRROI D,.NCFHS		;  ..
	GTNCP
	 ERJMP SYSTS6		; Hmmm...
	MOVX A,.GTHNS		; Get host name for this number
	HRROI B,HSTNAM		; Onto the stack
	GTHST			;  ..
	 ERJMP [HRROI A,HSTNAM
		MOVE B,C		; Copy host number to C
		MOVX C,^D8		; Octal number
		NOUT
		 JFCL
		JRST .+1]		; Rejoin
	MOVE A,COJFN		; Get current horizontal position
	RFPOS			;  ..
	 ERJMP [MOVEI B,7777		; Not terminal, assume column overflow
		JRST .+1]
	HRRZS B			; Drop line number
	MOVE A,HDRPOS		; Get desired column number of host column
	SUB A,B			; Compute distance there
	CAIGE A,2		; Force at least two spaces
	MOVEI A,2		;  ..
	CAIL A,^D100		; Unreasonably large number?
	MOVEI A,2		; Yes, use 2 instead
	PRINT " "		; Type enough spaces to line up
	SOJG A,.-1		;  ..
	PRINT "("		; Parenthesize it
	UETYPE HSTNAM		; Type the name
	PRINT ")"		; Tie it off

SYSTS6:	ETYPE <%_>
SYST9:	MOVE D,JNX
	AOBJN D,SYST2
	TXNE	Q1,SY%NOP
	JRST RLJFNS		;QUIT NOW IF NO OPERATOR JOBS
	TLO Z,F3		;FLAG CRLF SECOND TIME THROUGH
	TLON Z,F2		;SECOND PASS DONE?
	JRST SYST9A		;NO, DO IT (PRINT ONLY OPR JOBS)
	JRST RLJFNS

SYSTD:	MOVEM B,SISTAN		;SAVE DIR NUMBER
	CALL BUFFF		;GET THE DIR NAME STRING
	MOVEM A,SISTAS		;SAVE STRING POINTER
SYSTD1:	MOVEI A,SY$DIR
	CALL SSTACK		;ANNOUNCE DIRECTORY NUMBER COMING UP
	MOVE A,SISTAN		;GET NUMBER
	CALL SSTACK
	MOVE A,SISTAN		;STEP THE NUMBER
	MOVE B,SISTAS
	CALL STPDIR
	 JRST SYST1J		;NO MORE
	MOVEM A,SISTAN		;SAVE NEW DIR NUMBER
	JRST SYSTD1		;LOOP BACK FOR OTHERS

SYSTU:	MOVEM B,SISTAN		;SAVE THE USER NUMBER
	CALL BUFFF		;GET THE ATOM BUFFER
	MOVEM A,SISTAS		;SAVE STRING POINTER TO USER NAME
SYSTU1:	MOVEI A,SY$USR		;ANNOUNCE THAT USER NAME COMING UP
	CALL SSTACK
	MOVE A,SISTAN		;PICK UP USER NUMBER
	CALL SSTACK		;PUT IT ON STACK
	MOVE A,SISTAN		;NOW STEP THE USER
	MOVE B,SISTAS		;IF NEEDED
	CALL STPUSR
	 JRST SYST1J		;NO MORE USER NAMES
	MOVEM A,SISTAN		;SAVE NEW USER NUMBER
	JRST SYSTU1		;LOOP BACK FOR OTHER NAMES

SYST1J:	CALL .SYSEL
	JRST SYSTK1

SYSTJ:	PUSH P,B		;SAVE THE JOB NUMBER
	MOVEI A,SY$JOB		;FLAVOR IS "JOB NUMBER"
	CALL SSTACK
	POP P,A			;GET THE JOB NUMBER
	CALL SSTACK
	JRST SYST1J

DEFINE TB(TEXT,FLAGS,BIT)<
	T <TEXT>,FLAGS+,<[TXO Q1,SY%'BIT
				RET]>
>

$SESTA:	TABLE

T ALL,,.SYSAL
TB CLASS,,CLS
TB CONTROLLING,,CJB
TB DIRECTORY,,CON
IT FOREIGN-HOST,,F4NH
TB HEADER,,HED
TB LIMIT,,LIM
T LINE,,.SYSTT
T LPT,,.$LPT
T NO,,.SYSNO
T PROGRAM
TB STATE,,STA
TB SYSTEM,,NJB
TB TIME,,TIM
TB WHAT,,SUB
TB WHERE,,TTY
TB WHO,,USR

TEND
DEFINE TB(TEXT,FLAGS,BIT)<
	T <TEXT>,FLAGS+,<[CONFIRM
				TXO Q1,SY%'BIT
				RET]>
>

$SYSTB:	TABLE

T ALL,,..SYSA
TB CLASS,,CLS
TB CONTROLLING,,CJB
TB DIRECTORY,,CON
IT FOREIGN-HOST,,F4NH
TB HEADER,,HED
T JOB,,.SYJOB
TB LIMIT,,LIM
T LINE,,..SYST
T LPT,,..LPT
T NO,,..SYSN
T OUTPUT,,.SYOUT
T PROGRAM,,.PRCNF
TB STATE,,STA
TB SYSTEM,,NJB
TB TIME,,TIM
T USER,,.SYUSR
TB WHAT,,SUB
TB WHERE,,TTY
TB WHO,,USR

TEND

.SYOUT:	SKIPN CUSRNO
	ERROR <LOGIN please>
	NOISE <TO FILE>
	MOVE A,[XWD [ASCIZ /SYSTAT/],[ASCIZ /LST/]] ;DEFAULT NAME & EXT
	CALL COUTFN
	 JRST CERR
	CONFIRM
	MOVEM A,SYSJFN		;CAN'T SET UP COJFN UNTIL SUBCOMMANDS ARE OVER!
	RET

.$LPT:	SKIPN CUSRNO
	ERROR <LOGIN please>
	CALL GETLPT		;GET JFN ON LPT
	MOVEM A,SYSJFN		;REMEMBER TO USE IT FOR OUTPUT
	RET

..LPT:	SKIPN CUSRNO
	ERROR <LOGIN please>
	CALL FINLPT		;FINISH LPT SUBCOMMAND
	MOVEM A,SYSJFN		;REMEMBER LPT
	RET

.SYJOB:	DECX <Decimal job number>
	 CMERRX
	PUSH P,B		;SAVE THE NUMBER
	CONFIRM			;WAIT FOR CONFIRMATION
	MOVEI A,SY$JOB		;FLAVOR
	CALL SSTACK
	POP P,A			;RESTORE THE NUMBER
				;DON'T TRY TO BUM CODE BY STACKING THE
				;FLAVOR BEFORE READING VALUE.  THE
				;TYPIST MIGHT TYPE CONTROL-U, LEAVING
				;THE ARG STACK AMUCK
	CALL SSTACK
	JRST .SYSEL

.SYUSR:	STKVAR <SYUSN,SYUSS>
	TLZ Z,F1		;ALLOW DEFAULT
	SKIPN CUSRNO		;LOGGED IN?
	TLO Z,F1		;NO, SO DON'T ALLOW DEFAULTING
	CALL USRNMS
	 ERROR <No such user>
	MOVEM B,SYUSS		;SAVE POINTER TO WILD STRING
	MOVEM C,SYUSN		;SAVE USER NUMBER
	CONFIRM
.SYUS1:	MOVEI A,SY$USR		;ANNOUNCE FLAVOR IS USER
	CALL SSTACK
	MOVE A,SYUSN		;GET USER NUMBER
	CALL SSTACK
	MOVE A,SYUSN		;GET DIRECTORY NUMBER
	MOVE B,SYUSS		;AND POINTER TO STRING
	CALL STPUSR		;STEP TO NEXT USER NUMBER
	 JRST .SYSEL		;NO MORE
	MOVEM A,SYUSN		;SAVE THE NEW USER NUMBER
	JRST .SYUS1		;LOOP BACK FOR REST OF NUMBERS

;"SYSTAT PROGRAM FOO" ONLY LISTS JOBS RUNNING PROGRAM FOO

.PROGR:	CALL PROG1		;GET THE ARGS
	CALLRET .SYSEL		;SAY NO HEADING

PROG1:	STKVAR <PRGNAM>
	WORDX <Program name whose users should be displayed>
	 CMERRX <Invalid program name>
	HRROI A,ATMBUF		;POINT AT PROGRAM NAME
	CALL GETSIX		;CHANGE TO SIXBIT
	 ERROR <ILLEGAL CHARACTER IN PROGRAM NAME, OR NAME TOO LONG>
	MOVEM A,PRGNAM		;REMEMBER WHICH PROGRAM WE'RE LOOKING FOR
	MOVEI A,SY$PRG		;SAY PROGRAM NAME
	CALL SSTACK
	MOVE A,PRGNAM
	CALL SSTACK		;REMEMBER THE PROGRAM NAME
	RET

.PRCNF:	CALL PROG1		;GET PROGRAM NAME
	CONFIRM			;WAIT FOR CONFIRMATION
	CALLRET .SYSEL		;SET FLAGS SO HEADING DOESN'T APPEAR

..SYST:	CALL .SYSTT
	CONFIRM
	RET

.SYSTT:	HELPX <octal line number or>
	KEYWD $SYTTY
	 0
	 JRST .SYST1
	HRROI B,-1		;FLAG FOR DETACHED LINES
	JRST .SYST2

$SYTTY:	TABLE
T DETACHED,,0
TEND

.SYST1:	OCTX			;IF NOT A KEYWORD, HAS TO BE OCTAL NUMBER
	 CMERRX			;NOT EITHER
.SYST2:	PUSH P,B			;SAVE NUMBER
	MOVEI A,SY$TTY
	CALL SSTACK
	POP P,A				;GET NUMBER
	CALL SSTACK			;PUT IT ON STACK
.SYSEL:	TXO	Q1,SY%JOB!SY%NHD
	RET

SSTACK::SKIPL SFRAME
	 ERROR <Too many arguments>
	EXCH B,SFRAME
	MOVEM A,(B)
	ADD B,[1,,1]
	EXCH B,SFRAME
	RET

..SYSA:	CONFIRM
.SYSAL:	TXO	Q1,SYSALL
	RET

..SYSN:	CALL .SYSNO
	CONFIRM
	RET

.SYSNO:	KEYWD $SYSNO
	 0
	 JRST CERR
	JRST (P3)

DEFINE TB(TEXT,FLAGS,BIT)<
	T <TEXT>,FLAGS+,<[TXZ Q1,SY%'BIT
				RET]>
>

$SYSNO:	TABLE

TB CLASS,,CLS
TB CONTROLLING,,CJB
TB DIRECTORY,,CON
IT FOREIGN-HOST,,F4NHN
T HEADER,,.SYSNH
TB LIMIT,,LIM
T OPERATOR,,.NOOPR
TB STATE,,STA
T SYSTEM,,.SYSNS
TB TIME,,TIM
TB WHAT,,SUB
TB WHERE,,TTY
TB WHO,,USR

TEND

.SYSNH:	TXZ	Q1,SY%HED
	TXO	Q1,SY%NHD
	RET

.NOOPR:	TXO	Q1,SY%NOP
	RET

.SYSNS:	TXO	Q1,SY%JOB
	RET

F4NH:	TXO	Q1,SY%4NH
	RET

F4NHN:	TXZ	Q1,SY%4NH
	RET
;STATISTICS

CLBLN==7			;ROOM FOR COUNT, CLASS, SHAR, USE, 1 MIN LOAD, 5 MIN, 15 MIN

MONSTA::	STKVAR <CURCLS,<CLBLK,CLBLN>>
	MOVE A,[SIXBIT /SYSTAT/]
	CALL READT		;READ SYSTEM STATISTICS TABLE INTO AC'S 4-13
	ETYPE < Up %K
 Idle %4T  Waiting %5T  Sched ovh %6T  Pager traps %7T
 Swap reads %10Q Writes %11Q  File reads %12Q Writes %13Q
>
	MOVE A,[SIXBIT /NCPGS/]
	SYSGT
	ETYPE < %1Q Pages of user memory
>
	MOVE A,[SIXBIT /SYSTAT/]
	MOVEI B,10
	CALL MORET		;READ MORE OF TABLE
	TIME			;TOTAL UPTIME OF SYSTEM
	CALL FLOAT
	EXCH 1,6
	CALL FLOAT		;FLOAT NBAL TOTAL
	EXCH 1,7
	CALL FLOAT		;FLOAT NRUN TOTAL
	EXCH 1,6
	FDVR 6,1		;NRUN AVERAGE
	FDVR 7,1		;NBAL AVERAGE
	ETYPE < %4Q Term wakeups  %5Q Term interrupts
 NBAL av %7Q  NRUN av %6Q
>
	HLRE A,QTIMES		;GET NUMBER OF SHCED QUEUES
	MOVM A,A		;MAKE POSITIVE
	SUBI A,1		;MAKE LIMIT INCLUSIVE
	ETYPE < Runtime of jobs on sched queues 0-%1Q (sec)
>
	HLLZ D,QTIMES		;SETUP TO LOOP OVER QTIMES
STAT5C:	GTB .QTIME
	IDIVI A,^D1000		;CONVERT TO SECONDS
	ETYPE <	%1Q>
	AOBJN D,STAT5C
	MOVEI A,CLBLN		;BLOCK LENGTH
	MOVEM A,.SACNT+CLBLK
	CALL CLSON		;SEE IF CLASS SCHEDULER IS ON
	 JRST CLDON		;NO, SO DON'T TRY TO PRINT TABLE!
	ETYPE <%_ Class Share   Use   Loads%_>
	SETZB A,CURCLS		;START CURRENT CLASS AT 0
CLLUP:	MOVEM A,.SACLS+CLBLK		;SAY WHICH CLASS TO LOOK AT
	MOVEI A,SYCLN		;SET UP BLOCK SIZE FOR SKED%
	MOVEM A,.SACNT+SYCLB
	MOVEI A,.SKRCS		;READ CLASS PARAMETERS
	MOVEI B,CLBLK		;SAY WHERE ARG BLOCK IS
	SKED%			;GET THE INFO
	 ERJMP [	CALL DGETER	;FAILED, SEE WHY
			CAIE A,ARGX25	;SCAN ALL LEGAL CLASSES?
			CALL JERR	;NO, UNEXPECTED ERROR
			JRST CLDON]	;YES, JUST LEAVE LOOP
	SKIPN .SASHR+CLBLK		;DOES THIS CLASS HAVE A SHARE OF MACHINE?
	JRST CLNXT		;NO, SKIP IT
	MOVE A,CURCLS		;GET CURRENT CLASS
	ETYPE <  >
	CALL NUM4		;PRINT 4-COLUMN CLASS NUMBER
	DMOVE A,.SASHR+CLBLK	;GET SHARE AND UTILIZATION
	ETYPE <%1=%%2=>		;SHARE, USE
	MOVSI Q1,-3		;SET UP TO PRINT 3 LOAD AVERAGES
	HRRI Q1,.SA1ML+CLBLK	;POINT TO FIRST LOAD AVERAGE
CLOD:	MOVE A,(Q1)		;GET NEXT LOAD
	MOVEI B,7		;PRINT IN 7 COLUMNS
	PRINT " "		;SEPARATE WITH SPACE IN CASE OVERFLOW
	CALL FLTTAB
	AOBJN Q1,CLOD		;LOOP FOR REST OF LOADS
	ETYPE <%_>
CLNXT:	AOS A,CURCLS		;STEP TO NEXT CLASS
	JRST CLLUP
CLDON:	RET
;STATISTICS...
;TABLE OF SUBSYSTEM USAGE

SUBSTA::ETYPE<%_>
	TYPE < Subsys  Time(sec)   PGF/SEC   Nblocks   WS-size
>
	HLLZ D,SNAMES		;SETUP TO LOOP OVER ALL NAMES
STAT5A:	GTB .SNAME		;GET SIXBIT NAME
	JUMPE A,STAT5Z		;0 MEANS NONE
	PRINT " "
	CALL SIXPRT		;PRINT IT
	PRINT TAB
	GTB .STIME		;GET RUNTIME
	IDIVI A,^D1000		;CONVERT TO SECONDS
	CALL STAT5N		;PRINT SECONDS
	GTB .STIME		;GET TIME AGAIN
	JUMPE A,[CALL STAT5N	;IF 0, PRINT 0 FOR PGF/SEC ALSO
		JRST STAT5B]
	CALL FLOAT
	FDVRI A,(1000.0)	;CONVERT TO SECONDS
	MOVEM A,C
	GTB .SPFLT		;GET PAGE FAULTS
	CALL FLOAT		;FLOAT IT
	FDVR A,C		;COMPUTE PAGE FAULTS PER SECOND
	ETYPE <    %1Q>		;PRINT IT IN 10-SPACE FIELD
STAT5B:	GTB .SNBLK		;GET NUMBER OF BLOCKS
	PUSH P,A
	CALL STAT5N		;PRINT IT
	POP P,A
	JUMPE A,[CALL STAT5N	;IF 0, PRINT 0 FOR WSSIZE ALSO
		JRST STAT5Y]
	CALL FLOAT		;FLOAT IT
	PUSH P,A
	GTB .SSIZE		;GET SIZE INTEGRAL
	CALL FLOAT		;FLOAT IT
	POP P,B
	FDVR A,B		;COMPUTE WSSIZE
	ETYPE <    %1Q>		;PRINT IT IN 10-SPACE FIELD
STAT5Y:	ETYPE<%_>
STAT5Z:	AOBJN D,STAT5A		;DO ALL NAMES
	JRST EOLRET

;print floating point number.  Number in A, columns in B

DADP==2			;NUMBER OF DIGITS AFTER DECIMAL POINT

FLTTAB:	MOVX C,FL%ONE!FL%PNT!FL%OVL!FLD(DADP,FL%SND)	;AT LEAST ONE DIGIT, DECIMAL POINT, OUTPUT ON COLUMN OVERFLOW, 2 DIGITS AFTER POINT
	SUBI B,DADP+1		;SUBTRACT DIGITS AFTER POINT PLUS ONE FOR POINT
	STOR B,FL%FST,C		;TELL SYSTEM HOW MANY PLACES BEFORE POINT
	MOVE B,A		;NUMBER IN B
	MOVE A,COJFN		;OUTPUT CHANNEL IN A
	FLOUT			;TYPE THE FLOATING POINT NUMBER
	 JRST [	CAIN C,FLOTX1	;OVERFLOW OF COLUMN 1?
		JRST .+1	;YES, O.K.  JUST MEANS NUMBER REAL LARGE.
		CALL CJERRE]	;NO, PROBABLY OVER QUOTA ON "TAKE" OUTPUT.
	RET

;4-COLUMN NUMBER

NUM4:		MOVX B,NO%LFL!FLD(4,NO%COL)!<5+5>	;LEADING FILLER, 4 COLUMNS, DECIMAL
	CALLRET SYNUM

;PRINT FORMATTED NUMBER

STAT5N:	MOVX B,NO%MAG!NO%LFL!NO%OOV!FLD(12,NO%COL)!FLD(5+5,NO%RDX)	;MAGNITUDE, LEADING FILLER, ERROR IF COLUMN OVERFLOW, 12 COLUMNS, DECIMAL
	CALLRET SYNUM		;PRINT NUMBER

;ROUTINE TO PRINT NUMBER FOR SYSTAT (COULD BE MADE MORE GENERAL!)
;ACCEPTS:	A/	NUMBER
;		B/	FORMAT, RADIX BITS PER NOUT SPECIFICATION
;RETURNS:	+1 ALWAYS, NUMBER OUTPUTTED TO COJFN

SYNUM:	MOVE C,B		;PUT FORMAT IN B
	MOVE B,A		;NUMBER IN B
	MOVE A,COJFN
	NOUT
	JRST [	CAIE A,NOUTX2	;CHECK FOR COLUMN OVERFLOW ERROR CODE
		CAIN C,NOUTX2	;IN A OR C
		RET		;ALLOW IT
		JRST JERR]	;REPORT ANY OTHER ERROR
	RET
;SUBROUTINE TO READ SYSTEM TABLE WHOSE NAME IS IN A INTO AC'S 4-14.
;USED IN SYSTAT, ERRSTAT.

READT:	SETZ B,			;NORMAL ENTRY: START AT BEGINNING OF TABLE
MORET:	MOVE D,B		;ENTRY FOR TABLE INDEX IN B
	SYSGT
	JUMPN B,.+2
	CALL SCREWUP		;NO SUCH TABLE
	HLLZ C,B		;FORM AOBJN INDEX
	SOJGE D,[AOBJP C,[RET]	;PASS UNWANTED ENTRIES
		JRST .]
	PUSH P,[D]		;INIT PTR TO AC'S TO STORE VALUES IN
READT1:	HRR A,B			;TABLE #
	HRL A,C			;INDEX
	GETAB			;READ A WORD OF TABLE INTO A
	 CALL JERR
	MOVEM A,@(P)
	AOS A,(P)
	CAIGE A,15		;STOP BEFORE OVERWRITING 15!
	AOBJN C,READT1		;END-OF-TABLE TEST AND LOOP
	SUB P,[XWD 1,1]
	RET
;TERMINAL CHARACTERISTICS COMMANDS GROUP
;	LOWERCASE, FORMFEED, TABS, NO LOWERCASE, NO FORMFEED, NO TABS,
;	RAISE, NO RAISE, HALFDUPLEX, FULLDUPLEX, INDICATE.

;THESE COMMANDS CHANGE THE FILE MODE WORD AND THE CONTROL CHARACTER
;OUTPUT CONTROL (CCOC) WORDS FOR THE PRIMARY OUTPUT FILE,
;AND ALSO THE THREE SETS OF THESE VALUES KEPT IN STORAGE.

;THE "NO" PREFIXED VERSIONS GO THRU THE SAME ROUTINES AS THE UNPREFIXED
;VERSIONS, BUT WITH F1 SET WHICH REVERSES THE EFFECT OF THE SUBROUTINES
;THEY CALL.  F1 IS CLEAR ON DISPATCH FROM THE MAIN LOOP.

.TERNO:	KEYWD $TERNO		;"NO". LOOK UP NEXT WORD.
	 0			;NO DEFAULT
	JRST CERR		;NULL ILLEGAL
	TLO Z,F1		;SAY NO
	JRST (P3)		;GO TO .FORMF, .TABS, OR .LOWER.

$TERNO:	TABLE
	T FLAG
	T FORMFEED
	T IMMEDIATE
	T INDICATE
	T LOWERCASE
	T PAGE
	T PAUSE
	T RAISE
	T TABS
	TEND

;LOW ORDER BIT POSITION OF TT%DUM
LB.DUM==<TT%DUM&-TT%DUM>

.LINE:	LDF C,<.TTLDX>*<LB.DUM>	;SET LINE HALFDUPLEX
	JRST SETDU		;DO SET DUPLEX

.FULLD:	LDF C,<.TTFDX>*<LB.DUM>	;SET FULLDUPLEX
	JRST SETDU

.HALFD:	LDF C,<.TTHDX>*<LB.DUM>
SETDU:	NOISE (MODE FOR TERMINAL)
	CONFIRM
setdu1:	MOVEI A,.CTTRM
	RFMOD
	TXZ B,TT%DUM		;CLEAR ALL DUPLEX BITS
	IOR B,C			;SET THE DESIRED ONES
	STPAR			;SET NEW DUPLICITY
	RET

.FORMF:	NOISE (EXISTS ON TERMINAL)
	LDF C,TT%MFF		;SET MECH FORMFEED BIT
	CALLRET CMOD		;CHANGE MODE WORD AND RETURN

.TABS:	NOISE (EXIST ON TERMINAL)
	LDF C,TT%TAB		;SET HARDWARE TABS BIT
	MOVE D,[POINT 2,(Q1),19] ;PTR TO ^I CCOC BYTE
	CALL CMOD		;CHANGE FILE MODE WORD
	JRST CCCOC		;CHANGE CONT. CHAR. OUTPUT CONT. WORDS
;PAGE MODE

.PAGE:	NOISE <MODE>
	decx <Carriage return or page length>
	 JRST PAGE1		;NO NUMBER TYPED
	PUSH P,B		;A NUMBER SUPPLIED
	CALL PAGE1
	POP P,B
	JRST PLENT1

PAGE1:	CONFIRM
	CALL ..END		;DO BOTH "PAUSE (ON) END-OF-PAGE"
	CALLRET ..COMM		;AND "PAUSE (ON) COMMAND"

;TERMINAL PAUSE (ON)

.PAUSE:	NOISE <ON>
	KEYWD $PAUSE
	 0
	 JRST CERR
	TXNE P3,ONEWRD		;SINGLE WORD COMMAND?
	CONFIRM
	JRST (P3)		;DISPATCH

$PAUSE:	TABLE
T COMMAND,ONEWRD,..COMM
T END-OF-PAGE,ONEWRD,..END
TEND

..END:	MOVEI A,.CTTRM
	MOVEI B,.MOXOF
	MOVEI C,.MOONX		;ASSUME ON
	TLNE Z,F1		;"NO" ?
	MOVEI C,.MOOFF		;YUP, OFF
	MTOPR
	 ERCAL CJERRE		;GO SAY WHY IT FAILED
	RET

..COMM:	LDF C,TT%PGM
	JRST CMOD1		;GO CHANGE MODE

;IMMEDIATE ECHO MODE

.IMMED:	NOISE <ECHO MODE>
	MOVEI C,TT%ECM
	JRST CMOD

;LOWERCASE: CONTROLS LOWER CASE OUTPUT.
;IT MAY ALSO BE NECESSARY TO CLEAR "INDICATE WITH %" BIT,
;BUT PREFERABLE NOT TO IF IT HAS NO EFFECT WHEN B3 ON.

.LOWER:	NOISE (EXISTS ON TERMINAL)
	LDF C,TT%LCA		;SET LOWER CASE AVAILABLE BIT
	JRST CMOD		;CHANGE FILE MODE WORD

;RAISE: CONTROLS CONVERSION OF LOWER CASE TO UPPER ON INPUT.

.RAISE:	NOISE (TERMINAL INPUT)
	LDF C,TT%LIC		;SET LOWERCASE INPUT CONTROL
	JRST CMOD

;FLAG UPPERCASE OUTPUT

.FLAG:	NOISE <UPPER CASE OUTPUT>
	LDF C,TT%UOC		;SET UPPERCASE OUTPUT CONTROL
	JRST CMOD
;TWO SUBROUTINES FOR TERMINAL CHARACTERISTICS COMMANDS

;CHANGE TELETYPE MODE WORD SUBR
;CHANGES MODE IN EFFECT
;TAKES: C: MASK INDICATING BITS TO CHANGE.
;	AC Z LH BIT F1: ON TO CLEAR BIT(S), OFF TO SET THEM.
;PRESERVES D, DESTROYS A, B.

CMOD:	CONFIRM			;NO TTY COMMANDS CONFIRMED BEFORE HERE
CMOD1:	MOVEI A,.CTTRM
	RFMOD
	ANDCAM C,B		;IF NO, TURN OFF THE BITS
	TLNN Z,F1
	IORM C,B		;OTHERWISE, TURN THEM ON
	STPAR			;THESE ARE ALL TERMINAL PARAMETERS
	RET

;TERMINAL TYPE IS

.TERMI:	NOISE (MODE IS)
	KEYWD $TERMI
	0
	JRST CERR
	JRST (P3)

;TERMINAL COMMANDS TABLE (ALPHABETICAL)

$TERMI:	TABLE
	T 33,,.T33
	T 35,,.T35
	T 37,,.T37
	T EXECUPORT,,.TI
	T FLAG
	T FORMFEED
	T FULLDUPLEX
   NOSHIP,<
	T GT40
   >;NOSHIP
	T HALFDUPLEX
	T HELP,,TTYHLP
	T IMMEDIATE
	T INDICATE
	T LA120
	T LA30,,.LA30
	T LA36,,.LA36
	T LA38
	T LENGTH,,PLENTH
	T LINE-HALFDUPLEX,,.LINE
	T LOWERCASE
	T NO,,.TERNO
	T PAGE
	T PAUSE
	T RAISE
	T SPEED,
	T SYSTEM-DEFAULT,,.DFLT
	T TABS
	T TERMINET,,.TRMNT
	T TI,,.TI		;NOTE:  DON'T FORGET "TERMINAL TYPE MUMBLE" WHEN ADDING TERMINALS TO "TERMINAL MUMBLE" LIST
	T TYPE,,.TTYPE
	T VT05
	T VT100
	T VT50
	T VT52
	T WIDTH,,.LWIDTH
	TEND

;HELP FOR TERMINAL COMMANDS.

TTYHLP:	CONFIRM
	HRROI 2,TTYTXT		;GET TEXT PTR
	MOVE 1,COJFN
	SETZ 3,
	SOUT			;PRINT IT
	RET

	.DIRECT FLBLST
TTYTXT:	ASCIZ \
 The TERMINAL command allows you to set various modes or parameters
 for your terminal. Following "TERMINAL (MODE IS)", you can type any
 of the following general catagories of arguments:

   1. The specific name of your terminal type, e.g. LA30, VT52, etc.
      The list of known terminal types is obtained by typing
      "TERMINAL TYPE ?". Declaring your terminal type establishes
      the proper amount of fill and the applicable modes.

   2. A specific mode (optionally preceded by "NO" to turn it off).

      FLAG       Print a ' before every uppercase character.

      FORMFEED   Terminal has form-feed capability.

      IMMEDIATE  Echo each character as you type it.

      INDICATE   Print ^L instead of a form-feed.

      LOWERCASE  Terminal handles lowercase output properly.

      PAGE       Put your terminal in 'page' mode (i.e. stop on ^S).

      TABS       Terminal has tab stops every 8 columns.

   3. A value of a certain terminal parameter.

      LENGTH     Set the page length of your terminal.

      SPEED      Set the baud rate for terminal input and output.

      WIDTH      Set the width of your terminal line.

\
	.DIRECT NO FLBLST
;TERMINAL TYPE N OR <TYPE>

.TTYPE:	MOVEI B,[FLDDB. .CMNUM,CM%SDH,5+5,<Terminal type>,<SYSTEM-DEFAULT>,[
		FLDDB. .CMKEY,,$TTYP]]
	CALL FLDSKP
	 CMERRX			;NEITHER NUMBER OF KEYWORD TYPED
	LOAD D,CM%FNC,.CMFNP(C)	;GET DATUM TYPE
	CAIN D,.CMNUM		;NUMBER?
	JRST .TTYP1		;YES
	CALL GETKEY		;NO, KEYWORD, GET INFO
	JRST 0(P3)		;OK - DISPATCH
.TTYP1:	PUSH P,B
	JRST .TTY3

.T33:	PUSH P,[0]
	JRST .TTY3

.T35:	PUSH P,[1]
	JRST .TTY3

.T37:	PUSH P,[2]
	JRST .TTY3

.TI:	PUSH P,[3]
	JRST .TTY3

.DFLT:				;SYSTEM-DEFALUT TERMINAL TYPE
.TRMNT:	PUSH P,[^D8]
	JRST .TTY3

.VT05:	PUSH P,[^D10]
	JRST .TTY3

.VT50:	PUSH P,[^D11]
	JRST .TTY3

.VT52:	PUSH	P,[^D15]
	JRST	.TTY3

   NOSHIP,<
.GT40:	PUSH P,[^D13]
	JRST .TTY3
   >;NOSHIP

.LA36:	PUSH P,[^D14]
	JRST .TTY3

.LA38:	PUSH P,[.TTL38]
	JRST .TTY3

.LA120:	PUSH P,[.TT120]
	JRST .TTY3

.VT100:	PUSH P,[.TT100]
	JRST .TTY3

.LA30:	PUSH P,[^D12]
.TTY3:	CONFIRM
	POP P,B
	MOVEI A,.CTTRM
	STTYP
	 ERJMP [ERROR <Invalid terminal type>]
	LDF C,<.TTFDX>*<LB.DUM>	;SET FULLDUPLEX
	jrst setdu1


;TYPE TABLE

$TTYP:	TABLE
	T 33,,.T33
	T 35,,.T35
	T 37,,.T37
	T EXECUPORT,,.TI
   NOSHIP,<
	T GT40
   >;NOSHIP
	T LA120
	T LA30,,.LA30
	T LA36,,.LA36
	T LA38			;THIS IS "TERMINAL TYPE MUMBLE".  YOU MUST IMPLEMENT "TERMINAL MUMBLE" ALSO
	T SYSTEM-DEFAULT,,.DFLT
	T TERMINET,,.TRMNT
	T TI,,.TI
	T VT05
	T VT100
	T VT50
	T VT52
	TEND
;WIDTH OF TERMINAL LINE

.LWIDTH: NOISE (OF LINE IS)
	DECX <Terminal line width in decimal>
	 CMERRX
	CONFIRM
	MOVE C,B
	MOVEI A,.CTTRM
	MOVEI B,.MOSLW		;SPECIFY SETTING LINE WIDTH
	MTOPR			;DO IT
	 ERCAL CJERRE		;GO SAY WHY IT FAILED
	RET

;LENGTH OF TERMINAL PAGE

PLENTH:	NOISE <OF PAGE IS>
	DECX <Length of page in decimal>
	 CMERRX
	CONFIRM
PLENT1:	MOVE C,B
	MOVEI A,.CTTRM
	MOVEI B,.MOSLL			;SPECIFY SETTING LENGTH
	MTOPR				;DO IT
	 ERCAL CJERRE			;FAILED, SAY WHY AND DIE
	RET
;INDICATE (FORMFEED)

.INDIC:	NOISE (FORMFEED)
	CONFIRM
	TLZN Z,F1		;'NO'?
	TLO Z,F2
	MOVE D,[POINT 2,(Q1),25]
				;JRST CCCOC

;SUBR TO CHANGE CCOC BYTE TO SIMULATE (IF F1 ON & F2 OFF)
; OR SEND (IF F1 AND F2 OFF) OR INDICATE (IF F2 ON).
;BYTE TO CHANGE IS INDICATED BY A BYTE PTR IN D, INDEXED BY E.
;DESTROYS A, B, C, E.

CCCOC:	MOVE A,COJFN
	RFCOC
	MOVEI Q1,B
	CALL CCCOCS		;OPERATE ON CCCOC WORDS IN B,C
	MOVE A,COJFN
	SFCOC			;PUT NEW VALUE INTO EFFECT
	MOVEI Q1,ETTYMD+TTWCOC	;OPERATE ON STORED VALUES
	CALL CCCOCS
	MOVEI Q1,ITTYMD+TTWCOC
NOXTND,<
	CALL CCCOCS
	MOVEI Q1,PTTYMD+TTWCOC
>
;SUBSUBROUTINE TO OPERATE ON BYTE IN WORDS Q1 POINTS TO

CCCOCS:	MOVEI A,2		;2 = SEND CODE
	TLNE Z,F1
	MOVEI A,3		;3 = SIMULATE
	TLNE Z,F2
	MOVEI A,1		;1 = INDICATE BY ^X
	DPB A,D
	RET
; SET TERMINAL SPEED

.SPEED:	MOVEI	A,.CTTRM	;TO CURRENT TERMINAL
SPEEDA::	STKVAR <STERM,<SPNBUF,3>>
	MOVEM A,STERM		;REMEMBER TERMINAL NUMBER
NOISE	<OF INPUT>
	KEYWD	$BAUDR		;BAUD RATE TABLE
	  0			;NO DEFAULT
	  JRST	CERR		;ERROR IF NONE GIVEN
	NOISE <AND OUTPUT>
	HRLZ	Q1,P3		;SAVE VALUE
	HRRZ B,P3		;USE INPUT FOR OUTPUT DEFAULT
	HRROI A,SPNBUF
	MOVEM A,CMDEF
	MOVEI C,5+5		;SPEEDS ARE DECIMAL
	NOUT			;SET UP DEFAULT STRING
	 CALL JERR		;SHOULD NEVER FAIL
	KEYWD $BAUDR		;READ OUTPUT SPEED
	0			;DEFAULT ALREADY SET UP
	 CMERRX			;BAD OUTPUT SPEED SPECIFIED
	HRR Q1,P3		;FILL IN SELECTED OUTPUT SPEED
	CONFIRM
	MOVE	A,STERM	;TERMINAL NUMBER
	MOVEI	B,.MOSPD	;FCN CODE
	MOVE C,Q1		;PICK UP SELECTED SPEEDS
	MTOPR			;C := INPUT,,OUTPUT
	 ERCAL CJERRE		;FAILED, TELL USER WHY
	RET			;RETURN

$BAUDR:	TABLE
	T 0,,0
	T 110,,^D110
	T 1200,,^D1200
	T 134,,^D134
	T 150,,^D150
	T 1800,,^D1800
	T 200,,^D200
	T 2400,,^D2400
	T 300,,^D300
	T 4800,,^D4800
	T 50,,^D50
	T 600,,^D600
	T 75,,^D75
	T 9600,,^D9600
	TEND

;ROUTINE TO PRINT SYSTEM-MESSAGES THAT HAVEN'T BEEN PRINTED

PNTMES::
XTND,<
	SKIPE MESMSF		; MAIL CHECK YET?
	 CALL MESMES		; PUT OUT "YOU HAVE A MESSAGE" IS NECESSARY
>
	AOSE SYSMF		;YES, SO MAYBE TIME TO PRINT SYSTEM MESSAGES
	RET			;THEY'VE ALREADY BEEN PRINTED
	SKIPE BATCHF
	RET			;DON'T PUT MESSAGES IN BATCH FILE
			;NOTE BUG HERE: IF SYSTEM MESSAGE GETS SENT
			;AND BATCH JOB FOR USER GETS RUN BEFORE NEXT
			;TIME THAT USER "REALLY" LOGS IN, MESSAGE GETS
			;ENTIRELY MISSED!!!  EO 6/29/77
	MOVE A,LOGDAT		;THEY HAVEN'T, GET LOGIN DATE.
	CALL MESS		;TYPE APPLICABLE LOGIN MESSAGES
	RET

;CODE TO USE RDMAIL TO TYPE <SYSTEM>MAIL.TXT

MESS:	STKVAR <MALJFN,SJFNP,CJPFRK>	;CELLS TO HOLD JFNS WE'LL USE
	MOVE A,.JBUFP		;GET CURRENT JFN STACK POINTER
	MOVEM A,SJFNP		;SAVE IT FOR RESTORATION LATER
	MOVE A,JBUFP
	MOVEM A,.JBUFP		;MARK STACK SO RLJFNS DOESN'T CLOSE THINGS OUR CALLER OPENED
	MOVE A,FORK		; Pick up possible CRJOB/PRARG fork
	MOVEM A,CJPFRK		; And save it in case FORK clobbered
	SETOM FORK		; Mark as no lower fork (ERESET clobbers it)
	HRROI B,[ASCIZ /PS:<SYSTEM>MAIL.TXT/]
	CALL TRGTV1		;TRY TO ASSIGN JFN TO FILE
	 JRST SYSLEV		;NO SUCH FILE
	MOVE B,[XWD 1,.FBSIZ]
	MOVEI C,C
	CALL $GTFDB		;GET # BYTES IN FILE
	 JRST SYSMDO		;LET RDMAIL FIGURE IT OUT
	JUMPLE C,SYSLEV		;THERE'S NO MESSAGE IF FILE IS NULL
	MOVE B,[XWD 1,.FBWRT]
	MOVEI C,C
	CALL $GTFDB
	 JRST SYSMDO
	CAMGE C,LOGDAT		;HAS FILE BEEN WRITTEN SINCE LAST LOGIN?
	JRST SYSLEV		;NO
SYSMDO:	HRROI B,[GETSAVE(SYS:RDMAIL.)]
	CALL TRYGTJ
	 JRST SYSLEV		;LEAVE IF NO SUCH PROGRAM
	MOVEM A,MALJFN
	CALL ERESET		; Reset lower fork
	MOVE A,MALJFN		;SAY WHICH FILE TO GET
	CALL $GET2		; Get RDMAIL into it
	MOVE A,FORK		; Get fork handle
	CALL JFNSTK		;STACK IT SO IT GOES AWAY LATER
	GEVEC			;GET ENTRY VECTOR POINTER
	HLRZ A,B
	CAIGE A,3		;MUST BE AT LEAST 3
	JRST SYSLOS		;LOSE
	ADDI A,-1(B)		;USE ENTRY -1 FROM LAST
	CALL LOADF		;READ IT
	 JRST SYSLOS		;Can't read it
	HRRZ C,A		;SAVE STARTING ADDR
	HLRZ A,A		;GET POINTER TO WHERE TO STORE DATE AND TIME
	MOVE B,LOGDAT		;GET DATE AND TIME
	CALL STOREF		;STORE IT
	 JRST SYSLOS 		;Can't set it
	SETO A,
	CALL MAPPF		;FREE MAPPED PAGE
	 JFCL			;Unmap should never fail
	MOVEI Q1,ETTYMD		;SAVE EXEC TTY MODES
	CALL RTTYMD
	TLO Z,RUNF
NOXTND,<
	MOVEI Q1,PTTYMD		;LOAD PROGRAM TTY MODES
	CALL LTTYMD
>
	MOVE B,C		;START ADDR IN B
	MOVE A,FORK		;SETUP AS RUNNING FORK
	SFORK			;START FORK HERE FOR SYSTEM MESSAGE
	RFORK			;RESUME IT
	WFORK			;WAIT FOR IT
SYSLEV:	CALL ERESET
	CALL RLJFNS		;CLOSE FILES WE USED
	MOVE A,SJFNP		;GET JFN STACK MARKER AS BEFORE WE TOUCHED IT
	MOVEM A,.JBUFP		;RESTORE IT
NOXTND,<
	MOVEI Q1,PTTYMD		;SAVE TTY MODES, AS MODIFIED BY PROGRAM
	CALL RTTYMD		;..
>
	TLZ Z,RUNF		;SAY PROG'S TTY MODES NOT IN EFFECT
	MOVE A,CJPFRK
	MOVEM A,FORK		; Reset fork
	MOVEI Q1,ETTYMD		;RESTORE EXEC'S TTY MODES
	CALL LTTYMD		;..
	RET

SYSLOS:	ETYPE <%_%%%Error while reading system message -  %?%%_>
	JRST SYSLEV
	END