Google
 

Trailing-Edge - PDP-10 Archives - BB-M081H-SM - exec/exec0.mac
There are 47 other files named exec0.mac in the archive. Click here to see a list.
;Edit 1011 to EXEC0.MAC by TBOYLE on Tue 24-Jul-84, for SPR #4
;		Fix misleading errors at .TTY3+3 with ERJMP CJERRE
;Edit 1002 to EXEC0.MAC by SHTIL on Wed 2-May-84
;		MAKE SET DEFAULT WAITING FOR CONFIRMATION
;Edit 997 to EXEC0.MAC by PRATT on Thu 19-Apr-84
;		Fix bad byte pointer that causes problems with ucode 346
;Edit 961 to EXEC0.MAC by LOMARTIRE on Thu 2-Jun-83, for SPR #17895
;		Allow range of terminal lines in ^ESET TERMINAL command
;Edit 960 by TSANG on Wed 4-May-83, for SPR #19024
;		Make TERMINAL "NO" PAUSE CHARACTER X work.
; UPD ID= 99, FARK:<5-WORKING-SOURCES.EXEC>EXEC0.MAC.7,  21-Sep-82 15:02:11 by TSANG
;EDIT 910 - Addition to EDIT 906.
; UPD ID= 88, FARK:<5-WORKING-SOURCES.EXEC>EXEC0.MAC.5,   8-Sep-82 15:10:12 by TSANG
;EDIT 906 - Modify text string for HELP option of TERMINAL command.
;EDIT 902 - Fix INFO MONITOR-STATISTICS command to show the correct .SASHR.
; UPD ID= 80, FARK:<5-WORKING-SOURCES.EXEC>EXEC0.MAC.3,  19-Aug-82 14:14:54 by MOSER
;EDIT 745 - CORRECTLY SIMULATE LOGIN FOR CRJOB STARTUP.
; UPD ID= 3, FARK:<4-1-WORKING-SOURCES.EXEC>EXEC0.MAC.2,  29-Mar-82 09:50:22 by DONAHUE
;Edit 714 - Fix INFO SUBSYSTEM command to check version
;Edit 713 - Check which monitor we're running under
; UPD ID= 138, SNARK:<5.EXEC>EXEC0.MAC.42,   7-Feb-82 13:41:31 by CHALL
;TCO 5.1700 .TERMI- AND .TTYPE- ADD TERMINAL TYPES VT125 AND VK100
; UPD ID= 133, SNARK:<5.EXEC>EXEC0.MAC.41,  22-Jan-82 14:44:35 by CHALL
;TCO 5.1644 - UPDATE COPYRIGHT NOTICE
; UPD ID= 129, SNARK:<5.EXEC>EXEC0.MAC.40,   5-Jan-82 10:00:30 by MOSER
; UPD ID= 108, SNARK:<5.EXEC>EXEC0.MAC.27,  30-Nov-81 13:59:11 by MOSER
;TCO 5.1613 - ADD NEW BIT B4 TO CRJOB FLAGS. MEANS SIMULATE LOGIN.
; UPD ID= 97, SNARK:<5.EXEC>EXEC0.MAC.26,  21-Oct-81 13:43:45 by GROUT
;TCO 5.1578 MAKE CMDINI GLOBAL SO IT CAN BE CALLED FROM EOFJER
; UPD ID= 71, SNARK:<5.EXEC>EXEC0.MAC.23,  21-Sep-81 09:06:15 by CHALL
;TCO 5.1521 SUBSTA- OUTPUT SCOUNTS IN INFO SUBSYS (SEE TCO 5.1301)
; UPD ID= 60, SNARK:<5.EXEC>EXEC0.MAC.21,   1-Sep-81 18:01:29 by CHALL
;TCO 5.1483 SYSNX- IF USER TYPED "SYS:" GIVE FILESPEC-LIKE ERROR
; UPD ID= 43, SNARK:<5.EXEC>EXEC0.MAC.19,  17-Aug-81 22:48:14 by MURPHY
;MAKE MESS NOT FLUSH CURRENT FORK
; UPD ID= 31, SNARK:<5.EXEC>EXEC0.MAC.18,  14-Aug-81 19:11:43 by CHALL
;TCO 5.1454 CHANGE NAME FROM XDEF TO EXECDE
; UPD ID= 22, SNARK:<5.EXEC>EXEC0.MAC.17,   5-Aug-81 16:00:09 by MURPHY
;BUG IN MESS - LEAVING GARBAGE FORK HANDLE IN FORK.
; UPD ID= 18, SNARK:<5.EXEC>EXEC0.MAC.16,  21-Jul-81 11:53:08 by GROUT
;TCO 5.1426 - Make SYSTAT work with wild directory and user args
;<HELLIWELL.EXEC.5>EXEC0.MAC.2, 13-May-81 19:58:17, EDIT BY HELLIWELL
;REMOVE DOCCL AND DOCC1 (NOW UNUSED)
;<HELLIWELL.EXEC.5>EXEC0.MAC.1, 13-May-81 14:51:16, EDIT BY HELLIWELL
;REMOVE GT40 TERMINAL TYPE
; UPD ID= 2099, SNARK:<5.EXEC>EXEC0.MAC.12,  28-May-81 10:58:35 by GROUT
; TCO 5.1351 - Make TERMINAL terminal-type not change duplex mode
; UPD ID= 2063, SNARK:<5.EXEC>EXEC0.MAC.11,  22-May-81 11:51:03 by GROUT
;TCO 5.1343 - Make IPCF code flush buffers only when necessary
; UPD ID= 2035, SNARK:<5.EXEC>EXEC0.MAC.10,  19-May-81 16:55:38 by MURPHY
;Raise input on TER PAUSE CHARACTER CONTROL x
; UPD ID= 1974, SNARK:<5.EXEC>EXEC0.MAC.9,  11-May-81 11:35:56 by TILLSON
;TCO 5.1306 - Make LOGIN messages print in Batch log file
; UPD ID= 1962, SNARK:<5.EXEC>EXEC0.MAC.8,   8-May-81 10:03:01 by SCHMITT
;TCO 5.1309 - Check for DWNTIM of -1 for system shutdown at SYSDWN
; UPD ID= 1949, SNARK:<5.EXEC>EXEC0.MAC.4,   6-May-81 14:53:33 by MURPHY
; TCO 5.1315  - PAUSE (ON) CHARACTER etc.
; UPD ID= 1871, SNARK:<5.EXEC>EXEC0.MAC.3,  22-Apr-81 11:29:57 by PAETZOLD
;fix typo in previous (TCO 5.1295)
; UPD ID= 1868, SNARK:<5.EXEC>EXEC0.MAC.2,  22-Apr-81 10:49:55 by PAETZOLD
;TCO 5.1295 Add cosmetic fix for systat for foreign arpanet host
;previous edit history line missing
;ADD PCLF SWITCHES WHERE VISIBLE TO USER
;REMOVE MFRK SWITCHES EXCEPT WHERE VISIBLE TO USER
;<4.EXEC>EXEC0.MAC.1, 23-Dec-80 19:03:03, Edit by DK32
;Programmable Command Language
; UPD ID= 1434, SNARK:<5.EXEC>EXEC0.MAC.41,  13-Jan-81 09:58:33 by OSMAN
;More 5.1129 - Make EXAMINE show octal contents "...too, if different"
; UPD ID= 1397, SNARK:<5.EXEC>EXEC0.MAC.40,   6-Jan-81 10:27:42 by OSMAN
;tco 5.1225 - Implement jsys trapping and file-opening trapping!
; UPD ID= 1394, SNARK:<5.EXEC>EXEC0.MAC.39,  31-Dec-80 16:08:32 by LYONS
; UPD ID= 1392, SNARK:<5.EXEC>EXEC0.MAC.38,  31-Dec-80 15:09:40 by LYONS
;for the time being, keep both sets of system mail code.
; UPD ID= 1355, SNARK:<5.EXEC>EXEC0.MAC.37,  16-Dec-80 09:51:38 by OSMAN
;Don't get second symbol buffer upon restarting customized exec
; UPD ID= 1280, SNARK:<5.EXEC>EXEC0.MAC.36,  17-Nov-80 16:40:55 by OSMAN
;Remove ^L hack
; UPD ID= 1252, SNARK:<5.EXEC>EXEC0.MAC.35,  10-Nov-80 13:24:26 by OSMAN
;More 5.1189 - Make DDT see /USE-SECTION switch
; UPD ID= 1237, SNARK:<5.EXEC>EXEC0.MAC.34,   6-Nov-80 15:20:32 by OSMAN
;tco 5.1189 - Use $GET0 instead of $GET2
; UPD ID= 1233, SNARK:<5.EXEC>EXEC0.MAC.33,   5-Nov-80 15:31:57 by LCAMPBELL
; UPD ID= 1188, SNARK:<5.EXEC>EXEC0.MAC.31,  23-Oct-80 10:09:49 by OSMAN
; UPD ID= 1187, SNARK:<5.EXEC>EXEC0.MAC.30,  22-Oct-80 17:01:15 by OSMAN
;Fix SET PROG EPHEMERAL
; UPD ID= 1146, SNARK:<5.EXEC>EXEC0.MAC.29,  10-Oct-80 09:31:07 by OSMAN
;More 5.1151 - Unbreak "DEC SYN CD CONNECT"
; UPD ID= 1145, SNARK:<5.EXEC>EXEC0.MAC.28,  10-Oct-80 09:25:26 by OSMAN
; UPD ID= 1127, SNARK:<5.EXEC>EXEC0.MAC.27,   6-Oct-80 10:16:23 by OSMAN
;tco 5.1167 - Remove FDB autokeep feature
; UPD ID= 1114, SNARK:<5.EXEC>EXEC0.MAC.26,   3-Oct-80 11:32:25 by OSMAN
;tco 5.1162 - Parse program names as keywords.
; UPD ID= 1040, SNARK:<5.EXEC>EXEC0.MAC.25,  25-Sep-80 14:12:54 by OSMAN
;tco 5.1156 - Add SET DEFAULT PROGRAM
; UPD ID= 1034, SNARK:<5.EXEC>EXEC0.MAC.24,  23-Sep-80 14:03:54 by OSMAN
;tco 5.1151 - prevent spurious error from "INFO MON"
; UPD ID= 1025, SNARK:<5.EXEC>EXEC0.MAC.23,  22-Sep-80 10:37:46 by OSMAN
;tco 5.1150 - Add SET PROGRAM
; UPD ID= 1016, SNARK:<5.EXEC>EXEC0.MAC.22,  16-Sep-80 10:14:20 by HESS
; New version of MIC
; UPD ID= 918, SNARK:<5.EXEC>EXEC0.MAC.21,  19-Aug-80 14:28:14 by HESS
; Fix Examine/Deposit commands for multi-forking
; UPD ID= 871, SNARK:<5.EXEC>EXEC0.MAC.20,  11-Aug-80 11:21:43 by OSMAN
;5.1129 - Allow "@FOO" as contents for DEPOSIT
; UPD ID= 865, SNARK:<5.EXEC>EXEC0.MAC.19,  11-Aug-80 10:59:05 by OSMAN
;More 5.1129 - Allow symbolic deposit into empty fork
; UPD ID= 863, SNARK:<5.EXEC>EXEC0.MAC.18,  10-Aug-80 16:41:16 by OSMAN
;More 5.1129 - Fix EXAMINE and DEPOSIT
; UPD ID= 852, SNARK:<5.EXEC>EXEC0.MAC.17,  10-Aug-80 15:20:04 by OSMAN
;tco 5.1129 - Add symbolic expression and address support
; UPD ID= 837, SNARK:<5.EXEC>EXEC0.MAC.16,   5-Aug-80 10:27:28 by OSMAN
;tco 5.1124 - Do LOGIN.CMD before COMAND.CMD
; UPD ID= 836, SNARK:<5.EXEC>EXEC0.MAC.15,   5-Aug-80 10:07:21 by OSMAN
;Remove SY abbreviation
; UPD ID= 829, SNARK:<5.EXEC>EXEC0.MAC.14,   4-Aug-80 12:36:58 by LYONS
; Change ^V echo to fix listings alignment
; Fix herald suppression code
; UPD ID= 825, SNARK:<5.EXEC>EXEC0.MAC.13,   4-Aug-80 09:48:52 by OSMAN
;Move version stuff into EXECIN
; UPD ID= 805, SNARK:<5.EXEC>EXEC0.MAC.12,  28-Jul-80 14:54:35 by MURPHY
;Remove effect of .FBKEP
; UPD ID= 787, SNARK:<5.EXEC>EXEC0.MAC.11,  23-Jul-80 15:25:57 by OSMAN
;tco 5.1111 - Don't croak SYSTAT if SKED% keels over due to job logging out
; UPD ID= 770, SNARK:<5.EXEC>EXEC0.MAC.10,  21-Jul-80 13:58:49 by MURPHY
;FORCE SY AS ABBREV FOR SYSTAT
; UPD ID= 586, SNARK:<5.EXEC>EXEC0.MAC.9,   2-Jun-80 14:35:06 by MURPHY
;<5.EXEC>EXEC0.MAC.8, 30-May-80 16:42:15, EDIT BY MURPHY
;PUT ALERT AND MAIL-WATCH UNDER NEWF
; UPD ID= 565, SNARK:<5.EXEC>EXEC0.MAC.7,  28-May-80 16:54:41 by MURPHY
; UPD ID= 551, SNARK:<5.EXEC>EXEC0.MAC.6,  23-May-80 13:36:11 by MURPHY
;MAKE EDIT/CREATE USE IMPLICIT RUN COMMAND LOGIC
; UPD ID= 543, SNARK:<5.EXEC>EXEC0.MAC.5,  21-May-80 12:06:57 by MURPHY
;ADD MFRK TO CONTROL MULTI-FORK FEATURES ONLY
;ADD NEWF TO CONTROL "NEW" FEATURES PENDING REVIEW
;Change handling of fork name as command
;<5.EXEC>EXEC0.MAC.4,  8-May-80 14:01:08, EDIT BY OSMAN
;Remove R.L.5 and R.GE.5 macro calls
;<4.1.EXEC>EXEC0.MAC.27, 29-Apr-80 13:30:31, EDIT BY OSMAN
;Make "Up again at" have space before it
; UPD ID= 457, SNARK:<4.1.EXEC>EXEC0.MAC.25,  22-Apr-80 16:42:13 by OSMAN
;tco 4.1.1146 - Make CTRL/Q during advice work.
;<4.1.EXEC>EXEC0.MAC.24, 28-Mar-80 09:52:19, Edit by HESS
; New version of MIC support
;<4.1.EXEC>EXEC0.MAC.23, 17-Mar-80 14:10:16, EDIT BY OSMAN
;Get rid of ONEWRD checks
;<4.1.EXEC>EXEC0.MAC.22, 17-Mar-80 10:53:23, EDIT BY OSMAN
;PUT R.L.5 CONDITIONAL AROUND SMOUNT, SDISMOUNT, TMOUNT
;<4.1.EXEC>EXEC0.MAC.21, 13-Mar-80 10:50:22, EDIT BY OSMAN
;tco 4.1.1108 - Print n.m instead of nx in version numbers
;Put SMOUNT and SDISMOUNT back in for release 4.1
;<4.1.EXEC>EXEC0.MAC.19,  7-Mar-80 17:00:41, EDIT BY OSMAN
;tco 4.1.1101 - lowercase error message "Illegal character in program name..."
;<4.1.EXEC>EXEC0.MAC.11, 29-Feb-80 09:31:36, EDIT BY OSMAN
;tco 4.1.1095 - allow "SYS NO ."
; UPD ID= 261, SNARK:<4.1.EXEC>EXEC0.MAC.8,  14-Feb-80 08:52:57 by OSMAN
;tco 4.1.1079 - Flush SMOUNT, SDISMOUNT, TMOUNT
; UPD ID= 258, SNARK:<4.1.EXEC>EXEC0.MAC.7,  12-Feb-80 10:10:48 by OSMAN
;Remove QCM (old QUENCH startup stuff)
; UPD ID= 236, SNARK:<4.1.EXEC>EXEC0.MAC.6,   1-Feb-80 08:51:12 by OSMAN
;tco 4.1.1076 - Wait for confirmation on FOREIGN-HOST subcommand
; UPD ID= 195, SNARK:<4.1.EXEC>EXEC0.MAC.5,   8-Jan-80 14:31:09 by OSMAN
; UPD ID= 192, SNARK:<4.1.EXEC>EXEC0.MAC.4,   8-Jan-80 14:25:26 by OSMAN
;tco 4.1.1061 - Use generation 1 on system mail
;<4.1.EXEC>EXEC0.MAC.2, 20-Nov-79 10:46:37, EDIT BY OSMAN
;TCO 4.1.1023 - FIX TAKE STUFF
;<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) 1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH EXECDE
	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

