      HED SYSTEM CONSOLE DRIVER 
* THE SYSTEM CONSOLE DRIVER CONTROLS ALL TRANSMISSION OF DATA BE- 
* TWEEN THE SYSTEM CONSOLE (ASR-35) AND THE SYSTEM. IT HANDLES ALL
* * IO FOR THE DEVICE AND PROVIDES FOR COMMUNICATION OF MESSAGES TO 
* THE SYSTEM, THE FOLLOWING VARIABLES ARE SIGNIFICANT:
* 
* T35F1: =0 DURING INPUT, -1 DURING OUTPUT. 
* T35F2: NORMALLY 0, IT IS SET TO -1 WHEN A COMPLETE MESSAGE HAS
*        BEEN RECEIVED. UNTIL IT IS CLEARED BY THE SYSTEM, ALL FUR- 
*        THER INPUT IS INHIBITED. 
* T35F3: NORMALLY 0, IT IS SET TO -1 WHEN A COMPLETE MESSAGE HAS
*        BEEN RECEIVED.  UNTIL IT IS CLEARED BY THE OUTPUT
*        INITIALIZATION SECTION OF THE DRIVER, LOG AND MESSAGE
*        ENTLRIES ARE HELD OFF. 
* TOG:   NOT USED DURING INPUT. DURING OUTPUT, BIT 0 = 0 IF NEXT
*        CHARACTER IS ON LEFT, 1 IF ON RIGHT. 
* TADR:  NOT USED DURING INPUT. DURING OUTPUT, TADR(14:0) POINTS TO 
*        THE WORD FROM WHICH THE NEXT CHARACTER WILL BE TAKEN.
*        BIT 15=1 FOR PUNCH & PRINT, 0 FOR PRINT ONLY.
* TCNT:  DURING INPUT, TCNT=# OF CHARS IN SO FAR. DURING OUTPUT,
*        TCNT(14:0)=# OF CHARS REMAINING TO BE OUTPUT, BIT 15=0 
*        IF A CRLF IS TO BE APPENDED, 1 IF NOT. 
* TBITS: CONTAINS CURRENT CONTROL BITS. 
*         120000 => PRINT 
*         130000 => PUNCH AND PRINT 
*         160000 => INPUT 
* TTA,TTB,TTE: USED TO SAVE THE VALUES OF A,B,E REGISTERS DURING
*        INTERRUPTS.
* 
* CALLING SEQUENCE: 
*     JSB TTY35,I  A=# OF CHARS (BIT 15=0 FOR CRLF, 1 FOR NONE) 
*                  B=BUFFER ADDRESS (BIT 15=1 FOR PUNCHING) 
* qq
* INPUT MESSAGES ARE STORED IN THE 72 CHARACTER BUFFER T35BF. 
* qq
      SPC 2 
?TT35 NOP           ENTRY POINT FOR OUTPUT. 
      CLF 0         INHIBIT INTERRUPT.
      STA TCNT      SET UP INITIAL PARAMETERS.
      STB TADRDn
      CCA           SET FLAG TO SAY 
      STA T35F1      OUTPUT.
      LDA ?TT35     COPY RETURN ADDRESS INTO THAT OF
      STA ?TT2       INTERRUPT SECTION. 
      CLA           SET TOG TO SAY LEFT HAND CHAR.
      STA TOG G#
      STA T35F3 
* 
* TEST FOR PENDING INPUT. IF THERE IS ANY, EXIT IMMEDIATELY AND LET 
* THE INTERRUPT TRIGGER THE FIRST OUTPUT CHARACTER. 
* 
      LIA ?SC 
      SSA,RSS 
      JMP TT18      NONE PENDING--GO OUTPUT 1ST CHAR. 
      STF 0 
      JMP ?TT35,I 
