
      HED SCHEDULER 
      ORG 70000B
B140  OCT 140 
M60B  OCT -60 
M41B  OCT -41 
M133B OCT -133
MCOM2 ABS -COM2 
M36K  ABS -30000-6000 
ASCIN ASC 1,N 
ASCFF ASC 1,FF
ASCBA ASC 1, @
ASC0B ASC 1,0 
DCOM6 DEF COM6
TTYCK ABS TTY00 
OUTM1 BSS 1         TEMPS USED BY OUTCH ROUTINE.
X     OCT -2
CTEMP BSS 1 
SMAIN OCT 0         CURRENT SWAPR DISC TRANSFER FLAG
FMAIN OCT 0         OLD TOP OF Q FLAGS POINTER
XCOM5 DEF COM5-2
INSQA DEF INSEQ 
TRNFP DEF TRNOF 
      SKP 
*  THE CLOCK DRIVER IS THE CENTRAL POINT THROUGH WHICH CONTROL IS 
*  PASSED TO THE SCHEDULER. ENTRY COMES TO THE DRIVER WHENEVER THE
*  CLOCK (REAL TIME SCALAR) INTERRUPTS.  THIS EVENT OCCURS EVERY
*  100 MS.  BESIDES GIVING CONTROL TO THE SCHEDULER, THE CLOCK
*  DRIVER ALSO HAS THE TASK OF UPDATING THE TIME OF DAY CLOCK.
* THIS CLOCK IS A TWO WORD ENTRY WHOSE VALUE IS AS FOLLOWS: 
*     DATIM=24*DAY+HOUR 
*     DATIM+1=600*MIN+10*SEC-36000
      SPC 3 
CLKIN NOP           ENTRY POINT.
      STA CTEMP     SAVE A. 
      ISZ DATIM+1   BUMP 100MS COUNTER
      JMP CLC0      NO PROBLEM IF NO SKIP 
      LDA M36K      RESET 100MS COUNTER.
      STA DATIM+1 
      ISZ DATIM     BUMP HR COUNTER.
      NOP           JUST IN CASE. 
CLC0  ISZ X         ENTER SCHEDULER THIS TIME?
      JMP CLC1+1    NO
      LDA .-2       YES, RESET
      STA X           RESET SKIP WORD 
      LDA CTEMP     RESET A 
      SPC 1 
* THE NEXT INSTRUCTION IS NORMALLY A JMP. WHEN THE
* SCHEDULER IS RUNNING, HOWEVER, IT PREVENTS ITSELF 
* FROM BEING REENTERED BY INSERTING A NOP.
      SPC 1 
CLC1  NOP 
      LDA CTEMP     RESET A 
      CLF CLOCK     ALLOW ANOTHER CLOCK INTERRUPT.
      JMP CLKIN,I   RETURN. 
      SPC 1 
CLC2  JMP SCHED     USED TO INSERT IN CLC1. 
      SPC 3 
*  THE SCHEDULER SECTION OF TSB DETERMINES WHICH
*  PROGRAM IS TO RUN NEXT. FIRST IT CLEARS CLC1,
*  ALLOWING THE CLOCK TO CONTINUE INTERRUPTING. 
      SPC 1 
SCHED STA AREG      SAVE A-REGISTER.
      CLA           INSERT NOP IN CLC1 TO PREVENT 
      STA CLC1       REENTERING SCHED.
      LDA CLKIN     SAVE THE PROGRAM COUNTER
      STA PREG       ALSO.
CLKED CLF CLOCK     NOW LET THE CLOCK IN AGAIN. 
      STB BREG      SAVE B REGISTER,
      ERA,ALS       E-REGISTER, 
      SOC           AND OVERFLOW REGISTER.
      INA 
      STA EREG
      LDB MLINK+1   GET POINTER 
      ADB .-?LINK 
      STB FMAIN       TO FLAG WORD
      LDA TIMEF     GET TIMER FLAG. 
      SZA           IF 0, THIS IS NOT A TIMED PROG. 
      ISZ TIMER,I   IF NOT 0, BUMP TIMER. 
      JMP SCH1      IF NOT OUT OF TIME, SKIP
