
      HED MULTIPLEXER DRIVER - END OF PROCESSING
* 
**
***   MULTIPLEXER END OF PROCESSING 
**
* 
MPXEP CLF 0 
      LDA YFLAG     IS Y-MULTIPLEXER FLAG SET?
      SZA 
      JMP MP.Y      YES 
      LDA XFLAG     NO - IS X-MULTIPLEXER FLAG SET? 
      SZA 
      JMP MP.X      YES 
      LDA MPXE      NO - RESTORE
      ELA             E,
      LDA MPXA        A,
      LDB MPXB        AND B 
      CLF MPX       ENABLE X-MULTIPLEXER INTERRUPTS 
      STF 0 
      JMP MPXIO,I 
* 
MP.X  CLA 
      STA XFLAG     CLEAR X-MULTIPLEXER FLAG
      LDA MPYE      RESTORE 
      ELA             E,
      LDA MPYA        A,
      LDB MPYB        AND B 
      CLF MPX       ENABLE X-MULTIPLEXER INTERRUPTS 
      STF 0 
      JMP MPYIO,I 
* 
MP.Y  LDA XFLAG     IS X-MULTIPLEXER
      SZA             FLAG ALSO SET?
      JMP MP.YX     YES 
      STA YFLAG     CLEAR Y-MULTIPLEXER FLAG
      LDA MPYE      RESTORE 
      ELA             E,
      LDA MPYA        A,
      LDB MPYB        AND B 
      CLF MPY       ENABLE Y-MULTIPLEXER INTERRUPTS 
      STF 0 
      JMP MPYIO,I 
* 
MP.YX CLA 
      STA YFLAG     CLEAR Y-MULTIPLEXER FLAG
      CLF MPY       ENABLE Y-MULTIPLEXER INTERRUPTS 
      STF 0 
      JMP MUXX      GO PROCESS X-MPX INTERRUPT
      HED CR AND LF DELAY SUBROUTINES 
* 
*  SUBROUTINE TO SET CR-DELAY.
* 
CRDLY NOP 
      LDA XTYPE,I   IS TERMINAL 
      SZA             A SELECTRIC?
      JMP CRDL1     YES 
      LDB XTNUM     NO
      ADB .+?CDLY 
      LDB B,I       B= ?CDLY
      STB XDCNT,I   SET CR-DELAY=(?CDLY)
      STA XSCNT,I   CLEAR CR DELAY COUNTER
      SZB           ?CDLY=0?
      JMP MPXEP     NO. GO TO END-OF-PROCESSING.
      JMP CRDLY,I   YES. RETURN.
CRDL1 EQU * 
      LDA XSCNT,I   A= ?SCNT.      COMPUTE *********
      ALS           *2
      ADA XSCNT,I   *3                  IBM 2741 ***
      STA XSCNT,I 
      ALF,RAR       *24 
      CLE,ELA                                CR ****
      ADA XSCNT,I   *51 
      ERA 
      ALF,ALF                                DELAY.*
      AND B377      A= (?SCNT):10 
      ADA .+3       A=NR. OF FILL CHARS.
      ADA .-16
      SSA,RSS       LARGER THAN 15? 
      CCA           YES. SET TO 15. 
      ADA .+16      NO. RESTORE.
      CMA,INA       NEGATE. 
      STA XDCNT,I   SET CR-DELAY IN ?DCNT.
      CLA 
      STA XSCNT,I   SET ?SCNT=0.
      JMP MPXEP     GO TO END-OF-PROCESSING.
* 
*  SUBROUTINE TO SET LF-DELAY.
* 
LFDLY NOP 
      LDA XTYPE,I   A= ?TYPE. 
      CCB           B=-1
      SZA           TYPE#1? 
      JMP LFDL2     NO. 
      LDB XTNUM     YES. B=> ?LDLY
      ADB .+?LDLY 
      LDB B,I       B= ?LDLY. 
LFDL2 EQU * 
      STB XDCNT,I   SET LF-DELAY. 
      CLA 
      STA XSCNT,I   SET ?SCNT=0.
      SZB           LF-DELAY=0? 
      JMP MPXEP     NO. GO TO END-OF-PROCESSING.
      JMP LFDLY,I   YES. RETURN.
