
* 
**    IDLE LOOP 
* 
IDLE  EQU * 
      CLF 0 
      LDA LFLAG     CHECK FOR 
      SZA             LINE PRINTER
      JMP LPIN,I        INITIALIZATION
      LDA LPDIS     CHECK FOR 
      SZA             LINE PRINTER
      JSB LPCLR,I       DISCONNECTION            [B]
      LDA LPDRF     CHECK FOR LP
      SZA             DOWN MESSAGE
      JMP LDWR,I        RETURN
      STF 0 
      CCE 
      CCA 
      CCB 
      SEZ,RSS 
      HLT 70B 
      CMA,SZA 
      HLT 71B 
      CMB,SZB 
      HLT 72B 
      CLE 
      CLA 
      CLB 
      SEZ 
      HLT 73B 
      SZA 
      HLT 74B 
      SZB 
      HLT 75B 
      JMP IDLE
      SPC 1 
* 
**    CLEAR LINE PRINTER FLAGS
* 
CLRLP NOP                                        [B]
      CLF 0                                      [B]
      CLA                                        [B]
      STA LPTTY     CLEAR                        [B]
      STA TLSUP                                  [B]
      STA TLPR        LINE                       [B]
      STA LFLAG                                  [B]
      STA LPERF         PRINTER                  [B]
      STA LPDRF                                  [B]
      STA LPDIS           FLAGS                  [B]
      STA LPXOF                                  [B]
      JMP CLRLP,I                                [B]
      SKP 
* 
* 
*  ENTER WITH A= LOWEST PORT# AND B= HIGHEST PORT#. 
*  THIS SUBROUTINE WILL:
*     SET ?TYPE TO 0
*     SET ?CDLY TO -1 
*     SET ?LDLY TO 0
* 
*     SET BAUD RATE TO 110
*     SET CHAR.SIZE TO 2           -?RPRM 
*     SET ECHO BIT
*     SET ENABLE BIT
* 
*     SET BAUD RATE TO 110
*     SET CHAR.SIZE TO 2           -?SPRM 
*     SET PARITY BIT
*     SET ENABLE BIT
* 
*     SET ?PPRM TO ON              -?PPRM 
* 
*  ABOVE ACTIONS WILL BE TAKEN FOR EACH PORT
*  WITHIN THE RANGE AS INDICATED BY A & B.
* 
ISUBA NOP 
      STB STEMP     SAVE LIMIT. 
      ADA TTYTP     ADD ON TABLE ADDRESS. 
      LDB A,I       B=> ?TNUM 
ISBA1 EQU * 
      LDA B,I       A= ?TNUM
      STA TEMP1     SAVE IT.
      ADB .+?TYPE   B=> ?TYPE 
      CLA           SET ?TYPE=0.
      STA B,I 
      INB           B=> ?CDLY 
      CCA           SET ?CDLY=-1. 
      STA B,I 
      INB           B=> ?LDLY 
      CLA           SET ?LDLY=0.
      STA B,I 
      ADB .+?RPRM-?LDLY  B=> ?RPRM
      LDA RPINT     SET ?RPRM 
      STA B,I 
      INB           B=> ?SPRM 
      LDA SPINT     SET ?SPRM 
      STA B,I 
      INB           B=> ?PPRM 
      LDA TEMP1 
      ALF,CLE,ERA   ADJUST TTY NR. TO 0-15. 
      RAR           UNIT# IN BITS 10-13.
      IOR DTRON     SET "DATA TERM. READY ON" IN
      STA B,I       ?PPRM 
      LDA TEMP1 
      ALF,ALF       TTY NR. INTO LOWER. 
      CPA STEMP     DONE? 
      JMP ISUBA,I   YES. EXIT.
      ADB .+TTY01-TTY00+?TNUM-?PPRM     MOVE TO NEXT
      JMP ISBA1 
* 
* 
* 
* 
*  ENTER WITH A=STARTING PORT#. 
*  SUBROUTINE SETS THE ENABLE BIT IN ?RPRM TO 0 
*  AND SETS ?PPRM TO OFF FOR EACH PORT STARTING 
*  WITH THE PORT# AS INDICATED BY A AND ENDING
*  AT THE LAST PORT.
* 
ISUBB NOP 
      ADA TTYTP     ADD ON TABLE ADDRESS. 
      LDB A,I       B=> ?TNUM 