*                                     ROTATING THE RUN QUEUE
* 
*     AT THIS POINT WE HAVE DISCOVERED THAT THE PROGRAM THAT HAS
*     BEEN RUNNING HAS EXHAUSTED ITS TIME LIMIT. THE NEXT STEP IS 
*     TO ADJUST THE QUEUE SO THAT THIS PROGRAM IS MOVED TO THE
*     BOTTOM.  THIS IS ACCOMPLISHED BY DELETING THE PROGRAM 
*     FROM THE QUEUE AND THEN REINSERTING IT WITH ITS NEW PRIORITY. 
* 
      LDB MLINK+1   GET THE ADDRESS OF PRIORITY 
      INB            FOR THE CURRENT PROGRAM. 
      LDA .+4       SET IT TO LOW PRIORITY. 
      STA 1,I 
      ADB .+?LINK-?PLEV 
      LDA 1,I       GET THE LINK FROM THE CURRENT 
      STA MLINK+1    PROGRAM AND STORE IT IN MLINK+1. 
SCH3  JSB INSQA,I   INSERT USER IN QUEUE
      JSB SWAPR     START EARLY SWAPPING
      JMP SCH1      CHECK FOR COMMUNICATION 
*                                     FROM I/O PROCESSOR
      SPC 1 
* 
**    TEST FOR ANY TTY35 BUSINESS 
* 
SCHS1 EQU *        JUST FINISHED CHECKING TTYS
      LDB DTTY0     REINITIALIZE
      STB TTYCK       POINTER 
SCH5  CCA           TEST FOR DRIVER BUSY
      CPA T35F1 
      JMP SCH15     DRIVER IS BUSY. 
      CPA T35F3 
      JMP SCH16     COMMAND ENTERED BUT NOT STARTED 
* 
* WHEN T35F1=0, THE CONSOLE IS QUIET SO WE CAN DO LOGGING.
* 
      ADA MSQCT     TEST FOR ANY ENTRIES ON MESSAGE Q 
      CPA .-1 
      JMP SCH52     MESSAGE QUEUE EMPTY 
* 
*     OUTPUT AN ELEMENT OF THE MESSAGE QUEUE
* 
      STA MSQCT     DECREMENT MESSAGE COUNTER 
      LDB MSQP1     ADVANCE MESSAGE POINTER 
      ADB .+MESLN 
      CPB MSQND     IF AT END OF BUFFER 
      LDB MSQBG       THEN WRAP AROUND
      STB MSQP1     SET UP NEW ADDRESS
      LDA B,I       GET ADDRESS AND 
      INB             LENGTH OF MESSAGE 
      JSB TTY35,I       AND OUTPUT IT 
      JMP SCH15 
* 
SCH52 EQU * 
      ADA LOGCT     TEST FOR ANY ENTRIES IN LOGTABLE. 
      CPA .-1 
      JMP SCH16     LOG TABLE IS EMPTY. 
* 
*     SET UP LOG BUFFER 
* 
      STA LOGCT     DECREMENT LOG COUNTER.
      LDA LOGP1     BUMP LOG POINTER
      INA 
      CPA LOGND     IF AT END,
      LDA LOGBG       WRAP AROUND.
      STA LOGP1 
      LDA LOGP1,I   TEST FOR LOGON
      LDB ASCIN       OR LOGOUT.
      SSA 
      LDB ASCFF 
      STB LOGBF+3 
      LSR 10        SHIFT LOG CHAR TO LEAST 5 BITS. 
      AND .+37B     MASK OFF OTHER STUFF. 
      ADA ASCBA     CONVERT TO ASCII. 
      STA LOGBF+4 
      LDA LOGP1,I   GET ACCOUNT NUMBER AGAIN. 
      AND B1777     KEEP ONLY # PART. 
      CLB 
      DIV .+10      GET 1ST 2 DIGITS IN A, LAST IN B
      BLF,BLF       SET UP LAST DIGIT AS
      ADB ASC0B      ASCII LEFT HALF. 
      STB LOGBF+6 
      JSB #LTEN     CONVERT FIRST 2 TO ASCII ALSO 
      STA LOGBF+5 
      ISZ LOGP1 
      LDA LOGP1,I   NOW GET THE TIME. 
      AND .+37B     GET TERMINAL NUMBER 
      JSB #LTEN     CONVERT AND STORE IN BUFFER.
      STA LOGBF+10
      LDA LOGP1,I 
      CLB 
      ASR 5 
      DIV D60 
      STB LOGP1,I   SAVE SECOND HALF
      JSB #LTEN     CONVERT FIRST HALF TO ASCII.
      STA LOGBF+7 
      LDA LOGP1,I 
      JSB #LTEN     CONVERT 2ND HALF TO ASCII.
      STA LOGBF+8 
      LDA .+22
      LDB LOGR2     TO PRINT THE