MPXIE EQU * 
MPYIE EQU * 
      HED LINE PRINTER DRIVER 
* 
**
***      LINE PRINTER DRIVER
**
* 
*    THIS DRIVER IS USED FOR THE 2767A, THE 2778A, AND THE 2610A
*    LINE PRINTERS.  NORMAL ENTRY IS FROM THE IDLE LOOP AND ONCE
*    ENTERED, THE DRIVER REPLACES THE IDLE LOOP UNTIL OUTPUT IS 
*    COMPLETED.  THE FLAG, LPTYP, INDICATES WHICH LINE PRINTER IS 
*    ON THE SYSTEM: 
*        2767A = TYPE -1    2778A = TYPE 0    2610A = TYPE 1
* 
* 
* 
**    DRIVER INITIALIZATION 
* 
LPINT CLA           CLEAR THE 
      STA LFLAG       INITIALIZATION FLAG 
      LDB LPTTY     B => TTY# 
      STB LTNUM 
      INB 
      STB LCCNT     S 
      INB            E
      STB LBPNT       T   B 
      INB              U   U
      STB LBSTR         P   F   P 
      INB                    F   O
      STB LBHED               E   I 
      INB                      R   N
      STB LBSAV                     T 
      INB                            E
      STB LBGIN                       R 
      INB                              S
      STB LBEND 
      INB 
      STB LSTAT 
* 
**    PROCESS NEXT CHARACTER
* 
LPPNC STF 0 
      LDA LPTTY     IF USER NO
      SZA,RSS         LONGER HAS LP,
      JMP IDLEL,I       GO TO IDLE LOOP 
      CLF 0 
      JSB LPCHR     GET NEXT CHARACTER
      STA LCHAR       AND SAVE IT 
      STB LBPNT,I   ADJUST BUFFER POINTER 
      CPA .+23B     CHECK 
      JMP LPSUP       FOR X-OFF 
      CLB 
      STB LPXOF 
      CPA .+15B     CHECK 
      JMP LPCR        FOR CR
      CPA .+12B     CHECK 
      JMP LPLF        FOR LF
      CPA .+14B     CHECK FOR PAGE               [B]
      JMP LPPER       EJECT REQUEST              [B]
      ADA .40       CHARACTER < 40B?
      SSA 
      JMP LPECT     YES - IGNORE IT 
      ADA .100      CHARACTER > 137B? 
      SSA 
      JMP LPOUT     NO - OUTPUT CHARACTER 
      LDA LCHAR     YES.
      LDB LPTYP 
      CPB .+1       IF LP NOT 
      RSS             A 2610A,
      AND B137          REMOVE BIT5 
      CPA B137      CHECK FOR 
      JMP LPECT       RUBOUT
      STA LCHAR 
* 
**    OUTPUT THE CHARACTER
* 
LPOUT STF 0                                      [C]
      JSB LPSCK     CHECK LINE PRINTER STATUS    [C]
      JMP LDWN      LP DOWN 
LOUT2 SFS 0         WAIT UNTIL
      JMP LPOUT       LP NOT BUSY 
      LDA LCHAR 
PSC4  OTA 0         OUTPUT THE
PSC5  STC 0,C         CHARACTER 
* 
**    END OF CHARACTER TRANSMISSION 
* 
LPECT CLF 0 
      LDA LPTTY     IF USER NO
      SZA,RSS         LONGER HAS LP,
      JMP IDLEL,I       GO TO IDLE LOOP 
      ISZ LCCNT,I   INCREMENT CHARACTER COUNT 
      RSS           IF COUNT IS ZERO, GO
      JMP LPEND       TO END OF OUTPUT LOGIC
      JSB LBECK     BUFFER EMPTY CHECK
      JMP LPPNC 
* 
**    NOTIFY SYSTEM - BUFFER CAN TAKE CHARACTERS AGAIN
* 
LBECK NOP 
      LDA LCCNT,I   IS CHARACTER
      ADA .+10        COUNT <= 10?
      SSA 
      JMP LBECK,I   NO
      LDA LSTAT,I   YES 
      AND STNBT     IF 'BUFFER FULL' BIT
      CPA LSTAT,I 
      JMP LBECK,I     IS SET, REMOVE IT AND 
      STA LSTAT,I 
      LDA LTNUM,I       TELL OTHER MACHINE TO 
      IOR BFE 
      JSB IOMTM,I          SEND MORE CHARACTERS 
      JMP LBECK,I 
      SPC 1 
