Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - mit/exec/exec0.mac
There are 47 other files named exec0.mac in the archive. Click here to see a list.
;127 TERM [NO] MARGIN-WRAP to set tc%wrp
;126 Turn on .NSEND code for XX
;124 Improve uptime greeting message
;122 (OZ)Add uptime to greeting message
;117 Don't let the user change the type of a supdup terminal
;1020 AAA and C100 tctyps, make "c" valid for concept-100
;1015 various startup functions
;1014 INFORMATION SUBSYSTEM command changes
;1013 INFORMATION MONITOR command changes
;1012 SYSTAT command changes
;1011 revise command parsing routine 
;1010 seperate command files for batch jobs
;1007 set error return before allowing control-c 
;1006 change herald print out
;1005 make batch jobs refuse system-messages
;1004 control-c keep forks 
;1002 revise fork control code 
;770 lazy restart control 
;757 attach initialization file 
;755 lazy login 
;754 lazy connect 
;752 INFORMATION MAIL-WATCH command 
;751 various not-logged-in program commands 
;750 program name defaults revision 
;747 simple command level 
;745 inferior fork capabilities control 
;743 wake-every-field control 
;742 noisy fork control 
;741 lazy feature control 
;740 group login file 
;736 first login of user 
;731 FDB fork control 
;730 TTYLOK deamon support for OZ
;724 IDDT support
;720 not logged in commands handled in seperate command tables
;717 add terminal features, use VTS
;716 add command-edit features
;715 add CMU PCL 5(100) features
;713 prevent conflict with site switch
;   add new configuration conditionals
;   add literal label
;   cosmetic changes
;712 DEC release version
; 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
;   STATUS AND TERMINAL CHARACTERISTICS COMMANDS

;TOPS10 JOB DATA AREA
	JOBDDT==:74
	JOBSYM==:116
;	JOBSA==:120		;713 not used anywhere

;TOPS20 ENTRY VECTOR
;   NOTE: "EXEC" IS ASSUMED TO BE FIRST SYMBOL IN EXEC0.REL, AND AT A PAGE
;   BOUNDARY, BY PAGE BOUNDARY CHECK IN "ALOFRK" AT END OF THIS FILE.
;713 actually in XSAVE in EXECPR 
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.
;713 not true, though std patch area at PAT.. is still availible 
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,[CRPRA,,CRPRA+1]
	BLT A,CRPRA+17
	RET

;"EXEC" AND ITS VERSION
EXECV::	TYPE < MIT TOPS-20 Command Processor > ;713 EXEC name
;713	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
	MOVX 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
	MOVX A,ATMLEN*5		;LENGTH OF ATOM BUFFER
	MOVEM A,CMABC
	MOVEI A,CJFNBK		;ADDRESS OF GTJFN BLOCK
	MOVEM A,CMGJB
	RET