SCH21 JSB TTY35,I    STUFF. 
      JMP SCH15 
      SPC 1 
      SUP 
LOGR2 DEF *+1,I     BUFFER ADDRESS (I=>PUNCH) 
LOGBF ASC 11,**LOGOFF A123 0930 #01 
      UNS 
      SPC 1 
* 
**    TTY35 I/O COMPLETE
* 
SCH16 CPA T35F2     TEST DRIVER COMMUNICATE FLAG. 
      RSS 
      JMP SCH15 
      LDA T35ST     GET CONSOLE STATUS. 
      LDB T35PR 
      CPA %OUTW     IF OUTPUT WAIT, 
      JMP SCH23     GO SET HIM UP.
      SZA           IF NOT IDLE WEVE ALREADY
      JMP SCH15       QUEUED HIM. 
* 
*     TTY35 INPUT COMMAND 
* 
      LDA T35B2     POINTER TO FIRST CHARACTER
      STA SBHED      OF CONSOLE BUFFER. 
      LDA T35ND     POINTER TO END OF 
      STA SCHL       CONSOLE BUFFER.
      LDA .+40B     INITIALIZE COMMAND
      STA SCHP       HOLDER.
      JSB SCOM      GET COMMAND.
      JMP SCH17     BLANK LINE
      JMP SCH18     ERROR 
      JMP SCH18     ERROR 
* 
* SET UP QUEUE ENTRY FOR CONSOLE. 
* 
      LDA SBHED     SET POINTER FOR 
      STA T35CP      T35CR. 
      LDA .+40B     SET UP THE LAST 
      STA T35LC       CHARACTER AS A BLANK
      LDA #LIB#     SET RESTART ADDRESS.
      STA T35RS 
      ADB SCH19     SET PROGRAM STATUS
SCH23 STB T35ST      TYPE.
      LDA .+2       SET PRIORITY. 
      STA T35PR 
      LDB T35LN     GO INSERT IN QUEUE
      JMP SCH3
SCH19 ABS -COM2+%SYNT-.+1 
      SPC 1 
SCH17 LDA ONEI      OUTPUT LINE FEED
      RSS 
SCH18 LDA .+4       OUTPUT ERROR MESSAGE
      CLB 
      STB T35F2 
      LDB DEH 
      JMP SCH21 
      SKP 
* 
* 
SCH15 JSB SWAPR     CHECK FOR ANYTHING TO DO. IF NOT
*                                   SWAPR WILL GO TO SCH1 AGAIN.
*                                   IT WILL RETURN HERE IF THERE IS 
*                                   AN EXECUTABLE PROGRAM IN CORE.
      SPC 3 
*     THE PROGRAM TO RUN IS AT THE HEAD OF THE QUEUE, AND SWAPR HAS 
*     GUARANTEED THAT IT IS IN CORE. THE FOLLOWING SECTION OF CODE
*     SETS IT UP TO RUN, AND ALSO SETS UP THE CLOCK DRIVER SO THAT
*     FUTURE INTERRUPTS WILL GO BACK INTO THE SCHEDULER.
      SPC 1 
      CLF 0         INHIBIT INTERRUPT.
      LDA CLC2      RESTORE A <JMP SCHED> IN THE
      STA CLC1        CLOCK INTERRUPT ROUTINE.
      LDA MLINK+1          GET THE STATUS 
      ADA .+?STAT-?LINK      OF THIS PROGRAM
      LDB A,I                  AND CHECK TO SEE 
      ADB .+.-%SYNT+COM2-COM3-1  IF IT IS TYPE III
      ADA .+?PLEV-?STAT 
      SSB 
      JMP SCH2           NOT TYPE III 
      CLB                IT IS, SO SET THIS 
      STB A,I              USER'S PRIORITY TO ZERO
