      HED TELETYPE TABLES 
* 
**tt
***            TELETYPE TABLES
**
* 
      SPC 1 
?TNUM EQU 0 
*                   PORT NUMBER IN BITS 12-8
      SPC 1 
?CCNT EQU ?TNUM+1 
*                   USED BY MPX FOR COUNTING OUTPUT CHARACTERS.  IT 
*                   EQUALS -# OF CHARACTERS, INCLUDING CURRENT ONE. 
      SPC 1 
?BPNT EQU ?CCNT+1 
*                   ON INPUT - POINTS TO THE CHARACTER LOCATION INTO
*                              WHICH THE NEXT CHARCTER WILL BE
*                              DEPOSITED. 
*                   ON OUTPUT- POINTS TO THE LAST CHAR. TRANSMITTED.
      SPC 1 
?BSTR EQU ?BPNT+1 
*                   ON INPUT - POINTS TO THE FIRST CHARACTER OF THE 
*                              MOST RECENT BUFFER.
*                   ON OUTPUT- POINTS TO THE LOCATION INTO WHICH THE
*                              NEXT CHARACTER WILL BE PLACED BY THE 
*                              OUTCR ROUTINE. 
      SPC 1 
?BHED EQU ?BSTR+1 1
*                   ON INPUT - POINTS TO THE NEXT CHARACTER TO BE 
*                              FETCHED. 
      SPC 1 
?BGIN EQU ?BHED+1 
*                   POINTS TO BEGINNING OF PHYSICAL BUFFER
      SPC 1 
?BEND EQU ?BGIN+1 
*                   POINTS TO FIRST CHARACTER FOLLOWING PHYSICAL
*               BUFFER. 
      SKP 
?TSTA EQU ?BEND+1 
      SPC 1 
IOBT  EQU BIT0      USER IS IN INPUT MODE 
IONBT EQU NBT0
NIBT  EQU BIT1      NO INPUT ALLOWED
NINBT EQU NBT1
ICBT  EQU BIT2      INPUT CONFIGURATION NEEDED
ICNBT EQU NBT2
RNBT  EQU BIT3      USER IS RUNNING 
RNNBT EQU NBT3
CXBT  EQU BIT4      'CONTROL X' WASIT 
XOBT  EQU BIT5      X-OFF WAS READ FROM 
XONBT EQU NBT5        TERMINET OR ASR-37
LTBT  EQU BIT6      WAIT FOR LOG TIMING 
LTNBT EQU NBT6
LDBT  EQU BIT7      LINE DROPOUT OCCURRED 
LDNBT EQU NBT7
HUBT  EQU BIT8      HANG USER UP
PDBT  EQU BIT9      PHONE DISCONNECTED
UNABT EQU BIT10     USER NOT ABLE TO ABORT
ABTRY EQU BIT11     USER TRIED TO ABORT 
XOFBT EQU BIT12     X-OFF BIT FOR ASR-37         [E]
XOFNT EQU NBT12       AND GE TERMINETS           [E]
      SPC 1 
?DCNT EQU ?TSTA+1 
*                   CR AND LF DELAY COUNTER.
      SPC 1 
?CDLY EQU ?DCNT+1 
*                   CARRIAGE RETURN DELAY (NEGATIVE). 
      SPC 1 
?LDLY EQU ?CDLY+1 
*                   LINE FEED DELAY (NEGATIVE). 
      SPC 1 
?PHON EQU ?LDLY+1 
*                   USED AS TIME COUNTER FOR PHONES LOGIC.
      SPC 1 
?RPRM EQU ?PHON+1 
*                   RECEIVE CHANNEL PARAMETERS. 
      SPC 1 
?SPRM EQU ?RPRM+1 
*                   SEND CHANNEL PARAMETERS.
      SPC 1 
?PPRM EQU ?SPRM+1 
*                   PHONE PARAMETER.
      SPC 1 
?MASK EQU ?PPRM+1 
*                   =2^N FOR USER N.
      SKP 
?DISC EQU ?MASK+1 
*                   DISC ADDRESS. 
      SPC 1 