;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

;"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.
	SKIPE CUSTMF		;PCL Is this just a customized Exec?
	JRST EXEC0		;PCL It is, do full initialization

;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		;..
	SKIPN XDICT		;PCL Does permanent pool need initialized?
	CALL XFRINI		;INITIALIZE PERMANENT FREE SPACE
	MOVEI A,NFRKS		;INITIALIZE FORK NAME TABLE
	MOVEM A,FRKNMS		;SAY MAXIMUM NAMES ALLOWED IN TABLE
	MOVEM A,KEPNMS		;INITIALIZE KEPT FORKS TABLE TOO
	CALL GETFB1		;GET FORK BLOCK FOR DEFAULTS
	MOVEM A,FRKDEF		;REMEMBER ADDRESS OF DEFAULT BLOCK
	SKIPE SYMBF		;DO WE ALREADY HAVE SYMBOL BUFFER (IS THIS A CUSTOMIZED EXEC)
	JRST SYMDON		;YES
	MOVEI A,777+NSMPGS_9	;GET WINDOW FOR SYMBOL TABLE MAPPING
	CALL GTBUFX
	TRZE A,777		;WE NEED PAGE-ALIGNED ADDRESS FOR PMAP
	ADDI A,1000		;IF BLOCK STARTED ON PARTIAL PAGE, GET TO FULL ONE
	MOVEM A,SYMBF		;REMEMBER WHERE BUFFER STARTS