SCH2  ADA .+?RSTR-?PLEV  GET RESTART ADDRESS
      LDB 0,I         IF NOT 0, PUT IT IN PREG
      SZB            TO START UP PROPERLY.
      STB PREG
      CLB           PUT 0 INTO TABLE IN ANY CASE
      STB 0,I 
      STB TIMEF     SET TO SAY NO TIMING. 
      INA           GET PROGRAM STATUS. 
      LDB 0,I 
      ADA .+?CLOC-?STAT   SET TIMER POINTER.
      STA TIMER 
      CPB %SYNT+1   IF STATUS IS RUN, SET 
      ISZ TIMEF      TIMEFLAG FOR CLOCKING. 
      ADA .-?CLOC   SAVE FLAGS
      LDB A           POINTER 
      LDA B,I       RESTORE 
      AND MBUST       DISC BUSY 
      STA MBUSY         FLAG
      LDA EREG      RESTORE E 
      CLO            AND OVERFLOW 
      SLA,ELA         REGISTERS.
      STO 
      LDA AREG      RESTORE A AND 
      LDB BREG        B REG.
      STF 0         ENABLE INTERRUPT AND
      JMP PREG,I     TRANSFER TO PROGRAM. 
      SKP 
* 
**    START OF SYSTEM 
* 
TSB   LDA .+3       START CLOCK COUNTING IN 
      OTA CLOCK     100 MS UNITS. 
      STC CLOCK,C   START CLOCK 
      CLC CH2 
      CLC ?SC 
      LDA NPORT 
      CMA           A _ NUMBER OF LEGAL PORTS - 1 
      ALF,ALF 
      IOR INI       PLUG IN INITIALIZATION CODE.
      JSB S14SC,I     WE'RE STARTING
      SFS CH2       WAIT FOR 2114 
      JMP *-1         TO FINISH 
      STC CH1,C 
      LDA .+6       START SYSTEM
      LDB READY     TELETYPE BY OUTPUTTING
      JSB TTY35,I     READY MESSAGE.
* 
*     THIS SECTION IS THE BEGINNING OF THE MAIN PART OF THE SCHEDU- 
*     LER. CONTROL ALWAYS COMES HERE TO EXAMINE THE TTQ UNTIL IT'S
*     EXHAUSTED, OR WHEN THERE IS NOTHING TO DO. SWAPR ALWAYS COMES 
*     TO THIS POINT WHEN THE QUEUE IS EMPTY OR THE FIRST PROGRAM ON 
*     THE QUEUE IS ABSENT.
*  THIS SECTION ACTUALLY PROCESSES A TTQ ENTRY. THERE ARE SEVERAL 
*  KINDS OF ENTRIES WHICH MAY BE CLASSIFIED AS FOLLOWS: 
* 
*     1) ABORT - THIS IS INDICATED BY THE TELETYPE STATUS BEING 
*       -1. THE ACTION TAKEN IS TO STOP THE PROGRAM (IF IT IS 
*        IN THE QUEUE), AND TO INITIATE THE ABORT MESSAGE.
* 
*     2) OUTPUT TERMINATE - THIS IS INDICATED BY THE STATUS BEING 
*        %OUTW.  THE TTQ ENTRY REALLY MEANS THAT THE OUTPUT BUFFER
*        IS ALMOST EMPTY. THE PROGRAM IS PLACED BACK ON THE QUEUE 
*        ACCORDING TO ITS PRIORITY. 
* 
*     3) INPUT - THIS IS INDICATED BY STATUS BEING %INPT. IT INDI-
*        CATES THAT A USER PROGRAM OR SYSTEM PROGRAM THAT HAS 
*        REQUESTED INPUT HAS GOTTEN IT. THE PROGRAM IS PLACED IN
*        THE QUEUE. 
* 
*     4) COMMAND - WHEN STATUS IS %IDLE, EITHER A COMMAND OR
*        A SYNTAX STATEMENT HAS BEEN ENTERED. THESE CAN BE DISTIN-
*        GUISHED BY THE FIRST NON BLANK INPUT CHARACTER, WHICH IS 
*        A DIGIT ONLY IF SYNTAX HAS BEEN ENTERED. 
* 
*     5) DISCONNECT - THIS IS INDICATED BY STATUS BEING %DISC.
*        THE ACTION TAKEN IS TO CALL THE BYE ROUTINE
* 
*     6) ENTER TIMEOUT - THIS IS INDICATED BY THE STATUS BEING
*        %ENTO. THE RESTART ADDRESS IS BUMPED AND THE PROGRAM IS
*        PLACED ON THE QUEUE. 
* 
SCH1  STF 0 
      LDB TTYCK 
      CPB DTT32    HAVE ALL TELETYPES BEEN CHECKED? 
      JMP SCHS1    YES
      LDA 1,I      LOAD STATUS FOR THIS USER
      ADB .+TTY01-TTY00  GENERATE ADDRESS FOR NEXT
      STB TTYCK    USER 
      AND COM14     COMMUNICATION FROM IOP? 
      SZA,RSS      SKIP IF SO 
      JMP SCH1     NO-- CHECK NEXT ONE
      ADB .+TTY00-TTY01  MOVE ADDRESS BACK TO THIS USER 
      CLF 0 
      XOR 1,I       CLEAR 
      STA 1,I         COM14 BIT 
      STB TTQ       SAVE TABLE ADDRESS
      ADB .+?ID     STORE ID
      STB SCHID       ADDRESS 
      ADB .+?STAT-?ID 
      LDA 1,I       A=STATUS
      ADA .-4       MAKE SURE 
      SSA,RSS         STATUS<4
      JMP SCH1      IGNORE OTHERWISE
      ADA *+2       BRANCH TO SECTION 
      JMP 0,I         TO HANDLE REQUEST 
      DEF *+8 
      JMP SCH4      ENTER TIMEOUT 
      JMP SCH8      DISCONNECT
      JMP SCH7      ABORT 
      JMP SCH6      COMMAND 
      JMP SCH5      ABORTING
      NOP           INPUT 