ISBB1 EQU * 
      LDA B,I       A= ?TNUM
      STA TEMP1     SAVE IT.
      ADB .+?RPRM   B=> ?RPRM 
      LDA B,I       A= ?RPRM
      AND NBT13     SET ENABLE BIT=0. 
      STA B,I 
      ADB .+?PPRM-?RPRM  B=> ?PPRM
      LDA TEMP1 
      ALF,CLE,ERA   ADJUST TTY NR. TO 0-15. 
      RAR,RAR       UNIT# IN BITS 10-13.
      IOR DTROF     SET "DATA TERM. READY OFF" IN 
      STA B,I       ?PPRM 
      LDA TEMP1 
      ALF,ALF       TTY NR. INTO LOWER. 
      CPA B37       DONE? 
      JMP ISUBB,I   YES. EXIT.
      ADB .+TTY01-TTY00+?TNUM-?PPRM     MOVE TO NEXT
      JMP ISBB1 
      HED POWER FAIL/AUTO RESTART 
* 
**
***   POWER FAIL/AUTO RESTART 
**
* 
POWF  NOP 
      SFC 4   TEST FOR FAIL OR RESTART. 
      JMP POW1 RESTART. 
      SPC 1 
* 
**
***   POWER FAIL SECTION
**
* 
      STA POWAT     SAVE REGISTERS
      STB POWBT     TEMPORARILY.
      ERB 
      CCA           SET FLAG TO INDICATE THAT 
      STA POWFF     MACHINE WAS RUNNING AT TIME OF
*                                   POWER FAILURE.
* 
      LDA POWF      TEST FOR POWER FAIL OUT OF
      ADA POWD1     RESTART SECTION.
      SSA                                        [B]
      JMP POWF0     NO                           [B]
      ADA POWD2     MAYBE                        [B]
      SSA                                        [B]
      JMP POW2      FAILED IN RESTART            [B]
* 
POWF0 STB POWE      NORMAL POWER FAIL            [B]
      LDA POWAT     SAVE REGISTERS. 
      STA POWA
      LDB POWBT 
      STB POWB
      LDA POWF      SAVE POWER FAIL RETURN ADR. 
      STA POWP
      STA POWR                                   [C]
* 
* GET FLAGS FOR ALL DEVICES THAT CAN INTERRUPT. 
* 
      CLA 
      SFC C1        CHECK FLAG OF REC CHANNEL    [C]
      IOR BIT1      SET BIT1, IF SET             [C]
      SFC C2        CHECK FLAG OF SEND CHANNEL. 
      IOR BIT2      SET BIT2,IF SET.
      SFC TBASE     CHECK FLAG OF TBG.
      IOR BIT3      SET BIT3, IF SET. 
      SFC MPX       CHECK FLAG OF 1ST MUX.
      IOR BIT4      SET BIT4, IF SET. 
      SFC DSCB1     CHECK FLAG OF 1ST DSC.
      IOR BIT6      SET BIT6, IF SET. 
      LDB NNPRT                                  [C]
      ADB .-16      MORE THAN                    [C]
      SSB             16 PORTS?                  [C]
      JMP POWF1     NO. 
      SFC MPY       YES.HECK FLAG OF 2ND MUX. 
      IOR BIT7      SET BIT7,IF SET.
      SFC DSCB2     CHECK FLAG OF 2ND DSC.
      IOR BIT9      SET BIT9,IF SET.
POWF1 EQU * 
      STA PWFLG 
      STA POWFL                                  [C]
      CLB           IF CENTRAL INTERRUPT FLAG IS
      SFC 0         SET, STORE "STF 0". OTHERWISE 
      LDB STF0      STORE "NOP".
      STB POWND 
* 
POW2  CLC 4         SET FOR RESTART.
      HLT 4         DONE. 
      SPC 1 