?PROG EQU ?DISC+1 
*                   POINTS TO LAST USED WORD OF CORE PROGRAM. 
      SPC 1 
?ID   EQU ?PROG+1 
*                   USER ID.
      SPC 1 
?NAME EQU ?ID+1 
*                   8 CHAR PROGRAM NAME 
      SPC 1 1
?TIME EQU ?NAME+3 
*                   STARTING TIME 
      SPC 1 
?CLOC EQU ?TIME+2 
*                   USER'S TIMEOUT CLOCK. 
      SPC 1 
?RSTR EQU ?CLOC+1 1V
*                   RESTART ADDRESS FOR SUSPENDED PROGRAMS. 
      SPC 1 
?STAT EQU ?RSTR+1 
*                   USER STATUS--WHEN ON Q INDICATED PROGRAM TYPE;
*                   WHEN NOT ON Q INDICATED REASON WHY. 
      SPC 1 
?LINK EQU ?STAT+1 
*                   POINTS TO LINK POSITION OF NEXT ENTRY ON QUEUE. 
      SPC 1 
?PLEV EQU ?LINK+1 
*                   FOR PROGRAMS ON Q, CONTAINS PRIORITY LEVEL. FOR 
*                   SUSPENDED PROGRAMS CONTAINS PROGRAM TYPE. 
      SKP 
TTY00 OCT 0,0 
      REP 4 
      DEF BUF00+BUF00 0-
      DEF BUF00+BUF00+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,140374
      DEC 1,0 
      DEF PROGB+1 xx
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY01 OCT 400,0 
      REP 4 
      DEF BUF01+BUF01 
      DEF BUF01+BUF01+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,142374
      DEC 2,0 0j
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* *q
TTY02 OCT 1000,0
      REP 4 
      DEF BUF02+BUF02 
      DEF BUF02+BUF02+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,144374
      DEC 4,0 ;;
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* qq
TTY03 OCT 1400,0
      REP 4 4d
      DEF BUF03+BUF03 
      DEF BUF03+BUF03+BUFLN+BUFLN 
      OCT 0,0,0,0,0 06
      OCT 131202,171202,146374
      DEC 8,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
      SKP 
TTY04 OCT 2000,0
      REP 4 
      DEF BUF04+BUF04 
      DEF BUF04+BUF04+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,150374
      DEC 16,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* *q
TTY05 OCT 2400,0
      REP 4 
      DEF BUF05+BUF05 
      DEF BUF05+BUF05+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,152374
      DEC 32,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY06 OCT 3000,0
      REP 4 
      DEF BUF06+BUF06 
      DEF BUF06+BUF06+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,154374
      DEC 64,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY07 OCT 3400,0
      REP 4 
      DEF BUF07+BUF07 
      DEF BUF07+BUF07+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,156374
      DEC 128,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
      SKP Pl
TTY10 OCT 4000,0
      REP 4 
      DEF BUF10+BUF10 
      DEF BUF10+BUF10+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,160374
      DEC 256,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY11 OCT 4400,0
      REP 4 
      DEF BUF11+BUF11 
      DEF BUF11+BUF11+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,162374
      DEC 512,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY12 OCT 5000,0
      REP 4 
      DEF BUF12+BUF12 
      DEF BUF12+BUF12+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,164374
      DEC 1024,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* qq
TTY13 OCT 5400,0
      REP 4 
      DEF BUF13+BUF13 
      DEF BUF13+BUF13+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,166374
      DEC 2048,0,
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
      SKP 
TTY14 OCT 6000,0
      REP 4 
      DEF BUF14+BUF14 
      DEF BUF14+BUF14+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,170374
      DEC 4096,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* *q
TTY15 OCT 6400,0
      REP 4 
      DEF BUF15+BUF15 
      DEF BUF15+BUF15+BUFLN+BUFLN 
      OCT 0,0,0,0,0 06
      OCT 131202,171202,172374
      DEC 8192,0
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY16 OCT 7000,0
      REP 4 
      DEF BUF16+BUF16 
      DEF BUF16+BUF16+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,174374
      DEC 16384,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* 