* 
*  CODE TO HANDLE INPUT OR OUTPUT.
* 
      ADB .+?PLEV-?STAT 
SCH51 LDA 1,I       GET ACTUAL STATUS 
      ADB .+?STAT-?PLEV 
      STA 1,I       SET ACTUAL STATUS 
      STF 0 
      ADB .+?PLEV-?STAT 
      CLA           SET PRIORITY TO 0 
      STA 1,I 
      ADB .+?LINK-?PLEV 
      JMP SCH3      GO INSERT USER IN QUEUE 
* 
*  CODE TO HANDLE ABORT 
* 
SCH7  STF 0 
      INB           B=>LINK 
      JSB DEQUE     REMOVE USER FROM QUEUE. 
      LDB TTQ 
      CLF 0 
      LDA OUTWT     CLEAR OUTPUT
      IOR CHNFG                                  [B]
      CMA             WAIT AND CHAIN
      AND B,I 
      STA B,I           FLAG BITS 
      INB 
      LDA B,I       GET TTY NUMBER
      IOR KAO 
      JSB S14SC,I   KILL OUTPUT 
      ADB .-1 
      LDA DFCHK 
      AND 1,I 
      SZA,RSS       NEED TO UPDATE CHANGE DATE? 
      JMP SCH75     NO
      LDA UNABT     YES 
      IOR B,I       DISALLOW
      STA B,I         ABORTS
      STF 0 
      ADB .+?PLEV 
      CLA 
      STA B,I       SET PRIORITY TO 0 
      ADB .+?STAT-?PLEV 
      LDA .+%SYNT-.+1+UCDAB-COM2
      STA B,I       SET STATUS TO LAST CHANGE DATE
      ADB .+?RSTR-?STAT 
      ADA XCOM5     FIND POSITION IN TABLE
      LDA A,I       GET RESTART ADDRESS 
      STA B,I       SAVE IT 
      ADB .+?LINK-?RSTR 
      JMP SCH3      GO INSERT IN QUEUE
SCH75 EQU * 
      ADB .+?STAT   SET STATUS
      STA 1,I 
      JSB TRNFP,I   CLEAR PBFLG & CBFLG BITS
*                                   AND TELL OTHER MACHINE. 
      CPB PRIST       USER HAVE LP? 
      JSB SCLPR     YES.
      LDB TTQ       NO. PRINT ABORT 
      LDA .-8         MESSAGE 
      JSB TYPE
      OCT 6412     CRLF 
      ASC 2,STOP
      OCT 6412     CRLF 
      LDB TTQ       SCRATCH IF $HELLO IS RUNNING
      JSB HTEST 
      JMP SCH1
* 
**    CODE TO SET UP FORCED DISCONNECT
* 
SCH8  ADB .+?LINK-?STAT 
      JSB DEQUE     REMOVE FROM QUEUE 
      LDB TTQ       CLEAR 
      LDA UNABT 
      IOR ABTRY       ABORT 
      CMA 
      AND 1,I           FLAGS 
      STA 1,I 
      STF 0 
      LDA 1 
      ADA .+?RSTR 
      JMP SCH61     GO SET UP STARTING INFO.
