**                                    **
***  MULTIPLY UNPACKED NUMBER BY 10  ***
**                                    **
* 
*  THE FLOATING POINT NUMBER IN MANT1, MANT2, AND EXP 
*  IS MULTIPLIED BY 10. 
* 
#MB10 LDA MANT1     LOAD HIGH MANTISSA
      SZA,RSS       ZERO NUMBER?
      JMP MBY10,I   YES 
      LDB EXP       NO, 
      ADB .+3         MULTIPLY
      STB EXP           BY 8
      LDB MANT2     LOAD LOW MANTISSA 
      CLE,ERA       DIVIDE
      ERB             BY
      CLE,ERA           4 
      ERB,CLE 
      ADB MANT2     ADD INTO
      SEZ             BOTH REGISTERS
      INA               PRODUCING 
      ADA MANT1           1.25 * MANTISSA 
      SSA,RSS       CORRECT 
      JMP MBY01 
      CLE,ERA         ON
      ERB 
      ISZ EXP           OVERFLOW
      NOP 
MBY01 STA MANT1     STORE 
      STB MANT2       MANTISSA
      JMP MBY10,I 
**                               ** 
***  NORMALIZE UNPACKED NUMBER  *** 
**                               ** 
* 
*  ENTER WITH NUMBER IN (A), (B), AND EXP.  EXIT WITH 
*  NORMALIZED NUMBER IN MANT1, MANT2, AND EXP (MANTISSA 
*  IS LEFT IN (A) AND (B) AS WELL). 
* qq
#NRML STA NT0       SET 
      CLA             LEFT-SHIFT
      STA TEMP+2        COUNTER 
      LDA NT0             TO ZERO 
      SZA,RSS       IF NUMBER 
      SZB             IS ZERO,
      JMP NORM2+1       CLEAR 
      STA EXP             EVERYTHING
      STA MANT1     STORE 
NORM1 STB MANT2       MANTISSA
      JMP NORML,I 
NORM2 ISZ TEMP+2    COUNT A LEFT SHIFT
      CLE,ELB       ROTATE (A)
      ELA             AND (B) LEFT
      SEZ,SSA,RSS   TWO HIGHEST BITS 0? 
      JMP NORM2     YES, POSITIVE UNNORMALIZED
      SEZ,SSA       NO, TWO HIGHEST BITS 1? 
      JMP NORM2     YES, NEGATIVE UNNORMALIZED
      ERA           NO, NORMALIZE 
      ERB,CLE         MANTISSA
      STA MANT1     COMPUTE 
      LDA TEMP+2
      CMA,INA         CORRECTED 
      ADA EXP 
      STA EXP           EXPONENT
      LDA MANT1 1R
      JMP NORM1 
      SKP 
**                               ** 
***  NORMALIZE AND PACK NUMBER  *** 
**                               ** 
* 
*  NUMBER IN (A), (B), AND EXP ON ENTRY.  ON EXIT (A) 
*  AND (B) CONTAIN THE NORMALIZED, ROUNDED, AND PACKED
*  NUMBER.  UNDERFLOW BECOMES A ZERO, OVERFLOW BECOMES
*  THE LARGEST REPRESNTABLE NUMBER OF APPROPRIATE SIGN. 
* 
#PACK JSB NORML     NORMALIZE NUMBER
      CLE,SZA,RSS   ZERO? 
      JMP .PACK,I   YES 
      ADB B177      NO, ROUND 
      SSA,RSS       POSITIVE? 
      INB           YES, FINISH ROUND 
      CLO 
      SEZ           ON OVERFLOW FROM (B)
      CLE,INA         CORRECT (A) 
      SOS           OVERFLOW? ( (A)=100000, (B)=0 ) 
      RAL           TWO HIGH BITS 
      SSA,SLA,RSS     BOTH 1? ( IF (A) WAS 140000 ) 
      JMP PACK1     NO
      CCE           YES 
      ARS,SLA,ALS   SET (A) = 100000 AND SKIP 