* 
**
***   AUTO RESTART SECTION
**
* 
POW1  STC 4,C       RESET FOR POWER FAIL. 
      LDA POWFF     WAS I/O PROCESSOR RUNNING WHEN
      SZA,RSS       POWER WENT DOWN?
      JMP INI       NO. DO A COMPLETE RESTART.
      CLA           YES. SET FAIL INDIC.=0. 
      STA POWFF 
      LDA .+7       SET J AS POWER FAIL POINTER 
      STA POWJ      AND I AS RECEIVE CHANNEL
      INA           POINTER.
      STA POWI
      LDA .+3 
      OTA TBASE     RESET TBG FREQUENCY.
* 
*    CHECK TO SEE IF POWER FAIL OCCURRED WHILE OMTOM OR MUXOR 
*    WAS BEING ACCESSED.  IF POWER FAILED IN EITHER ROUTINE,
*    USE ITS RETURN ADDRESS FOR THE RETURN ADDRESS TESTING. 
* 
      LDA POWR      DID POWER FAIL               [C]
      ADA POWOA       IN EITHER OMTOM            [C]
      SSA               OR MUXOR?                [C]
      JMP POW4      NO                           [C]
      ADA POWOL     MAYBE                        [C]
      SSA,RSS       IN OMTOM?                    [C]
      JMP POW41     NO                           [C]
      LDA OMTOM     YES, MODIFY ADDRESS          [C]
      STA POWR        USED FOR TESTING           [C]
      JMP POW4                                   [C]
* 
POW41 ADA POWML                                  [C]
      SSA,RSS       IN MUXOR?                    [C]
      JMP POW4      NO                           [C]
      LDA MUXOR     YES, MODIFY                  [C]
      STA POWR        TEST ADDRESS               [C]
* 
* NOW TEST THE DEVICES. IF THE FLAG WAS CLEAR, PER- 
* FORM A "CLF". IF IT WAS SET, TAKE STRONGER
* ACTION. 
* 
POW4  LDA PWFLG     GET INDICATOR. THE ONE TO BE
      RAR           TESTED IS IN BIT0 AND I=ITS 
      STA PWFLG     SELECT CODE.
      SLA 
      JMP POW5      FLAG IS SET!
* 
* FLAG WAS NOT SET. 
* 
      LDA POWI      CONSTRUCT "CLF SC" INSTR. 
      ADA CLF0
      STA *+1 
      NOP           EXECUTE "CLF SC" INSTR. 
POW6  LDA POWI      TEST IF DONE. 
      LDB NNPRT                                  [C]
      ADB .-16      MORE THAN                    [C]
      SSB,RSS         16 PORTS?                  [C]
      JMP POWF2     YES.
      CPA .+15B     NO. CHECK FOR DSCB1 LOC.
      JMP POW14     DONE. 
POWF3 EQU * 
      ISZ POWI      NOT DONE.BUMP I AND LOOP. 
      JMP POW4
* 
POWF2 EQU * 
      CPA .+20B     CHECK FOR DSCB2 LOC.
      JMP POW14     DONE. 
      JMP POWF3     NOT DONE. 
* 
* FLAG WAS SET. TEST IF DRIVER HAD ACTUALLY BEEN
* ENTERED, IF SO, PERFORM A DUMMY INTERRUPT 
* TO PREVENT IT FROM BEING REENTERED. 
* 
POW5  LDB POWTB     COMPUTE LOCATION OF RET. ADR. 
      ADB POWJ      OF HIGHEST PRIORITY ROUTINE 
      LDB B,I       NOT YET TESTED. 
      LDA B,I       GET ITS RET. ADR. 
      LDB POWTB     POINT TO RET. ADR. OF ROUTINE.
      ADB POWI      TEST FOR INTERRUPT OUT OF 
      CMA           THAT ROUTINE. 
      STA POWSV     SAVE RETURN ADDRESS.
      ADA B,I 
      SSA,RSS 
      JMP POW6      INTERRUPT WAS PENDING!
      ADB .+11B 
      ADA B,I 
      SSA 
      JMP POW3
      ADB .+22B 
      JMP POW10 
POW3  EQU * 
      ADB .+11B 
      LDA POWSV     A=RETURN ADDRESS. 
      ADA B,I 
      SSA,RSS 
      JMP POW6      INTERRUPT PENDING.