* 
**    END OF OUTPUT PROCESSING
* 
LPEND LDA LBGIN,I   RESET ALL 
      STA LBPNT,I     BUFFER POINTERS 
      STA LBSTR,I       TO THE BEGINNING
      STA LBHED,I         OF THE USER'S 
      STA LBSAV,I           BUFFER
      LDA LSTAT,I   CHANGE
      IOR IOBT        STATUS
      STA LSTAT,I       TO INPUT
      JMP IDLEL,I   GO TO IDLE LOOP 
      SPC 1 
* 
**    GET NEXT CHARACTER
* 
LPCHR NOP 
      LDB LBPNT,I 
      INB           B => NEXT CHARACTER 
      CPB LBEND,I   IF END OF BUFFER
      ADB MBLEN       CHANGE TO BEGINNING 
      LDA B 
      CLE,ERA       POSITION AS WORD POINTER
      LDA A,I       A = WORD CONTAINING CHARACTER 
      SEZ,RSS       POSITION CHARACTER
      ALF,ALF         IN BITS 7-0 
      AND B177      MASK OUT CHARACTER
      JMP LPCHR,I 
      SPC 1 
* 
**    PAGE EJECT REQUEST
* 
LPPER LDB LPTYP     GET LP TYPE FLAG             [B]
      SSB           2778A OR 2610A LINE PRINTER? [B]
      JMP LPOUT     NO, 2767A                    [B]
      LDA PEJCT     YES, A = 2778A PAGE EJECT CODE
      ADA B         ADD 1 FOR 2610A CODE         [B]
      STA LCHAR     SAVE CODE                    [B]
      JMP LPOUT                                  [B]
      SPC 1 
* 
**    LINE PRINT (CR)  AND  PAPER ADVANCE (LF)
* 
LPCR  LDA LPTYP     GET THE LP TYPE FLAG
      SSA           2767A LINE PRINTER? 
      JMP LPCR1     YES - OUTPUT 15B
      CLA,INA       NO, 2778A OR 2610A
      RAR           OUTPUT
      STA LCHAR       100000B 
LPCR1 LDA LCCNT,I   IF THIS IS
      CPA .-1         LAST CHARACTER, 
      JMP LPOUT         OUTPUT IT 
      JSB LPCHR     GET NEXT CHARACTER
      CPA .+12B     IS IT 
      RSS             A 'LF'? 
      JMP LPOUT     NO
      STB LBPNT,I   YES, UPDATE BUFFER POINTER
      ISZ LCCNT,I     AND CHARACTER COUNT 
      STA LCHAR 
      JSB LBECK     BUFFER EMPTY CHECK
* 
LPLF  LDA LPTYP     GET LP TYPE FLAG
      SSA           2767A LINE PRINTER? 
      JMP LPOUT     YES - OUTPUT 12B
      LDA .+3       NO, 2778A OR 2610A
      RAR           OUTPUT
      STA LCHAR       100001B 
      JMP LPOUT 
      SPC 1 
* 
**    LINE PRINTER STATUS CHECK 
* 
LPSCK NOP                                        [C]
PSC1  LIA 0         GET LP STATUS                [C]
      LDB LPTYP     GET LP TYPE FLAG             [C]
      SSB           2778A OR 2610A TYPE LP?      [C]
      JMP LPCK1     NO - 2767A LP                [C]
      SSA,RSS       YES, IS LP READY?            [C]
      JMP LPSCK,I   NO, RETURN TO P+1            [C]
      SLB,RSS       YES, 2610A TYPE LP?          [C]
      JMP LPCK3     NO, 2778A LP                 [C]
      RAL           FOR 2610A, CHECK FOR POWER ON[C]
LPCK1 SSA           FOR 2767A, CHECK FOR LP READY[C]
      JMP LPSCK,I   NO, RETURN TO P+1            [C]
LPCK3 ISZ LPSCK     YES - STATUS OK              [C]
      JMP LPSCK,I   RETURN TO P+2                [C]
      SPC 1 