PACK1 RAR           UNDOES RAL ABOVE
      STA TEMP+2    SAVE (A)
      LSR 8         DELETE 8 LOW BITS 
      BLF,BLF         OF MANTISSA 
      LDA EXP       DECREMENT 
      SEZ             EXPONENT
      ADA .-1           ON (E) # 0
      SOC           INCREMENT 
      INA             EXPONENT ON OVERFLOW
      ADA B200      EXPONENT
      SSA             UNDERFLOW?
      JMP PACK3     YES 
      ADA M256      NO, EXPONENT
      SSA,RSS         OVERFLOW? 
      JMP PACK4     YES 
      ADA B200      NO, RESTORE EXPONENT
      RAL           POSITION
      AND B377        EXPONENT AND
      ADB 0             ADD LOW MANTISSA
      LDA TEMP+2    RETRIEVE HIGH MANTISSA
      CPA MNEG
      RSS           NEGATIVE
      JMP .PACK,I 
      CPB MNEG+1      OVERFLOW? 
      JMP PACK4     YES 
      JMP .PACK,I   NO
PACK3 JSB CHOUF     CHECK STATUS
      JSB WERRS+6,I Ie
      CLA           ZERO RESULT 
      CLB             ON UNDERFLOW
      JMP .PACK,I 
PACK4 JSB CHOUF     CHECK STATUS
      JSB WERRS+5,I 
      LDA TEMP+2    RETRIEVE HIGH MANTISSA
      JSB OVFLW 
      JMP .PACK,I 
**                                  **
***  DIVIDE UNPACKED NUMBER BY 10  ***
**                                  **
* 
*  INVERSE OF MBY10 
* 
#DB10 LDA MANT1     RETURN
      SZA,RSS         ON
      JMP DBY10,I       ZERO
      LDB .-2       ADD EXPONENT
      ADB EXP         OF 1/10 TO
      STB EXP           THAT OF NUMBER
      LDA MANT2     JUSTIFY 
      CLE,ERA         LOWER MANTISSA
      MPY TENTH         MULTIPLY BY 1/10
      CLE,ELA       SHIFT 
      ELB,CLE         BACK
      ADA 1         ADD IN EQUIVALENT OF
      SEZ             LOWER MANTISSA* 
      CLE,INB           TENTH*2^(-16) 
      STB MANT2           AND ROUND TO 16 BITS
      LDA MANT1     DO
      MPY TENTH       SAME TO 
      ADA 1             HIGH MANTISSA 
      ADA MANT2     PERFORM EFFECTIVE 
      SEZ             SUM OF DOUBLE-LENGTH
      INB               PRODUCTS
      SWP           SWAP (A) AND (B)
      JSB NORML     NORMALIZE 
      JMP DBY10,I     RESULT
      HED **  DISC DRIVER  ** 
* qq
*  A-REG = DISC ADDRESS 
*        A(15)  =DISC DRIVE 
*        A(14:7)=CYLINDER NUMBER
*        A(6)   =1 IF FIXED DISC/0 IF CARTRIGE
*        A(5:0) =SECTOR NUMBER
* 
*  B-REG = CORE ADDRESS AND DIRECTION 
*        B(15)  =1 FOR DISC READ/0 FOR DISC WRITE 
*        B(14:0)=CORE ADDRESS 
* *q
*  WORD  = - NUMBER OF WRODS TO BE TRANSFERRED
* qq
*  ENDSK = DRIVER FLAG, SET WHEN A TRANSFER IS INITIATED
*          AND CLEARED UPON SUCCESSFUL COMPLETION 
* qq
*  WHEN AN ATTEMPTED TRANSFER FAILS, IT IS REPEATED NINE
*  ADDITIONAL TIMES.  IF IT CONTINUES TO FAIL, THE COMPUTER 
*  HALTS DISPLAYING THE DISC STATUS IN THE A-REGISTER.
* 
      SPC 2 