SYMDON:	SETZ Z,			;CLEAR FLAGS
	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
	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 OLDIDX		;SAY NO IPCF MESSAGE WAITING 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
	SETZM TAKLEN		;NO JFNS ON STACK YET
	DMOVE A,[XWD .PRIIN,.PRIOU ;USE PRIMARY IO
		 TKALEF]	;ALLOW ERRORS AT THIS LEVEL, NO ECHOING OF COMMAND
	CALL PUSHIO		;START INITIAL 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

;INITIALIZE MODES FOR USE WHEN EXEC IS RUNNING:
;ASSUME IT'S ALREADY CORRECT WITH REGARD TO HARDWARE FEATURES;

	MOVEI Q1,ETTYMD		;KEEP EXEC MODES UP TO DATE IN STORAGE
	CALL RTTYMD		;...FOR ^C.
	MOVEI A,0		;DON'T TYPE ^V IN ANY FORM
;**;[997]  Replace 1 line at EXEC02 + 27    JMP    19 Apr 84
	DPB A,[POINT 2,ETTYMD+TTWCOC+1,9]
				;MAKE CONTROL-V ECHO LITERALLY AS IN FILENAMES
	MOVEI A,3		;FORMAT LINEFEED (MAKE IT ECHO AS CRLF)
;**;[997]  Replace 1 line at EXEC02 + 31    JMP    19 Apr 84
	DPB A,[POINT 2,ETTYMD+TTWCOC,21]