* 
**    TEMPORARY LINE PRINTER SUSPENSION 
* 
LPSUP LDB LPXOF     X-OFF FLAG SET? 
      SZB 
      JMP *+3       YES 
      ISZ LPXOF     NO, SET IT
      JMP LPECT 
* 
      STF 0 
      LDB LTNUM     IS THE
      ADB .+?TYPE     CIRCLE D
      LDA B,I           INTERRUPT 
      AND BIT8            CLEARED?
      SZA 
      JMP *-3       NO - WAIT 
      CLF 0 
      LDB LPTTY     SET TEMPORARY LP
      STB TLSUP       SUSPENSION FLAG AND 
      STA LPTTY         CLEAR LP USER FLAG
      STA LPXOF 
      ISZ LCCNT,I 
      JSB LBECK     BUFFER EMPTY CHECK
      SKP 
* 
**      START TTY OUTPUT
* 
LSYNC LDB LTNUM 
      ADB .+?TYPE   B=> ?TYPE 
      LDA B,I      IF SELCTRIC AND
      SZA,RSS       BIT12 IS SET, 
      JMP LSYN1     SET BIT8. 
      AND BIT12 
      SZA,RSS 
      JMP LSYN1 
      LDA B,I 
      IOR BIT8
      STA B,I 
LSYN1 LDA SYNCC     GET SYNC CHARACTER. 
      LDB B,I       ADD BIT7 FOR SELECTRIC. 
      SZB 
      IOR SLBIT 
      LDB LTNUM,I   GET TTY#
      JSB IMUXR,I    OUTPUT SYNC CHARACTER
      JMP IDLEL,I   GO TO IDLE LOOP 
      SPC 4 
* 
**
***     LINE PRINTER DOWN PROCESSING
**
* 
LDWN  CLF 0 
      LDA LPTTY     IF USER NO
      SZA,RSS         LONGER HAS LP,
      JMP IDLEL,I       GO TO IDLE LOOP 
      LDA LSTAT,I   IS OTHER MACHINE
      IOR STBT        STILL SENDING 
      CPA LSTAT,I       CHARACTERS
      JMP LDW1      NO
      STA LSTAT,I   YES, SET 'BUFFER FULL' BIT
      LDA LTNUM,I   TELL OTHER MACHINE
      IOR BFL         TO STOP SENDING 
      JSB IOMTM,I      CHARACTERS 
LDW1  CLF 0 
      LDA LBPNT,I 
      STA LPBT1     SAVE
      LDA LCCNT,I     BUFFER
      STA LPBT2         POINTERS
      LDA DMBPT 
      STA LBPNT,I   SET ERROR 
      LDA .-10        BUFFER
      STA LCCNT,I       POINTERS
      LDB LTNUM 
      STB LPERF     SET LP ERROR FLAG 
      STF 0 
      ADB .+?TYPE    IS THE 
      LDA B,I         CIRCLE D
      AND BIT8          INTERRUPT 
      SZA                 CLEARED?
      JMP *-3       NO - WAIT 
      STA LPTTY     CLEAR LP USER INDICATOR 
      JMP LSYNC     START TTY OUTPUT
      SPC 2 
* 
**      LINE PRINTER DOWN RETURN
* 
LDWNR LDA LPERF 
      STA LPTTY 
      CLA           CLEAR LP DOWN 
      STA LPDRF       RETURN FLAG 
      STA LPERF 
      LDA LPBT1 
      STA LBPNT,I   RESTORE 
      LDA LPBT2       BUFFER
      STA LCCNT,I       POINTERS
      ADA .+10      IS CHARACTER
      SSA             COUNT 10 OR LESS? 
      JMP LDWN0     NO
      LDA LTNUM,I   YES - TELL OTHER
      IOR BFE         MACHINE TO SEND 
      JSB IOMTM,I      MORE CHARACTERS
      LDA LSTAT,I   REMOVE THE
      AND STNBT       'BUFFER FULL' 
      STA LSTAT,I       BIT 