* 
* INTERRUPT SECTION 
* 
?TT2  NOP P+
      STA TTA       SAVE REGISTERS. 
      STB TTB 
      ERA 
      STA TTE 
      LDA T35F1     TEST FLAG TO DETERMINE IF 
      SZA,RSS        INPUT OR OUTPUT. 
      JMP TT17      INPUT 
      LIA ?SC       LOAD BACK LINE STATUS DURING OUTPUT 
      LDB T35ST     GET CONSOLE STATUS           B] 
      CPB %OUTW     IF STATUS IS OUTPUT          B] 
      LDB T35PR       WAIT, USE PRIORITY         B] 
      CMB,INB                                    B] 
      ADB %RUN-COM2+ROS                          [E]
      SSB,RSS       ABORTABLE LIBRARY ROUTINE?   B] 
      CPA B377      YES, CHECK FOR A KEY STRUCK  B] 
      JMP TT18      NO INPUT, CONTINUE ON 
      CLA 
      STA T35F2     CLEAR CONTINUEING OUTPUT FLAG 
      STA T35ST     SET CONSOLE STATUS TO IDLE
* qq
TT18  LDA TCNT       GET # OF CHARS LEFT. 
      RAL,CLE,ERA   COPY CRLF BIT INTO E. 
      LDB FILCT     PRINTING FILL CHARACTERS?     (D) 
      ISZ FILCT     CHECK IF DONE                 (D) 
      SSB,RSS       MAKE SURE FILCT IS NEGATIVE   (D) 
      JMP TT7       POSITIVE OR DONE            (D) 
      LDA B377      GET FILL CHARACTER           [E]
      JMP TT8                                     (D) 
* qq
TT7   SZA           ANY CHARACTERS LEFT?        (D) 
      JMP TT5       YES--GO OUTPUT NEXT ONE.
      SEZ           NO--WANT CRLF?
      JMP TT6       NO--GO RESET FOR INPUT. 
      STA TOG       SET UP OUTPUT OF CRLF.
      LDA .+3       3 CHARS WITH
      IOR BIT15      NO CRLF FOLLOWING. 
      STA TCNT
      LDA TADR      KEEP PRINT/PUNCH BIT. 
      AND BIT15 
      IOR TTXCP 
      STA TADR
      JMP TT18
* qq
* END OF OUTPUT--RESET FOR INPUT. 
* 
TT6   STA TCNT      SET COUNTER TO SAY NO CHARS IN. 
      STA T35F1     SET FLAG TO SAY INPUT.
      LDA B160K     GET CONTROL BITS FOR INPUT. 
      STA TBITS     SAVE. 
TT8   OTA ?SC       OUTPUT TO CONSOLE.
TT10  LDA TTE       RESTORE REGISTERS.
      ELA 
      LDA TTA 
      LDB TTB B2
      STC ?SC,C     ENABLE DEVICE.
      STF 0         ENABLE INTERRUPT. 
      JMP ?TT2,I    EXIT. 
* qq
* OUTPUT NEXT CHARACTER 
* qq
TT5   CCA           DECREMENT 
      ADA TCNT       COUNTER. 
      STA TCNTN8
      LDB TADR      GET POINTER TO OUTPUT BUFFER. 
      LDA B120K     GET BITS FOR PRINT ONLY.
      RBL,CLE,SLB,ERB    TEST & CLEAR BIT 15 OF B.
      LDA B130K     GET PRINT/PUNCH BITS. 
      STA TBITS     SAVE CONTROL BITS.
      OTA ?SC       OUTPUT TO DEVICE. 
      LDA 1,I       GET WORD CONTAINING CHARACTER.
      LDB TOG       GET LEFT/RIGHT TOGGLE.
      SLB           IF RIGHT CHARACTER, 
      ISZ TADR       BUMP POINTER.
      SLB,RSS       IF LEFT CHARACTER,
      ALF,ALF        POSITION ON RIGHT. 
      ISZ TOG       REVERSE TOGGLE SENSE. 
TT15  AND B177      KEEP BITS 6-0 AND 
      IOR B200       SET BIT 7. 
      LDB FILLR     GET # OF FILL CHARACTERS      (D) 
      CPA B212      PRINTING A LINE FEED?         (D) 
      STB FILCT     YES, FOLLOW WITH FILLS        (D) 
      JMP TT8       GO OUTPUT CHARACTER.