LDISC NOP 
      CLF 0 
      STA DADDR     SAVE DISC AND 
      STB CORE        CORE ADDRESSES
      LDB LDISC     STORE RETURN
      STB DINT        ADDRESS 
      ISZ ENDSK     SET BUSY FLAG 
LDOR  LDB WORD      IS WORD 
      SZB,RSS         COUNT=0?
      JMP LDEND     YES-NO TRANSFER 
* 
LDORP EQU * 
      RAL 
      AND .+1       ISOLATE 
      STA DRIVE       DRIVE NUMBER
* 
      LDA DADDR     ISOLATE 
      AND B100        HEAD NUMBER 
      STA B 
      LDA DADDR     ISOLATE SECTOR
      AND B77         ADDRESS 
      ADA .-24      IF SECTOR NUMBER
      SSA,RSS         GREATER THAN 23, THEN 
      ADB .+40B         ADJUST HEAD NUMBER
      SSA           IF SECTOR NUMBER LESS 
      ADA .+24        THAN 12, RESET IT 
      BLF,RBR       POSITION AND ADD
      IOR B           DISC NUMBER 
      STA HDSCT     SAVE
* 
      LDA DADDR 
      AND CYLMK     ISOLATE 
      ALF,ALF         CYLINDER
      RAL               NUMBER
      STA CYL#
* 
**    INITIATE SEEK OPERATION 
* 
      OTA DC        OUTPUT CYLINDER # 
      STC DC,C        TO DATA CHANNEL 
      LDA SEEK      LOAD SEEK COMMAND AND 
      IOR DRIVE       ADD ON DRIVE NUMBER 
      CLC CC        CLEAR PREVIOUS COMMAND
      OTA CC        OUTPUT SEEK TO
      STC CC,C        COMMAND CHANNEL 
      SFS DC        WAIT FOR CYLINDER # 
      JMP *-1         TO BE ACCEPTED
      LDA HDSCT     OUTPUT
      OTA DC          HEAD/SECTOR 
      STC DC,C          ADDRESS 
      SFS DC        WAIT FOR
      JMP *-1         ACCEPTANCE
* 
**    INITIATE DISC TRANSFER
* *q
      LDA CORE
      LDB CMDMA     SET UP
      OTB 6           DMA 
      CLC 2 
      OTA 2         OUTPUT CORE 
      STC 2           ADDRESS 
      LDB WORD      OUTPUT WORD 
      OTB 2           COUNT 
      LDB READ      LOAD
      SSA,RSS         DISC
      LDB WRIT          COMMAND 
      ADB DRIVE     ADD ON DRIVE #
      CLC CC
      OTB CC        OUTPUT COMMAND
      SSA,RSS       IF OUTPUT, PRESET 
      STF DC          DATA CHANNEL FLAG 
      SSA           IF INPUT, CLEAR THE 
      STC DC,C        FLAG AND SET CONTROL
      STC 6,C       START DMA 
      STC CC,C      START DISC
      JMP LDE2      RETURN
      SPC 2 
* qq
**    PROCESS COMMAND CHANNEL INTERRUPT 
* 
DINT  NOP 
      CLF 0 
      DST DSAVE     SAVE REGISTERS
      STF 6         TURN OFF DMA
      LIA 4         WAS INTERRUPT 
      CPA .+CC        FROM DISC?
      RSS FF
      JMP LDE1      NO
* *q
**    CHECK STATUS
* 
      LIA CC        GET ATTENSION BITS AND
      ADA .-1         CONVERT TO DRIVE NUMBER 
      STC DC,C      SET UP DATA CHANNEL 
      OTA CC        OUTPUT
      CLC CC          STATUS
      STC CC,C          COMMAND 
      SFS DC        WAIT FOR
      JMP *-1         STATUS
      LIA DC        RETRIEVE STATUS 
      CLC DC        TURN OFF DATA CHANNEL 
      SLA           ANY ERRORS? 
      JMP LDERR     YES 