LDWN0 STF 0 
LDWN1 EQU *                                      [C]
      LDB LPTTY     IF USER NO
      SZB,RSS         LONGER HAS LP,
      JMP IDLEL,I       GO TO IDLE LOOP 
      JSB LPSCK     CHECK LINE PRINTER STATUS    [C]
      JMP LDWN1     STILL DOWN                   [C]
      JMP LPOUT     OK - CONTINUE                [C]
* 
      HED PROCESS OUTPUT CHARACTER ROUTINE
* 
**
***       PROCESS OUTPUT CHARACTER
**
* 
*   THIS ROUTINE PLACES CHARACTERS IN THE USER'S BUFFER AND HANDLES 
*   THE FOLLOWING THREE SPECIAL CASES:
*       1) STATUS IS INPUT - THE USER'S STATUS IS CHANGED TO OUTPUT 
*          AND A SYNCHRONIZING SIGNAL IS SENT TO THE USER'S TELETYPE
*          UNLESS CONDITION #2. 
* 
*       2) LINE PRINTER IS OUTPUT DEVICE - THE LINE PRINTER 
*          INITIALIZATION FLAG IS SET.
* 
*       3) BUFFER FULL - THE USER IS PLACED IN OUTPUT WAIT STATUS.
* 
      SPC 1 
POC   STB PTNUM     SAVE TTY TABLE POINTER
      ADB .+?STAT 
      LDA B,I       A = USER'S STATUS 
      AND IOBT      IS USER IN
      SZA             OUTPUT MODE?
      JSB OINIT     NO - GO INITIALIZE FOR OUTPUT 
      LDA RCODE     GET REQUEST WORD
      AND B377      MASK CHARACTER
      STA PCHAR       AND SAVE IT 
      LDB PTNUM 
      ADB .+?BSTR   B => BUFFER TAIL
      LDA B,I 
      INA           A = LOCATION FOR THIS CHARACTER 
      ADB .+?BEND-?BSTR 
      CPA B,I       IF A => BEYOND END OF BUFFER, 
      ADA MBLEN       PERFORM WRAPAROUND
      ADB .+?BSTR-?BEND 
      STA B,I       SET NEW POINTER VALUE 
      LDB A         B = CHARACTER ADDRESS 
      CLE,ERB       B = WORD ADDRESS
      LDA B,I       A = DESTINATION WORD
      SEZ,RSS       IF HIGH CHARACTER,
      ALF,ALF         ROTATE TO BOTTOM
      AND HIMSK     CLEAR LOWER 8 BITS
      IOR PCHAR     MERGE WITH NEW CHARACTER
      SEZ,RSS       IF HIGH CHARACTER,
      ALF,ALF         ROTATE BACK 
      STA B,I       STORE BACK IN BUFFER
      LDB PTNUM 
      CPB LPERF 
      LDB LPBT
      INB           B => CHARACTER COUNT
      CCA           INCREMENT 
      ADA B,I         CHARACTER 
      STA B,I           COUNT 
      CPA MAXBL     IS BUFFER FULL? 
      RSS 
      JMP SRRTN     NO - RETURN 
      SKP 
* 
*     BUFFER FULL PROCESSING
* 
      ADB .+?STAT-?CCNT 
      LDA B,I       A = STATUS
      IOR STBT      SET 'TURNED OFF' BIT
      STA B,I       RESTORE STATUS
      LDA PTNUM,I   GET USER'S TTY# 
      IOR BFL       ADD BUFFER FULL CODE
      JSB IOMTM,I      AND TELL OTHER MACHINE 
      JMP SRRTN     RETURN
      SPC 1 