;REENTER ENTRY
REE::
REENTE::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! 
	MOVX 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
	MOVX A,.FHSLF
	RPCAP			;GET CURRENT CAPABILITIES
	HLLZ C,C		;PREVENT "ATTACH" WITHOUT PASSWORD 
	EPCAP			;   (MONITOR MAKES VIRGIN JOB BE WHEEL!)
	SETZM CSZ1
        MOVE A,[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
        MOVE A,[CALL CUUO]	;SET UP 41 FOR UUO'S, P=17 FOR PUSHDOWN POINTER
        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
CEF,<	SETOM CEPSIC>		;716 no default interrupt character
	MOVX A,NFRKS		;INITIALIZE FORK NAME TABLE
	MOVEM A,FRKNMS		;SAY MAXIMUM NAMES ALLOWED IN TABLE
	MOVEM A,KEPNMS		;INITIALIZE KEPT FORKS TABLE TOO
	MOVEM A,PRGNMS		;750 initialize set program table
	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
	MOVX 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
	MOVX 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
	TXNN 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
;724	SETOM IDFORK		;NO IDDT FORK
	SETOM EDFORK		;NO EDITOR FORK
	SETOM EFORK		;NO EPHERMERAL FORK
MIC,<	SETOM MICFRK>		;NO MIC FORK
	SETOM FDBAK		;731 FDB autokeep
	SETOM FDBEPH		;731 FDB ephemeral
	SETOM CAPMSK		;745 pass all capabilities to inferiors
	SETOM CCKEEP		;1004 keep forks interrupted by ^c
	SETOM LAZFEA		;741 lazy features
	SETOM LAZRES		;770 lazy-restart all-forks
CEF,<	SETOM CERECD		;716 set command recording on
	CALL .FLUS0		;716 initialize command edit buffer
VTS,<	MOVX A,.CTTRM		;717 a meta key?
	RTCHR			;717 get VTS characteristics
	 ERJMP EXEC02		;717
	TXNE B,TC%MET		;717 
	 SETOM CEMETA		;717 set command-edit flag on
       >>			;716 end CEF,VTS
EXEC02:	SETOM NPAGE		;SAY NO PAGE OF INFERIOR IS MAPPED
	SETOM OLDIDX		;SAY NO IPCF MESSAGE WAITING YET
	MOVX 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: CHANNEL 1 FOR ASSIGNMENT TO ^C BELOW,
;   OVERFLOW, AND CHANNEL 2 FOR AUTOLOGOUT.
	MOVX A,.FHSLF		;SAY THIS FORK
	MOVE B,[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,[.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.
	MOVX 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.
	SETZ A,			;DON'T TYPE ^V IN ANY FORM
	DPB A,[POINT 2,ETTYMD+TTWCOC+""*2/^D36,""*2+1-""*2/^D36*^D36]
				;MAKE CONTROL-V ECHO LITERALLY AS IN FILENAMES
	MOVX A,3		;FORMAT LINEFEED (MAKE IT ECHO AS CRLF)
	DPB A,[POINT 2,ETTYMD+TTWCOC+<"J"-100>*2/^D36,<"J"-100>*2+1-<"J"-100>
*2/^D36*^D36]

;DISABLE COMPAT FOR EXEC
	MOVX A,.FHSLF		;FOR SELF
	SETO B,			;SET TO -1
	SETZ C,			;...
	SCVEC			;BYE

;DETERMINE HERE IF BATCH MODE
	SETZM BATCHF		;ASSUME NOT BATCH JOB
	SETO A,
	HRROI B,A
	MOVX 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
	MOVX A,.CTTRM		;1005 refuse system-messages
	MOVX B,.MOSNT		;1005
	MOVX C,.MOSMN		;1005
	MTOPR			;1005
	 ERNOP			;1005 forget it

NOBTCH:
STAT,<	HRROI B,[ASCIZ/PS:<QUEUES>COMMANDS-USAGE.THAW;0/]
	CALL TRYGTJ
	 JRST STLOSE		;GIVE UP IF NO FILE
	MOVX B,OF%RD!OF%WR!OF%THW
	OPENF
	 JRST STLOSE
	HRLZ A,A
	MOVE B,[.FHSLF,,STBPN]
	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
OZ,<	MOVEM D,ATTYNO>		;730 get attached TTY NO for use with TYYLOK
	MOVE A,C		;GET THE JOB NUMBER
	HRROI B,LIDNO		;READ LOGGED-IN DIRECTORY NUMBER INTO LIDNO
	MOVX C,.JILNO		;ASK FOR ONLY THIS ONE.
	GETJI			;DO IT.
	 NOP			;IGNORE FAILURE, SEE LIDNO REF. ABOVE.
	MOVX 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
	SKIPN BATCHF		;743 not in batch?
	 SKIPN CUSRNO		;743  and not logged in?
	  SETOM WAKFLD		;743 yes, set wake-every-field
OZ,<	SKIPE CUSRNO		;730 if not logged in set up the TTYLOK stuff
	 JRST ICOMPL		;730 otherwise forget it, and say init complete
	MOVX A,TLPLEN		;730 find out TTYLOK's PID from INFO
	MOVEI B,TLTO		;730      
	MSEND%			;730 send out the request
	 JRST ICOMPL		;730 error, forget the whole thing
	MOVE A,TLTO+.IPCFS	;730 put EXEC's PID in as reciever of INFO's
	MOVEM A,TLFROM+.IPCFR	;730    response
	MOVEM A,TLFLBK+1	;730 also as the PID to flush when cleaning up
	MOVX A,TLPLEN		;730 
	MOVEI B,TLFROM		;730 
	MRECV%			;730 get our queue, hopefully INFO's response
	 JRST TLFLSH		;730 error, cleanup and exit
	LDB A,[POINTR TLFROM+.IPCFL,IP%CFE] ;730  get the error field
	JUMPN A,TLFLSH		;730 error, cleanup and exit
	MOVE A, TLIMSG+.IPCI1	;730 get TTYLOK's PID and put it as the receiver
	MOVEM A,TLTOTL+.IPCFR	;730 
	MOVX A,TLPLEN		;730  
	MOVEI B,TLTOTL		;730  
	MSEND%			;730 tell TYYLOK to reset location for terminal
	 NOP			;730 error, fall into cleanup routine
TLFLSH: MOVX A,TLFLLN		;730 clean up delete EXEC's PID, load args
	MOVEI B,TLFLBK		;730 
	MUTIL%			;730 
	 NOP			;730 well we tried
ICOMPL:				;730 add local label
       >			;730 end OZ
;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
	SKIPGE CRPRA(A)		;HERALD SUPPRESS?
	 JRST CMDIN2		;YES
	TXNN B,1B4		;SIMULATE LOGIN?
	 JRST CMDIN0		;NO SO GO ON.
	JRST CMDIN1		;1006 save some code

CMDIN0:	SKIPE BATCHF		;BATCH JOB?
	 JRST CMDI1A		;1006 yes, skip blanking screen
	CALL CHKPTY		;1006 is it a PTY? (sysjob or otherwise)
	 JRST CMDIN2		;1006 yes, so skip herald etc.
CMDIN1: SKIPN CUSRNO		;1006 not logged in?
	 CALL BLANK1		;1006 yes, blank the screen
CMDI1A:	ETYPE <%_>		;HERALD
	CALL $VERSI		;VERSIONS
	SKIPE BATCHF		;1006 batch?
	 JRST CMDIN2		;1006 yes, skip these messages
	CALL DWNTYP		;IF THERE IS A DOWN TIME
	SKIPE CUSRNO		;1006 logged in?
	 JRST CMDIN2		;1006 yes, skip load avg print out
OZ,<	ETYPE < The system has been up for>
	TIME%			;122 Get uptime
	IMULI B,^D60		;122 convert to minutes
	IDIV A,B		;122 A=minutes
	IDIVI A,^D60		;122 A=hours, B=minutes
	EXCH A,B		;122 A=minutes, B=hours
	IDIVI B,^D24		;122 C=hours, B=days
	IFN. B			;122 Any days?
	  ETYPE < %2Q day>	;122 yes, say so
	  CAIE B,1		;124 Pluralize
	    ETYPE <s>		;124
	ENDIF.			;122
	IFN. C			;122 Any hours?
	  SKIPE B		;124 Yes, did we have days?
	    ETYPE <,>		;124 yes, separate them
	  ETYPE < %3Q hour>	;122 say hours
	  CAIE C,1		;124 Pluralize
	    ETYPE <s>		;124
	ENDIF.			;122
	SKIPN B			;124 If said something before
	 SKIPE C		;124
	  ETYPE < and>		;124 separate
	MOVEI D,"s"		;124 Pluralize as appropriate
	CAIN A,1		;124
	  SETZ D,		;124
	ETYPE < %1Q minute%4\%%_>	;122
>				;122
	MOVX D,14		;1006 1-min load avg
	GTB .SYSTA		;1006
	ETYPE < There are %I jobs and the load average is %1Q%%_> ;1006
	HRROI B,[ASCIZ/SYSTEM:MOD.TXT/]	;1006 try to print message of the day
	CALL TRYGTJ		;1006
	 JRST CMDIN2		;1006 probably file not found - skip it
	CALL JFNSTK		;1006 print it out
	MOVE A,JBUFP		;1006
	HRRZM A,INIFH1		;1006 copy code stuff
	HRRZM A,INIFH2		;1006
	MOVX Q1,CP%HEL		;1006
	CALL TYPE1		;1006
;COMMANDS THAT RUN PROGRAMS RETURN HERE WHEN THEY STOP.
;   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
	MOVX 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::	MOVX 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::	MOVX 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,[CTRLC,,1]
	ATI
	MOVX 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:	MOVX A,ADVESC		;MAKE SURE ADVICE CHARACTER NO LONGER SPECIAL
	DTI
	MOVE A,[CTCODE,,3]
	ATI
CEF,<	HRLZ A,CEPSIC		;716 get command edit interrupt character
	HRRI A,CECHN		;716
	CAILE A,0		;716 code assigned?
	 ATI			;716 yes, enable it
       >			;716

;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:	SETO A,
	HRROI B,D		;GET CURRENT LIMIT INTO D
	MOVX 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
	MOVX C,4		;CHANNEL
	TIMER
TIMERR:	 ERROR <Couldn't set time limit - %?>
	RET

;SUBROUTINE TO INIT GTTAB NUMBERS - USED AT STARTUP ONLY
;NOTE:  THE ONLY ONES THAT SHOULD BE INITED HERE ARE ONES TO BE USED FOR
;   *OTHER* THAN GETAB JSYS.  FOR GETAB JSYS, USE MONITOR SYMBOLS.
STSYST:	MOVSI D,-NGTTBS		;NUMBER OF TABLES
STSYS1:	MOVE A,GTTBS(D)		;GET THE SIXBIT NAME OF THE TABLE
	SYSGT			;GET ITS NUMBER
	JUMPN B,STSYS2		;JUMP UNLESS NO SUCH TABLE
	TYPE <%No system table named: >
	MOVE A,GTTBS(D)
	CALL SIXPRT
	SETZ B,
STSYS2:	MOVEM B,@GTTBS+1(D)	;PUT NUMBER IN VARIABLE
	AOBJN D,.+1
	AOBJN D,STSYS1		;DO ALL TABLES
	RET

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

;LIST OF GTTAB TABLES KNOWN TO EXEC
;713 rename local XX to SIXTBL
DEFINE SIXTBL (NAMS)
  <IRP NAMS,<SIXBIT/NAMS/
	     Z NAMS>>

GTTBS: SIXTBL <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::	SKIPN ADVFLG		;INDICATE NOT IN ADVISE CODE
	 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:	MOVX A,1
	MOVEM A,INTDF
	MOVEM A,IINTDF		;MAKE SURE IPCF INTERRUPTS ALLOWED
				;1007 code moved

;MISCELLANEOUS INITIALIZATION
	MOVEI A,RERET		;SAY WHERE TO GO ON ERROR WHILE TYPING
	MOVEM A,CERET		;   ...LOGIN MESSAGE
				;1007 moved code - make sure error return is
				;1007  set before ^C is allowed
	CALL PION		;MAKE SURE ^C ALLOWED
	CALL IPCON		;MAKE SURE IPCF INTERRUPTS ALLOWED

;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)
		TXNE B,1B4	;SIMULATE LOGIN?
		 SETOM LOGINI	;YES.
		TXNN 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
		MOVX 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
	 CALL MESMES		;   SUBROUTINE NEAR "LOGIN" 
        >			;   (NON-0 FROM LOGIN TO SUCCESSFUL COMPLETION
				;   OF "MESMES") 
;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
	  NOP
	SETO A,
	CAME A,NPAGE
	 CALL MAPPF		;DON'T LEAVE FORK PAGES MAPPED
	  NOP			;UNMAP SHOULDN'T FAIL
	SETZM CSZ1		;ZERO STORAGE
	MOVE A,[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
;724 make sure a valid handle on fork being debugged by IDDT-style debugger
;724  exists, possible for fork handle to be garbage if debugger killed old
;724  fork and started new one underneath 
	MOVSI D,-NFRKS		;724 set up fork counter 
	MOVX C,FK%UND		;724 test for "under debugger" bit
CMDI4A:	TDNN C,FRKTAB(D)	;724
	 JRST CMDI4E		;724 no, continue looking for "under debugger"
	MOVEI A,FRKDES(D)	;724 yes, get status
	RFSTS			;724
	CAME C,[-1]		;724 deleted process?
	 JRST CMDI4E		;724 no, this fork is okay
	MOVEI A,FRKDES(D)	;724 yes
	HLRZ C,@SLFTAB+.FKOWN(A) ;724 get superior handle (debugger)
	HLLZS @SLFTAB+.FKOWN(C)	;724  and for now, say debugger has no inferior
	CALL KEFOR0		;724 kill fork
	MOVX B,FRKDES+1		;724 find a new user fork handle for the EXEC
CMD14B:	MOVE A,C		;724 
	GFRKH			;724 
	 ERJMP CMDI4C		;724 error, try another possible fork handle
	HRRM A,@SLFTAB+.FKOWN(C) ;724 sucess, store new debugger inferior 
	PUSH P,B		;724 get a new fork block for new handle
	PUSH P,A		;724
	MOVX A,.FKSZE		;724
	MOVEI B,XDICT		;724
	CALL GETME0		;724
	 JRST  [ADJSP P,-2	;724 no space, cleanup and try next fork
		JRST CMDI4D]	;724
	POP P,A			;724 set up SLFTAB entry 
	TXO B,FK%UND!FK%RUN	;724 
	MOVEM B,SLFTAB(A)	;724
	HRLZM C,.FKOWN(B)	;724 say debugger is superior
	SETOM .FKEDL(B)		;724 no examine/deposit by EXEC yet
	SETOM CODSEC(B)		;724 no special section number yet
	HRRZI A,.FKPTM+1(B)	;724 zero rest of fork block
	HRLI A,-1(A)		;724
	SETZM .FKPTM(B)		;724
	BLT A,.FKPTM+NTTYMD+1(B) ;724
	POP P,B			;724
CMDI4C:	ADDI B,1		;724 try the next possible user fork handle
	CAIE B,FRKDES+NFRKS	;724 run out of fork handles?
	 JRST CMD14B		;724 no, try this one
CMDI4D:	MOVX C,FK%UND		;724 go back to checking "under debugger"
CMDI4E:	AOBJN D,CMDI4A		;724
;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
	MOVX B,AUTOL2*^D1000	;FOR THAT FAR IN FUTURE
	MOVX 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

;CHECK TO SEE IF CRJOB/PRARG START UP & IF SO, A PROGRAM TO RUN
CMDN5E:	SKIPE CRPRA		;CRJOB START UP?
	 JRST  [HRRZ A,CRPRA+.CJPLP ;YES, GET FLAGS PTR
		MOVE B,CRPRA(A)	;THEN FLAGS
		TXNN 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
				;740 group login 
 	SKIPN GLGINI		;740 take "group-login.cmd"?
	 JRST DEFTK2		;740 no, skip around
	SETZM GLGINI		;740 yes, turn flag off
	MOVE A,CSBUFP		;740 build "<topleveldir>group-login.cmd"
	MOVE B,LIDNO		;740 get logged-in directory 
	DIRST			;740
	 CALL JERR		;740
	MOVE A,CSBUFP		;740 scan it for an unquoted "."
DEFTK1:	ILDB B,A		;740 
	JUMPE B,DEFTK2		;740 check for end
	CAIN B,.CHCNV		;740 check for ^V quote
	 JRST  [ILDB B,A	;740 
		JRST DEFTK1]	;740
	CAIE B,"."		;740 "."?
	 JRST DEFTK1		;740 no, go on to next character
				;740 match angle bracket in next line <
	MOVEI B,">"		;740 terminate the directory specification
	DPB B,A			;740
EE,<	HRROI B,[ASCIZ/COURSE-LOGIN.CMD/]> ;740 add this on
NOEE,<	HRROI B,[ASCIZ/GROUP-LOGIN.CMD/] ;740 load default
	SKIPE BATCHF		;1010 batch?
	 HRROI B,[ASCIZ/GROUP-BATCH.CMD/] ;1010 yes, use this instead
       >			;740
	SETZ C,			;740
	SOUT			;740 append it
	MOVE B,CSBUFP		;740
	CALL TAKEIN		;740 take it
	 ABSKP			;740 probably file not found, do not reset
	  JRST CMDIN4		;740 reset 
DEFTK2:	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
	 ABSKP			;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/]
	SKIPE BATCHF		;1010 use different file if in BATCH
	 HRROI B,[ASCIZ/BATCH-COMAND.CMD/] ;1010
	CALL TAKEIN
	 ABSKP			;DON'T RESET ANYTHING UNLESS WE'RE REALLY DOING
				;   "TAKE" NOW 
	  JRST CMDIN4		;RESET ALL COMMAND INFO AFTER TAKEIN ATTEMPT
NLGINI: SKIPN ATTINI		;757 take ATTACH.CMD?
	 JRST NLGIN1		;757 no, skip around
	HRROI B,[ASCIZ/ATTACH.CMD/] ;757 yes
	CALL TAKEIN		;757
	 ABSKP			;757 probably file not found, do not reset
	  JRST CMDIN4		;757 reset
NLGIN1:	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"! 
				;715 code moved
	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
	SETZ Z,			;CLEAR FLAGS

;BEGIN INPUTTING AND DECODING A COMMAND
	CALL COMSET		;SET UP THINGS FOR COMMAND INPUT
	MOVE B,PCLDCO		;715 set default value for original flag (after
	MOVEM B,ORIFLG		;715    reparse addr but before original cmd)
CIN1:
CEF,<	SKIPN CERECD		;716 are we recording?
	 SETOM CEBPTR		;716
       >			;716
	SETZM CIPF		;715 code moved here
	SKIPE CUSRNO		;720 not logged in?
	 JRST CIN1A		;720 no
	MOVEI B,$CM0		;720 load default
	JRST CIN10		;720 PCL must not change the descriptor

CIN1A:	SKIPN SIMPLE		;747 simple command level?
	 JRST CIN1B		;747 no
	MOVEI B,$CM1S		;747 load default 
	SKIPN LAZRES		;770 lazy-restart only kept forks?
	 MOVEI B,$CM1SK		;770 yes
	SKIPN LAZFEA		;741 lazy features?
	 MOVEI B,$CM1SN		;741 no
	JRST CIN10		;747 PCL must not change the descriptor

CIN1B:	MOVX B,WHLU!OPRU!ERRU	;1011 is wheel, operator, or CIA enabled?
	SKIPE PRVENF		;1011 
	 CALL PRVCK		;1011 
	  JRST CIN1C		;1011 no 
	  MOVEI B,$CM1E		;1011 yes, load default
	SKIPN LAZRES		;770 lazy-restart only kept forks?
	 MOVEI B,$CM1EK		;770 yes
	SKIPN LAZFEA		;741 lazy features?
	 MOVEI B,$CM1EN		;741 no
	JRST CIN7		;1011 join common code

CIN1C:	MOVEI B,$CM1		;1011 load default
	SKIPN LAZRES		;770 lazy-restart only kept forks?
	 MOVEI B,$CM1K		;770 yes
	SKIPN LAZFEA		;741 lazy features?
	 MOVEI B,$CM1N		;741 no

DELETE,<			;1011 old code here
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,CM0DB		;714 new FLDDB. for not logged in
	MOVEI B,[FLDDB. .CMKEY,,CTBL1,<a command,>]
       >			;1011 end DELETE

CIN7:	SKIPN PCFLDB		;IS PCL A FACTOR?
	 SKIPE PCFLDP
	  ABSKP			;YES
	   JRST CIN10		;NO
	MOVEI C,PCFLDB		;ASSUME USER TABLE
	SKIPN ORIFLG		;715 does he want the original set?
	 SKIPN PCFLDB		;DOES HE HAVE HIS OWN?
	  ABSKP			;YES, OR NO
	   JRST CIN8		;NO AND YES, USE HIS
	SKIPN PCFLDP		;IS THERE A PRESERVED TABLE?
	 JRST CIN10		;NO, USE ORIGINAL ONE
	SKIPLE ORIFLG		;715 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
	 JRST CHKOTH		;1011 check various other possibilites
	MOVEM B,COMAND		;SAVE COMMAND INFO
	LOAD D,FKFLAG,+@FRKDEF	;GET DEFAULT FLAGS
	MOVEM D,NAMFLG
	GTFLDT D		;GOOD PARSE, SEE WHAT GOT TYPED
	CAIN D,.CMKEY		;1011 keyword? 
	 JRST CIN2		;1011 yes, a command or fork name
	CAIN D,.CMTOK		;^E?
	 JRST CINE		;YES
	CAIN D,.CMFIL		;FILESPEC?
	 JRST CIN3P		;YES, GO RUN PROGRAM
	CAIN D,.CMDIR		;754 directory name?
	 JRST LAZCON		;754 yes, lazy connect
	CAIN D,.CMUSR		;755 user name?
	 JRST LAZLOG		;755 yes, lazy login
	CMERRX <Couldn't Parse> ;1011 shouldn't get here

;741 check other file possibilities here
;741  since can only be one set of default file specs
CHKOTH: SKIPE CUSRNO		;741 logged in?
	 SKIPN LAZFEA		;741 lazy features?
	  JRST CHKOT1		;741 no, then its and error
	SETOM LAZCMD		;741 only thing left is lazy commands
	CALL LAZTAK		;741 lazy take?
	 JRST CMDIN4		;741 
	CALL LAZDO		;741 lazy do?
	 JRST CMDIN4		;741 
CHKOT1:	ERROR <Eh>		;741 finally give up

;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
	CALL GETKEY		;1011 
	JRST CIN2D		;1011 bypass fork name checking

;HAVE VALID FIRST KEYWORD IN COMMAND MAKE PRE-DISPATCH CHECKS
CIN2::	MOVE B,COMAND		;PCL GET WHICH COMMAND WE'RE DOING
	HRRZ P3,(B)		;1011 do this instead of calling GETKEY
	MOVE P3,(P3)		;1011  since flags in fork block can be
;1011	CALL GETKEY		;1011  mistaken for ONEWRD 
	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
	SKIPN LAZRES		;770 lazy-restart only kept forks?
	 JRST CIN2A		;770 yes, check kept fork table instead
	HLRZ C,FRKNMS		;1002 in normal fork table?
	ADDI C,FRKNMS		;1002 
	CAIL B,FRKNMS+1		;1002 less than lowest valid address?
	 CAMLE B,C		;1002 greater than highest possible?
	  JRST CIN2C		;1002 yes, it's a command
	CALL CIN3D0		;1002 no, it's a fork, get rest of command line
				;1002  (rescan args); save ACs entry point
	MOVEM B,PTBLP		;1002 save table address
	JRST CINFRK		;1002 join common code 

CIN2A:	HLRZ C,KEPNMS		;770 in kept fork table?
	ADDI C,KEPNMS		;770 
	CAIL B,KEPNMS+1		;770 less than lowest valid address?
	 CAMLE B,C		;770 greater than hihghest possible?
	  JRST CIN2C		;770 yes, it's a command
	CALL CIN3D		;770 no, it's a fork, get rescan and confirm

				;1002 enter here only if lazy-restart for
				;1002  kept-forks only and thus searched KEPNMS
				;1002  (which doesn't have all necessary info)
				;1002  instead of FRKNMS 
CIN2B:	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

CIN2C:	TXNE P3,ONEWRD		;1011 it's a command - do ONEWRD confirmation
	 CONFIRM		;1011
CIN2D:	MOVE P4,P3		;1ST KW'S VALUE WD STAYS IN P4.
;720	TXNE P4,NOLG		;720 not necessary anymore
;720	 JRST .+3
;720	SKIPN CUSRNO		;SKIP IF LOGGED IN
;720	 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.
;751 can run a few special programs not logged in via these commands

ALLON <CHA,MIT>,<		;751 check the DOVER QUEUE
NOEE,<				;751
.DVRQ:: HRROI B,[GETSAVE <SYS:DVRQ.>] ;751
	CALL TRYGTJ		;751 try GTJFN on prog name
	 ERROR <No Dover Queue facility at this site> ;751 probably not found
	CALLRET STEPH		;751 ephemeral start
      >>			;751 end ALLON <CHA,MIT>, NOEE

.FINGE::HRROI B,[GETSAVE <SYS:FINGER.>]	;751 FINGER users on the system
	CALL TRYGTJ		;751
	 ERROR <FINGER utility not installed at this site> ;751
	MOVE B,CMPTR		;751 set up the command line for RSCAN
	MOVE C,CMINC		;751
	ADJBP C,B		;751
	SETZ B,			;751
	SKIPGE CMFLG		;751 end with esc?
	 IDPB B,C		;751 yes, end with <space><nul>
	CALLRET STEPH		;751

ONEON <EE,OZ>,<			;751 OPEN an account
.OPEN:: NOISE <an account>	;751
	CONFIRM			;751
	HRROI B,[GETSAVE <SYS:OPEN.>] ;751
	CALL TRYGTJ		;751
	 ERROR <No OPEN facility at this site> ;751
	CALLRET STEPH		;751 
       >			;751 end ONEON <EE,OZ>

NOEE,<				;126 XX has this now too
.NSEND::HRROI B,[GETSAVE <SYS:SEND.>] ;751 SEND message to another user
	CALL TRYGTJ		;751
	 ERROR <SEND utility not installed at this site> ;751
	NOISE <to user>		;751 
	CALLRET STEPH		;751
      >				;126 end NOEE

EE,<				;751
.TESS::	NOISE <of the Daubervilles> ;751
	CONFIRM			;751
	HRROI B,[GETSAVE <SYS:TESS.>] ;751 signup for a terminal at EE
	CALL TRYGTJ		;751
	 ERROR <TESS terminal signup system not installed at this site>	;751
	CALLRET STEPH		;751
       >			;751

;751 interface to some programs to run while logged in

ONEON <EE,OZ>,<			;751 ITS-style directory listings
.NDIRE::HRROI B,[GETSAVE <SYS:NDIR.>] ;751
	CALL TRYGTJ		;751
	 ERROR <NDIRECTORY utility not installed at this site> ;751
	NOISE <of files>	;751
	MOVE B,CMPTR		;751 set up the command line for rscan
	MOVE C,CMINC		;751
	ADJBP C,B		;751
	SETZ B,			;751
	SKIPGE CMFLG		;751
	 IDPB B,C		;751
	CALLRET STEPH		;751
       >			;751 end OZ

;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

;1002 fork behavior of MIT EXEC: 
;1002		no MOO fork	MOO fork exists	in correct table*
;1002 input:			 w/o JCL	w/ JCL
;1002 mo	1.fail		2.lazy-restart	3.lazy-restart
;1002 moo	4.new fork	5.lazy-restart	6.new fork
;1002 moo.exe	7.new fork	8.new fork	9.new fork
;1002	* correct table is FRKNMS unless lazy-restart only kept-forks,
;1002	  then it's KEPNMS 
;1002
;1002 case 2,3 handled at CIN2
;1002 cases 4-9 handled at CIN3P
;1002 note: that cases 4-6 are parsed as "program name" and not as "fork name"
;1002	due to order of FLDDB.s, which is necessary to allow MOO to complete to
;1002	MOO.EXE 

CIN3P:	CALL SPNAME		;SET UP PROGRAM NAME
				;1002 code moved to preserve ATMBUF so that
				;1002  can distinguish betw MOO and MOO.EXE
	SKIPN LAZRES		;770 lazy-restart only kept forks?
	 JRST CIN3P1		;770 yes, check KEPNMS
	MOVEI A,FRKNMS		;1002 no,  check FRKNMS
	HRROI B,ATMBUF		;1002
	TBLUK			;1002 in FRKNMS?
	TXNE B,TL%EXM		;1002 exact match?
	 SETOM AMBFRK		;1002 yes, set ambiguous fork flag
	CALL CIN3D0		;1002 get rest of line (save acs), moved code
	TLNN Z,F3		;1002 do we have any jcl?
	 SKIPN AMBFRK		;1002 is it also in the table?
	  JRST CIN3P2		;1002 jcl, not exact match, start new fork
	MOVEM A,PTBLP		;1002 save table address
	JRST CINFRK		;1002 join common code

CIN3P1:	MOVEI A,KEPNMS		;1002 in KEPNMS?
	HRROI B,ATMBUF		;1002
	TBLUK			;1002 
	TXNE B,TL%EXM		;1002 exact match?
	 SETOM AMBFRK		;1002 yes, set ambiguous fork flag
	CALL CIN3D		;1002 get rest of line, moved code
	TLNN Z,F3		;1002 do we have any jcl?
	 SKIPN AMBFRK		;1002 is it also in the table?
	  ABSKP			;1002 jcl, no exact match, start new fork
	   JRST CIN2B		;1002 continue fork
CIN3P2:	MOVEI A,PRGNMS		;750 point to SET PROGRAM names
	MOVE B,PNAMP		;750 get pointer, not pointer to pointer
;750	HRROI 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
	TXNE A,FN%KEP		;750 run as kept program?
	 JRST CIN3P4		;750 yes
	SKIPN FDBAK		;731 can we do FDB autokeep?
	 JRST  [SKIPN FDBEPH	;731 no, how about FDB ephemeral?
		 JRST RSUBS4	;731 no, well skip checking
		JRST .+1]	;731
	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]
	SKIPN FDBEPH		;731 can we do FDB ephemeral?
	 JRST CIN3P3		;731 no
	CAIN C,.FBEPH		;731 ephemeral bit set?
	 JRST EPH		;731 yes
CIN3P3:	SKIPN FDBAK		;731 can we do FDB autokeep?
	 JRST RSUBS4		;731 no
	CAIN C,.FBKEP		;731 autokeep bit set?
CIN3P4:  SETOM AUTKEP		;731 yes, set flag
	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
	MOVX 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,FLD(.JSAOF,JS%NAM) ;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
;1002 can restart unkept forks too
;1002	MOVE A,SLFTAB(A)	;GET FLAGS FOR THIS FORK
;1002	TXNE A,FK%KPT		;IS FORK KEPT ALREADY?
	 JRST RSTFK		;YES, SO GO RESTART IT
;1002	JRST RSUBS4
CIN3D0: ATSAVE			;1002 save acs entry
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
	SETZ C,			;END ON NULL
	SOUT			;START COMMAND LINE WITH PROGRAM NAME
	MOVX B," "		;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).CHLFD,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
;1002 HIDFRK - (HIDDEN FORK) #0: never print fork messages
;1002 QCALLF - (QUICK CALL) #0: PJFN in A (so can be called like STEPH)
;731 AUTKEP - (AUTOKEEP) #0: fork is autokept
RSUBS4:	SKIPE QCALLF		;1002 quick call?
	 PUSH P,A		;1002 yes, push PJFN
	MOVEI Q1,ETTYMD		;MAKE SURE NORMAL TTY MODE RESTORED
	CALL LTTYMD
	CALL ERESET		;PREPARE TO LOAD AND RUN PGM
	SKIPN QCALLF		;1002 PJFN pushed?
	 JRST RSUB4A		;1002 no
	POP P,A			;1002 yes
	ABSKP			;1002
RSUB4A:	 MOVE A,PJFN		;SAY WHICH PROGRAM TO GET
	CALL $GET0		;GET PROGRAM
	SKIPN AUTKEP		;731 auto-keep this fork?
	 JRST RSUB4B		;731 no, skip around
	MOVE A,FORK		;731 yes
	MOVX B,FK%KPT		;731 set keep bit so ANNKEP won't say anything 
	IORM B,SLFTAB(A)	;731
	CALL ANNKEP		;731 put fork's name in table of kept forks
	SKIPE HIDFRK		;1002 hidden fork?
	 JRST ..STRT		;1002 yes, just start
	SKIPE NOISY		;742 noisy forks?
	 ETYPE <[Keeping]%_>	;742 yes, print msg
	JRST ..STRT		;1002 start

RSUB4B:	SKIPE HIDFRK		;1002 hidden fork?
	 JRST ..STRT		;1002 yes, just start
	SKIPE NOISY		;742 noisy forks?
	 ETYPE <[Unkept]%_>	;742 yes, print msg
	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
	SETZ D,			;MAKE SURE NULL AFTER STRING
	IDPB D,COJFN
	HRROI D,OCTBF		;NOW CREATE OCTAL VERSION
	MOVEM D,COJFN
	ETYPE <%1O/ %3#>
	SETZ D,
	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
;
;   ACCEPTS:	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
	MOVX A,3		;ENOUGH ROOM FOR NUMBER
	CALL GETBUF		;GET BUFFER ON WORD BOUNDARY
	MOVE D,A		;REMEMBER WHERE BUFFER STARTS
	HRLI A,(ASCPTR)		;MAKE BYTE POINTER
	MOVX C,FLD(10,NO%RDX)	;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 
DELETE,<TLNN B,-1		;ANY SIGNIFICANCE IN LEFT HALF?
	 JRST EXDPRH		;NO--JUST DO RIGHT HALF
	PUSH P,B		;SAVE NUMBER FOR RIGHT HALF LATER
	HLRZ B,B		;SET TO PRINT LEFT HALF NOW
	NOUT			;IN OCTAL
	 JRST  [POP P,(P)	;CAN'T--DON'T DEFAULT
		RET]
	MOVX B,","		;SEPARATE HALVES WITH ",,"
	IDPB B,A
	IDPB B,A
	POP P,B			;GET BACK NUMBER
EXDPRH:	HRRZ B,B		;PRINT JUST RIGHT HALF NOW
      >
	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 ORIFLG		;715 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
	MOVX Q1,SYSDEF
	HRLI A,-SYSTAL
	HRRI A,SYSTAK		;MAKE STACK POINTER
	MOVEM A,SFRAME		;SAVE ARG START
	TLZ Z,F3
SYSTK1:	MOVEI B,[FLDDB. .CMKEY,,$SESTA,,,[
		FLDDB. .CMCMA,,,,,[ ;1012 move dot into different FLDDB. 
		FLDDB. .CMTOK,CM%SDH,TXTPTR <.>,<"." to specify own job>,,[
		FLDDB. .CMNUM,CM%SDH,^D10,<a decimal job number>,,[
		FLDDB. .CMUSR,,CM%DWC,,,[
	     	FLDDB. .CMDIR,,CM%DWC,,,[ ;KEEP AFTER USER NAME TO ALLOW
		FLDDB. .CMCFM]]]]]]] ;  RECOGNITION ON USER NAME 
	CALL FLDSKP		;GET SOME INPUT
	 JRST SYSNX		;NO
	GTFLDT D		;GET FUNCTION CODE
	CAIN D,.CMKEY		;KEYWORD?
	 JRST SYSKEY		;YES
	CAIN D,.CMCMA		;COMMA?
	 JRST SYSSUB		;YES, MAYBE SUBCOMMANDS COMING
	CAIN D,.CMTOK		;1012 dot?
	 JRST SYSTK.		;1012 yes
	CAIN D,.CMNUM		;DECIMAL JOB NUMBER?
	 JRST SYSTJ		;YES
	CAIN D,.CMUSR		;USER NAME?
	 JRST SYSTU		;YES
	CAIN D,.CMDIR		;DIRECTORY NAME?
	 JRST SYSTD		;YES
	CAIN D,.CMCFM		;END OF LINE?
	 JRST SYSTS0		;YES GO EXECUTE COMMAND
	CALL SCREWUP		;SHOULD NEVER GET HERE
;HERE FOR "SYS ."
SYSTK.:	MOVX 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 ."
	CALL .SYSEL		;1012 do it
	JRST SYSTK1		;1012 

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

;COMMA TYPED..
SYSSUB:	CRRX <a 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
		 ABSKP		;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 <  Uptime %K%%_ %I Jobs   Load avg >
	SETO A,			;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%%_%%_>
	MOVX 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::SETZ D,			;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:	MOVX D,1		;GET ITEM 1
	GTB .DWNTI
	CAIE A,0
	 ETYPE <%_ Reload scheduled for %1D %E> ;1012 format change
	ETYPE <%_%%_>
	RET
;LOOP TO TYPE TSS JOB #, TTY #, USER  FOR EACH JOB
JBPART:	TLZ Z,F1!F2		;CLEAR LOCAL FLAGS
	MOVX A,.GTHNS		;1012 in release 5.3, CVHST will disappear
	MOVX B,.NULIO		;1012
	SETO C,			;1012
	GTHST			;1012 has +1/+2 returns, but do ERJMP to pickup
	 ERJMP  [TXZ Q1,SY%4NH	;1012  an illegal instruction interrupt 
		JRST .+1]	;1012
;1012	MOVX A,.NULIO		;TOSS AWAY THE HOST NAME
;1012	SETO B,			;GET OUR HOST NAME
;1012	CVHST			;TO SEE IF THIS IS AN ARPA SYSTEM
;1012	 ERJMP [TXZ Q1,SY%4NH	;IT ISN'T, SO DON'T DO 4N HOST NAME
;1012		JRST .+1]	;REJOIN MAIN FLOW
	MOVX A,RC%EMO		;EXACT MATCH ONLY
	HRROI B,[ASCIZ/OPERATOR/]
	RCUSR			;GET OPERATOR'S USER NUMBER
	TXNE A,RC%NOM!RC%AMB	;GOT IT?
	 HRLOI C,0		;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
	SETZ C,			;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
	MOVX C,.JILNO
	GETJI			;TRY TO GET LOGGED-IN DIR NUMBER
	 NOP			;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
	MOVX A,SYCLN		;SET UP BLOCK SIZE FOR SKED%
	MOVEM A,.SACNT+SYCLB
	MOVX 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:	ADJSP A,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
	TYPE < Job >
	TXNE Q1,SY%CJB
	 TYPE < CJB>
	TXNE Q1,SY%TTY
	 TYPE < Line>
	TXNE Q1,SY%SUB
	 TYPE < Program>
	TXNE Q1,SY%STA
	 TYPE < State>
	TXNE Q1,SY%TIM
	 TYPE <  Time   >
	TXNE Q1,SY%CLS		;CLASS INFO REQUESTED?
	 TYPE < Class Share Use > ;1012 line up columns
	TXNE Q1,SY%LIM
	 TYPE <  Limit  >
	TXNN Q1,SY%USR
	 JRST SYST2U
	TYPE <  User>
	TXNE Q1,SY%CON
	 UTYPE [ASCIZ/, <Directory>/]
	TXNN Q1,SY%4NH		;DOING FOREIGN HOST?
	 JRST SYST2U		;NO, SKIP THIS THEN
	TXNN Q1,SY%CON		;IF PREVIOUS HEADING NOT TYPED,
	 TYPE <            >	;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
	TYPE <  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
	MOVX B," "		;ASSUME NOT CURRENT JOB
	HRRZ D,JNX
	CAMN C,D		;OUR JOB?
	 MOVX 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)!FLD(^D10,NO%RDX) ;LEADING FILLER, 4
				;   COLUMNS, DECIMAL 
	CALL SYNUM

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

;SUBSYSTEM NAME
SYST4:	TXNN Q1,SY%SUB
	 JRST SYST8
	SKIPN A,.JIPNM+.JIBAS
	 MOVE A,.JISNM+.JIBAS	;IF NO PROGRAM NAME, USE SUBSYSTEM NAME
	ETYPE <  %1'>
	SETZ B,
	JUMPE A,[TYPE <        > ;1012 SIX SPACES IF 0 NAME, add two more
		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,[TXTPTR <  TI  >]
SYST8B:	  HRROI B,[ASCIZ/  RUN /]
	ETYPE <%2M>
SYST8A:	TXNN Q1,SY%TIM
	 JRST SYSTS3
	MOVE A,.JIRT+.JIBAS
	ETYPE <  %1B>

;CLASS SCHEDULER INFO
SYSTS3:	TXNN Q1,SY%CLS		;PRINT CLASS STUFF?
	 JRST SYSECL		;NO
	MOVE A,.SAJCL+SYCLB	;GET CLASS
	CALL NUM4		;PRINT AS FOUR COLUMNS
	DMOVE A,.SAJSH+SYCLB	;GET SHARE AND UTILIZATION
	ETYPE < %1=%%2=>	;1012 line up columns
SYSECL:	TXNN Q1,SY%LIM
	 JRST SYSTS4

;LIMIT
	TYPE <  >
	SKIPG A,.JIRTL+.JIBAS
	 JRST  [TYPE <       >
		JRST SYSTS4]
	ETYPE <%1B>

;USER NAME OR "?" IF CONVERSION FAILS.
SYSTS4:	TXNN Q1,SY%USR
	 JRST SYSTS5
	TYPE <  >
	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  [TYPE <Not logged in>
		JRST SYSTS5]
	ETYPE <%2R>
SYSTS7:	TXNN Q1,SY%CON
	 JRST SYSTS5
	MOVE B,.JIDNO+.JIBAS
	CAMN B,.JILNO+.JIBAS
	 JRST SYSTS5
	TYPE <, >
	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
;1012 this stuff needs to be changed with 5.3 release
TCP,<	MOVE A,.JITNO+.JIBAS	;1012 controlling terminal of job
	TXO A,TCP%TV!TCP%SY	;1012 get foreign host for TVTs
	HRROI B,[ASCIZ/TFH/	;1012
		0]		;1012
	HRROI C,D		;1012 put host number into D
	STAT%			;1012
	 ERSKP			;1012 not a TVT, try NVT stuff
	  JRST [MOVE C,D	;1012
		JRST TVTHST]	;1012
       >			;1012 end TCP
	MOVX 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...
TVTHST:				;1012 add local label
	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,FLD(10,NO%RDX) ;OCTAL NUMBER
		NOUT
		 NOP
		JRST .+1]	;REJOIN
	MOVE A,COJFN		;GET CURRENT HORIZONTAL POSITION
	RFPOS			;  ...
	 ERJMP [MOVX B,7777	;NOT TERMINAL, ASSUME COLUMN OVERFLOW
		JRST .+1]
	HRRZ B,B		;DROP LINE NUMBER
	MOVE A,HDRPOS		;GET DESIRED COLUMN NUMBER OF HOST COLUMN
	SUB A,B			;COMPUTE DISTANCE THERE
;1012	CAIG A,0		;RANGE CHECK...IS IT POSITIVE?
;1012	 MOVX A,2		;NO SO DEFAULT IT TO TWO SPACES
	CAIL A,2		;FORCE AT LEAST TWO SPACES
	 CAIL A,^D100		;UNREASONABLY LARGE NUMBER?
	  MOVX A,2		;YES, USE 2 INSTEAD
	PRINT " "		;TYPE ENOUGH SPACES TO LINE UP
	SOJG A,.-1		;   ...
	PRINT "("		;PARENTHESIZE IT
	UTYPE 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
	MOVX 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
		TXTPTR <*>
		TXTPTR <*>
		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,FLD(.JSAOF,JS%DEV)!FLD(.JSAOF,JS%DIR)!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
	MOVX 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
	MOVX 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
;1012	T .,,SYSTK.		;1012 dot is handled elsewhere
	T all,,.SYSAL
	TB class,,CLS
	TB controlling,,CJB
	T directory,,.SYCON	;1012
;1012	TB directory,,CON
ONEON <ARPA,CHA,DECN>,<		;713
	T foreign-host,,F4NH>	;1012 visible entry
	TB header,,HED
	TB limit,,LIM
	T line,,.SYSTT
LPTD,<	T lpt,,.$LPT>		;713
	T no,,.SYSNO
	T program
	TB state,,STA
	TB system,,NJB
	T terse,,.SYTR		;1012 no header, no operator jobs
	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
	T directory,,..SYCO	;1012
;1012	TB directory,,CON
ONEON <ARPA,CHA,DECN>,<		;713
	T foreign-host,,CF4NH>	;1012 visible entry
	TB header,,HED
	T job,,.SYJOB
	TB limit,,LIM
	T line,,..SYST
LPTD,<	T lpt,,..LPT>		;713
	T no,,..SYSN
	T output,,.SYOUT
	T program,,.PRCNF
	TB state,,STA
	TB system,,NJB
	T terse,,..SYTR		;1012 no header, no operator jobs
	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,[[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

LPTD,<				;713
.$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
       >			;713 end LPTD

.SYJOB:	DECX <a decimal job number>
	 CMERRX
	PUSH P,B		;SAVE THE NUMBER
	CONFIRM			;WAIT FOR CONFIRMATION
	MOVX 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
	MOVX 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 <a 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
	MOVX 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 <an octal line number or>
	KEYWD $SYTTY
	 0
	 JRST .SYST1
	SETO B,			;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
	MOVX 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)
	ADJSP B,1
	EXCH B,SFRAME
	RET

..SYTR:	CONFIRM			;1012 terse: no header, no operator jobs
.SYTR:	TXO Q1,SY%NHD!SY%NOP!SY%JOB ;1012
	TXZ Q1,SY%HED		;1012
	RET			;1012

..SYSA:	CONFIRM
.SYSAL:	TXO Q1,SYSALL
	SKIPN CUSRNO		;1012 not logged in?
	 TXZ Q1,SY%CON		;1012 yes, can't see connected directory
	RET

..SYCO:	CONFIRM			;1012
.SYCON:	SKIPE CUSRNO		;1012 logged in?
	 TXO Q1,SY%CON		;1012 yes, can see connected directory
	RET			;1012

..SYSN:	CALL .SYSNO
	CALLRET CONF

.SYSNO:	MOVEI B,[FLDDB. .CMKEY,,$SYSNO,,,[ ;1012 move dot to own FLDDB.
		FLDDB. .CMTOK,CM%SDH,TXTPTR <.>,<"." to supress own job>]]
	CALL FLDSKP
	 CMERRX
	GTFLDT D		;1012 get field type
	CAIE D,.CMTOK		;1012 dot?
	 JRST .SYSN1		;1012 no, go dispatch on command
	TXZ Q1,SY%IME		;1012 yes, handle it
	RET			;1012

.SYSN1:	CALL GETKEY
	JRST (P3)
;1012 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
;1012	TB .,,IME		;1012 dot is handled elsewhere
	TB class,,CLS
	TB controlling,,CJB
	TB directory,,CON
ONEON <ARPA,CHA,DECN>,<		;713
	T foreign-host,,F4NHN>	;1012 visible entry
	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

ONEON <ARPA,CHA,DECN>,<		;713
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
       >			;713 end ONEON <ARPA,CHA,DECN>
;INFORMATION (ABOUT) MONITOR-STATISTICS

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

MONSTA::STKVAR <CURCLS,<CLBLK,CLBLN>>
	MOVX A,SIXBIT/SYSTAT/
	CALL READT		;READ SYSTEM STATISTICS TABLE INTO AC'S 4-13
				;1013 format changes
	ETYPE < Uptime %K
 Idle %4T  Waiting %5T  Scheduler overhead %6T  Pager traps %7T
 Swap reads %10Q Writes %11Q  
 File reads %12Q Writes %13Q%%_>
	MOVX A,SIXBIT/NCPGS/
	SYSGT
	ETYPE < User memory %1Q pages%_>
	MOVX A,SIXBIT/SYSTAT/
	MOVX B,10
	CALL MORET		;READ MORE OF TABLE
	TIME			;TOTAL UPTIME OF SYSTEM
	CALL FLOAT
	EXCH A,Q2
	CALL FLOAT		;FLOAT NBAL TOTAL
	EXCH A,Q3
	CALL FLOAT		;FLOAT NRUN TOTAL
	EXCH A,Q2
	FDVR Q2,A		;NRUN AVERAGE
	FDVR Q3,A		;NBAL AVERAGE
	ETYPE < Terminal wakeups %4Q  Terminal interrupts %5Q
 NBAL avg %7Q  NRUN avg %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 scheduler 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
	MOVX A,CLBLN		;BLOCK LENGTH
	MOVEM A,.SACNT+CLBLK
	CALL CLSON		;SEE IF CLASS SCHEDULER IS ON
	 RET			;NO, SO DON'T TRY TO PRINT TABLE!
				;1013 use RET, since new routine at CLDON
				;1013 line up the columns
	ETYPE <%_%%_                        Load Averages>
	ETYPE <%_ Class  Share Use    1 min   5 min  15 min%_> 
	SETZB A,CURCLS		;START CURRENT CLASS AT 0
CLLUP:	MOVEM A,.SACLS+CLBLK	;SAY WHICH CLASS TO LOOK AT
	MOVX A,SYCLN		;SET UP BLOCK SIZE FOR SKED%
	MOVEM A,.SACNT+CLBLK
	MOVX 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?
	 SKIPE .SAUSE+CLBLK	;1013 SPR #:20-18109 
	  ABSKP			;1013 print zero classes that got windfall
	   JRST CLNXT		;NO, SKIP IT
	MOVE A,CURCLS		;GET CURRENT CLASS
	CALL NUM4		;PRINT 4-COLUMN CLASS NUMBER
	TYPE <  >		;1013 line up columns
	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
	MOVX 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:	CALL GLOVER		;1013 print out overall load avg
	ETYPE   <     overall usage  %2Q  %3Q  %4Q%%_> ;1013
	RET
;STATISTICS

;INFORMATION (ABOUT) SUBSYSTEM-STATUS - TABLE OF SUBSYSTEM USAGE
				;1014 format changes
SUBSTA::ETYPE <%_ Subsystem  Runtime Page Fault  Blocks  Work Space   SETSN%_>
 	ETYPE <             (sec)   /Runtime              Size      Count%_%%_>
	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
STAT5Y:	GTB .SCOUNT		;GET COUNT OF SETSN'S DONE
	POP P,B			;GET STORED PROGRAM NAME
	CAMN B,[OURNAM]		;1014 EXEC scount is meaningless & big
	 JRST  [TYPE <       ->	;1014
		JRST .+2]	;1014
	CALL STAT5N		;ELSE OUTPUT IT IN 12 COLUMNS
	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)!FLD(^D10,NO%RDX) ;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(10,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

;752 print out one word quanity as 12 column, decimal, filled
;752   largest positive number printed as "+INF"
WRDNUM::CAME A,[.INFIN]		;752 is it equal to largest positive number?
	 JRST WRDNM1		;752 no
	TYPE <        +INF>	;752 yes, print special form
	RET			;752

WRDNM1:	SAVEAC <B,C>		;752
	MOVX B,NO%LFL!NO%OOV!FLD(14,NO%COL)!FLD(^D10,NO%RDX)	;752 12 column,
				;752   decimal, filled 
	JRST SYNUM		;752 join common code
 
;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
	CAIN B,0
	 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
	ADJSP P,-1
	RET
;717 general house-cleaning of terminal code
;CODE TO SET TERMINAL TYPES AND PARAMETERS

.TERMI::NOISE <mode is>
	MOVEI B,[FLDDB. .CMKEY,, $TPAR, <a terminal parameter,>,,[
		FLDDB. .CMKEY,, $TTYP, <a terminal type,>,,[
		FLDDB. .CMNUM, CM%SDH,^D10,<a terminal type number>,,[
		FLDDB. .CMKEY,, $THLP]]]] ;717 divide possibilities by class 
	CALL FLDSKP		;717
	 CMERRX <terminal parameter or type required> ;717
	GTFLDT D		;717 get field type
	CAIN D,.CMNUM		;717 type number?
	 JRST .TTYNM		;717 yes
	CALL GETKEY		;717 load dispatch address
	CALL (P3)		;717 execute command
	MOVEI Q1,ETTYMD		;717 get EXEC mode block
	CALLRET RTTYMD		;717 set new modes

;717 terminal paramter table - all abbrevs in this table
$TPAR:	TABLE
	TA c			;1020 Concept-100 abbrev
	T flag
	T formfeed
	T fullduplex
	T halfduplex
MIT,<	TA hp>			;717 HP 2645
	T immediate
	T indicate
VTS,<	T ITS-style,,.ITSTY>	;717
	T length,,PLENTH
	T line-halfduplex,,.LINE
	T lowercase
VTS,<	T margin-wrap,,.MARG>	;127
ONEON <CEF,VTS>,<		;717
	T meta-key,,.METAK>	;717
	T no,,.TERNO
	TA p			;717 "P" means "PAGE"
.P:				;717
	T page
	T pause
	T raise
VTS,<	T reverse>		;717
VTS,<	T scroll>		;717
	T speed
	T tabs			
	T type,,.TTYPE
VTS,<	T verbose>		;717
VTS,<	T visible-bell,,.VISIB>	;717
	TA vt			;717 "VT" means "VT100"
	T width,,.LWIDTH
VTS,<	T wrap>			;717
	TEND

;717 terminal type table 
$TTYP:	TABLE
MIT,<	T AAA,,.AMBAS		;1020
	T ambassador		;717
	T ansi-vt100,,..TAN	;717
	T bitgraph		;717
	T C100,,.C100		;1020
.C:	T concept-100,,.C100	;717
	T datamedia,,.DM	;717
       >			;717 end MIT
	T execuport,,.TI
MIT,<	T fox			;717
	T glass,,.GLASS		;717
	T heath			;717
	T hp2640,,.H2640	;717
.HP:	T hp2645,,.H2645	;717
	T imlac,,.IMLAC		;717
       >			;717 end MIT
	T la120			
	T la30,,.LA30
	T la36,,.LA36
	T la38			
MIT,<	T nvt			;717
	T ptv			;717
	T supdup-nvt,,.SUPDP	;717
       >			;717
	T system-default,,.DFLT	
MIT,<	T teleray>		;717
	T terminet,,.DFLT
	T ti
MIT,<	T ti733,,.DFLT>		;717
	T tty-33,,.T33
	T tty-35,,.T35
	T tty-37,,.T37
	T vk100
	T vt05
.VT:	T vt100			;717 code checks for vt52 or ansi mode
	T vt125
	T vt50
	T vt52
	TEND

$THLP: TABLE			;717 HELP command
	T help,,TTYHLP
	TEND
;TERMINAL CHARACTERISTICS COMMANDS GROUP:
;    [NO] FORMFEED, [NO] LOWERCASE, [NO] RAISE, [NO] TABS
;    HALFDUPLEX, FULLDUPLEX, INDICATE

;THESE COMMANDS CHANGE THE FILE MODE WORD,
;   CONTROL CHARACTER OUTPUT CONTROL (CCOC) WORDS FOR THE PRIMARY OUTPUT AND
;   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)		;DISPATCH

$TERNO:	TABLE
	T flag
	T formfeed
	T immediate
	T indicate
VTS,<	T ITS-style,,.ITSTY>	;717
	T lowercase
VTS,<	T margin-wrap,,.MARG>	;127
ONEON <CEF,VTS>,<		;717
	T meta-key,,.METAK>	;717
	TA p,..P		;717 "P" means "PAGE"
..P:				;717
	T page
	T pause
	T raise
VTS,<	T reverse		;717
OLDF,<	IT scroll>		;717
       >			;717
	T tabs
VTS,<	T verbose		;717
	T visible-bell,,.VISIB	;717
OLDF,<	IT wrap>		;717
       >			;717
	TEND

;FLAG UPPERCASE OUTPUT
.FLAG:	NOISE <upper case output>
	LDF C,TT%UOC		;SET UPPERCASE OUTPUT CONTROL
	JRST CMOD

;RAISE: CONTROLS CONVERSION OF LOWER CASE TO UPPER ON INPUT.
.RAISE:	NOISE <terminal input>
	LDF C,TT%LIC		;SET LOWERCASE INPUT CONTROL
	JRST CMOD

;IMMEDIATE ECHO MODE
.IMMED:	NOISE <echo mode>	
	LDF C,TT%ECM
	JRST CMOD

VTS,<				;717
;717 scroll/wrap
.WRAP:  TLC Z,F1		;717 
.SCROL:	NOISE <mode>		;717
	MOVX C,TM%SCR		;717
	JRST MMOD		;717

;717 visible-bell
.VISIB:	MOVX C,TM%VBL		;717
	JRST MMOD		;717
       >			;717 end VTS

;MECHANICAL SETTINGS
.FORMF:	NOISE <exists on terminal>
	LDF C,TT%MFF		;SET MECH FORMFEED BIT
	CALLRET CMOD		;CHANGE MODE WORD AND RETURN

;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

.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>
	MOVEI B,[FLDDB. .CMKEY,,$PAUSE,,command,]
	CALL FLDSKP
	 CMERRX <a pause parameter required>
	CALL GETKEY
	JRST (P3)
	
$PAUSE:	TABLE
	T character,,..PPCH
	T command,ONEWRD,..COMM
	T end-of-page,ONEWRD,..END
	TEND

;SPECIFY PAGE PAUSE AND UNPAUSE CHARACTER
..PPCH:	TLNN Z,F1		;717 SPR #:20-19024 
	 JRST ..PPC1		;717 if it's "NO", then just set the default
	CONFIRM			;717  characters up
	MOVE C,[.CHCNS,,.CHCNQ]	;717
	JRST ..PPC2		;717

..PPC1:	MOVEI B,[FLDDB. .CMKEY,,$PCHAR,,,[ ;717 add local label
		FLDDB. .CMQST,CM%SDH,,<any printing character in 
doublequotes>,,[
		FLDDB. .CMNUM,CM%SDH,10,<an octal ASCII code for character>]]]
	CALL PPGETC		;GET A CHARACTER
	MOVE Q1,A
	NOISE <and continue on>
	MOVEI B,[FLDDB. .CMKEY,,$PCHAR,,,[
		FLDDB. .CMQST,CM%SDH,,<any printing character in 
doublequotes>,,[
		FLDDB. .CMNUM,CM%SDH,10,<an octal ASCII code for character>,,[
		FLDDB. .CMCFM]]]]
	CALL PPGETC		;GET SECOND CHAR
	CAMN A,[-1]		;716 change default value, to allow null
;716	CAIN A,0		;DEFAULTED?
	IFNSK. <MOVE A,Q1	;YES, USE PREVIOUS
	   >,<CONFIRM
	   >			;ELSE CONFIRM
	MOVE C,A
	HRL C,Q1
..PPC2:	MOVX A,.CTTRM		;717 add local label
	MOVX B,.MOPCS		;SET PAUSE CHARACTER
	MTOPR
	 ERCAL CJERRE
	RET

$PCHAR:	TABLE
	T control,,PCHCON
	T space,,PCHSPA
	TEND

PPGETC::CALL FLDSKP		;716 make into global label
	 ERROR <Invalid, %?>
	GTFLDT C		;GET FUNCTION USED
	CAIE C,.CMQST		;ARBITRARY CHAR?
	 IFSKP. <
	  LDB A,[FIRCHR ATMBUF] ;GET CHAR FROM ATOM BFR
	  RET>
	CAIE C,.CMCFM		;CR?
	 IFSKP. <
;;716	  SETZ A,		;YES, RETURN 0
	  SETO A,		;;716 yes, return -1
	  RET>
	CAIE C,.CMNUM		;NUMBER
	 IFSKP. <
	  MOVE A,B		;YES, RETURN IT
	  RET>
	HRRZ B,(B)		;MUST BE KEYWORD, GET DISP ADR
	HRRZ B,(B)
	CALLRET (B)

PCHCON::			;716 make into global label
	MOVEI B,[FLDDB. .CMQST,CM%SDH,,<any printing character in 
doublequotes>]
	CALL FLDSKP
	 ERROR <Invalid, not a quoted string>
	LDB A,[FIRCHR ATMBUF]	;GET FIRST CHAR
;716	CAIL A,"a"		;RAISE LOWERCASE
;716	 CAILE A,"z"
;716	  IFSKP. <SUBI A,40>
;716	CAILE A,100		;CHECK RANGE
;716	 CAILE A,137
	CAIL A,40		;716 ASCII code lower than SPACE?
	 CAIL A,177		;716    or higher than RUBOUT?
	  ERROR <Invalid, not a control character>
	ANDI A,37		;716 take the lower five bits to make CTRL char
;716	SUBI A,100
	RET

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

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

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

;CHANGE TELETYPE MODE WORD SUBR - CHANGES MODE IN EFFECT
;
;   ACCEPTS:	Z/	F1 ON TO CLEAR BIT(S), OFF TO SET THEM
;		C/	MASK INDICATING WHICH BITS TO CHANGE
;   PRESERVES D, DESTROYS A, B
CMOD:	CONFIRM			;NO TTY COMMANDS CONFIRMED BEFORE HERE
CMOD1:	MOVX 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
VTS,<				;717
;717 [no] verbose
.VERBO:	NOISE <end-of-page indication> ;717
	MOVX C,TM%MVR		;717
	JRST MMOD		;717

;717 [no] ITS-style
.ITSTY:	NOISE <end-of-page processing> ;717
	MOVX C,TM%MOR		;717
	JRST MMOD		;717

;717 [no] reverse 
.REVER:	NOISE <delete and underscore characters> ;717
	MOVX C,TM%RSU		;717
;	JRST MMOD		;717

;717 change VTS TTY modes via STMOD
;717
;717 accepts:	Z/	F1 set if its "no"
;717		C/	bits to set/reset
MMOD:	CONFIRM			;717 don't confirm before here
MMOD1:	MOVX A,.CTTRM		;717
	RTMOD			;717 read settings
	 ERJMP [ERROR <This system is not running VTS>]	;717 
	ANDCAM C,B		;717 turn off bits
	TLNN Z,F1		;717 if it "no"?
	 IORM C,B		;717 no, so turn bits back on
	MOVEM B,ITTYMD+TTDMOD	;717
	STMOD			;717 write settings
	RET			;717

;127 [no] margin-wrap
.MARG:	NOISE <is automatic on terminal>	;127
	MOVX C,TC%WRP		;127
	CALLRET MCHAR		;127

;717 [no] meta-key
.METAK:	NOISE <present on terminal> ;717
CEF,<	TLNE Z,F1		;717 is it "no"?
	 TDZA B,B		;717 yes
	  SETO B,		;717 no 
	MOVEM B,CEMETA		;717 set command-editor flag
       >			;717
	MOVX C,TC%MET		;717 
;	CALLRET MCHAR		;717 set VTS bit

;717 change VTS terminal characteristics via STCHR (most should not be changed)
;717
;717 accepts:	Z/	F1 set if its "NO"
;717		C/	bits to set/reset
MCHAR:	CONFIRM			;717 don't confirm before here
	MOVX A,.CTTRM		;717
	RTCHR			;717 read settings
	 ERJMP [ERROR <This system is not running VTS>]	;717
	ANDCAM C,B		;717 turn off bits
	TLNN Z,F1		;717 is it "no"?
	 IORM C,B		;717 no, so turn bits back on
	STCHR			;717 write settings
	RET			;717
       >			;717 end VTS

NOVTS,<				;717
CEF,<				;716
;716 [no] meta-key
.METAK:	NOISE <present on terminal> ;716
	TLNE Z,F1		;716 is it "no"?
	 TDZA B,B		;716 yes
	  SETO B,		;716 no 
	MOVEM B,CEMETA		;716 set command-editor flag
	RET			;716
       >>			;716 end NOVTS,CEF
;LENGTH OF TERMINAL PAGE
PLENTH:	NOISE <of page is>
	DECX <Length of page in decimal>
	 CMERRX
	CONFIRM
PLENT1:	MOVE C,B
	MOVX A,.CTTRM
	MOVX B,.MOSLL		;SPECIFY SETTING LENGTH
	MTOPR			;DO IT
	 ERCAL CJERRE		;FAILED, SAY WHY AND DIE
	RET

;WIDTH OF TERMINAL LINE
.LWIDTH: NOISE <of line is>
	DECX <Terminal line width in decimal>
	 CMERRX
	CONFIRM
	MOVE C,B
	MOVX A,.CTTRM
	MOVX B,.MOSLW		;SPECIFY SETTING LINE WIDTH
	MTOPR			;DO IT
	 ERCAL CJERRE		;GO SAY WHY IT FAILED
	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
;
;   ACCEPTS:	Z/	F1 & F2 OFF: SEND
;			F1 ON & F2 OFF: SIMULATE
;			F2 ON: INDICATE
;		D/	BYTE POINTER INDICATING BYTE TO CHANGE
;		E/	INDEX FOR D
;   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
	  MOVX A,2		;2 = SEND CODE
	TLNE Z,F2
	 MOVX A,1		;1 = INDICATE BY ^X
	DPB A,D
	RET
;DUPLEX SETTING
LB.DUM==<TT%DUM&-TT%DUM>	;LOW ORDER BIT POSITION OF TT%DUM

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

.HALFD:	LDF C,<.TTHDX>*<LB.DUM>	;SET HALF DUPLEX
	JRST SETDU

.LINE:	LDF C,<.TTLDX>*<LB.DUM>	;SET LINE HALF DUPLEX
SETDU:	NOISE <mode for terminal>
	CONFIRM
SETDU1:	MOVX A,.CTTRM
	RFMOD
	TXZ B,TT%DUM		;CLEAR ALL DUPLEX BITS
	IOR B,C			;SET THE DESIRED ONES
	STPAR			;SET NEW DUPLICITY
	RET

;SET TERMINAL SPEED
.SPEED:	MOVX A,.CTTRM		;TO CURRENT TERMINAL
SPEEDA::STKVAR <STERM,<SPNBUF,3>>
	MOVEM A,STERM		;REMEMBER TERMINAL NUMBER
	NOISE <of input>
	KEYWD $BAUDR		;BAUD RATE TABLE
	 0			;NO DEFAULT
	 JRST CERR		;ERROR IF NONE GIVEN
	NOISE <and output>
	HRLZ Q1,P3		;SAVE VALUE
	HRRZ B,P3		;USE INPUT FOR OUTPUT DEFAULT
	HRROI A,SPNBUF
	MOVEM A,CMDEF
	MOVX C,FLD(^D10,NO%RDX)	;SPEEDS ARE DECIMAL
	NOUT			;SET UP DEFAULT STRING
	 CALL JERR		;SHOULD NEVER FAIL
	KEYWD $BAUDR		;READ OUTPUT SPEED
	 0			;DEFAULT ALREADY SET UP
	 CMERRX	<supported baud rate required> ;717 better message
	HRR Q1,P3		;FILL IN SELECTED OUTPUT SPEED
	CONFIRM
	MOVE A,STERM		;TERMINAL NUMBER
	MOVX B,.MOSPD		;FCN CODE
	MOVE C,Q1		;PICK UP SELECTED SPEEDS
	MTOPR			;C := INPUT,,OUTPUT
	 ERCAL CJERRE		;FAILED, TELL USER WHY
	RET			;RETURN

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

;HERE TO HANDLE NUMERICAL TYPE
.TTYPE: MOVEI B,[FLDDB. .CMNUM,CM%SDH,^D10,<a terminal type number>,,[
		FLDDB. .CMKEY,,$TTYP]]
	CALL FLDSKP
	 CMERRX	<bad terminal type number>
	GTFLDT D		;GET DATUM TYPE
	CAIN D,.CMNUM		;NUMBER?
	 JRST .TTYNM		;YES
	CALL GETKEY		;OTHERWISE, KEYWORD
	JRST (P3)		;SO DISPATCH ON IT

.TTYNM:	PUSH P,B		;SAVE TYPE NUMBER
	JRST .TTY3		;GO SET IT

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

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

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

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

MIT,<				;717
.IMLAC:	PUSH P, [.TTIMX]	;717
	JRST .TTY3		;717

.DM:	PUSH P, [.TTDM]		;717
	JRST .TTY3		;717

.H2645:	PUSH P, [.TTHP]		;717
	JRST .TTY3		;717

.NVT:	PUSH P, [.TTNVT]	;717
	JRST .TTY3		;717
       >			;717 end MIT

.DFLT:	PUSH P,[.TTDEF]
	JRST .TTY3

;717 can't set your terminal to IDEAL

.VT05:	PUSH P,[.TTV05]
	JRST .TTY3

.VT50:	PUSH P,[.TTV50]
	JRST .TTY3

.LA30: PUSH P, [.TTL30]
	JRST .TTY3

;717 we don't support GT40

.LA36:	PUSH P,[.TTL36]
	JRST .TTY3

.VT52:	PUSH P,[.TTV52]
	JRST .TTY3

MIT,<				;717
.GLASS:	PUSH P, [.TTGLS]	;717
	JRST .TTY3		;717

.FOX:	PUSH P, [.TTFOX]	;717
	JRST .TTY3		;717

;717 VT100 either in VT52 or ANSI mode
.VT100:	NOISE <in>		;717
	MOVEI B, [FLDDB. .CMKEY,,$modes,<a mode,>,vt52]	;717
	CALL FLDSKP		;717
	 CMERRX <bad terminal mode> ;717
	CALL GETKEY		;717
	JRST (P3)		;717

$MODES: TABLE			;717
	T ansi,,.T$AN		;717
	T vt52,,.T$VT		;717
	TEND			;717

.T$AN:	NOISE <mode>		;717
..TAN:	PUSH P,[.TT100]		;717 VT100 in ANSI mode
	JRST .TTY3		;717

.T$VT:	NOISE <mode>		;717
	PUSH P,[.TTV10]		;717 VT100 in VT52 mode 
	JRST .TTY3		;717

.TELER:	PUSH P, [.TTT10]	;717
	JRST .TTY3		;717

.HEATH:	PUSH P, [.TTH19]	;717
	JRST .TTY3		;717

.C100:	PUSH P, [.TTC10]	;717
	JRST .TTY3		;717
       >			;717 end MIT

NOMIT,<				;717
.VT100:	PUSH P,[.TT100]
	JRST .TTY3
      >				;717

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

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

MIT,<				;717
.PTV:	PUSH P, [.TTPTV]	;717
	JRST .TTY3		;717

.SUPDP:	PUSH P, [.TTSUP]	;717
	JRST .TTY3		;717

.H2640:	PUSH P, [.TTHP0]	;717
	JRST .TTY3		;717

.AMBAS: PUSH P, [.TTAAA]	;717
	JRST .TTY3		;717

.BITGR:	PUSH P, [.TTBBN]	;717
	JRST .TTY3		;717
       >			;717 end MIT

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

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

.TTY3:	CONFIRM
	MOVX A,.CTTRM		;117
MIT,<	GTTYP			;117
	CAIE B,.TTSUP		;117 Are we on a supdup terminal?
	IFSKP.			;117 Then don't allow (but don't err out, so
	  POP P,B		;117 people's login files don't abort)
	  CAIE B,.TTSUP		;117 Don't complain if not really changing
	   TYPE <%You can't change the basic type of a SUPDUP terminal> ;117
	  RET			;117
	ENDIF.			;117