* qq
**    TRANSFER COMPLETED - NO ERRORS
* 
LDEND CLC CC
      LDA .-10      RESET FAIL
      STA FAIL        COUNTER 
      CLA           CLEAR DRIVER
      STA ENDSK       BUSY FLAG 
LDE1  CLC 6,C       TURN OFF DMA
LDE2  DLD DSAVE     RESTORE REGISTERS 
      STF 0 
      JMP DINT,I    RETURN
      SPC 2 
* 
**    ERROR HAS BEEN DETECTED 
* 
LDERR ISZ FAIL      INCREMENT FAIL COUNTER
      JMP LDER1     INITIATE RESTART
LDER2 HLT DEATH+10B,C  HALT WITH STATUS 
      LDA .-10        IN A-REGISTER 
      STA FAIL
* 
LDER1 LDA DADDR     INITIATE
      JMP LDOR        RESTART 
* 
*  THE FOLLOWING INSTRUCTIONS ARE USED BY "DISC-UP" COMMAND 
*  TO PREVENT A SYSTEM HALT WHEN OPERATOR ERRONEOUSLY UPS 
*  A NON-EXISTENT OR NOT READY DISC.
*  IT WILL BE ENTERED BY INSERTING THE INSTR. AT LABEL "LDER5" INTO 
*  LOCATION "LDER2" 
* 
LDER3 STA STATS     STORE STATUS
      LDA LDER4     RESTORE "HALT" INSTRUCTION
      STA LDER2 
      JMP LDEND     EXIT
* 
LDER4 HLT DEATH+10B,C                            [E]
LDER5 JMP LDER3 
* 
LDSND EQU * 
      SPC 3 
      HED * POWER FAIL/RESTART ROUTINE *
* 
**    POWER FAIL/RESTART
* 
POW   NOP 
      SFC 4         FAIL OR RESTART?
      JMP POW1      RESTART.
* 
**    POWER FAIL SECTION
* 
      DST POWIT     SAVE REGISTERS TEMP.
      ERB,BLS 
      SOC 
      INB 
* 
      LDA FLAG
      SZA           CHECK FLAG. 
      JMP POW2      FLAG=1 OR FLAG=2, 