* 
* CHARACTER HAS BEEN INPUT. 
* 
TT17  LDA T35F2     IGNORE CHARACTER IF T35F2 IS SET
      MIA 1          OR SWITCH 0 IS SET.
      SLA 
      JMP TT10
      LIA ?SC       GET CHARACTER IN A. 
      AND B177
      CCB           PREPARE -1 IN B.
      CPA .+12B     IGNORE LF, RUBOUT, NULL, XOFF.
      JMP TT10
      CPA B177
      JMP TT10
      SZA 
      CPA .+23B 
      JMP TT10
* 
**   TEST FOR 'CONTROL X' 
* 
      CPA .+30B 
      JMP TT11
* qq
      CPA BKSPC     TEST FOR "_"
      JMP TT12
      CPA .+15B     TEST FOR CR.
      STB T35F2     SET COMMUNICATION FLAG. 
      CPA .+15B 
      STB T35F3 3?
* qq
* NOW INSERT CHARACTER IN BUFFER. 
* 
      LDB TCNT      GET COUNT IN B. 
      CPB ?72       DON'T IF BUFFER IS FULL.
      JMP TT10
      CLE,ERB       MOVE LEFT/RIGHT BIT TO E, AND 
      ADB T35B1      COMPUTE ADDRESS OF DESTINATION.
      SEZ,RSS       LEFT/RIGHT TEST.
      ALF,SLA,ALF   LEFT. 
      IOR 1,I       RIGHT.
      ISZ TCNT      BUMP COUNTER. 
TT16  STA 1,I        STORE IN BUFFER. 
      JMP TT10      GO EXIT.
* 
* HANDLE BACKSPACE. 
* 
TT12  LDB TCNT      GET CHARACTER COUNT 
      SZB,RSS       IGNORE IF NO CHARS YET. 
      JMP TT10
      ADB .-1       GET NEW TCNT. 
      STB TCNT
      CLE,ERB       CLEAR RIGHT HALF OF NEW DESTIN- 
      ADB T35B1     ATION.
      LDA 1,I 
      AND HIMSK 
      JMP TT16
* *q
**   HANDLE 'CONTOL X'
* 
TT11  STB T35F1     SET OUTPUT FLAG.
      CLA           SET TCNT FOR CRLF AFTER "\".
      STA TCNT
      STA TADR      SET FOR NO PUNCHING 
      LDA B120K     SET FOR PRINT ONLY. 
      STA TBITS 
      OTA ?SC 
      LDA RVRSL     GO OUTPUT "\" 
      JMP TT15
TTYED EQU * 
TTXCP DEF *+1 
      OCT 11415 
      OCT 5000
FILCT DEC -1                                    (D) 
B212  OCT 212       LINE FEED                   (D) 
      HED MULTIPLEXER OUTPUT ROUTINE
* 
**
***    MULTIPLEXER OUTPUT ROUTINE 
**
* 
*   THIS ROUTINE HANDLES ALL OUTPUT TO BOTH MULTIPLEXER BOARDS. 
*   THE FORMAT IS AS FOLLOWS: 
*               A REGISTER = DATA 
*               B REGISTER = UNIT NUMBER
* 
MUXOR NOP 
      CLF 0         STOP INTERRUPTS 
      STA ATEMP     SAVE A
      RBL,RBL       POSITION UNIT NUMBER
      LIA MPX+1     WAIT FOR
      SSA             SEEKING BIT 
      JMP *-2           TO CLEAR
      LDA ATEMP     RESTORE A 
      OTA MPX       OUTPUT DATA 
      OTB MPX+1       AND UNIT NUMBER 
      STC MPX X
      JMP MUXOR,I   RETURN
MUXND EQU * 
      SPC 1 
* qq
**        MULTIPLEXER CONSTANTS AND TEMPORARIES 
* 
XTNUM BSS 1         =>  PORT NUMBER 
XCCNT BSS 1         =>  CHARACTER COUNT 
XBPNT BSS 1         =>  RUNNING BUFFER POINTER
XBSTR BSS 1         =>  START OF BUFFER 
XBHED BSS 1         =>  START OF FIRST BUFFER 
XBGIN BSS 1         =>  START OF PHYSICAL BUFFER
XBEND BSS 1         =>  END OF PHYSICAL BUFFER
XSTAT BSS 1         =>  STATUS
XDCNT BSS 1         =>  CR AND LF DELAY COUNT 
XRPRM BSS 1         =>  RECEIVE PARAMETER 
XMASK BSS 1         => MASK WORD
XCHAR BSS 1         TEMPORARY CHARACTER STORAGE 
XTPNT BSS 1         BUFFER POINTER TEMPORARY
MPXA  BSS 1         MULTIPLEXER 
MPXB  BSS 1           REGISTER
MPXE  BSS 1             STORAGE 
MPXLC BSS 1         LOWER MPX SC STORAGE
MPXUC BSS 1         UPPER MPX SC STORAGE
      SPC 1 