* 
* CODE TO HANDLE ENTER TIMEOUT
* 
SCH4  ADB .+?RSTR-?STAT 
      ISZ 1,I       BUMP RESTART ADDRESS
      ADB .+?PLEV-?RSTR 
      JMP SCH51     GO RESTORE STATUS 
* 
* 
*  CODE TO HANDLE COMMANDS. 
* 
SCH6  STF 0 
      CLA           FLAG BUFFER HEAD TO 
      STA SBHED       SAY BUFFER IN 2114
      STA SCHP      INITIALIZE TO HOLD CHARACTERS 
      JSB SCOM      INTERPRET COMMAND 
      JMP SCH30     EMPTY LINE. 
      JMP SCH9      FIRST CARACTER A DIGIT
      JMP EHERR     INVALID COMMAND.
      JMP SCH11     COMMAND IS OK.
* 
* THE FIRST CHARACTER IS A DIGIT. THIS MEANS THE LINE IS SYNTAX AND 
* WE HAVE TO QUEUE IT AS SUCH.
* 
SCH9  LDB TTQ 
      LDA PUALT     REMOVE
      CMA             PROGRAM 
      AND B,I           UNALTERED 
      STA B,I             FLAG
      ADB .+?PLEV   B=> PRIORITY
      CLA           SET PRIORITY TO 0 
      CPA SCHID,I   IF NO ID, GO LOG IN.
      JMP SCH25 
      STA 1,I 
      ADB .+?RSTR-?PLEV  SET UP STARTING ADDRESS
      LDA SYNTA         FOR SYNTAX
      STA 1,I 
      ADB .+?STAT-?RSTR 
      LDA %SYNT     SET STATUS TO 
      STA 1,I        SYNTAX.
      INB           GO INSERT IN QUEUE. 
      JMP SCH3
* 
SCH30 LDB TTQ       TEST FOR TAPE MODE IF NULL LINE.
      LDA TAPEF 
      AND B,I 
      INB           => TTY #
      SZA,RSS 
      JMP SCH31     NO TAPE - GO EMIT LINE FEED 
      LDA 1,I       SPACE 
      IOR GTC         PAST
      JSB S14SC,I       CARRIAGE RETURN 
      LDA 1,I       INFORM 2114 
      IOR ALI         THAT MORE INPUT 
      JSB S14SC,I       IS ALLOWABLE
      JMP SCH1
* 
SCH31 CPB PRIST     IF USER HAS LP, 
      JSB SCLPR       RELEASE IT
SCH20 LDA .+12B     OUTPUT A LINE FEED. 
      LDB TTQ 
      JSB OUTCH,I 
      JMP SCH1
* 
* COME HERE WHEN ANY ILLEGAL INPUT IS FOUND.
* 
EHERR LDB TTQ 
      INB 
      CPB PRIST     IF USER HAS LP, 
      JSB SCLPR       RELEASE IT
      LDA .-6 
      JSB TYPE
EH    OCT 5077,37477,6412   (???) 
      JMP SCH1
* 
* COME HERE WHEN A LEGITIMATE COMMAND IS FOUND
* 
SCH11 LDA SCHID,I   PROCESS COMMAND ONLY IF 
      SZA,RSS        ID#0 OR
      CPB HI          HELLO COMMAND.
      JMP SCH22 
SCH25 LDA .-16      PRINT LOG IN MESSAGE
      JSB TYPE
      OCT 5120      LF-P
      ASC 6,LEASE LOG IN
      OCT 6412
      JMP SCH1
HI    DEF HELLO 
DTAPR DEF CTAPR 
SCH22 LDB TTQ 
      LDA 1,I       TAPE
      AND TAPEF 
      SZA,RSS         MODE? 
      JMP SCH24     NO
      INB 
      LDA 1,I       YES--CHECK
      IOR ILI       FOR ADDITIONAL
      JSB S14SC,I       INPUT 
      SFS CH2       WAIT FOR
      JMP *-1         ACKNOWLEDGMENT
      LIA CH2 
      SZA           ILLEGAL INPUT?
      JMP EHERR     YES 
      CLF 0         NO
      ADB .-1 
      LDA TAPEF     CLEAR 
      CMA             TAPE
      AND 1,I           FLAG
      STA 1,I 
      STF 0 