* qqq{
* 
* qq
      LDA POW       FLAG=0. FAILED IN RESTART?
      ADA POWD1 1?
      SSA 
      JMP POW81     NO. NORMAL FAIL.
      ADA POWD2 
      SSA 
      JMP POW2      YES. FAILED IN RESTART. 
      ADA POWD3     MAY BE. 
      SSA,RSS 
      JMP POW81     NO. NORMAL FAIL.
      LDA LDER2     YES. FAILED IN RESTART. 
      STA SVHLT     SAVE CONTENTS OF "LDER2" AND
      LDA LDER4     REPLACE WITH "HALT" INSTRUC-
      STA LDER2     TION. 
      JMP POW2
* 
* NORMAL POWER FAILURE. 
* 
POW81 STB POWEO     SAVE REGISTERS
      DLD POWIT       PERMANENTLY.
      DST POWAB 
      LDA POW       SAVE RETURN ADDRESS.
      STA POWP
      LIA 01        FETCH AND 
      STA POWSW       SAVE SWITCH REGISTER. 
* 
      CLA           GET ALL DEVICE FLAGS. 
      SFC DMA       CHECK DMA FLAG. 
      INA           SET BIT 0, IF SET.
      SFC ?SC       CHECK CONSOLE FLAG. 
      IOR .+4       SET BIT 2,IF SET. 
*                                   * DISC
*                                       * CHANNELS. 
*                                 * PHOTOREADER CHANNEL.
      SFC MPX       CHECK MUX(DATA) FLAG. 
      IOR B100      SET BIT 6, IF SET.
*                                  * MUX(STATUS) CHANNEL. 
      SFC DSCB      CHECK PHONES FLAG.
      IOR B400      SET BIT 8, IF SET.
      SFC CLOCK     CHECK TBG FLAG. 
      IOR B1000     SET BIT 9,IF SET. 
      STA POWFL     SET FLAG WORD.
      LDA DADDR     SAVE DISC ADDRESS.
      STA PDADR 
      LDA CORE      SAVE CORE ADDRESS 
      STA PCORE 
      LDA WORD      SAVE WORD COUNT.
      STA PWORD 
      LDA ENDSK     SAVE DISC FLAG. 
      STA PNDSK 
      LDA DINT      SAVE INTERRUPT RET.ADDR.
      STA PDINT       OF DISC DRIVER. 
      LDA LDER2     SAVE CONTENTS OF "LDER2" AND
      STA SVHLT     REPLACE WITH "HALT" INSTR.
      LDA LDER4 
      STA LDER2 
* qq
      CLB           IF CENTRAL INTERRUPT
      SFC 0           FLAG IS SET, STORE "STF 0"
      LDB SETF0         IN "POWND"; ELSE "NOP". 
      STB POWND 
* 
POW2  EQU * 
      CLC 4 
      HLT DEATH+4                                [E]
* 
* qq
* 
******************************************************************* 
***** END OF POWER FAIL SECTION ***** 
******************************************************************* 
* 
* qq
* *q
* 
* *q
******************************************************************* 
**    CORE RESIDENT RESTART SECTION 
******************************************************************* 
* 
* 
POW1  STC 4,C       SET FOR POWER FAIL. 
      LDA M256      SET WORD LENGTH FOR ROLL IN AND 
      STA WORD        ROLL OUT. 
* 
*  WAIT FOR DISC TO GET UP TO SPEED.
* qq
      LDA LOOPS     DELAY.
POW30 EQU * *8
      CLB 
      ISZ B 
      JMP *-1 
      ISZ A 
      JMP POW30 
POW3  EQU * 
      STC DC,C      SET UP DATA CHANNEL.
      OTB CC        OUTPUT
      CLC CC        STATUS. 
      STC CC,C          COMMAND.
      SFS DC        WAIT FOR ACCEPTANCE.
      JMP *-1 
      LIA DC        GET STATUS. 
      CLC DC
      SZB           DRIVE #1? 
      JMP POW31     YES. CONTINUE.
      AND B100      NO. CHECK READY BIT.
      SZA,RSS       SET?
      INB           NO. NOW DO DRIVE #1.
      JMP POW3      YES. RECHECK. 
* 
POW31 EQU * 
      CLC CC
      LDA FLAG      CHECK FLAG. 
      SLA ;;
      JMP POW56     FLAG=1. 
      SZA 
      JMP POW51     FLAG=2. 
* 
POW55 ISZ FLAG      SET FLAG=1. 
POW56 EQU * 
      LDA SWLBA,I   ROLL OUT SYSTEM LIBRARY.
      LDB #LIB# 
      JSB DISCP,I 
* 
      ISZ FLAG      SET FLAG=2. 
POW51 EQU * 
      LDA RSLBA,I   ROLL IN RESTART.
      LDB #LIBI 
      JSB DISCP,I 
* 
      JMP #LIB#,I   EXECUTE RESTART.
* 
* 
* 
******************************************************************* 
*  CONTINUATION OF CORE RESIDENT RESTART LOGIC. 
******************************************************************* 
* 
*  OVERLAY RESTART LOGIC MUST HAVE BEEN EXECUTED
*  BEFORE ENTERING THIS SECTION.
* qq
* 
POW57 EQU * 
      LDA SWLBA,I    ROLL IN SYSTEM LIBRARY.
      LDB #LIBI 
      JSB DISCP,I 
* 
* qq
*  TURN ON ALL DEVICES. 
* 
      STC CLOCK     START TBG.
      STC ?SC       START CONSOLE.
      LDA TBITS     RE-ESTABLISH PREVIOUS 
      OTA ?SC         STATE OF CONSOLE. 
      STC MPX       START MUX.
      STC DSCB      START PHONES. 
* 
* 
      LDA PNDSK     RESTORE DISC BUSY FLAG. 
      STA ENDSK 
      LDA PWORD 
      STA WORD
      LDB PCORE 
      LDA CKFLG     CHECK FLAG. 
      SZA,RSS 
      JMP POW58     =0. DRIVER NOT BUSY.
      SLA 
      JMP POW59     =1.DRIVER BUSY.NOT FAILED IN DR.
      LDA PDINT     =2.DRIVER BUSY.FAILED IN DRIVER.
      STA DINT
      LDA SVHLT     RE-INSTATE CONTENTS OF
      STA LDER2       LOCATION "LDER2". 
      CLA           ST FLAG=0.
      STA FLAGA
      LDA PDADR 
      JMP LDORP 
* 
POW59 EQU * 
      LDA PDADR     RECALL DISC DRIVER. 
      JSB DISCP,I 
      CLF 0 
POW58 EQU * 
      CLA 
      LDB SVHLT     RE-INSTATE LOCATION "LDER2".
      STB LDER2 
      STA FLAG      SET FLAG=0. 
* 
      DLD POWAB     RESTORE A AND B REGISTERS.
* qq
*  RESET INTERRUPT TO SAME
*     AS BEFORE POWER FAILURE.
* 
POWND NOP 
      JMP POWP,I    EXIT. 
PEXIT EQU * 
* 
* qq
* *q
POWIT BSS 2 
POWFL BSS 1 
FLAG  NOP 
POWD1 ABS -POW1 
POWD2 ABS -POW55+POW1 
POWD3 ABS -PEXIT+POW55
SVHLT HLT DEATH+10B,C                            [E]
CKFLG BSS 1 
PDINT BSS 1 
POWAB BSS 2 
POWEO BSS 1 
POWSW BSS 1 
PDADR BSS 1 1-
PCORE BSS 1 
PWORD BSS 1 1O
PNDSK BSS 1 
POWP  BSS 1         TO SAVE RETURN ADDRESS. 
SETF0 STF 0 
LOOPS DEC -190
RSLBA DEF RSLIB     POINTERS
SWLBA DEF SWLIB     TO DISC ADDRESSES.
* qq
* 
* qq
      HED PRINT NAME TABLE
**                                                 ** 
***  PRINT NAME TABLE FOR MULTICHARACTER SYMBOLS  *** 
**                                                 ** 
* 
*  BITS 15-9 OF THE 'OCT' WORD ARE THE BASIC OPERATOR 
*  CODES OF THE SYMBOLS.  BITS 2-0 ARE THE LENGTH IN
*  CHARACTERS OF THE SYMBOLS.  THE ASCII VERSION (PRINT 
*  NAME) FOLLOWS. 
* 
*                                    *
**  MULTICHARACTER BINARY OPERATORS  ** 
*                                    *
MCBOS OCT 33003     AND 
      ASC 1,ANA
      OCT 42000 
      OCT 34002     OR
      ASC 1,OR
      OCT 35003     MIN 
      ASC 1,MI
      OCT 47000 
      OCT 36003     MAX 
      ASC 1,MA
      OCT 54000 
MRELS OCT 37002     UNEQUAL 
      ASC 1,<>
      OCT 40002     GREATER THAN OR EQUAL 
      ASC 1,>=
      OCT 41002     LESS THAN OR EQUAL
      ASC 1,<=
*                                   * 
**  MULTICHARACTER UNARY OPERATOR  ** 
*                                   * 
NOT   OCT 42003 
      ASC 1,NO
      OCT 52000 
*                     * 
**  STATEMENT TYPES  ** 
*                     * 
STYPS OCT 45003     COM 
      ASC 1,CO
      OCT 46400 
      OCT 46003     LET 
      ASC 1,LE
      OCT 52000 
      OCT 47003     DIM 
      ASC 1,DID.
      OCT 46400 
      OCT 50003     DEF 
      ASC 1,DE
      OCT 43000 0n
      OCT 51003     REM 
      ASC 1,RE
      OCT 46400 
      OCT 52004     GOTO
      ASC 2,GOTO
      OCT 53002     IF
      ASC 1,IF
      OCT 54003     FOR 
      ASC 1,FO
      OCT 51000 
      OCT 55004     NEXT
      ASC 2,NEXT
      OCT 56005     GOSUB 
      ASC 2,GOSU
      OCT 41000 
      OCT 57006     RETURN
      ASC 3,RETURN
EOFOP OCT 60003     END 
      ASC 1,ENEO
      OCT 42000 
      OCT 61004     STOP
      ASC 2,STOP
      OCT 62004     DATA
      ASC 2,DATA
IOSTS OCT 63005     INPUT 
      ASC 2,INPU
      OCT 52000 
      OCT 64004     READ
      ASC 2,READ
      OCT 65005     PRINT 
      ASC 2,PRIN
      OCT 52000 
      OCT 66007     RESTORE 
      ASC 3,RESTOR
      OCT 42400 
      OCT 67003     MAT 
      ASC 1,MA
      OCT 52000 
      OCT 70005     FILES 
      ASC 2,FILE
      OCT 51400 
      OCT 71005     CHAIN 
      ASC 2,CHAI
      OCT 47000 
      OCT 72001    'IMPLIED' LET                 X] 
      OCT 0 