TTY17 OCT 7400,0
      REP 4 4d
      DEF BUF17+BUF17 
      DEF BUF17+BUF17+BUFLN+BUFLN 
      OCT 0,0,0,0,0 
      OCT 131202,171202,176374
      DEC 32768,0 
      DEF PROGB+1 
      OCT 0,0,0,0,0,0,0,0,0,0,0 
* *q
      BSS 0              END OF TELETYPE TABLES 
      HED SCHEDULER 
HLDTP OCT 1700
B360  OCT 360       DATA TERMINAL READY ON
SPT1  OCT 0 0+
SPT2  OCT 0 
HI    DEF HELLO 
TP2SA DEF COM3+COM5-COM1
DTAPR DEF CTAPR 
INSQA DEF INSEQ 
SCH19 ABS -COM2+%RUN-.                           [E]
      SKP 
* 
**
***   CLOCK DRIVER
**
* 
*  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.
      CLF 0 
      ISZ DATIM+1   BUMP 100MS COUNTER
      JMP CLC1      NO PROBLEM IF NO SKIP 
      STA CTEMP     SAVE A. 
      LDA M36K      RESET 100MS COUNTER.
      STA DATIM+1 
      LDA CTEMP     RESET A.
      ISZ DATIM     BUMP HR COUNTER.
      NOP           JUST IN CASE. 
      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 GG
      SPC 1 
      CLF CLOCK     ALLOW ANOTHER CLOCK INTERRUPT.
      STF 0 
      JMP CLKIN,I   RETURN. 
CLC2  JMP SCHED     USED TO INSERT IN CLC1. 
      SPC 3 3h
*  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.
      CLF CLOCK     NOW LET THE CLOCK IN AGAIN
CLKED EQU * 
      STF 0 
      STB BREG      SAVE B REGISTER,
      ERA,ALS       E-REGISTER, 
      SOC           AND OVERFLOW REGISTER.
      INA 
      STA EREG
      SPC 1 
      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 ROTAT- 
*                                  ING 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. 
* *q
      LDB MLINK+1   GET THE ADDRESS OF PRIORITY 
      INB            FOR THE CURRENT PROGRAM. 
      LDA .+4       SET IT TO LOW PRIORITY. 
      STA 1,I 
      ADB .-1 
      LDA 1,I       GET THE LINK FROM THE CURRENT 
      STA MLINK+1    PROGRAM AND STORE IT IN MLINK+1. 
* qq
*  THE NEXT SECTION INSERTS A USER INTO THE QUEUE IN ORDER OF HIS 
*  PRIORITY. WHEN WE ARRIVE HERE, THE B REGISTER POINTS TO THE LINK 
*  WORD FOR THE USER. 
* 
SCH3  JSB INSQA,I   INSERT USER INTO QUEUE
      JSB SWAPR     START EARLY SWAPPING
      SPC 2 
* 
**
***   TIMED TELEPHONE LOGIC HANDLER 
**
* 
* 
*     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.
* 
* THE FOLLOWING SECTION OF CODE TAKES CARE OF THE TELEPHONE LOGIC.
* IT IS RESPONSIBLE FOR MAKING 3 DECISIONS: 
*     1) A USER HAS CALLED UP;
*     2) A USER HAS HUNG UP;
*     3) A USER HAS BEEN ON TOO LONG WITHOUT SUCCESSFULLY LOGGING IN
* THE FOLLOWING BIT FLAGS IN THE USER'S I/O STATUS ARE USED:
*     LTBT - LOG TIMING 
*     LDBT - LINE DROP-OUT
*     PDBT - PHONE DISCONNECTED 
*     HUBT - HANG USER UP 
* TAINS THE TIMEOUT VALUE AS NEGATIVE TENTHS OF A SECOND. 
* TAINS THE VALUE OF DATIM+1 NECESSARY FOR TIMEOUT TO BE ACHIEVED.
      SPC 1 1
SCH1  EQU * 
      LDA DATIM+1   GO THROUGH
      CMA             PHONES LOGIC
      ADA SPT1           ONCE A 
      LDB DATIM             SECOND
      CMB 
      ADB SPT2
      IOR 1 1%
      SSA,RSS 
      JMP SCH54 4h
      LDA DATIM+1   SET 
      ADA .+10        FOR 
      STA SPT1           NEXT 
      LDA DATIM             TRIP
      INA 
      STA SPT2
      LDA NPORT     SET COUNTER TO
      STA TCNTR       NUMBER OF PORTS 
      LDB TTYTP,I 