SCH24 LDA SCHP,I    TEST FOR HELLO,BYE, OR SCRATCH
      CPA HELLO     OK TO PROCEDE IF ANY
      JMP SCH27     OF THESE. 
      CPA SCR 
      JMP SCH27 
      CPA BYE 
      JMP SCH27 
      LDA 1,I       TEST FOR ANY TAPE ERRORS. 
      AND TERR
      SZA,RSS 
      JMP SCH26     NO TAPE ERRORS--CONTINUE. 
* 
      LDA DTAPR     OTHERWISE, SET UP FOR EXECU-
      STA SCHP       TION OF TAPE ERROR 
      JMP SCH26       PRINTOUT ROUTINE. 
* 
SCH27 LDA TERR      IF HELLO, BYE OR SCRATCH, 
      CMA             CLEAR TAPE
      AND 1,I           ERROR BIT 
      STA 1,I             AND PROCEED 
SCH26 ADB .+?NAME 
      LDA 1,I       TEST FOR
      SSA,RSS       RUN-ONLY PROGRAM. 
      JMP SCH28     NOT RUN-ONLY. 
      LDA SCHP,I    IF RUN-ONLY, DON'T
      CPA SAVE       ALLOW THESE
      JMP SCH29       COMMANDS. 
      CPA CSAV
      JMP SCH29 
      CPA LIS 
      JMP SCH29 
      CPA PUN 
      JMP SCH29 
      CPA XPUN
      JMP SCH29 
* 
SCH28 LDB SCHP
      ADB MCOM2     TEST FOR TYPE I COMMAND.
      SSB,RSS 
      JMP SCH12     NOT TYPE I. 
      LDA TTQ 
      INA           ** TYPE I COMMAND  ** 
      CPA PRIST     IF USER HAS LP, 
      JSB SCLPR       RELEASE IT
      LDB SCHP      COMPUTE STARTING ADDRESS
      ADB *+2         FOR COMMAND PROCESSOR 
      JMP B,I           AND GO THERE
      DEF COM5-COM1,I 
      SPC 2 
SCH29 LDA .-10
      JSB TYPE
      OCT 5122      LF-R
      ASC 3,UN ONL
      OCT 54415     Y-CR
      JMP SCH20 
      SPC 2 
* 
**    TYPE II AND III COMMANDS
* 
SCH12 ADB %SYNT+1   DETERMINE PROGRAM STATUS. 
      LDA TTQ 
      ADA .+?STAT 
      STB 0,I 
      ADA .+?RSTR-?STAT  A=>RESTART ADDRESS 
      ADB .+.-%SYNT+COM2-COM3-1    TYPE II OR III ??
      SSB 
      JMP SCH13     TYPE II COMMAND 
SCH61 LDB #LIB#     TYPE III COMMANDS HAVE A STAN-
      STB 0,I        DARD STARTING ADDRESS AND
      LDB .+2         PRIORITY 2. 
SCH14 ADA .+?PLEV-?RSTR 
      STB 0,I 
      CCB           GET LINK POINTER IN B AND GO
      ADB 0          TO INSERT INTO QUEUE.
      JMP SCH3
      DEF COM3+COM5-COM1
SCH13 ADB *-1       GET STARTING ADDRESS FOR TYPE 
      LDB 1,I        II COMMANDS. 
      STB 0,I 
      CLB,INB       GO SET PRIORITY TO 1
      JMP SCH14 
* 
* "SCRATCH" COMMAND 
* 
#SCR  LDB TTQ       B=>TTY TABLE. 
      JSB SCRAT     PERFORM SCRATCH FUNCTION. 
      JMP SCH20     TERMINATE.
* 
SCRAT NOP           SCRATCH A PROGRAM (B=>USERS TTY)
      LDA PUALT     REMOVE
      CMA             PROGRAM 
      AND B,I           UNALTERED 
      STA B,I             FLAG
      LDA PBUFF     IF MAIN=B, SET PBPTR. 
      CPB MAIN
      STA PBPTR 
      ADB .+?PROG   B=>PROGEND
      STA 1,I       RESET TABLE(PROG) 
      ADB .+?NAME-?PROG   CLEAR 
      CLA           PROGRAM NAME
      STA 1,I 
      JMP SCRAT,I 