;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 THAN TYPE MESSAGES.
; AND "REENTER" DOES A "START".

	SETOM CINITF
	CALL DOATI		;ASSIGN TERMINAL INTERRUPTS (DON'T ALLOW ^C EARLIER !)
	SKIPN CRPRA		;CRJOB SET UP?
	JRST CMDIN0		;NO
	HRRZ A,CRPRA+.CJPLP	;FETCH FLAG POINTER
;**;[745] CHANGE 1 LINE AT STLOSE:+31L	TAM	19-AUG-82
	SKIPGE B,CRPRA(A)	;[745] HERALD SUPPRESS?
	JRST CMDIN2		;YES
	TLNN B,(1B4)		;SIMULATE LOGIN?
	JRST CMDIN0		;NO SO GO ON.
	ETYPE <%_>		;PRINT A LINE.
	CALL %VERSI		;VERSION AND STUFF
	CALL DWNPNT		;DOWN TIME
	JRST CMDIN2		;AND CONTINUE
CMDIN0:	SKIPE BATCHF		;BATCH JOB?
	JRST CMDIN1		;GO PRINT HERALD
	SETO A,			;SUPPRESS HERALD FOR SYSJOB
	HRROI B,C
	MOVEI C,.JICPJ
	GETJI			;FETCH CONTROLLING JOB NUMBER
	 CALL JERR
	JUMPE C,CMDIN2		;SYSJOB, SO SKIP IT
CMDIN1:	ETYPE <%_>		;HERALD
	CALL $VERSI		;VERSIONS
	CALL DWNTYP		;IF THERE IS A DOWN TIME

;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

$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

;FIXON IS CALLED AFTER ADVISE IS ENDED TO RESTORE TERMINAL PAGING.

FIXON::	MOVEI A,.CTTRM		;REFERENCE CONTROLLING TERMINAL
	RFMOD			;GET CURRENT SETTINGS
	TXZ B,TT%PGM		;START WITH CLEAN PAGE MODE BIT
	IOR B,SAVPGM		;GET SAVED VALUE OF PAGE MODE BIT
	STPAR			;RESTORE VALUE OF PAGING BIT
	RET

;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
;**;[713] Add 7 lines at STSYS2:+3L	PED	24-MAR-82
	MOVEI A,.SCOUNT		;[713]
	GETAB			;[713] SEE WHICH VERSION WE'RE RUNNING UNDER
	 ERJMP	[ CAIN A,GTABX1	;[713] DOES THIS TABLE EXIST
		  SKIPA B,[-1]	;[713] NO - SAY VERSION 4.1
		  SETZM B	;[713] SAY V 5
		  MOVEM B,MONVER;[713] STORE IT
		  JRST .+1]	;[713]
	RET

DEFINE PRGSTG			;STORAGE NEEDED FOR PROGRAM COMMANDS
<	TRVAR <PNAMP,NAMFLG,PJFN,PTBLP>
>
;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
	CALL DOATI		;MAKE SO ^E AND ^C WORK AS NORMAL AGAIN
	CALL FIXON		;FIX PAGE MODE SETTING
	MOVE B,ADVTNM		;GET TERMINAL FOR BREAKING LINKS WITH
	CALL BREAK1		;BREAK LINKS TO REALLY END THE ADVICE
	XCT ADVMES		;GIVE STANDARD END MESSAGE (AFTER BREAK SO WE DON'T HANG UP 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		;IS CRJOB START UP?
	 JRST [ HRRZ A,CRPRA+.CJPLP ;GET FLAGS PTR
		MOVE B,CRPRA(A)
		TLNE B,(1B4)	;SIMULATE LOGIN?
		SETOM LOGINI	;YES.
		TLNN B,(1B3!1B4);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]
NONEWF,<
	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
	SKIPN PCCURC		;PCL If no stored command in progress
	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
	PRGSTG			;GET LOCAL STORAGE FOR PROGRAM NAME STUFF
	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

;SET UP 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 IT'S 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
	SKIPN LOGINI		;LOGIN JUST DONE?
	JRST NL1		;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		;SET UP EXEC INPUT
	CAIA			;DON'T RESET ANYTHING IF NOTHING GOT TAKEN
	JRST CMDIN4		;RESET ALL COMMAND INFO AFTER TAKEIN ATTEMPT
NL1:	SKIPE CUSRNO		;IF NOT LOGGED IN,
	SKIPE FILINI		;OR INITIALIZATION DONE,
	JRST NLGINI		;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
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
NONEWF,<
	SKIPE MWATCF		;MAIL WATCH ON?
	CALL MWATCH		;YES.  SEE IF ANY NEW MAIL.
>
NEWF,<
	SETZM TYPING		;NO TYPEOUT IN PROGRESS
	SETZM AUTOF		;NO INTERRUPT 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
;**;[1002]	ADD LABEL CIN0 AT CIN1-1
CIN0::	CALL COMSET		;[1002]SET UP THINGS FOR COMMAND INPUT
CIN1:	MOVX B,WHLU+OPRU+ERRU	;PCL
	SKIPE PRVENF		;USER "ENABLE"D?
	CALL PRVCK		;CHECK FOR PRIVILEGED USER
	 JRST CIN9		;NOT PRIVILEGED, SO ^E NO POSSIBILITY
	MOVEI B,CM1DBE		;DESCRIPTOR BLOCKS FOR COMND CALL
	JRST CIN7		;CHECK FOR PCL COMMANDS

CIN9:
	MOVEI B,CM1DB		;DESCRIPTOR BLOCKS
	SKIPN CUSRNO		;IF NOT LOGGED IN, CAN'T RUN PROGRAMS
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<Command,>]
CIN7:	SKIPN PCFLDB		;IS PCL A FACTOR?
	SKIPE PCFLDP
	TRNA			;YES
	JRST CIN10		;NO
	MOVEI C,PCFLDB		;ASSUME USER TABLE
	SKIPN PCLDCO		;DOES HE WANT THE ORIGINAL SET?
	SKIPN PCFLDB		;DOES HE HAVE HIS OWN?
	TRNA			;YES, OR NO
	JRST CIN8		;NO AND YES, USE HIS
	SKIPN PCFLDP		;IS THERE A PRESERVED TABLE?
	JRST CIN10		;NO, USE ORIGINAL ONE
	SKIPLE PCLDCO		;USE PRESERVED COMMANDS?
	JRST CIN10		;NO, USE ORIGINAL ONE
	MOVEI C,PCFLDP		;USE PRESERVED COMMANDS
CIN8:	HRRZ B,(B)		;STEP PAST THE ORIGINAL TABLE
	HRRM B,(C)		;LINK AFTER PCL TABLE
	MOVEI B,(C)		;USE IT
CIN10:	CALL FLDSKP		;TRY TO READ COMMAND NAME
	 CMERRX <Unrecognized command>
	MOVEM B,COMAND		;SAVE COMMAND INFO
	LOAD D,FKFLAG,+@FRKDEF	;GET DEFAULT FLAGS
	MOVEM D,NAMFLG
	LDB D,[331100,,(C)]	;GOOD PARSE,  SEE WHAT GOT TYPED
	CAIN D,.CMFIL		;FILESPEC?
	JRST CIN3P		;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:	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		;PCL GET WHICH COMMAND WE'RE DOING
	CALL GETKEY
	HLRO A,@COMAND		;GET NAME OF COMMAND IN CASE IT'S A FORK
	MOVEM A,PNAMP		;SAVE IT FOR ROUTINE THAT BUILD RESCAN STRING
	MOVE A,COMAND		;GET WHICH COMMAND WE'RE DOING
	HLRZ B,KEPNMS		;SEE HOW MANY FORKS IN FORK TABLE
	ADDI B,KEPNMS		;GET HIGHEST TABLE ADDRESS POSSIBLE
	CAIL A,KEPNMS+1		;IS OUR COMMAND IN RANGE OF FORK TABLE?
	CAMLE A,B		;LARGE ENOUGH.  IS IT SMALL ENOUGH?
	CAIA			;TOO SMALL OR TOO LARGE.
	JRST [	CALL CIN3D	;GET RESCAN LINE AND CONFIRMATION
		MOVEI A,FRKNMS	;SAVED FORK, FIND WHERE IT IS IN FORK TABLE
		MOVE B,COMAND	;GET POINTER TO NAME ("FIELD" PUT POINTER IN COMAND)
		TBLUK		;GET TABLE ADDRESS
		MOVEM A,PTBLP	;SAVE TABLE ADDRESS
		JRST CINFRK]	;JOIN OTHER CODE
	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>
	CALL (P4)		;DISPATCH WITH PUSHJ,
				;CAN RETURN WITH POPJ
				;OR JRST CMDIN2,3,4.
	JRST CMDIN4		;WHERE MOST COMMANDS SHOULD RETURN.

;RUN 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 IT'S A SUBSYSTEM NAME

CIN3P:	CALL SPNAME		;SET UP PROGRAM NAME
	CALL CIN3D		;GET REST OF LINE
	MOVEI A,FRKNMS		;POINT TO TABLE OF KNOWN FORK NAMES
	MOVE B,PNAMP		;GET POINTER TO CURRENT PROGRAM NAME
	TBLUK			;SEE IF NAME IS IN TABLE
	TXNE B,TL%EXM		;EXACT MATCH?
	JRST [	HRRZ A,(A)	;YES, GET ADDRESS OF FORK BLOCK
		LOAD A,FKFLAG,(A) ;GET FLAGS FOR THIS FORK
		MOVEM A,NAMFLG	;REMEMBER THEM
		JRST .+1]
	MOVE A,NAMFLG		;GET FLAGS FOR THIS PROGRAM
	TXNE A,FN%EPH		;RUN THIS AS AN EPHEMERON?
	JRST EPH		;YES
	TXNE A,FN%NEF		;NEVER RUN THIS AS AN EPHEMERON?
	JRST RSUBS4		;YES
	MOVE A,PJFN
	DVCHR			;GET DEVICE CHARACTERISTICS
	TLNE A,177777		;IS IT A DISK?
	 JRST RSUBS4		;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]
	CAIE C,.FBEPH		;EPHEMERAL?
	 JRST RSUBS4		;NO - GO ON
EPH:	MOVEI Q1,ETTYMD		;SET TTY MODES
	CALL LTTYMD
	MOVE A,PJFN		;PASS ON JFN
	JRST REPH		;GO RUN EPHEMERAL

;SPNAME is used to set up the program name cell.
;
;Accepts:	B/	jfn

SPNAME:	MOVEM B,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
	RET

;ENTER HERE FROM EDIT/CREATE COMMAND

CIN3::	CALL SPNAME		;SET UP PROGRAM NAME
	MOVEI A,FRKNMS		;POINT TO LIST OF KNOWN FORKS
	MOVE B,PNAMP		;POINT TO NAME OF EDITOR
	TBLUK			;LOOK UP EDITOR IN KNOWN NAMES
	TXNN B,TL%EXM		;IS EDITOR IN LIST OF KNOWN FORKS?
	JRST CINXED		;NO, SO IT WILL BE LOADED AND STARTED FOR SURE
	HRRZ C,(A)		;YES, GET ADDRESS OF FORK BLOCK
	LOAD D,FKHAN,(C)	;GET FORK HANDLE OF EDITOR
	JUMPE D,CINXED		;IF NONE, GO START EDITOR
	MOVX C,FK%RUN		;FORCE EDITOR TO ALWAYS BE "START"ED ON "EDIT"
	ANDCAM C,SLFTAB(D)	;COMMAND, SO FRESH COPY OF EDITED FILE IS GUARANTEED.