>				;117
	POP P,B
;117	MOVX A,.CTTRM
	STTYP
	 ERJMP [ERROR <Invalid terminal type>]
	RET
;HELP FOR TERMINAL COMMANDS.
TTYHLP:	CONFIRM
	HRROI B,TTYTXT		;GET TEXT PTR
	MOVE A,COJFN
	SETZ C,
	SOUT			;PRINT IT
	RET

	.DIRECT FLBLST

;717 help text updated, must be hand edited if VTS switch turned off
;127 Added MARGIN-WRAP documentation

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

 1. The specific name of your terminal type or the terminal type number e.g.
    VT100, TTY-33, 12, 14, etc. Declaring your terminal type establishes the
    proper amount of fill and the applicable modes.

 2. A specific mode (optionally preceded by "NO" to turn it off).
    FLAG       Print a ' before every uppercase character.
    FORMFEED   Terminal has form-feed capability.
    IMMEDIATE  Echo each character as you type it.
    INDICATE   Print ^L instead of a form-feed.
    ITS-STYLE  Use ITS-style end-of-page processing.
    LOWERCASE  Terminal handles lowercase output properly.
    META-KEY   Terminal handles meta-key.
    PAGE       Put your terminal in 'page' mode (set both 'pause' modes).
    PAUSE      Set the various pause modes.
    RAISE      Raise lowercase input to uppercase.
    REVERSE    Reverse interpretation of _ and RUBOUT keys.
    SCROLL     Output scrolls up at bottom of screen.
    TABS       Terminal has tab stops every 8 columns.
    VERBOSE    Verbose indication of end-of-page pause.
    VISIBLE    Terminal bells print instead of ringing.
    WRAP       Output wraps at bottom of screen.

 3. A value of a certain terminal parameter.
    LENGTH      Set the page length of your terminal.
    MARGIN-WRAP Indicate that your terminal wraps lines at the right margin.
    SPEED       Set the baud rate for terminal input and output.
    TYPE        Set the terminal type number.
    WIDTH       Set the width of your terminal line.

 4. Terminal duplex setting.
    FULLDUPLEX, HALFDUPLEX, LINE-HALFDUPLEX