*                             * 
**  MISCELLANEOUS OPERATORS  ** 
*                             * 
      OCT 74002     OF
      ASC 1,OF
THEN  OCT 75004 
      ASC 2,THEN
      OCT 76002     TO
      ASC 1,TO
STEP  OCT 77004 
      ASC 2,STEP
*                                               * 
**  PREDEFINED FUNCTIONS.  BITS 13-9 ARE USED  ** 
**    FOR INTERNAL IDENTIFICATION              ** 
*                                               * 
TAB   OCT 1003      TAB 
      ASC 1,TA
      OCT 41000 0}
PRDFS OCT 2003      SIN 
      ASC 1,SI
      OCT 47000 ))
      OCT 3003      COS 
      ASC 1,CO
      OCT 51400 
      OCT 4003      TAN 
      ASC 1,TATn
      OCT 47000 0)
      OCT 5003      ATN 
      ASC 1,AT
      OCT 47000 
      OCT 6003      EXP 
      ASC 1,EX
      OCT 50000 
      OCT 7003      LOG 
      ASC 1,LO
      OCT 43400 
      OCT 10003     ABS 
      ASC 1,AB
      OCT 51400 
      OCT 11003     SQR 
      ASC 1,SQ
      OCT 51000 
      OCT 12003     INT 
      ASC 1,IN
      OCT 52000 
      OCT 13003     RND D
      ASC 1,RN
      OCT 42000 
      OCT 14003     SGN 
      ASC 1,SG
      OCT 47000 
      OCT 15003     LEN 
      ASC 1,LE
      OCT 47000 
      OCT 16003     TYP 
      ASC 1,TY
      OCT 50000 
      OCT 17003     TIM 
      ASC 1,TI
      OCT 46400 