ADB11 ADB .+11B 
      ADA B,I 
      SSA,RSS 
      JMP POW10 
      LDA POWSV     A=RETURN ADDRESS. 
      ADA LMXOR 
      SSA 
      JMP POW6      INTERRUPT WAS PENDING.
POW10 EQU * 
      LDA POWI
      CPA .+13B     I=> MPX?
      RSS 
      JMP POW15     NO. 
      LDA YFLAG     YES - IS                     [C]
      SZA,RSS         YFLAG CLEAR?               [C]
      JMP POW16     YES.
      JMP POW6      NO. 2ND MUX BEING SERVICED. 
POW15 EQU * 
      CPA .+16B     I=>MPY? 
      RSS 
      JMP POW16     NO. 
      LDA YFLAG     YES - IS                     [C]
      SZA,RSS         YFLAG CLEAR?               [C]
      JMP POW6      YES. 1ST MUX BEING SERVICED.
* 
* DRIVER WAS ENTERED. PERFORM A DUMMY INTERRUPT 
* TO PREVENT AN UNWANTED ONE LATER. 
* 
POW16 EQU * 
      LDA ADB11     SET "ADB .+11B" " IN TRAP CELL. 
      STA POWI,I
      LDA POWI
      IOR STF0      CREATE "STF SC"              [C]
      STA POWSF                                  [C]
      IOR STC0      CREATE "STC SC"              [C]
      STA POWST                                  [C]
      IOR CLC0      CREATE "CLC SC"              [C]
POWSF STF 0         EXECUTE "STF SC"             [C]
POWST STC 0         EXECUTE "STC SC". 
STF0  STF 0         ENABLE INTERRUPTS. CAUSES ADDI- 
      STA POWCL     TION OF 12B TO B-REGISTER.
CLF0  CLF 0         DISABLE INTERRUPTS. 
POWCL CLC 0         EXECUTE "CLC SC". 
      LDA B,I       RESTORE TRAP CELL 
      STA POWI,I    CONTENTS. 
      LDA POWI      UPDATE INTERRUPT BHAIN
      STA POWJ      POINTER.
      JMP POW6      TEST NEXT DRIVER. 
      SPC 1 
* 
**    ALL DUMMY INTERRUPTS ARE DONE - START UP INTERCONNECT AND TBG 
* 
POW14 EQU * 
      STC C1        START UP RECEIVE CHANNEL     [C]
      LDA MTEMP     OUTPUT LAST DATA WORD 
      OTA C2        TO SEND CHANNEL.
      LDA POWFL     GET INTERRUPT INDICATOR.
      AND .+4 
      SZA,RSS       WAS FLAG SET? 
      STC C2,C      NO. 2116 NEVER RESPONDED. 
      CLC C2        YES. WE WANT NO INTERRUPT.
      STC TBASE     START UP TBG. 
      LDA CKFLG     IF FLAG=0 DO NOT OUTPUT 
      SZA,RSS       PARAMETERS TO MUX AND 
      JMP POW13     DSC BOARDS
      SPC 1 
* 
**
***   REINSTATE MUX AND DSC PARAMETERS
**
* 
      LDA NNPRT     INITIALIZE                   [C]
      CMA             PORT COUNTER               [C]
      STA CTEMP                                  [C]
      LDA MUXOR     SAVE MUXOR                   [C]
      STA MUXRA       RETURN ADDRESS             [C]
      LDB TTRP      => ?RPRM OF TTY00            [C]