* 
**    GENERAL USAGE CONSTANTS 
* *q
DMASK OCT 43400 
SCLER OCT 71102 
ATEMP BSS 1 
      HED MULTIPLEXER DRIVER
* *q
**    DRIVER INITIALIZATION 
* qq
MPXIO NOP 
      STA MPXA      S   A,
      STB MPXB       A   B, 
      ERB             V   AND 
      STB MPXE         E   E
      LIA MPX       GET MPX 
      STA MPXLC       STATUS
      LIA MPX+1         AND 
      STA MPXUC           SAVE IT 
      ALF           MOVE TTY# TO
      RAL,RAL         RIGHT END AND 
      AND B17           MASK TO 4 BITS
      ADA TTYTP     ADD ON TTY TABLE POINTER
      LDB A,I       B => TTY# 
      STB XTNUM     SAVE
      INB           B => CHARACTER COUNT
      STB XCCNT 
      INB           B => RUNNING BUFFER POINTER 
      STB XBPNT 
      INB           B => START OF BUFFER
      STB XBSTR 
      INB           B => START OF FIRST BUFFER
      STB XBHED 
      INB           B => START OF PHYSICAL BUFFER 
      STB XBGIN N@
      INB           B => END OF PHYSICAL BUFFER 
      STB XBEND 
      INB           B => STATUS 
      STB XSTAT 
      INB           B => DELAY COUNTER
      STB XDCNT 
      ADB .+?RPRM-?DCNT  B=> RECEIVE PARAMETER
      STB XRPRM 
      ADB .+?MASK-?RPRM  B => MASK
      STB XMASK 
      LDA MPXLC     GET CHARACTER.
      AND B1777     IS IT A BREAK?
      SZA,RSS 
      JMP ABORT     YES - GO TO ABORT LOGIC 
      LDA MPXUC     NO - GET STATUS AND 
      SLA             TEST FOR INPUT
      JMP MPXOP     NO GO TO OUTPUT LOGIC 
      LDA XSTAT,I   GET USER'S STATUS 
      AND NIBT      IS INPUT ALLOWED? 
      SZA           YES 
      JMP MPXEP     NO - IGNORE IT
      HED MULTIPLEXER DRIVER - RECEIVE CHANNEL PROCESSING 
* 
**
***   RECEIVE CHANNEL PROCESSING
**
* qq
      LDA MPXLC     GET DATA WORD 
      AND B177      MASK DATA BITS
      STA XCHAR 
      LDB A         B = CHARACTER 
      LDA XSTAT,I   A = STATUS
      AND XOBT      CHECK FOR X-OFF BIT 
      SZA 
      JMP INPX      YES 
      LDA XSTAT,I   A = STATUS
      AND CXBT      CHECK FOR CANCEL BIT
      SZA,RSS 
      JMP INPX0     NONE
* 
*     TAPE MODE - IGNORE CHARACTERS UNTIL 'CR'
* qq
INPX  XOR XSTAT,I   REMOVE CANCEL OR X-OFF
      CPB .+15B       BIT IF CHARACTER IS A 
      STA XSTAT,I       CARRIAGE RETURN 
      JMP MPXEP 