* 
**    OUTPUT INITIALIZATION ROUTINE 
* 
OINIT NOP 
      XOR B,I       REMOVE
      STA B,I         INPUT BIT 
      ADB .+?CCNT-?STAT 
      CLA           SET CHARACTER 
      STA B,I         COUNT TO ZERO 
      ADB .+?BGIN-?CCNT 
      LDA B,I       A = POINTER TO BUFFER HEAD
      ADB .+?BPNT-?BGIN 
      STA B,I       RESET ALL BUFFER
      INB 
      STA B,I         POINTERS TO THE 
      INB 
      STA B,I           BEGINNING OF THE
      INB 
      STA B,I             USER'S BUFFER 
      ADB .+?TNUM-?BSAV  B = TTY# ADDRESS 
      CPB LPTTY     DOES THIS USER HAVE THE LP? 
      JMP POINT     YES 
      ADB .+?STAT 
      LDA B,I       A= STATUS 
      IOR NIBT      IS PORT SETUP 
      CPA B,I         FOR OUTPUT? 
      JMP OINT0     YES.
      STA B,I       NO, SET "NO INPUT ALLOWED" BIT
      ADB .+?RPRM-?STAT 
      LDA B,I 
      AND NECHO     MAKE SURE 
      LDB PTNUM,I     USER'S ECHO IS
      JSB IMUXR,I      TURNED OFF 
      LDB PTNUM 
      ADB .+?TYPE   GET THE 
      LDA B,I         TERMINAL TYPE 
      SZA,RSS       SELECTRIC?
      JMP OINT1     NO
      IOR TRINT     PREPARE UNIT
      STA B,I         FOR TRANSMIT
      JMP OINT3         INTERRUPT 
OINT0 ADB .+?TYPE-?STAT 
      LDA B,I 
      SZA           BRANCH IF PORT
      JMP OINT2       IS A SELECTRIC
OINT1 ADB .+?CDLY-?TYPE     GET 
      LDA B,I              CR DELAY 
      INA               IF ANY
      SSA,RSS 
      JMP OINT3     NO DELAY
      RSS 
OINT2 LDA .-14      SELECTRIC DELAY 
      LDB PTNUM 
      ADB .+?DCNT 
      STA B,I       STORE DELAY AND 
      CCA             INCREMENT 
      ADB .+?CCNT-?DCNT  CHARACTER
      STA B,I              COUNT
      INB 
      LDA B,I       A = CHARACTER POINTER 
      INA           INCREMENT 
      INB             CHARACTER 
      STA B,I           POINTER 
OINT3 LDA SYNCC     GET SYNC CHARACTER
      LDB PTNUM 
      ADB .+?TYPE   ADD BIT 7 
      LDB B,I         FOR SELECTRICS
      SZB 
      IOR SLBIT 
      LDB PTNUM,I   GET TTY#
      JSB IMUXR,I    OUTPUT SYNC CHARACTER
      JMP OINIT,I 
* 
**    LINE PRINTER OUTPUT INITIALIZATION
* 
POINT CLA,INA 
      STA LFLAG     SET LP INITIALIZATION FLAG
      ADB .+?TYPE   IF USER HAS 
      LDA B,I         A SELECTRIC 
      AND BIT8          AND IS IN INPUT 
      SZA,RSS             MODE - -
      JMP OINIT,I 
      LDA CRCLD           OUTPUT
      LDB PTNUM,I           CIRCLE D
      JSB IMUXR,I              TO HIS PORT
      JMP OINIT,I 
      HED SERVICE ROUTINES
* 
**    LINE PRINTER SELECT CODE
* 
PSC   EQU * 
      CLB           B = 0 
      LDA RCODE     GET SELECT CODE AND TYPE
      ALF,ALF       MOVE SC TO RIGHT END
      SSA 
      INB           LP TYPE:
      RAL             B = -1  2767A 
      SSA                  0  2778A 
      CCB                  1  2607A,2610-14,2613-18 
      RAR 
      AND B37       MASK TO SELECT CODE 
      STA PRISC     STORE IN SC INDICATOR 
      SZA,RSS       IS SELECT CODE = 0? 
      JMP PSC10     YES - REMOVE USER IF ANY     [B]
      STB LPTYP     SET LP TYPE FLAG
      STA B         B = SC
      LDA PSC.      FORM  CLC SC
      IOR B 
      STA B,I 
      LDA PSC1      FORM  LIA SC
      AND SCMSK 
      IOR B 
      STA PSC1
      LDA PSC2      FORM  OTA SC
      AND SCMSK 
      IOR B 
      STA PSC2
      STA PSC4
      LDA PSC3      FORM  STC SC,C
      AND SCMSK 
      IOR B 
      STA PSC3
      STA PSC5
      LDA LOUT2     FORM  SFS SC
      AND SCMSK 
      IOR B 
      STA LOUT2 
PSC10 JSB LPCLR,I   REMOVE USER IF ANY           [B]
      JMP SRRTN                                  [B]
      SKP 