*                      *
**  MATRIX FUNCTIONS  **
*                      *
MATFS OCT 24003     ZER 
      ASC 1,ZE
      OCT 51000 
      OCT 25003     CON 
      ASC 1,CO
      OCT 47000                                                           999999
      OCT 26003     IDN                                                     9999
      ASC 1,ID
      OCT 47000 
      OCT 27003     INV 
      ASC 1,IN
      OCT 53000 
      OCT 30003     TRN 
      ASC 1,TR
      OCT 47000 
      HED PHONES LOGIC
* qq
**
***   DATA SET CONTROL BOARD LOGIC
**
* 
DSCBL NOP 
      CLF 0 
      STA PHNA      SAVE
      STB PHNB
      ERA             REGISTERS 
      STA PHNE
      LIA DSCB      LOAD AND SAVE 
      STA NSTAT       PHONES STATUS 
      ALF,RAL 
      RAL 
      AND .+15      A = PORT# 
      ADA TTYTP 
      LDB A,I       B => TTY TABLE
      ADB .+?PPRM 
      LDA B,I       A = PHONES PARAM
      AND .+3       ISOLATE AND SAVE
      STA OSTAT     PHONES STATUS BITS
      LDA NSTAT     STORE NEW 
      STA B,I         PHONES STATUS 
      OTA DSCB      OUTPUT TO PHONES BOARD
      ADB .+?TSTA-?PPRM  B => I/O STATUS
      AND .+3       ISOLATE NEW STATUS BITS 
      XOR OSTAT     TAKE CARE 
      SZA,RSS         OF NOISE
      JMP DEXIT 
      SLA     DID DSR CHANGE? 
      JMP DSC2 YES
      SPC 1 