* *q
**    TEST THE CHARACTER
* 
INPX0 CPB CANCL     TEST FOR 'CONTROL X'
      JMP INPX2 2:
      CPB BKSPC     TEST FOR BACKSPACE
      JMP INPX7 
      SZB           IGNORE FEED FRAMES
      CPB B177        AND RUBOUTS 
      JMP MPXEP 
      CPB .+12B     IGNORE LINEFEEDS
      JMP MPXEP 
      CPB .+23B     TEST FOR X-OFF
      RSS 
      JMP INPX1     NO
      LDA XSTAT,I   YES 
      AND XOFBT     TEST FOR SPECIAL            [E] 
      SZA,RSS         X-OFF PROCESSING
      JMP MPXEP     NO - IGNORE CHARACTER 
      LDA XSTAT,I   YES 
      IOR XOBT      SET X-OFF BIT 
      STA XSTAT,I     AND REPLACE THE 
      LDA .+15B         X-OFF WITH A CR 
      STA XCHAR 
* 
**    APPEND CHARACTER TO BUFFER
* 
INPX1 LDA XBPNT,I   A => POSITION FOR THIS CHARACTER
      INA           A => POSITION FOR NEXT CHARACTER
      CPA XBEND,I   IF A => BEYOND END OF BUFFER, 
      ADA MBLEN       MAKE IT POINT TO START
      CPA XBHED,I   IF BUFFER FULL, TRANSFER
      JMP INPX2       FOR SPECIAL HANDLING
      LDB XBPNT,I   B => ADDRESS FOR THIS CHARACTER 
      STA XBPNT,I   SAVE THE INCREMENTED POINTER
      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 XCHAR     MERGE WITH NEW CHARACTER
      SEZ,RSS       IF HIGH CHARACTER,
      ALF,ALF         ROTATE BACK 
      STA B,I       STORE BACK IN BUFFER
      LDA XCHAR     IF CHARACTER
      CPA .+15B       WAS A 'CR'
      JMP INPX4         GO PROCESS IT 
      JMP MPXEP 
* qq
**    PROCESS 'CONTROL X'  (CANCEL) 
* 
INPX2 LDA XBSTR,I   RESET BUFFER POINTER
      STA XBPNT,I     TO BEGINNING
      LDA XMASK,I   IS USER IN
      AND TAPEF       TAPE MODE?
      SZA 
      JMP INPX3     YES 
      LDB XBSTR,I   NO, MOVE
      CLE,ERB         REVERSE 
      LDA RVRSL         SLASH AND 
      STA B,I             CR LF TO
      INB                   USER'S
      LDA CRLF                BUFFER
      STA B,I 
      LDA .-3       SET CHARACTER 
      STA XCCNT,I     COUNT TO -3 
      LDA XSTAT,I   CHANGE
      AND IONBT       STATUS
      STA XSTAT,I       TO OUTPUT 
      AND RNBT      IF USER NOT 
      SZA,RSS         RUNNING 
      JSB OTPUT     STOP INPUT
      LDA SYNCC 
      LDB XTNUM,I 
      JSB MUXR,I     OUTPUT 
      JMP MPXEP 
* 
INPX3 LDA XSTAT,I   SET THE 
      IOR CXBT        CANCEL BIT
      STA XSTAT,I       IN STATUS 
      JMP MPXEP 
* 
**    PROCESS CARRIAGE RETURN 
* 
INPX4 LDA XMASK,I   IS USER IN
      AND TAPEF       TAPE MODE?
      SZA             TAPE MODE?
      JMP INPX6     YES 
      JSB OTPUT     NO, CHANGE STATUS AND MPX PARAMS
* *q
**    INFORM SYSTEM OF COMPLETE LINE
* qq
INPX5 LDA XMASK,I   SET THE 
      IOR MPCOM       COMMUNICATION 
      STA MPCOM         FLAG
      JMP MPXEP Pk
* *q
INPX6 LDA XBSTR,I   GET POINTER TO BEGINNING
      LDB XBPNT,I     OF CURRENT BUFFER AND RESET 
      STB XBSTR,I       TO CURRENT CHARACTER
      CPA XBHED,I   IF BUFFER JUST COMPLETED WAS
      JMP INPX5       FIRST, TELL OTHER MACHINE 
      JMP MPXEP 
* qq
**    PROCESS BACKSPACE 
* 
INPX7 LDA XBPNT,I   GET BUFFER POINTER
      CPA XBSTR,I   IF NO CHARACTERS
      JMP MPXEP       RETURN IMMEDIATELY
      CPA XBGIN,I   IF AT BEGINNING OF PHYSICAL 
      ADA BLEN        BUFFER, MOVE TO END 
      ADA .-1       BACK-UP ONE SPACE 
      STA XBPNT,I nn
      JMP MPXEP 