CINXED:	MOVEM A,PTBLP		;SAVE TABLE POINTER
	TXNN B,TL%EXM		;EXACT MATCH OF NAME?
	JRST RSUBS4		;NO, GO RUN PROGRAM
CINFRK:	HRRZ B,(A)		;GET ADDRESS OF FORK BLOCK
	LOAD A,FKHAN,(B)	;GET FORK HANDLE
	CAIN A,0		;DOES THIS FORK EXIST?
	JRST RSUBS4		;NO
	MOVE B,PTBLP		;GET TABLE ADDRESS IN CASE FORK IS KEPT
	MOVE A,SLFTAB(A)	;GET FLAGS FOR THIS FORK
	TXNE A,FK%KPT		;IS FORK KEPT ALREADY?
	JRST RSTFK		;YES, SO GO RESTART IT
	JRST RSUBS4
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 SEPARATE FILENAME FROM REST OF LINE
	CAIE D,0		;IS THERE ANY MORE TO THE LINE?
	 TLOA Z,F3		;YES - LIGHT 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

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 $GET0		;GET PROGRAM
	JRST ..STRT		;START PROGRAM
;EXAMINE (MEMORY LOCATION) N

BLEN==20			;ENOUGH FOR ASCIZ STRINGS

.EXAMI::STKVAR <<FANCBF,BLEN>,<OCTBF,BLEN>>
	NOISE <MEMORY LOCATION>
	SETZ A,			;SAY EXAMINE
	CALL EXDPDF		;SET DEFAULT ADDRESS, IF ANY
	ADDRX <Address to examine>
	 ERROR <Couldn't parse address>
	CONFIRM
	MOVE A,B
	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>
	MOVE B,FORK		;CURRENT FORK
	SKIPE C,SLFTAB(B)	;EXISTS?
	 JRST [	MOVX D,FK%EDF
		ANDCAM D,SLFTAB(B) ;INDICATE LAST WAS EXAMINE
		MOVEM A,.FKEDL(C) ;SAVE THIS LOC
		JRST .+1]
	MOVE C,A		;FETCH CONTENTS
	ANDI C,777
	MOVE C,PAGEN(C)		;RH
	HRROI D,FANCBF		;FIRST POINT AT FANCY BUFFER
	MOVEM D,COJFN
	ETYPE<%1Y/ %3/>		;CREATE FANCY VERSION
	MOVEI D,.CHNUL		;MAKE SURE NULL AFTER STRING
	IDPB D,COJFN
	HRROI D,OCTBF		;NOW CREATE OCTAL VERSION
	MOVEM D,COJFN
	ETYPE <%1O/ %3#>
	MOVEI D,.CHNUL
	IDPB D,COJFN		;FINISH WITH NULL
	CALL FIXIO		;REVERT TO STANDARD IO
	UTYPE FANCBF		;FIRST, DISPLAY THE FANCY VERSION
	HRROI B,OCTBF		;COMPARE IT WITH OCTAL VERSION
	HRROI A,FANCBF
	STCMP
	JUMPN A,[HRROI A,OCTBF ;SHOW OCTAL VERSION IF DIFFERENT
		 ETYPE <   (%1M)>
		 JRST .+1]
	ETYPE <%_>		;FINISH LINE
	RET
;DEPOSIT (MEMORY LOCATION) N (CONTENTS) M

.DEPOS::STKVAR <DEADD,DECON>
	NOISE <MEMORY LOCATION>
	SETO A,			;INDICATE DEPOSIT
	CALL EXDPDF		;SET DEFAULT ADDRESS
	ADDRX <Address in which to deposit>
	 ERROR <Couldn't parse address>
	TLNE B,777740		;THIS COMMAND ONLY ALLOWS 32 SECTIONS
	ERROR <Memory address not between 0 and 37,,777777>
	MOVEM B,DEADD		;SAVE ADDRESS
	HRROI A,[ASCIZ /contents/] ;GUIDE WORD
	CALL RINST		;GET INSTRUCTION TO BE DEPOSITED
	MOVEM A,DECON		;SAVE UNEVALUATED DATA FOR DEPOSITING
	CONFIRM
	SKIPG FORK		;FORK EXISTS?
	CALL ECFORK		;NO, CREATE ONE
	MOVE A,DECON		;GET UNEVALUATED CONTENTS
	CALL PINST		;EVALUATE IT, NOW THAT WE HAVE A FORK
	 ERROR <Can't evaluate contents>
	MOVEM A,DECON		;REMEMBER EVALUATED CONTENTS
	MOVE A,DEADD		;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]
	MOVE B,DEADD		;GET LOCATION
	MOVE A,FORK
	SKIPE C,SLFTAB(A)	;FORK EXISTS?
	 JRST [	MOVX D,FK%EDF
		IORM D,SLFTAB(A) ;INDICATE LAST WAS DEPOSIT
		MOVEM B,.FKEDL(C) ;SAVE THIS LOC
		JRST .+1]
	MOVE A,DECON		;GET DATA

;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>
	SKIPE C,FORK		;FORK HANDLE
	 SKIPN C,SLFTAB(C)	;KNOWN?
	  RET			;NO FORK - DO NOT SET DEFAULT
	SKIPGE B,.FKEDL(C)	;ANY PREVIOUS E/D?
	 RET			;NO - DON'T SET DEFAULT
	XOR C,A			;MASK FLAG
	TXNN C,FK%EDF		;SAME AS LAST?
	 ADDI B,1		;YES - INCR LOC
	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
NONEWF,<
;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
>

;PCL Original Exec command

.ORIGI::NOISE (EXEC COMMAND)
	SETOM PCLDCO		;NEXT COMMAND USES ORIGINAL TABLE
	JRST CIN1		;PARSE AS IF REGULAR COMMAND
;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 <IME,ALL,CLS,HED,NHD,TTY,USR,SUB,TIM,CON,LIM,CJB,JOB,NJB,STA,NOP,4NH>

SYSDEF==SY%IME!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,SISLDS,SISCDS,SISTAN,<HSTNAM,10>,HDRPOS>
	SETZM SYSJFN		;NO SPECIAL OUTPUT JFN YET
	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