/
;ROUTINE TO PRINT SYSTEM-MESSAGES THAT HAVEN'T BEEN PRINTED
;1015 handle various startup functions

PNTMES::SKIPE BATCHF		;IN BATCH?
	 RET			;YES - DO NOT DO THIS
MIT,<
NOEE,<	SKIPN FIRLOG		;736 first login of this account?
	 JRST PNTME1		;736 no, skip around
	SETZM FIRLOG		;736 don't do this again
	HRROI B,[GETSAVE <SYS:INQUIR.>] ;736 yes, run INQUIR
	CALL TRYGTJ		;736
	 JRST PNTME1		;736 error, forget the whole thing
	MOVX B,3		;736 entry vector offset to new user entry
	CALL REPH1		;736 ephemeral, start
PNTME1:				;736 add local label
       >>			;736 end MIT, NOEE
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
MIT,<	HRROI B,[GETSAVE <SYS:SYSMSG.>] ;1015 print system messages w/ SYSMSG
	CALL TRYGTJ		;1015
	 RET			;1015
	MOVX B,3		;1015 offset 3
	CALLRET REPH1		;1015 ephemeral
       >			;1015 end MIT
NOMIT,< MOVE A,LOGDAT		;1015 THEY HAVEN'T, GET LOGIN DATE.
	CALL MESS		;TYPE APPLICABLE LOGIN MESSAGES
	RET

;CODE TO USE RDMAIL TO TYPE <SYSTEM>MAIL.TXT
MESS:	STKVAR <MALJFN,SJFNP,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,[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,[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
	 NOP			;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
       >			;1015 end NOMIT

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

LITS0:				;713 debugging aid: literals label
	END