* 
**    STOP INPUT - CONFIGURE SEND CHANNEL 
* qq
OTPUT NOP 
      LDA XSTAT,I   A = STATUS
      IOR NIBT        'NO INPUT ALLOWED'
      STA XSTAT,I     BIT 
      LDA XRPRM,I   A = RECEIVE PARAMETER 
      AND NECHO         ECHO
      LDB XTNUM,I   GET UNIT NUMBER 
      JSB MUXR,I     OUPUT TO MUX 
      STF 0 
      JMP OTPUT,I 
      HED MULTIPLEXER DRIVER - ABORT PROCESSING 
* *q
**tt
***  ABORT PROCESSING 
**
* qq
ABORT CLF 0 
      LDA MPXUC     GET MUX STATUS AND TEST 
      SLA             FOR RECEIVE INTERRUPT 
      JMP MPXOP     NO - OUTPUT NEXT CHARACTER
      LDA XSTAT,I   A = STATUS
      AND NIBT      CHECK FOR 
      SZA,RSS         OUTPUT MODE 
      JMP MPXEP     INPUT MODE - IGNORE 
      LDA XSTAT,I I
      AND UNABT     UNABLE TO 
      SZA,RSS         ABORT?
      JMP ABT1      NO
      LDA XSTAT,I   YES, SET
      IOR ABTRY       'ABORT TRY' 
      STA XSTAT,I       BIT IN STATUS 
      JMP MPXEP 
* 
ABT1  LDB XTNUM 
      ADB .+?STAT 
      LDA B,I       A = SYSTEM STATUS 
      CPA %SYNT     CHECK FOR SYNTAX
      JMP MPXEP     CANN'T ABORT OUT OF SYNTAX
      ADA .+.-%RUN+COM2-COM3
      SSA           SKIP IF LIBRARY PROGRAM,
      JMP ABT2        OTHERWISE ABORT ALWAYS ALLOWED
      ADA %RUN-COM2+CAT 
      CMA,INA       ABORTABLE 
      ADA B,I         LIBRARY 
      SSA               PROGRAM?
      JMP MPXEP     NO
      LDA B,I       MAYBE 
      CMA,INA 
      ADA %RUN-COM2+LIBRY 
      SSA Au
      JMP MPXEP     NO
* 
ABT2  LDA XSTAT,I 
      AND SCLER     CLEAR STATUS BITS 
      IOR IOBT      SET 'INPUT MODE' BIT
      STA XSTAT,I   STORE NEW I/O STATUS
      CCA           CHANGE USER'S SYSTEM
      STA B,I         STATUS TO -1
      LDA XMASK,I   SET THE 
      IOR MPCOM       COMMUNICATION 
      STA MPCOM         FLAG
      JMP MPXEP 
      HED MULTIPLEXER DRIVER - SEND CHANNEL PROCESSING
**
* 
***   SEND CHANNEL PROCESSING 
**tttt
* 
MPXOP LDB XCCNT,I   IF NO CHARACTERS
      SZB,RSS         LEFT, GO TO END OF
      JMP MPXEO         OUTPUT PROCESSING 
      LDB XBPNT,I   B => BUFFER POINTER 
      INB           B => NEXT CHARACTER 
      CPB XBEND,I   IF END OF BUFFER, 
      ADB MBLEN       CHANGE TO BEGINNING 
      STB XTPNT     SAVE POINTER
      LDA XDCNT,I   CHECK DELAY COUNTER FOR CR
      SZA             OR LF DELAY IN PROGRESS 
      JMP DELAY     GO TO DELAY PROCESSING
      CLE,ERB       POSITION AS WORD POINTER
      LDA B,I       A = WORD CONTAINING CHARACTER 
      SEZ,RSS       POSITION CHARACTER
      ALF,ALF         IN BITS 7-0 
      AND B177      MASK OUT CHARACTER
      STA XCHAR       AND SAVE IT 
      IOR DMASK     ADD STOP AND PARITY BITS
      LDB XTNUM,I   B = UNIT NUMBER 
      JSB MUXR,I     OUTPUT CHARACTER 
      STF 0 
      LDA XCHAR     A = CHARACTER 
      CPA .+15B     IF CHARACTER IS 
      JSB CRDLY       CR, SET UP DELAY
      CPA .+12B     IF CHARACTER IS 
      JSB LFDLY       LF, SET UP DELAY