SPL   EQU * 
      STB TPNTR     => START OF TTY TABLE 
      ADB .+?TSTA 
      STB TSPNT     => USER I/O STATUS
      LDA B,I 
      AND HLDTP     ANY PHONES
      SZA,RSS         BITS SET? 
      JMP SPLN      NO
      AND PDBT      YES, PHONE
      SZA             DISCONNECTED BIT? 
      JMP SPL4      YES 
      LDA B,I       NO, HANG
      AND HUBT        USER UP 
      SZA               BIT SET?
      JMP SPL1      YES 
      ADB .+?PHON-?TSTA  NO, BUMP PHONES TIME 
      ISZ B,I       COUNTER - IS TIME UP? 
      JMP SPLN      NO
      LDA TSPNT,I   YES, A = STATUS 
      AND LTBT      LOG TIMING
      SZA             BIT SET?
      JMP SPL3      YES S
* *q
**    LINE DROP-OUT 
* qq
      LDA TSPNT,I   NO, MUST BE LINE DROP-OUT 
      AND LDNBT     REMOVE LINE DROP-OUT AND
      AND ICNBT       INPUT CONFIGURATION BITS
      IOR IOBT      SET INPUT MODE BIT
      RSS 
* 
**    HANG USER UP
* 
SPL1  XOR B,I       REMOVE HANG USER UP BIT 
      STA TSPNT,I   STORE NEW STATUS
      LDB TPNTR 
      ADB .+?STAT 
      LDA B,I       A = USER'S SYSTEM STATUS
      CPA %SYNT     SYNTAX IN USE?
      JMP SPL5      YES. CAN NOT DISCONNECT.
      ADA .+.-%RUN-COM3+COM2
      SSA           LIBRARY PROGRAM IN USE? 
      JMP SPL2      NO
SPL5  LDA TSPNT,I   YES. SET
      IOR HUBT        HANG USER 
      STA TSPNT,I       UP BIT
      JMP SPLN
SPL2  LDA %DISC     SET STATUS TO 
      STA B,I         FORCED DISCONNECT 
      CLF 0 
      ADB .+?MASK-?STAT 
      LDA B,I       SET MPCOM BIT 
      IOR MPCOM M2
      STA MPCOM 
      STF 0 
      ADB .+?LINK-?MASK 
      JSB DEQUE     REMOVE USER FROM QUEUE
      JMP SPLN
* 
**    LOG-ON TIMED OUT
* 
SPL3  XOR TSPNT,I   REMOVE LOG TIMING 
      AND LDNBT       AND LINE DROP-OUT BITS
      IOR PDBT      SET PHONE DISCONNECTED
      IOR IOBT        AND INPUT MODE BITS 
      STA TSPNT,I   STORE NEW STATUS
      LDA TPNTR,I 
      RAL,RAL       GET THE 
      OTA DSCB        PHONES
      LIA DSCB          STATUS
      IOR B300      SET DTR OFF 
      OTA DSCB      OUTPUT TO PHONES BOARD
      JMP SPLN
* 
**    PHONE DISCONNECTED
* 
SPL4  CMA           REMOVE PHONE
      AND B,I         DISCONNECTED BIT
      STA B,I 
      LDA TPNTR,I   GET THE 
      RAL,RAL          PHONES 
      OTA DSCB           STATUS 
      LIA DSCB
      IOR B360      SET DTR ON
      OTA DSCB      OUTPUT TO PHONES BOARD
      ADB .+?PPRM-?TSTA 
      STA B,I       STORE IN PHONES PARAMETER 
* qq
**    UPDATE POINTERS TO NEXT USER
* 
SPLN  LDB TPNTR     ADJUST POINTER TO 
      ADB .+TTY01-TTY00  NEXT USER'S TABLE
      ISZ TCNTR     ALL DONE? 
      JMP SPL       NO
      SKP Pl