* 
POW7  LDA B,I       GET RECEIVE PARAMETER        [C]
      INB                                        [C]
      STB VTEMP     SAVE POINTER TO SEND PARAM   [C]
      ADB .+?TNUM-?SPRM                          [C]
      LDB B,I       GET AND SAVE                 [C]
      STB FTNUM       UNIT NUMBER                [C]
      JSB MUXOR     OUTPUT RECEIVE PARAM         [C]
      LDA VTEMP,I   GET SEND PARAM               [C]
      LDB FTNUM       AND UNIT NUMBER            [C]
      JSB MUXOR     OUTPUT THEM                  [C]
      LDB VTEMP                                  [C]
      INB                                        [C]
      LDA B,I       GET PHONES PARAM             [C]
      IOR B360      TURN ON "DTR" AND "RQS"      [C]
      SEZ           FIRST DSC?                   [C]
      JMP *+3       NO                           [C]
      OTA DSCB1     YES, OUTPUT PARAM            [C]
      RSS                                        [C]
      OTA DSCB2     OUTPUT PARAM TO SECOND DSC   [C]
      ADB .+?TYPE-?PPRM                          [C]
      LDA B,I       A = ?TYPE                    [C]
      STA B,I                                    [C]
      ADB .+?TNUM-?TYPE                          [C]
      CPB LPTTY     DOES THIS USER HAVE THE LP?  [C]
      JMP POW8      YES                          [C]
      ADB .+?STAT-?TNUM                          [C]
      LDA B,I       NO, IS HE                    [C]
      AND NIBT        CURRENTLY                  [C]
      SZA,RSS           OUTPUTTING               [C]
      JMP POW8      NO                           [C]
      LDA SYNCC     YES, GET SYNC CHARACTER      [C]
      ADB .+?TYPE-?STAT                          [C]
      LDB B,I       IF SELECTRIC,                [C]
      SZB             SET PROPER BIT             [C]
      IOR SLBIT                                  [C]
      LDB FTNUM                                  [C]
      JSB MUXOR     FIRE THIS TURKEY UP          [C]
* 
POW8  LDB VTEMP     SET B TO NEXT PORT           [C]
      ADB .+TTY01-TTY00+?RPRM-?SPRM              [C]
      ISZ CTEMP     DONE?                        [C]
      JMP POW7      NO                           [C]
      LDA MUXRA     YES, RESTORE MUXOR           [C]
      STA MUXOR       RETURN ADDRESS             [C]
* 
**    START UP DSC BOARD(S) 
* 
POW9  EQU * 
      STC DSCB1     START UP 1ST DSC. 
      LDB NNPRT                                  [C]
      ADB .-16      IF THERE ARE                 [C]
      SSB,RSS         MORE THAN 16 PORTS?        [C]
      STC DSCB2     START UP 2ND DSC. 
* 
**    RESTORE REGISTERS 
* 
POW13 EQU * 
      LDB POWE      RESTORE 
      ELB                E, 
      LDB POWB                B AND 
      LDA POWA                     A REGISTERS. 
* 
**    RESTORE CENTRAL INTERRUPT SYSTEM TO ITS PRE-POWER FAIL STATE
* 
POWND NOP 
      JMP POWP,I    RETURN. 
      SKP 
* 
**    POWER FAIL DRIVER TABLES
* 
POWTB DEF *-6 
* 
*  THIS TABLE POINTS TO THE ENTRY POINTS FOR THE DRIVERS
* 
      DEF POWR      POWER FAIL                   [C]
      DEF RFS       RECEIVE CHANNEL.
      ABS 0         NO INTERRUPT                 [C]
      DEF TBGEN     TBG.
      DEF MPXIO     1ST MUX.
      ABS 0         NO INTERRUPT                 [C]
      DEF DSCBX     1ST DSC                      [B]
      DEF MPYIO     2ND MUX.
      ABS 0         NO INTERRUPT                 [C]
      DEF DSCBY     2ND DSC                      [B]
* 
*  THIS TABLE GIVES THE LENGTH OF EACH ROUTINE SO THAT THE
*  POWER FAIL LOGIC CAN DETERMINE IF THE INTERRUPT OF THAT
*  DRIVER HAD ACTUALLY OCCURRED OR IF IT WAS STILL PENDING
*  AT THE TIME OF THE POWER FAILURE.
* 
      ABS RFSE-RFS+1     RECEIVE CHANNEL. 
      ABS 0              SEND CHANNEL.
      ABS TBGED-TBGEN+1  TBG. 
      ABS MPXIE-MPXIO+1  1ST MUX
      ABS 0              NON-EXISTING.
      ABS DSCE-DSCBX+1   1ST DSC                 [B]
      ABS MPYIE-MPYIO+1  2ND MUX. 
      ABS 0              NON-EXISTING.
      ABS DSCE-DSCBY+1   2ND DSC                 [B]