* 
**    ADJUST BUFFER POINTERS
* 
BUFAD CLF 0 
      LDA XTPNT     GET BUFFER POINTER TEMPORARY
      STA XBPNT,I   RESET BUFFER POINTER
      ISZ XCCNT,I   INCREMENT CHARACTER COUNT 
      RSS           IF COUNT IS ZERO, GO
      JMP MPXEP       TO MUX END OF PROCESSING
      LDA XCCNT,I   GET CHARACTER COUNT 
      STF 0 
      CPA .-10      ARE EXACTLY 10
      RSS             CHARACTERS LEFT?
      JMP MPXEP     NO - CONTINUE 
* 
**    NOTIFY SYSTEM - BUFFER CAN TAKE CHARACTERS AGAIN
* 
      LDA MPCOM     A = COMMUNICATION FLAG
      LDB XTNUM 
      ADB .+?STAT 
      LDB B,I       B = USER'S SYSTEM STATUS
      CPB .+3       IF STATUS IS OUTPUT WAIT, 
      IOR XMASK,I     SET COMMUNICATION FLAG
      STA MPCOM 
      JMP MPXEP Pk
* 
**    OUTPUT DELAY CHARACTER
* qqq{
DELAY LDA SYNCC     GET DELAY CHARACTER 
      LDB XTNUM,I   B = UNIT NUMBER 
      JSB MUXR,I     OUTPUT DELAY CHARACTER 
      ISZ XDCNT,I   CHECK FOR FURTHER DELAY TIME
      JMP MPXEP     YES 
      JMP BUFAD     NO - ADJUST BUFFER POINTERS 
* 
**    END OF OUTPUT PROCESSING
* 
MPXEO CLF 0 
      LDA XBGIN,I   RESET ALL 
      STA XBPNT,I     BUFFER POINTERS 
      STA XBSTR,I       TO THE BEGINNING
      STA XBHED,I         OF THE USER'S BUFFER
      LDA XSTAT,I   CHANGE
      IOR IOBT        STATUS
      STA XSTAT,I       TO INPUT
      AND ICNBT     REMOVE 'INPUT CONFIGURATION' BIT
      CPA XSTAT,I   BRANCH
      RSS             IF IT 
      JMP MPXIC         WAS SET 
      AND RNBT        CHECK FOR USER RUNNING
      SZA 
      JMP MPXEP     YES 
      LDA XSTAT,I   NO, REMOVE
MPXIC AND NINBT       'NO INPUT ALLOWED'
      STA XSTAT,I       BIT 
      LDA XRPRM,I   GET USER'S RECEIVE PARAMETER
      LDB XTNUM,I   B = UNIT NUMBER 
      JSB MUXR,I
      JMP MPXEP 
      SKP 
* *q
*  SUBROUTINE TO SET CR-DELAY.
* 
CRDLY NOP 
      LDB XTNUM 
      ADB .+?CDLY 
      LDA B,I       STORE CR DELAY
      STA XDCNT,I     IN THE COUNTER
      SZA           ANY DELAY?
      JMP MPXEP     YES 
      JMP CRDLY,I   NO
      SPC 2 
* *q
*  SUBROUTINE TO SET LF-DELAY.
* 
LFDLY NOP 
      LDB XTNUM 
      ADB .+?LDLY 
      LDA B,I       STORE LF DELAY
      STA XDCNT,I     IN THE COUNTER
      SZA           ANY DELAY?
      JMP MPXEP     YES 
      JMP LFDLY,I   NO
      SPC 3 
* qq
**
***   MULTIPLEXER END OF PROCESSING 
**
* qq
MPXEP LDA MPXE      RESTORE 
      ELA             E,
      LDA MPXA        A,
      LDB MPXB        AND B 
      CLF MPX       ENABLE MUX. 
      STF 0 
      JMP MPXIO,I 
MPXED EQU * 