* 
**    CARRIER STATUS CHANGED
* 
      AND OSTAT 
      RAR,SLA 
      JMP DSC1
* 
*  CONNECTION MADE OR CONNECTION RESTORED WITHIN
*  LINE DROP-OUT TIMING.
*        DSR(OLD)=1     CARRIER(OLD)=0
*        DSR(NEW)=1     CARRIER (NEW)=1 
* 
      LDA B,I       REMOVE LINE 
      AND LDNBT       DROP-OUT BIT
      STA B,I           FROM STATUS 
      JMP DEXIT Tv
* qq
*  LINE DROP-OUT OR HANG UP.
*        DSR(OLD)=1     CARRIER(OLD)=1
*        DSR(NEW)=1     CARRIER(NEW)=0
* 
DSC1  LDA B,I       LOG TIMING OR 
      AND LTLDB       LINE DROP-OUT 
      SZA               BIT SET?
      JMP DEXIT     YES, EXIT 
      LDA B,I       NO, SET LINE
      IOR LDBT        DROP-OUT BIT
      STA B,I 
      ADB .+?PHON-?TSTA 
      LDA .-2       SET FOR TWO 
      STA B,I         SECONDS TIMING
      JMP DEXIT 
      SPC 1 
* 
**    DATA SET READY CHANGED
* *q
DSC2  AND OSTAT 
      SLA 
* 
*  HERE'S JOE COOL ANSWERING THE PHONE -
*  RATS, WRONG NUMBER!
* *q
*    DSR(OLD)=1     CARRIER(OLD)=0 OR =1
*    DSR(NEW)=0     CARRIER(NEW)=0    =0
* qq
      JMP DSC1
* 
*  PHONE JUST ANSWERED OR HARDWIRED TERMINAL CONNECTED
*    DSR(OLD)=0     CARRIER(OLD)=0 OR =0
*    DSR(NEW)=1     CARRIER(NEW)=0    =1
* 
      LDA B,I       LOG TIMING OR 
      AND LTLDB       LINE DROP-OUT 
      SZA               BIT SET?
      JMP DEXIT     YES,EXIT
      LDA B,I       NO, SET LOG 
      IOR LTBT        TIMING BIT
      STA B,I 
      ADB .+?PHON-?TSTA 
      LDA PHR       STORE LOG-ON TIME 
      STA B,I         IN PHONES WORD
      SPC 1 
* 
**   EXIT 
* 
DEXIT LDA PHNE      RESTORE 
      ELA 
      LDA PHNA        REGISTERS 
      LDB PHNB
      CLF DSCB
      STF 0 
      JMP DSCBL,I 
DSCED EQU * 
      SPC 2 
* 
LTLDB EQU B300
OSTAT BSS 1 1z
NSTAT BSS 1 
PHNA  BSS 1 
PHNB  BSS 1 
PHNE  BSS 1 [[