SYSTK1:	MOVEI B,[
		FLDBK. .CMKEY,,$SESTA,,,DOTBRK,[
		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. .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,.CMCFM		;END OF LINE?
	JRST SYSTS0		;YES GO EXECUTE COMMAND
	CALL SCREWUP		;SHOULD NEVER GET HERE

;HERE FOR "SYS ."

SYSTK.:	MOVEI A,SY$JOB
	CALL SSTACK		;PUT FLAVOR ON STACK
	MOVE A,JOBNO
	CALL SSTACK		;PUT ITEM ON STACK
	TXO Q1,SY%IME		;"SYS NO . ." = "SYS ."
	CALLRET .SYSEL		;EXIT THROUGH CODE THAT SAYS NOT TO PRINT HEADER

;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

;HERE ON AN ERROR. "SYS:" IS A SPECIAL CASE BECAUSE IT LOOKS LIKE THE START
;OF A FILESPEC. IF THE SPEC IS ILLEGAL CONTROL GETS TO SYSTAT. BUT THE
;"INVALID SYSTAT ARGUMENT" MESSAGE IS PRETTY HOSTILE, SO THE KLUGE BELOW
;TELLS THE USER IT'S A FILESPEC ERROR, WHICH IT PROBABLY IS.

SYSNX:	MOVE A,CBUF		;GET WHAT WAS TYPED
	TRZ A,377		;KEEP ONLY THE FIRST FOUR CHARACTERS
	CAMN A,[ASCIZ /SYS:/]	;SPECIAL MESSAGE IF IT'S A BOGUS DEVICE NAME
	ERROR <Unrecognized command - Bad filespecs - "SYS:">
	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
	CAMN A,[-1]		;IS SYSTEM SHUTDOWN
	JRST [	ETYPE < System is shut down>
		JRST SYSDW1]	;YES, TYPE MESSAGE
	ETYPE < System shutdown scheduled for %1D %E>
SYSDW1:	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
	SETZM SISTAS		;CLEAR USER NAME STRING POINTER
	SETZM SISLDS
	SETZM SISCDS
	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
	TXNN Q1,SY%IME		;DID USER SAY "NO ."?
	JRST [	HRRZ B,JNX	;YES, SEE WHICH JOB WE'RE ON
		CAME B,JOBNO	;IS IT OURSELF?
		JRST .+1	;NO, SO DISPLAY IT
		JRST SYST9]	;YES, SO SKIP IT

	MOVE A,.JIJNO+.JIBAS	;GET JOB NUMBER
	MOVEM A,.SAJOB+SYCLB	;TELL MONITOR WHICH JOB TO INVESTIGATE
	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
	TXNE Q1,SY%CLS		;DON'T BOTHER DOING SKED% IF CLASS NOT WANTED
	SKED%			;READ THE INFO
	 ERJMP [CALL DGETER	;FAILED, SEE WHY
		CAIE A,ARGX15	;"JOB IS NOT LOGGED IN"?
		CALL JERR	;NO, UNEXPECTED ERROR
		JRST SYST9]	;YES, JOB LOGGED OUT, 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:	MOVEI B,SISTAS		;CHECK AGAINST CURRENT USER NUMBER/STRING
	MOVE D,.JIUNO+.JIBAS
	CALL SYSDUC
	 JRST SYST2Z		;SUCCESS, TYPE OUT JOB
	 JRST SYST2B		;FAILURE, NO MATCH

SYST2C:	MOVEI B,SISLDS		;CHECK AGAINST LOGGED-IN DIR
	MOVE D,.JILNO+.JIBAS
	CALL SYSDUC
	 JRST SYST2Z		;SUCCESS, GO TYPE JOB
	TXNN	Q1,SY%CON	;SHOWING CONNECTED DIR'S?
	JRST SYST2B
	MOVEI B,SISCDS		;CHECK AGAINST CONNECTED DIR
	MOVE D,.JIDNO+.JIBAS
	CALL SYSDUC
	 JRST SYST2Z		;SUCCESS
	 JRST SYST2B		;FAILURE

;ROUTINE TO CHECK CURRENT DIRECTORY/USER AGAINST DIRECTORY/USER ARGUMENT
;ACCEPTS:	B/	ADDRESS OF POINTER TO CURRENT DIRECTORY/USER STRING
;		C/	DIRECTORY/USER ARGUMENT (NUMBER OR 'WILD' BYTE POINTER)
;		D/	CURRENT DIRECTORY/USER NUMBER
;RETURNS:	+1 SUCCESS, CURRENT NUMBER/STRING MATCHES ARG
;		+2 FAILURE, CURRENT NUMBER/STRING DOES NOT MATCH ARG

SYSDUC:	STKVAR <ASAV,DUSTRP,DUCARG>
	CAMN C,D		;DOES IT MATCH ARG?
	 RET			;YES, GIVE SUCCESS RETURN
	HRRZM B,DUSTRP		;SAVE AC B
	LOAD B,NMFLG,C		;CHECK TO SEE IF ARG IS DIR/USER NUMBER
	CAIN B,NUMVAL		;IS IT?
	 RETSKP			;YES, GIVE FAILURE RETURN
	MOVEM A,ASAV		;SAVE AC'S A AND C
	MOVEM C,DUCARG
	SKIPE A,@DUSTRP		;HAVE WE GOTTEN DIR/USER STRING BEFORE?
	JRST SYSDU1		;YES, SKIP GETTING IT
	HRROI A,ATMBUF		;PUT IT IN ATOM BUFFER TEMPORARILY
	MOVE B,D
	DIRST
	ERJMP	[MOVE A,ASAV
		 MOVE C,DUCARG
		 RETSKP]	;IF ERROR, IT'S NO MATCH
	HRROI A,ATMBUF		;COPY STRING TO FREE AREA
	CALL BUFFS
	MOVEM A,@DUSTRP		;SAVE THE DIR/USER STRING POINTER
SYSDU1:	MOVE C,A		;PUT CUR DIR/USER STRING PTR IN N-W AC
	SETZ A,			;NO FLAGS TO WILD%
	MOVE B,DUCARG		;PUT DIR/USER ARG STRING PTR IN WILD AC
	WILD%			;CHECK CURRENT DIR/USER STRING
	 ERJMP JERR		;THIS IS A WILD ERORR!?
	TXNN A,WL%NOM		;WAS THERE A MATCH?
	TDZA B,B		;YES
	SETO B,			;NO
	MOVE A,ASAV		;RESTORE REGISTERS A AND C
	MOVE C,DUCARG
	JUMPN B,RSKP		;IF NO MATCH, SKIP RETURN
	RET			;IF MATCH, REGULAR RETURN

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

;HAVE A REAL JOB #. PRINT IT.

SYST2Z:	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		;SEPARATE 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,.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 <  >
	SKIPE B,SISTAS		;HAVE WE GOT USER STRING ALREADY?
	 JRST	[MOVE A,COJFN
		 SETZ C,
		 SOUT
		 JRST SYSTS7]	;YES, TYPE IT OUT
	SKIPN B,.JIUNO+.JIBAS
	JRST [	ETYPE <Not logged in>
		JRST SYSTS5]
	ETYPE <%2r>
SYSTS7:	TXNN Q1,SY%CON
	JRST SYSTS5
	MOVE B,.JIDNO+.JIBAS
	CAMN B,.JILNO+.JIBAS
	JRST SYSTS5
	ETYPE <, >
	SKIPE B,SISCDS		;DO WE HAVE STRING ALREADY?
	 JRST	[MOVE A,COJFN
		 SETZ C,
		 SOUT
		 JRST SYSTS5]	;YES, TYPE IT OUT
	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
	SKIPG A			;RANGE CHECK...IS IT POSITIVE?
	 MOVEI A,2		;NO SO DEFAULT IT TO TWO SPACES
	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:	SKIPE A,SISTAS		;RETURN USER STRING IF USED
	CALL STREM
	SKIPE A,SISLDS		;RETURN LOGGED-IN DIR STRING IF USED
	CALL STREM
	SKIPE A,SISCDS		;RETURN CONNECTED DIR STRING IF USED
	CALL STREM
	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
	MOVEI A,SY$DIR
	CALL SSTACK		;ANNOUNCE DIR NUMBER OR STRING COMING UP
	MOVE A,SISTAN		;STEP THE NUMBER
	MOVE B,SISTAS
	CALL STPDIR
	 JRST	[MOVE A,SISTAN
		 JRST SYSTD1]	;NO MORE, SAVE DIR NUMBER
	MOVEI A,[GJ%IFG+GJ%OFG
		.NULIO,,.NULIO
		0
		0
		POINT 7,[ASCIZ/*/]
		POINT 7,[ASCIZ/*/]
		0
		0]		;GET JFN ON WILD DIRECTORY STRING
	HRROI B,ATMBUF
	GTJFN
	 ERJMP JERR		;WILD ERROR!?
	MOVE B,A		;SET UP FOR JFNS
	HRROI A,ATMBUF
	MOVX C,1B2+1B5+JS%PAF
	JFNS
	MOVE A,B		;RELEASE THE JFN
	RLJFN
	 ERJMP JERR		;DITTO
	CALL BUFFF		;STORE STRING IN TEMPORARY FREE AREA
SYSTD1:	CALL SSTACK
	JRST SYST1J

SYSTU:	MOVEM B,SISTAN		;SAVE THE USER NUMBER
	CALL BUFFF		;GET THE ATOM BUFFER
	MOVEM A,SISTAS		;SAVE STRING POINTER TO USER NAME
	MOVEI A,SY$USR		;ANNOUNCE THAT USER NAME OR STR COMING UP
	CALL SSTACK
	MOVE A,SISTAN		;NOW STEP THE USER
	MOVE B,SISTAS		;IF NEEDED
	CALL STPUSR
	 SKIPA A,SISTAN		;NO MORE, SAVE USER NUMBER
	MOVE A,SISTAS		;IT'S WILD, SAVE STRING POINTER
	CALL SSTACK

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]>
>
;THIS IS THE KEYWORD TABLE.  SEE $SYSTB FOR THE SUBCOMMAND TABLE.

$SESTA:	TABLE
	T .,,SYSTK.
	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]>