* 
**    THIS TABLE POINTS TO DRIVER SUBROUTINE ENTRY POINTS 
* 
      DEF POC 
      ABS 0                                      [C]
      DEF TBGEN 
      DEF ICNVR 
      ABS 0                                      [C]
      DEF DSCBX                                  [B]
      DEF ICNVR 
      ABS 0                                      [C]
      DEF DSCBY                                  [B]
* 
*  THIS TABLE CONTAINS THE LENGTHS OF THE DRIVER SUBROUTINES
* 
      ABS SERND-POC+1 
      ABS 0 
      ABS TBGED-TBGEN+1 
      ABS ICVRE-ICNVR+1 
      ABS 0 
      ABS DSCE-DSCBX+1                           [B]
      ABS ICVRE-ICNVR+1 
      ABS 0 
      ABS DSCE-DSCBY+1                           [B]
* 
**  THIS TABLE CONTAINS THE CORRECT TRAP CELL CONTENTS
* 
      JSB PRFS,I    RECEIVE CHANNEL.
      CLC C2        SEND CHANNEL. 
      JSB  TBGDR,I  TBG.
      JSB MPX+1,I   FIRST MUX 
      DEF MPXIO       BOARD 
      JSB DSDR1,I   1ST DSC.
      JSB MPY+1,I   SECOND MUX
      DEF MPYIO       BOARD 
      JSB DSDR2,I   2ND DSC.
      SPC 2 
MUXRA OCT 0                                      [C]
POWR OCT 0                                       [C]
POWOA ABS -OMTOM                                 [C]
POWOL ABS OMTOM-MUXOR                            [C]
POWML ABS MUXOR-MUXRE                            [C]
POWD1 ABS -POW1        (THIS PAIR MUST BE POSITIONED
POWD2 ABS POW1-POWD1     AT THE END OF THIS ROUTINE)
      HED TELETYPE POINTER TABLE
* 
TTPT  EQU * 
      DEF TTY00 
      DEF TTY01 
      DEF TTY02 
      DEF TTY03 
      DEF TTY04 
      DEF TTY05 
      DEF TTY06 
      DEF TTY07 
      DEF TTY10 
      DEF TTY11 
      DEF TTY12 
      DEF TTY13 
      DEF TTY14 
      DEF TTY15 
      DEF TTY16 
      DEF TTY17 
      DEF TTY20 
      DEF TTY21 
      DEF TTY22 
      DEF TTY23 
      DEF TTY24 
      DEF TTY25 
      DEF TTY26 
      DEF TTY27 
      DEF TTY30 
      DEF TTY31 
      DEF TTY32 
      DEF TTY33 
      DEF TTY34 
      DEF TTY35 
      DEF TTY36 
      DEF TTY37 
* 
      HED USER BUFFERS
* 
BUF00 BSS BUFLN 
BUF01 BSS BUFLN 
BUF02 BSS BUFLN 
BUF03 BSS BUFLN 
BUF04 BSS BUFLN 
BUF05 BSS BUFLN 
BUF06 BSS BUFLN 
BUF07 BSS BUFLN 
BUF10 BSS BUFLN 
BUF11 BSS BUFLN 
BUF12 BSS BUFLN 
BUF13 BSS BUFLN 
BUF14 BSS BUFLN 
BUF15 BSS BUFLN 
BUF16 BSS BUFLN 
BUF17 BSS BUFLN 
BUF20 BSS BUFLN 
BUF21 BSS BUFLN 
BUF22 BSS BUFLN 
BUF23 BSS BUFLN 
BUF24 BSS BUFLN 
BUF25 BSS BUFLN 
BUF26 BSS BUFLN 
BUF27 BSS BUFLN 
BUF30 BSS BUFLN 
BUF31 BSS BUFLN 
BUF32 BSS BUFLN 
BUF33 BSS BUFLN 
BUF34 BSS BUFLN 
BUF35 BSS BUFLN 
BUF36 BSS BUFLN 
BUF37 BSS BUFLN 
      BSS 0        WHERE ARE WE?
      END 