>

;This is the subcommand table.  See $SESTA for the keyword table.

$SYSTB:	TABLE
	T ALL,,..SYSA
	TB CLASS,,CLS
	TB CONTROLLING,,CJB
	TB DIRECTORY,,CON
	IT FOREIGN-HOST,,CF4NH
	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:	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,SISTAS		;SAVE POINTER TO WILD STRING
	MOVEM C,SISTAN		;SAVE USER NUMBER
	CONFIRM
	MOVEI A,SY$USR		;ANNOUNCE FLAVOR IS USER
	CALL SSTACK
	MOVE A,SISTAN		;GET DIRECTORY NUMBER
	MOVE B,SISTAS		;AND POINTER TO STRING
	CALL STPUSR		;STEP TO NEXT USER NUMBER
	 SKIPA A,SISTAN		;NO MORE, SAVE USER NUMBER
	MOVE A,SISTAS		;IT'S WILD, SAVE USER STR POINTER
	CALL SSTACK
	CALLRE .SYSEL		;RETURN VIA .SYSEL

;"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
	CALLRET CONF

.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
	CALLRET CONF

.SYSNO:	MOVEI B,[FLDBK. .CMKEY,,$SYSNO,,,DOTBRK] ;ALLOW DOT
	CALL FLDSKP
	 CMERRX
	CALL GETKEY
	JRST (P3)

DOTBRK:	BRMSK. KEYB0.,KEYB1.,KEYB2.,KEYB3.,<.>	;BREAK SET FOR KEYWORDS THAT MAY HAVE DOT IN THEM

DEFINE TB(TEXT,FLAGS,BIT)<
	T <TEXT>,FLAGS+,<[TXZ Q1,SY%'BIT
			  RET]>
>
;$SYSNO IS USED FOR THE SYSTAT NO FEATURE, BOTH FOR SUBCOMMANDS AND FOR
;KEYWORDS.

$SYSNO:	TABLE
	TB .,,IME
	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

CF4NH:	CONFIRM			;MAKE SURE HE MEANS IT
F4NH:	TXO	Q1,SY%4NH
	RET

CN4NH:	CONFIRM			;MAKE SURE HE MEANS IT
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		;SET UP 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+CLBLK
	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?
;**;[902]	Add 2 lines at CLLUP+7		YKT	01-SEP-82
	SKIPE .SAUSE+CLBLK	;[902] NO, DOES THIS CLASS HAVE A USE OF MACHINE?
	CAIA			;[902] SHARE OR USE CLASS IS NON-ZERO
	JRST CLNXT		;SHARE AND USE CLASS BOTH ARE ZERO
	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
;INFO SUBSYSTEM-STATUS - TABLE OF SUBSYSTEM USAGE

SUBSTA::ETYPE<%_>
;**;[714] Change 1 line, add 4 at SUBSTA:+1L	PED	24-MAR-82
	TYPE < Subsys  Time(sec)   PGF/SEC   Nblocks   WS-size   >;[714]
	SKIPL MONVER		;[714] V5?
	TYPE<Scounts
>				;[714] YES
	SKIPGE MONVER		;[714] V4.1?
	ETYPE <%_>		;[714] YES
	HLLZ D,SNAMES		;SET UP TO LOOP OVER ALL NAMES
STAT5A:	GTB .SNAME		;GET SIXBIT NAME
	JUMPE A,STAT5Z		;0 MEANS NONE
	PUSH P,A		;SAVE NAME FOR LATER
	PRINT " "
	CALL SIXPRT		;PRINT IT
	PRINT TAB
	GTB .STIME		;GET RUNTIME
	PUSH P,A		;SAVE IT FOR LATER
	IDIVI A,^D1000		;CONVERT TO SECONDS
	CALL STAT5N		;PRINT SECONDS
	POP P,A			;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
	JUMPE A,[CALL STAT5N	;IF 0, PRINT SPECIALLY SO IT'LL ALIGN PROPERLY
		 JRST STAT5B]
	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
	JUMPE A,[CALL STAT5N	;IF 0, PRINT SPECIALLY SO IT'LL ALIGN PROPERLY
		 JRST STAT5Y]
	ETYPE <    %1Q>		;PRINT IT IN 10-SPACE FIELD

;**;[714] Add 2 lines at STAT5Y:+0L	PED	24-MAR-82
STAT5Y:	SKIPGE MONVER		;[714] V4.1?
	JRST [	POP P,B		;[714] YES,SKIP THIS COLUMN
		JRST STAT51]	;[714]
	GTB .SCOUNT		;GET COUNT OF SETSN'S DONE
	POP P,B			;GET STORED PROGRAM NAME
	CAME B,[OURNAM]		;IF IT'S THE EXEC, SCOUNT IS MEANINGLESS (& BIG)
	CALL STAT5N		;ELSE OUTPUT IT IN 12 COLUMNS
;**;[714] Change 1 line at STAT5Z:-1L	PED	24-MAR-82
STAT51:	ETYPE <%_>		;END THE LINE
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
;MAGNITUDE, LEADING FILLER, ERROR IF COLUMN OVERFLOW, 12 COLUMNS, DECIMAL

STAT5N:	MOVX B,NO%MAG!NO%LFL!NO%OOV!FLD(12,NO%COL)!FLD(5+5,NO%RDX)
;	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 HALF DUPLEX
	JRST SETDU		;DO SET DUPLEX

.FULLD:	LDF C,<.TTFDX>*<LB.DUM>	;SET FULL DUPLEX
	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
	JRST (P3)		;DISPATCH

$PAUSE:	TABLE
	T CHARACTER,,..PPCH
	T COMMAND,ONEWRD,..COMM
	T END-OF-PAGE,ONEWRD,..END
	TEND
;SPECIFY PAGE PAUSE AND UNPAUSE CHARACTER

..PPCH:	MOVEI B,[FLDDB. .CMNUM,CM%SDH,^D8,<octal ASCII code for character>,,[
	   FLDDB. .CMKEY,,$PCHAR,,,[
	    FLDDB. .CMQST,CM%SDH,,<any printing character in doublequotes>,,]]]
	CALL PPGETC		;GET A CHARACTER
	MOVEM A,Q1
	NOISE <AND UNPAUSE ON>
	MOVEI B,[FLDDB. .CMCFM,,,,,[
	  FLDDB. .CMNUM,CM%SDH,^D8,<octal ASCII code for character>,,[
	   FLDDB. .CMKEY,,$PCHAR,,,[
	    FLDDB. .CMQST,CM%SDH,,<any printing character in doublequotes>,,]]]]
	CALL PPGETC		;GET SECOND CHAR
	CAIN A,0		;DEFAULTED?
	IFNSK. <
	  MOVE A,Q1		;YES, USE PREVIOUS
	 >,<
	  CONFIRM>		;ELSE CONFIRM
	MOVE C,A
	HRL C,Q1
;**;[960] Add two lines at ..PPCH+14		YKT	03-MAY-83
	TLNE Z,F1		;[960] "NO"?
	MOVE C,[23,,21]		;[960] YES, RESTORE ^S,,^Q
	MOVEI A,.CTTRM
	MOVEI B,.MOPCS		;SET PAUSE CHARACTER
	MTOPR
	 ERCAL CJERRE
	RET

PPGETC:	CALL FLDSKP
	 ERROR <Invalid, %?>
	LOAD C,CM%FNC,.CMFNP(C) ;GET FUNCTION USED
	CAIE C,.CMQST		;ARBITRARY CHAR?
	IFSKP. <
	  LDB A,[POINT 7,ATMBUF,6] ;GET CHAR FROM ATOM BFR
	  RET>
	CAIE C,.CMCFM		;CR?
	IFSKP. <
	  MOVEI A,0		;YES, RETURN 0
	  RET>
	CAIE C,.CMNUM		;NUMBER
	IFSKP. <
	  MOVE A,B		;YES, RETURN IT
	  RET>
	HRRZ B,0(B)		;MUST BE KEYWORD, GET DISP ADR
	HRRZ B,0(B)
	CALLRET 0(B)

PCHCON:	MOVEI B,[FLDDB. .CMQST,CM%SDH,,<any printing character in doublequotes>,,]
	CALL FLDSKP
	 ERROR <Invalid, not a quoted string>
	LDB A,[POINT 7,ATMBUF,6] ;GET FIRST CHAR
	CAIL A,"a"		;RAISE LOWERCASE
	CAILE A,"z"
	IFSKP. <SUBI A,40>
	CAILE A,100		;CHECK RANGE
	CAILE A,137
	ERROR <Invalid, not a control character>
	SUBI A,100
	RET

PCHSPA:	MOVEI A," "		;USE 'SPACE' CHARACTER
	RET

$PCHAR:	TABLE
	T CONTROL,,PCHCON
	T SPACE,,PCHSPA
	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
	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"
	T TYPE,,.TTYPE		;WHEN ADDING TERMINALS TO "TERMINAL MUMBLE" LIST
	T VK100
	T VT05
	T VT100
	T VT125
	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
;**;[906]	Modify text string at TTYTXT	YKT	3-SEP-82
;**;[910]	Addition to EDIT 906		YKT	21-SEP-82
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 categories 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, if no
                 lowercase is in effect.

      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  n    Terminal stops printing when it reaches the end
                 of a page, or when you type a ^S. To set the page
		 length, give the number n or give a TERMINAL
		 LENGTH command.

      RAISE	 Interpret all lowercase terminal input as the
                 corresponding uppercase character.

      FULLDUPLEX Send to your terminal each character as the
                 program reads it.

      HALFDUPLEX  Don't send to your terminal each character as
                  the program reads it.

      PAUSE END-OF-PAGE  Stop sending output whenever it has sent
                         a full page.

      PAUSE COMMAND	 Stop sending output whenever you type
          		 CTRL/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

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

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

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

.VT125:	PUSH P,[.TT125]
	JRST .TTY3

.VK100:	PUSH P,[.TTK10]
	JRST .TTY3

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

.LA30:	PUSH P,[^D12]
.TTY3:	CONFIRM
	POP P,B
	MOVEI A,.CTTRM
	STTYP
	 ERJMP CJERRE
	RET

;TYPE TABLE

$TTYP:	TABLE
	T 33,,.T33
	T 35,,.T35
	T 37,,.T37
	T EXECUPORT,,.TI
	T LA120
	T LA30,,.LA30
	T LA36,,.LA36
	T LA38			;THIS IS "TERMINAL TYPE MUMBLE".
	T SYSTEM-DEFAULT,,.DFLT	;YOU MUST IMPLEMENT "TERMINAL MUMBLE" ALSO
	T TERMINET,,.TRMNT
	T TI,,.TI
	T VK100
	T VT05
	T VT100
	T VT125
	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

;SUBSUBROUTINE TO OPERATE ON BYTE IN WORDS Q1 POINTS TO

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

.SPEED:	MOVEI	A,.CTTRM	;TO CURRENT TERMINAL
;**;[961]  Replace 1 line with 2 at SPEEDA::		DML	1-JUN-83
	MOVEI	B,.CTTRM	;[961] HIGHEST TERMINAL IN RANGE
SPEEDA::STKVAR <STERM,RTERM,<SPNBUF,3>>  ;[961]
	MOVEM A,STERM		;REMEMBER TERMINAL NUMBER
;**;[961]  Add 1 line after SPEEDA::+1			DML	1-JUN-83
	MOVEM B,RTERM		;[961] REMEMBER HIGHEST TERMINAL IN RANGE
	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
;**;[961]  Change 2 lines at SPEEDA::+19		DML	1-JUN-83
	MOVE	A,STERM		;[961] TERMINAL NUMBER TO START WITH
SPEEDB:	MOVEI	B,.MOSPD	;[961] FCN CODE
	MOVE C,Q1		;PICK UP SELECTED SPEEDS
	MTOPR			;C := INPUT,,OUTPUT
	 ERCAL CJERRE		;FAILED, TELL USER WHY
;**;[961]  Replace 1 line with 4 at SPEEDA::+24		DML	1-JUN-83
	AOS A,STERM		;[961] INCREMENT TERMINAL NUMBER
	CAMG A,RTERM		;[961] STILL IN RANGE?
	JRST SPEEDB		;[961] YES, SET NEXT TERMINAL
	RET			;[961] NO, 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::
NEWF,<
	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
	MOVE A,LOGDAT		;THEY HAVEN'T, GET LOGIN DATE.
	CALL MESS		;TYPE APPLICABLE LOGIN MESSAGES
	RET

REPEAT 1,<
;CODE TO USE RDMAIL TO TYPE <SYSTEM>MAIL.TXT
MESS:	STKVAR <MALJFN,SJFNP,MSFK>	;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,FORK		;SAVE CURRENT FORK
	MOVEM A,MSFK
	SETOM FORK		;FORCE NEW FORK BELOW
	MOVE A,JBUFP
	MOVEM A,.JBUFP		;MARK STACK SO RLJFNS DOESN'T CLOSE THINGS OUR CALLER OPENED
	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 $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
	MOVE B,C		;START ADDR IN B
	MOVE A,FORK		;SET UP AS RUNNING FORK
	SFORK			;START FORK HERE FOR SYSTEM MESSAGE
	RFORK			;RESUME IT
	WFORK			;WAIT FOR IT
SYSLEV:	SKIPL A,FORK		;GET RID OF TEMP FORK
	CALL KEFORK
	CALL RLJFNS		;CLOSE FILES WE USED
	MOVE A,SJFNP		;GET JFN STACK MARKER AS BEFORE WE TOUCHED IT
	MOVEM A,.JBUFP		;RESTORE IT
	MOVE A,MSFK		;RESTORE CURRENT FORK
	MOVEM A,FORK
	TLZ Z,RUNF		;SAY PROG'S TTY MODES NOT IN EFFECT
	MOVEI Q1,ETTYMD		;RESTORE EXEC'S TTY MODES
	CALL LTTYMD		; ..
	RET
SYSLOS:	ETYPE <%_%%%Error while reading system message -  %?%%_>
	JRST SYSLEV
>
REPEAT 0,<
;RUN MS TO TYPE NEW SYSTEM MESSAGES

MESS:	HRROI B,[GETSAVE <SYS:MS.>]
	CALL TRYGTJ		;TRY TO GET A JFN ON THIS
	 RET			;CAN'T
	MOVEI B,1		;RUN AT OFFSET +1
	CALLRET REPH1		;RUN AS EPHEMERAL
>

	END