************************************************************************
*
*
*M*      COCU     7611 CHARACTER ORIENTED COMMUNICATION HANDLER (UMOV)
*
*
************************************************************************
*P*  NAME:    COC
*P*  PURPOSE: TO PROVIDE ALMOST ALL OF THE UNMAPPED FUNCTIONS UNIQUE TO
*P*           SUPPORTING A 7611 CHARACTER ORIENTED COMMUNICATIONS DEVICE.
************************************************************************
 TITLE 'C O C U   -   C O M M E N T A R Y   S Y M B O L S'
**************************************************************************
*
*  COMMENTARY PREFIXES:
*
*  SYMBOL         MEANING
*
*  L/             'LOAD'
*  S/             'STORE'
*  X/             'EXCHANGE'
*  XVALUE         'MULTIPLY BY (VALUE)'
*  &              'AND' (LOGICAL OPERATION)
*  G/             'GET'
*  C/             'COMPARE'
*  W/             'WITH'
*  B/             'BRANCH IF' OR 'BRANCH AND'
*  0/             'ZERO (CLEAR)' OR 'IF ZERO, THEN'
*  NZ/            'IF NON-ZERO, THEN'
*  +              'ADD' OR 'IF POSITIVE, THEN'
*  -              'SUBTRACT' OR 'IF NEGATIVE, THEN'
*  M/             'MULTIPLY BY' OR 'MOVE'
*  /              'DIVIDE' OR 'DIVIDE BY'
*  LJ/            'LEFT JUSTIFY'
*  RJ/            'RIGHT JUSTIFY'
*  MNEMONIC       LITERAL
*  VALUE/         'IF (VALUE), THEN'
*
**************************************************************************
 TITLE 'C O C U   -   A S S E M B L Y   F L A G S'
*
*  THE CONDITIONAL ASSEMBLY FLAGS IN COCR/COCU CAN BE CONTROLLED BY
*  'SET' DIRECTIVES INSERTED AT THE BEGINNING OF THE COCU MODULE.
*
*  1  IF THERE ISN'T A 'SET' FOR A PARTICULAR FLAG,
*     AN ASSEMBLED-IN DEFAULT IS USED.
*  2  IF THERE IS A 'SET' FOR A FLAG, THE VALUE SPECIFIED
*     WILL BE USED.
*     A  TO INCLUDE A PARTICULAR FEATURE, THE CORRESPONDING
*        LABEL SHOULD BE 'SET' TO A 1 (E.G., 2741CODE SET 0).
*     B  TO EXCLUDE A PARTICULAR FEATURE, THE LABEL SHOULD
*        BE 'SET' TO A 0 (E.G., 2741CODE SET 0).
*     C  VALUE-TYPE ASSEMBLY PARAMETERS SHOULD BE 'SET' TO THE
*        DESIRED VALUE (E.G., C:140 SET 200).
*
*  IF THE LABEL FIELD HAS NOT BEEN DEFINED YET, SET IT TO THE VALUE
*  OF THE ARGUMENT FIELD
*
TP       SET      1                 TP VERSION OF COCU
*
*
ASSEMCON CNAME
         PROC
         DO1      TCOR(S:FR,LF(1))
LF(1)    SET      AF(1)
         DISP     LF(1)
         PEND
*
TP       ASSEMCON 0                 GEN TRANSACTION PROCESSING CODE
MINCOC   ASSEMCON 0                 GENERATE SUBSET OF 'NORMAL' COC
PMONOFF  ASSEMCON MINCOC=0          GEN PERFORMANCE MONITORING CODE
ESCQST   ASSEMCON MINCOC=0          DISPLAY STATE ON ESC-Q
2741CODE ASSEMCON MINCOC=0          GEN 2741-HANDLING CODE
TCOUPL   ASSEMCON MINCOC=0          FOR COUPLING FEATURE
ZFLG     ASSEMCON MINCOC=0          FOR ESCAPE-Z FEATURE
HALF%DUPLEX ;
         ASSEMCON MINCOC=0          HALF-DUPLEX LINE SUPPORT
RT       ASSEMCON 1                 REAL TIME IN SYSTEM
HALT     ASSEMCON MINCOC=0          HALT OUTPUT MODE (ESC-H, PAGINATION)
OUTPUTIGNORE ;
         ASSEMCON MINCOC=0          IGNORE OUTPUT UNTIL NEXT READ (ESC-W)
         DEF      COCUFL            COC ASSEMBLY FLAGS; CONTAINS BITS
*,*                                 DESCRIBING ASSEMBLY OPTIONS AS FOLLOWS:
*,*                                 BIT MEANING
*,*                                 1   HALF-DUPLEX LINE SUPPORT
*,*                                 2   ESCAPE-Z (IGNORE INPUT) IN
*,*                                 3   COUPLING CODE ASSEMBLED IN
*,*                                 4   TP ASSEMBLED IN
*,*                                 7   MINCOC VERSION
*,*                                 10  2741 CODE ASSEMBLED IN
*,*                                 11  PERFORMANCE CODE ASSEMBLED IN
*,*                                 14  DISPLAY STATE ON ESC-Q
*,*                                 17  REAL-TIME SUPPORT IN
*,*                                 18  OUTPUT-HALT (ESC-H, PAGINATION)
*,*                                 19  OUTPUT IGNORE (ESC-W) CODE IN
COCUFL   EQU      HALF%DUPLEX**30+;
                  ZFLG**29+;
                  TCOUPL**28+;
                  TP**27+;
                  MINCOC**24+;
                  2741CODE**21+;
                  PMONOFF**20+;
                  ESCQST**17+;
                  RT**14+;
                  HALT**13+;
                  OUTPUTIGNORE**12
 TITLE 'C O C U   -   C O M M A N D   D E F I N I T I O N S'
BITS     SET      1                 REF'S MASKS&BT31TO0 & GETS
*                                   EQU'S FOR M'S, X'S, & Y'S.
         SYSTEM   UTS
*
S:S      FNAME
         PROC
         PEND     AF(AF(1)+2)
*
INHIBIT  COM,32   X'6D000037'       INHIBIT
UNINHIBIT COM,32  X'6D000027'       RESET INHIBITS
*
 TITLE 'C O C U   -   S Y M B O L I C   C O N S T A N T S'
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
*
BELL     EQU      X'07'             BELL CHAR; BUFFER EXHAUSTION WARNING
BS       EQU      X'08'             BACKSPACE CHARACTER
BSBS     EQU      X'46'             BACKSPACE THAT IMMEDIATELY FOLLOWS
*                                   .. ANOTHER BACKSPACE IN THE INPUT
*                                   .. BUFFERS
RUBOUT   EQU      X'FF'             RUBOUT CHAR; NON-2741 TIMING CHAR
TXNL     EQU      '
'               NEW-LINE CHARACTER (.15)
         DO       TP
COC:SPECHAR EQU   X'88'
RD:ERRCODE EQU    X'E'
WT:ERRCODE EQU    X'F'
         FIN
         PAGE
*
*  MODE6 TABLE BIT DEFINITIONS
*
*  THE FOLLOWING SYMBOLIC DEFINITIONS ARE USED TO SET, RESET, AND CHECK
*  MODE6 PARAMETERS.
*
HD       EQU      8                 HALF-DUPLEX LINE
HDIN     EQU      7                 HALF-DUPLEX LINE IN INPUT MODE
UTO      EQU      6                 READ WITH USER-CONTROLLED TIME-OUT
HLT      EQU      5                 HALT OUTPUT INTERRUPT PROCESSING
HDTA     EQU      4                 HALF-DUPLEX LINE TO BE TURNED AROUND
HDTA2    EQU      3                 HALF-DUPLEX LINE IN SECOND PHASE
*                                   .. OF TURN-AROUND
HW       EQU      1                 HARDWIRED LINE
*
*  THE FOLLOWING SYMBOLIC DEFINITIONS ARE USED TO CHECK THE
*  TERMINAL CHARACTERISTICS TABLE, COB:TC.
*
ESC7D7E  EQU      7                 ASCII .7D & .7E ARE ESCAPES
NOB      EQU      6                 EXCHANGE NOT/OR AND BRACKETS
PT       EQU      5                 TERMINAL HAS PHYSICAL TABS
*
CC       FNAME                      DEFINE CONDITION CODE
         PROC
         ERROR,3,AF(1)<5|AF(1)>8 'AF OUT OF RANGE'
         PEND     1**(AF(1)-5)
AC       FNAME                      DEFINE ABSOLUTE CONSTANT
         PROC
         ERROR,3,AF(1)<1|AF(1)>8 'AF OUT OF RANGE'
         PEND     1**(AF(1)-1)
LC       FNAME                      DEFINE LITERAL CONSTANT
         PROC
         ERROR,3,AF(1)<1|AF(1)>8 'AF OUT OF RANGE'
         PEND     BT31TO0+AF(1)
NLC      FNAME                      DEFINE .NOT. LITERAL CONSTANT
         PROC
         ERROR,3,AF(1)<1|AF(1)>8 'AF OUT OF RANGE'
         PEND     NB31TO0+AF(1)
 TITLE 'C O C U   -   D E F S'
         DEF      COCU:             XDELTA/PATCH SYMBOL
COCU:    EQU      %
         DEF      COCU              BASE ADR AND PRESENCE INDICATOR
*,*                                 FOR THE COCU MODULE
COCU     EQU      %
         DEF      COCITIO           INPUT INTERRUPT TIO INST ADR
         DEF      COCSTIO           T:COCHC COC STATUS TIO INST ADR
         DEF      ESCCHAR:          ESCAPE SEQUENCE CHARACTER TABLE
         DEF      ESCACT:           ESCAPE SEQUENCE ACTION TABLE
 TITLE 'C O C U   -   E N T R Y   P O I N T   D E F S'
*,*                                 FROM GHOST1D, PFSR, & CSECOM
         DEF      COCIP             INPUT INTERRUPT HANDLER ENTRY POINT
         DEF      COCOFF            LINE HANGUP ROUTINE
         DEF      COCOP             OUTPUT INTERRUPT HANDLER ENTRY POINT
         DEF      T:COCHC           CLOCK3-DRIVEN ROUTINE FOR COC
*,*                                 STATUS CHECKING
         DO       HALF%DUPLEX
         DEF      T:COCTA           CLOCK3 LINE TURNAROUND ENTRY POINT
         FIN
 TITLE 'C O C U   -   C O C R   R O U T I N E   R E F S'
         REF      COCDSABL          DISABLE COC INTERRUPTS
         REF      COCENABL          ENABLE COC INTERRUPTS
         REF      COCACSET          COMPARE ACTIVATION CHARACTER SET W/1,2
         REF      COCCPT1           SEND BELL FOR BUF DEPLETION
         REF      COCRLD            RESET LOST-DATA FLAG
         REF      COCECHO           ECHO CHARACTER
         REF      COCSENDT          SEND TRANSPARENT CHARACTER
         REF      COCSENDX          SEND CHARACTER
         REF      COCECESC          ECHO ESC SEQUENCE
         REF      COCECHO1          TURN 2741 AROUND
         DO1      2741CODE
         REF      COCEOT1           SEND 2741 EOT
         DO       HALT
         REF      COCSHALT          SET HALT FLAG
         REF      COCHLTGO          RESET HALT, CONTINUE
         FIN
         REF      COCINIT2          CLOCK3-DETECTED COCG REQUEST
         REF      COCKIO            KILL INPUT & OUTPUT BUFS
         REF      COCKO             KILL OUTPUT
         DO1      HALF%DUPLEX
         REF      COCPHYLN          GET PHYSICAL LINE, COC NUMBERS
         REF      COCSNXOF          SEND XOFF CHARACTER
         REF      COCSACTO          SET ACTIVATION ON READ TIMEOUT
         REF      COCSACT1          SET ACTIVATION RECEIVED
         REF      COCSACT2          SET ACTIVATION RECEIVED
         REF      COCSNDFF          SEND .FF CHARACTER
         DO       TP
         REF      COCGECBR          GET READ ECB
         REF      COCGECBW          GET WRITE ECB
         REF      COCKIOHU          KILL I/O ON HANG-UP
         REF      COCPECB           POST ECB
         REF      COCWLDLC          CHAIN ECB
         FIN
         DO       TCOUPL=1
         REF      DECOUPLE%         DECOUPLE LINES ENTRY
         FIN
         REF      COCMINT           REINITIALIZE LINE TABLES
         REF      COCGETB           GET COC BUFFER ROUTINE
         REF      COCPUTBL          RETURN COC BUFFER ROUTINE
 TITLE 'C O C U   -   T R A N S L A T E   T A B L E   P O I N T E R S'
         REF      COB:STAR          INDEXED BY COCTERM/2, GIVES THE STAR (*)
*,*                                 .. VALUE FOR 2741 CODE SETS
         REF      NOSTARS           # OF 'STAR' ENTRIES
         REF      COCITV            INPUT TRANSLATE TABLE POINTER TABLE
         REF      COCOTV            OUTPUT TRANSLATION TABLE POINTER
*,*                                 TABLE
         SREF     AAPLX             ASCII APL COCTERM INDEX
         REF      COB:TC            TERMINAL CHARACTERISTICS
 TITLE 'C O C U   -   C O N S T A N T   R E F S'
         REF      NB31TO0           MASK USED FOR MODE5 BYTE
         REF      XF                MASK
         REF      XFC               MASK
         REF      XFE               MASK
         REF      LOWLET            LIMITS OF LOWER-CASE LETTERS
 TITLE 'C O C U   -   S Y S T E M   L I M I T   R E F S'
         REF      SL:ONCB           MAX # OF COC BUFFERS FOR A USER
*,*                                 OUTPUT
         REF      SL:UB             TERMINAL UNBLOCK LIMIT, IN SECONDS
*,*                                 OF OUTPUT
 TITLE 'C O C U   -   M O N I T O R   T A B L E   R E F S'
         REF      S:RTIR            CHECK FOR DEFERRED RT INTERRUPTS
         REF      UH:DL             DEFERRED EVENT REPORTING
         REF      UH:FLG2           USER FLAGS
         REF      UH:FLG            CHECK FOR TEL-IN-CONTROL
         REF      UB:ACP            CHECK FOR LOGON ASSOCIATED
         REF      P:NAME            CHECK FOR LOGON ASSOCIATED
         REF      UB:US             STOB/STOBO STATE CHECK
         DO       PMONOFF=1
         REF      C:CI              TOTAL CHARACTERS INPUT
         REF      C:CO              TOTAL CHARACTERS OUTPUT
         FIN
 TITLE 'C O C U   -   S C H E D   E V E N T / S T A T E   R E F S'
         REF      E:CBA             REPORT COC BUFFERS AVAILABLE
         REF      E:CBK             REPORT BREAK RECEIVED
         REF      E:CEC             CONTROL E RECEIVED
         REF      E:CIC             INPUT COMPLETE
         REF      E:CUB             RECORD UNBLOCK
         REF      E:OFF             TERMINAL OFF EVENT
         REF      E:WU              WAKE-UP EVENT
         REF      STOB              TERMINAL OUTPUT BLOCKED STATE
         REF      STOBO             TERMINAL OUTPUT BLOCKED, OUT OF CORE STATE
         REF      SW                WAIT (SLEEP) STATE
 TITLE 'C O C U   -   M O N I T O R   S U B R O U T I N E   R E F S'
         REF      T:RCE             REPORT COC EVENT
         REF      T:RUE             REPORT USER EVENT
         REF      T:SSE             SCHEDULER
         DO       TP
         REF      ECBGBLK           GET ECB
         FIN
 TITLE 'C O C U   -   C O C   I N D E X E D   T A B L E   R E F S'
         REF      LCOC              INDEX TO LAST COC (# OF COCS - 1)
         REF      COD:LPC           LIMITS OF LOGICAL LINES PER COC
         REF      COH:DN            COC DEVICE ADR
         REF      COB:SIOS          SIO CC'S INDEXED BY COC#
         REF      CO:RINGE          GET ADR OF INPUT CHARACTERS
         REF      COH:RBS           RESET RING BUFFER POINTER
         REF      CO:LNM            MASK FOR LINE NUMBER
         REF      CO:LST            GET ADR OF INPUT CHARACTERS
         REF      CO:OUTRS          GET LINE # REQUESTING OUTPUT INTERRUPT
         REF      CO:RCVDOFF        HANG UP LINE
         REF      CO:RCVON          TURN RECEIVER ON
         REF      CO:STAT           'SENSE RECEIVER L STATUS' WD
         REF      CO:TSTAT          'SENSE TRANSMITTER STATUS'
         REF      CO:XDATA          TRANSMIT CHARACTER
         REF      CO:XSTOP          TERMINATE TRANSMISSION
 TITLE 'C O C U   -   I N T E R R U P T   D A T A   R E F S'
*,*                                 .. LEVEL SELECT BIT
         REF      CO:IN0
*,*                                 .. HIGHEST PRIORITY INPUT INT
         REF      CO:OUT            ADR OF OUTPUT INT PSD
         REF      CO:INTFL          COC INTERRUPT STATUS FLAGS
 TITLE 'C O C U   -   M I S C   C O C   D A T A   R E F S'
         REF      COB:CPS           INDEXED BY MODE4 SPEED, CONTAINS
*,*                                 .. THE CHARACTERS PER SECOND
*,*                                 .. CONTAINS THE COLUMN NUMBER FOR
*,*                                 .. MAXIMUM # OF IDLES ON A CARRIAGE RETURN
         REF      COCBLN            LINE # OF LAST INPUT INTERRUPT FROM
*,*                                 UN-SYSGEN'D LINE
         REF      COCBLC            # OF INPUT INTERRUPTS FROM
*,*                                 UN-SYSGEN'D LINES
         REF      COCIPL            INPUT PARITY LINE NUMBER
         REF      COCIPC            INPUT PARITY ERROR COUNT
         REF      COCOEL            OUTPUT EXTRANEOUS INTERRUPT LINE
         REF      COCOEC            OUTPUT EXTRANEOUS INTERRUPT COUNT
         REF      COCLNC            NOISY LINE CHAR COUNT
         REF      COCLNL            NOISY LINE NUMBER
         REF      COCLBC            NOISY LINE BREAK COUNT
         REF      COCLBL            NOISY (WITH BREAK BIT) LINE NUMBER
         REF      COCBUF            FREE COC BUFFER POOL ADR
         REF      COCGFLG           COCG FLAGS
         REF      DUMPLINE          CHECK ESC-ETB DUMP AUTHORIZATION
         REF      COCHPB
         REF      COC#BUFS          NUMBER OF COC BUFFERS IN USE
         DO       HALF%DUPLEX
         REF      COCHDFLN          LINE # OF FIRST HALF-DUPLEX LINE
*,*                                 .. BEING TURNED FROM INPUT TO
*,*                                 .. OUTPUT MODE
         REF      COCHDLLN          LINE # OF LAST HALF-DUPLEX LINE
*,*                                 .. BEING TURNED FROM INPUT TO
*,*                                 .. OUTPUT MODE
         REF      COCHDICB          INTERRUPT CONTROL BLOCK FOR HALF DUPLEX
*,*                                 .. LINE TURNAROUND TIMING
         FIN
         DO       TP
         REF      ECBFRCHN          HEAD POINTER TO CHAIN OF ECBS
*                                   .. THAT WERE RELEASED AT THE
*                                   .. INTERRUPT LEVEL
         FIN
         REF      COCMESS           ADMINISTRATIVE MESSAGE
         REF      COCE              EVENT-REPORTED FLAG
         REF      COCQST            MESSAGE FOR ESQ-Q
 TITLE 'C O C U   -   L I N E   I N D E X E D   T A B L E   R E F S'
         REF      BUFCNT            TOTAL BUFFER COUNT
         REF      COCII             INPUT INSERTION POINTER
         REF      COCIR             INPUT REMOVAL POINTER
         REF      COCOC             OUTPUT CHARACTER COUNT
         REF      COCOR             OUTPUT REMOVAL POINTER
         REF      COCTERM           TRANSLATE TABLE INDEX, TERMINAL TYPE
         REF      CPI               CARRIAGE POSITION AT START OF READ
         REF      EOMTIME           READ TIMEOUT PERIOD, ACTIVATION TIME, FLAG
         REF      LB:UN             USER NUMBER
         REF      MODE              STATUS
         REF      MODE2             STATUS
         REF      MODE3             STATUS
         REF      MODE4             STATUS
         REF      MODE4INIT         STATUS
         REF      MODE5             STATUS
         REF      MODE6             STATUS
         REF      TL                TAB BUF ADR, ACTIVATION POINT
 TITLE 'C O C U   -   S T A T I C   D A T A'
SCHPSD   :PSD     (IA,COCENABL),(WK,1)
X32X40   DATA     X'32',X'40'       TO SEE IF CHR REQUIRES BUFFERING
X7D7E    DATA     X'7D',X'7E'
TCLOGON  TEXTC    'LOGON'
TCOUMX   TEXTC    TXNL,'NEW ONLINE USERS NOT CURRENTLY ALLOWED',TXNL
         DO       ESCQST
TXSTATES DATA     'RT'              REALTIME
         DATA     'C0'              COMPUTE - 0
         DATA     'C1'              COMPUTE - 1
         DATA     'C2'              COMPUTE - 2
         DATA     'C3'              COMPUTE - 3
         DATA     'C4'              COMPUTE - 4
         DATA     'C5'              COMPUTE - 5
         DATA     'C6'              COMPUTE - 6
         DATA     'C7'              COMPUTE - 7
         DATA     'C8'              COMPUTE - 8
         DATA     'C9'              COMPUTE - 9
         DATA     'C10'             COMPUTE - 10
         DATA     'CU'              CURRENT USER
         DATA     'TOB'             TERMINAL OUTPUT BLOCKED
         DATA     'TOBO'            TERMINAL OUTPUT BLOCKED, OUT OF CORE
         DATA     'IOW'             IO WAIT
         DATA     'IOMF'            IO MASTER FUNCTION
         DATA     'W'               WAIT
         DATA     'QA'              Q'D FOR ACCESS
         DATA     'QR'              Q'D FOR RESOURCE
         DATA     'QRO'             Q'D FOR RESOURCE, OUT OF CORE
         DATA     'TI'              TERMINAL INPUT
         DATA     'TIO'             TERMINAL INPUT, OUT OF CORE
         DATA     'QFI'             Q'D FOR INTERRUPT
         DATA     '19'              UNDEFINED - X'19'
         DATA     '1A'              UNDEFINED - X'1A'
         DATA     '1B'              UNDEFINED - X'1B'
         DATA     '1C'              UNDEFINED - X'1C'
         DATA     '1D'              UNDEFINED - X'1D'
         DATA     'NULL'            NULL
         FIN
 TITLE 'C O C U   -   I N P U T   I N T E R R U P T   R O U T I N E'
************************************************************************
*F*  NAME:    COCIP
*F*  PURPOSE: HANDLE COC INPUT INTERRUPTS
*F*  DESCRIPTION: COCIP PERFORMS THE FOLLOWING BASIC FUNCTIONS:
*F*           *   IF TPCOC VERSION, TRANSFER ANY ECB'S PLACED
*F*               ON ECBFRCHN TO THE COC FREE BUFFER CHAIN.
*F*           *   REMOVE FROM THE RING BUFFER AND PROCESS ALL CHARACTERS
*F*               FOR ALL LINES ON ALL COC'S.  PROCESSING INCLUDES:
*F*               *   TRANSLATION TO EBCDIC (IF REQUIRED).
*F*               *   PERFORMING INDICATED FUNCTIONS FOR CTRL-X, CTRL-Y,
*F*                   RUBOUT, ESCAPE-ESCAPE, AND BREAK.
*F*               *   PLACING THE CHARACTER IN A COC BUFFER (IF REQUIRED).
*F*               *   IF A READ IS PENDING:
*F*                   *   ECHO THE CHARACTER
*F*                   *   IF AN ESCAPE SEQUENCE, PERFORM IT
*F*                   *   IF AN ACTIVATION CHARACTER, REPORT ACTIVATION,
*F*                       RESET READ PENDING.
************************************************************************
COCIP    MTB,-1   CO:INTFL          SET T:COCHC LOCK-OUT FLAG
         LI,R3    LCOC              SET COC 7611 NUMBER TO LAST COC
         DO       TP
         LI,R1    0                 L/0; NEW HEAD POINTER
         XW,R1    ECBFRCHN          X/0 W/ECB FREED CHAIN HEAD POINTER
         BEZ      COCIP01           BEZ; NO ECBS TO TRANSFER TO COC
*                                   .. BUF POOL
         MTW,-1   COC#BUFS          DEC # OF COC BUFFERS IN USE
         XW,R1    COCHPB            X/ECB ADR W/COC BUF HEAD POINTER
         LW,R2    COCHPB            L/ADR OF ECB CURRENTLY BEING
*                                   .. TRANSFERRED INTO COC BUF POOL
         XW,R1    COCBUF,R2         X/ADR OF OLD COC HEAD BUFFER W/WD 0
*                                   .. OF BUF BEING TRANSFERRED
         BNEZ     %-4               BNEZ; FLINK WASN'T 0, SO TRANSFER
*                                   .. NEXT BUFFER (ECB)
         FIN
*
*
COCIP01  LW,R6    CO:LST,R3         RING POINTER (RELATIVE POSITION OF
*                                   CHARACTER IN RING BUFFER)
         LW,R4    CO:RINGE,R3       END OF RING BUFFER
         LH,R15   COH:DN,R3         COC DEVICE ADDR
COCITIO  TIO,R15  *R15              TEST DEV.
         BCS,8    COCIP04           B/NO ADDRESS RECOGNITION
         BCR,4    COCIP04           B/DEVICE NOT BUSY; NO SIO ACTIVE
         AND,R15  MASKS+16          &/RBC W/.FFFF
         AW,R15   R6
         BNEZ     COCIP5            B/RBC CHANGED
COCIP04  AI,R3    -1                DECREMENT 7611 NUMBER
         BGEZ     COCIP01           PROCESS INPUT FROM NEXT 7611
         XW,R3    COCE              TURN OFF EVENT FLAG
         BGEZ     SCHDEXIT          BGEZ; EVENT WAS REPORTED; CHANGE REG
*                                   .. PNTR, SAVE ENVIRONMENT, ENABLE
*                                   .. COC INTERRUPTS, GO TO T:SSE
         DO       RT
         INHIBIT
         LW,R3    S:RTIR            CHECK FOR REAL-TIME DEFERRED EVENTS
         BEZ      SCHDEXIT          B/THERE MAY BE REAL-TIME
*                                   .. USERS NEEDING ATTENTION
         FIN
         MTB,1    CO:INTFL          RESET T:COCHC LOCK-OUT FLAG
         LPSD,11  CO:IN0            RETURN - ARM (CLEAR) INTERRUPT LEVEL
         PAGE
*
*
COCIP5   LI,R7    COCIP512
         LB,R5    *R4,R6            L/CHARACTER FROM RING BUF
         AI,R6    1                 +1 TO RING BUFFER POINTER
         LB,R2    *R4,R6            L/LINE NUMBER FROM RING BUFFER
         BIR,R6   %+2               +1 TO RING BUF POINTER; B/NOT AT END
         LCH,R6   COH:RBS,R3        L/-(RING BUFFER SIZE); WRAP AROUND
         STW,R6   CO:LST,R3         UPDATE RING POINTER
*
*                 TEST FOR VALID LINE NUMBER
*
         LD,R14   COD:LPC,R3        1ST & LAST LOGICAL LINES FOR COC
         AW,R2    R14               R2 IS LOGICAL LINE OF TERMINAL
COCIP7   LB,R4    COCTERM,R2
         LH,R10   COCOTV,R4
         CW,R2    R15
         BLE      0,R7              BRCH IF VALID LOGICAL LINE
         AI,R2    -X'80'            REMOVE BREAK BIT
         LI,R7    BREAK             SET R7 TO GO TO BREAK LOGIC
         CLM,R2   R14
         BCR,9    COCIP7            BRANCH IF BREAK FOR VALID LINE
*
*                 COUNT  INVALID  LINE INTERRUPTS
*
         MTW,1    COCBLC            COUNT INTERUPTS FROM INVALID LINES
         STW,R2   COCBLN            SAVE BAD LINE
         STB,R3   COCBLN            S/COC #
         B        COCIP01
*
         PAGE
*
*                 NORMAL CHAR PROCESSING - 2=LINE, 5= CHAR
*
COCIP512 EQU      %
         DO       PMONOFF=1
         MTW,1    C:CI              BUMP COUNT OF CHARACTERS INPUT
         FIN
         DO       TP
         LC       MODE5,R2          SEE IF SLAVE & NOT ACTIVE
         BCR,8    %+2               NOT SLAVE
         BCR,2    COCIP01           BR IF NO DCB OPEN TO LINE
         FIN
         LC       MODE2,R2
         DO1      2741CODE
         BCS,1    COCIP6            2741
         BCS,8    COCIP01           IGNORE INPUT FROM DISCONNECTED LINE
         LC       MODE,R2
         BCS,2    COCIP55
         LB,R7    MODE2,R2
         CI,R7    4
         BAZ      COCIP51           DONT CHECK PARITY
         SCS,R5   32
         BEV      COCIP51           PARITY OK
COCIP54  LI,R5    X'1A'             SUB(PARITY ERR)
         MTW,1    COCIPC            COUNT PARITY ERRORS
         STW,R2   COCIPL            SAVE LINE NUMBER
COCIP55  LB,R12   MODE,R2
         AND,R12  XFC
         STB,R12  MODE,R2
COCIP9   LI,R12   COCIP98
         LB,R11   MODE3,R2          MODE3 FLAGS INTO R11
         CI,R11   X'8'
         LH,R4    COCII,R2          INSERTION POINT IN R4
         BANZ     COCIP99           BRANCH IF IN THE LOST DATA MODE
         BNEZ     COCIP91           ALREADY SOME INPUT
         LB,R6    LB:UN,R2          L/USER NUMBER; SEE IF ANY ASSOCIATED
         BNEZ     COCIP9A           B IF WE'VE GOT A USER HERE
         MTW,1    COCLNC            OTHERWISE COUNT UP NOISY LINE CHARS
         STW,R2   COCLNL            AND KEEP TRACK OF NOISY LINE #
         B        COCIP01           DON'T BUFFER GARBAGE CHARACTERS
COCIP9A  BAL,R6   COCGETB           GET A BUFFER
         B        COCIP96           BRANCH IF NONE AVAILABLE
         STH,R4   COCIR,R2          SET UP NEW BUF
         B        COCIP92
*
*
COCIP91  AI,R4    1                 BUMP BUFFER POSITION
         CI,R4    X'F'
         BANZ     COCIP92H          BRANCH IF ROOM IN BUFFER
*                 OBTAIN A BUFFER AND LINK TO THIS USER'S CHAIN
         LW,R7    R4                PUT LINK INTO R7
         BAL,R6   COCGETB           GET A BUFFER
         B        COCIP95M          BRANCH IF NONE AVAILABLE
         SLS,R7   -1
         STH,R4   COCBUF-4,R7       LINK BUFFER TO CHAIN
*                 MOVE TRANSLATED INPUT CHARACTER INTO BUFFER
COCIP92  MTB,1    BUFCNT,R2         INC INPUT BUFFER COUNT
COCIP92H STH,R4   COCII,R2          UPDATE INSERTION POINT
COCIP93  STB,R5   COCBUF,R4         PUT CHARACTER IN BUFFER
*                 ECHO INPUT CHARACTER IF A READ IS PENDING
         LC       MODE,R2
         BCR,1    COCIP95
IP930    LH,R0    COCIR,R2          HEAD OF INPUT FOR ECHO
         BAL,R11  COCECHO
         B        COCIP95           NORMAL RETURN
*                 ACTIVATION RETURN, SET READ AHEAD.
         DO       TP
COCIP93A LC       MODE5,R2
         BCR,8    COCIP94A          BR IF NOT SLAVE LINE
         BAL,R11  COCGECBR          GET READ WAIT BLOCK
         BEZ      COCIP94A          NONE, USER IS REGED
         LB,R5    MODE5,R2
         OR,R5    X8                SET READ COMPLETE FLAG
         STB,R5   MODE5,R2
         LW,R6    2,R7              SAVE SUPPLEMENTARY BLOCK ADDRESS.
         LI,R9    X'01'             TYC= NORMAL.
         BAL,R11  COCPECB           POST ECB & FREE FIRST BLOCK.
         LW,R10   R6                10= BLOCK ADDRESS.
         LI,R7    X'40000'
         STW,R7   *R10                TYPE= COC:RDCOMP
         LI,R11   COCIP01            <RETURN FROM WLDLCHN>
PUTDOLIST2 LB,R7  LB:UN,R2          GET USER NUMBER
         ANLZ,R7  XXX               GET HA(CHAIN HEAD)
         B        COCWLDLC          CHAIN BLOCK TO UH:DL
XXX      LH,0     UH:DL,R7          USED IN ANLZ INSTR.
COCIP94A EQU      %
         FIN
         LI,R6    E:CIC             SET TO REPORT INPUT COMPLETE
COCIP94  EQU      %
         DO       TP
         AI,R6    0                 DON'T REPORT ZERO EVENTS
         BE       COCIP01           B/0 EVENT
         FIN
         BAL,R11  RCE               REPORT COC EVENT
         STW,R11  COCE              SET EVENT-REPORTED FLAG
         LB,R11   LB:UN,R2
         BNEZ     COCIP01           B/USER ASSOCIATED WITH THIS LINE
         LI,R7    TCOUMX            L/ADR OF 'NEW ONLINE USERS NOT
*                                   .. CURRENTLY ALLOWED'
         BAL,R6   SENDMESS          BAL/SEND MESSAGE
         LI,R7    COCMESS           L/ADR OF SEND,ALL/PAGE HEADING MESSAGE
SNDMESX  BAL,R6   SENDMESS          BAL/SEND MESSAGE
         B        COCIP01
*
SENDMESS LI,R4    1                 L/1; BTD INTO MESSAGE
         LI,R9    SM60              L/RETURN ADR FOR COCSENDX
SM10     CB,R4    *R7               C/BTD W/BC IN TEXTC MESSAGE
         BG       0,R6              BG; END OF MESSAGE; RETURN
         LB,R5    *R7,R4            L/BYTE OF MESSAGE
         BNEZ     COCSENDX          SEND CHARACTER
SM60     AI,R4    1                 INC BTD INTO MESSAGE
         B        SM10              B; G/NEXT BYTE OF MESSAGE
*
RCE      PUSH     (R2,R11)          PUSH R2 -> R11
         BAL,R11  T:RCE             REPORT COC EVENT
         PULL     (R2,R11)          PULL R2 -> R11
         B        *R11              RETURN
*
COCIP95  LB,R15   BUFCNT,R2         GET USER COC BUFFER COUNT
         CW,R15   SL:ONCB
         BL       COCIP01           BRANCH IF BUFFER LIMIT NOT REACHED
         LI,R12   COCIP01
         LI,R5    X'F'
         CS,R4    XF
         BNE      COCIP97           BRANCH IF BUFFER LIMIT NOT EXCEEDED
COCIP95M LH,R4    COCII,R2
*                 USER BUFFER LIMIT EXCEEDED OR BUFFERS ARE UNAVAILABLE
COCIP96  LB,R11   MODE3,R2
         OR,R11   X8                SET MODE BIT REFLECTING LOST DATA
         STB,R11  MODE3,R2
*                 SEND 'BE'S TO ALARM THE TERMINAL USER
COCIP97  BAL,R15  COCSNXOF          BAL/STOP PAPER TAPE READER
         LI,R1    BELL              L/BELL CHAR
         BAL,R15  COCCPT1           SEND BELL TO FRONT OF OUTPUT BUFFERS
         B        *R12
*                 OPERATING IN THE LOST DATA MODE
COCIP98  LI,R12   COCIP01
         LC       MODE,R2
         BCR,1    IP980             BRANCH IF IN READ AHEAD MODE
         BAL,R15  COCSACT1          SET ACTIVATION
         DO       TP
         LI,R12   COCIP93A
         ELSE
         LI,R12   COCIP94-1
         FIN
IP980    AI,R4    0
         BEZ      COCIP97           BRANCH IF NO INPUT BUFFERS EXIST
         LI,R5    X'BE'
         STB,R5   COCBUF,R4         GIVE BUFFER EXHAUSTION CHAR TO USER
         B        COCIP97
*                 INPUT RECEIVED WHILE LOST DATA MODE IS SET
COCIP99  BEZ      COCIP97           DATA HAS BEEN LOST IF NO BUFFERS
         LB,R15   COCBUF,R4
         AI,R15   -X'BE'
         BEZ      COCIP01           BRANCH IF LOST DATA CHAR IN BUFFER
         LB,R15   BUFCNT,R2
         CW,R15   SL:ONCB
         BGE      COCIP97           BRANCH IF BUFFER LIMIT REACHED
         LI,R9    COCIP91           NO LOST DATA, SET RETURN FOR COCRLD
         B        COCRLD            RESET LOST DATA AND CONTINUE
COCIP51  AND,R5   M7                SCRUB PARITY
         CLM,R5   X7D7E             C/CHAR W/.7D, .7E
         BOL      COCIP56           BOL; NOT .7D OR .7E
         LC       COB:TC,R4         L/TERMINAL CHARACTERISTICS
         BCR,CC(ESC7D7E) COCIP56    B/NOT TO CONSIDER .7D OR .7E ESCAPES
         LI,R5    X'1B'             L/ESCAPE CHARACTER
COCIP56  LH,R7    COCITV,R4
         LC       MODE,R2
         BCR,4    COCIP5F           BRANCH IF NO ESCAPE PENDING
         LB,R12   MODE,R2
         AI,R12   -X'40'            RESET ESC
         STB,R12  MODE,R2
         LB,R6    *R7,R5            TRANSLATE TO EBCDIC
COCIP59  CLM,R6   LOWLET
         BCS,9    %+2
         AI,R6    X'40'             ADJUST LC
         LI,R11   TTESCS
         LI,R4    NTTESCS           SET UP
         DO       2741CODE
         LC       MODE2,R2              TO CHECK
         BCR,1    %+3                        ESCAPE
         LI,R11   27ESCS                          TABLE
         LI,R4    N27ESCS
         FIN
         CB,R6    *R11,R4
         BE       COCIP5B           FOUND AN ESCAPE
         BDR,R4   %-2
         DO       2741CODE
         LC       MODE2,R2
         BCS,1    IP681             IGNORE 2741 EOT IF NOT AN ATTN SEQ
         FIN
COCIP5F  LB,R5    *R7,R5            TRANSLATE
         BEZ      COCIP01           NULL = NOP
         LC       *R10,R5
         BCR,8    COCIP55           NO SPEC FLAG
         LI,R7    #IMCHR            L/# OF IMMEDIATE CHARACTERS
         CB,R5    IMCHR,R7
         BE       %+3
         BDR,R7   %-2
         B        COCIP55
         DO       HALT
         BAL,R9   COCHLTGO          IF IN HALT MODE, RESTART OUTPUT
         BCR,CC(HLT) %+3            B/NOT IN HALT MODE
         CI,R5    X'19'             C/CHAR W/CONTROL-Y
         BNE      COCIP01           B/NOT C-Y; IGNORE IT
         FIN
         LB,R7    IMTV,R7           L/DISPLACEMENT TO ROUTINE
         B        COCIBS,R7         GO TO IMMED PROC.
*
IMCHRS   SET      0                 INITIALIZE IMCHRS LIST
*
IMCHR    CNAME
         PROC
LF       DATA,1   AF(2)-COCIBS
IMCHRS   SET      IMCHRS,AF(1)
         PEND
*
IMTV     DATA,1                     DUMMY ENTRY
         IMCHR    X'0D',COCIPCR     CARRIAGE RETURN
         IMCHR    BS,COCIBS         BACKSPACE
         IMCHR    X'19',ESCESC      ESC-ESC/ESC-Y/CONTROL-Y
         IMCHR    X'30',COCIESC     ESC
         IMCHR    X'32',CTLX        CONTROL-X
         IMCHR    X'31',COCIRUB     RUBOUT
#IMCHR   EQU      BA(%)-BA(IMTV)-1  # OF IMMEDIATE CHARACTERS
         BOUND    4
*
IMCHR    DATA,1   IMCHRS            IMMEDIATE CHARACTERS
         BOUND    4
*
COCIBS   LH,R7    COCII,R2          L/INPUT INSERTION POINTER
         BEZ      COCIP55           BEZ; NO INPUT BUFFERED
         LB,R7    COCBUF,R7         L/LAST CHARACTER BUFFERED
         CI,R7    BS                C/CHAR W/BACKSPACE CHAR
         BE       %+3               BE; CONTIGUOUS BACKSPACE
         CI,R7    BSBS              C/CHAR W/CONTIGUOUS BACKSPACE
*                                   .. 'CHARACTER'
         BNE      COCIP55           BNE; NOT CONTIGUOUS BACKSPACE
         DO       2741CODE
         LC       MODE2,R2
         BCS,1    COCIP55           B/2741
         FIN
         LI,R5    BSBS              L/CONTIGUOUS BACKSPACE 'CHARACTER'
COCIPCR  B        COCIP55           B; BUFFER IT
*
ESCESC   EQU      %
         DO       TP
         LC       MODE5,R2          IF SLAVE LINE, JUST PUT CHAR
         BCS,8    COCIP55           IN BUFFER.
         FIN
         LI,R7    1                 CONTROL Y EVENT
         STB,R7   CPI,R2            RESET INITIAL CARRIAGE POSITION
         LI,R7    E:CEC
BRKYC    LB,R5    LB:UN,R2
         BNEZ     %+2               B/USER # NOT 0; LINE INITIALIZED
         BAL,R4   COCMINT           BAL/INITIALIZE LINE TABLES
         LC       MODE2,R2          LOGGING OFF
         BCS,8    COCIP01
         DO       2741CODE
**************************************************************************
*  IF 2741 BREAK RECEIVED (AS OPPOSED TO B-ATTN), DO THE FOLLOWING:
*  IF THIS IS A BREAK BEFORE THE TRANSLATE TABLE HAS BEEN IDENTIFIED,
*     TURN LINE AROUND, DO NOT REPORT THE BREAK EVENT; EXIT.
*  RELEASE OUTPUT BUFFERS.
*  IF OUTPUT EXISTS, DON'T REPORT THE FIRST BREAK, BUT
*     INCREMENT THE BREAK COUNT.
**************************************************************************
         BCR,1    BRKYC30           B/NOT 2741
         LB,R8    COCTERM,R2        L/COCTERM; SEE IF TRNS TBL IDENTIFIE
         BEZ      COCIP65E          BEZ; TURN LINE AROUND, DON'T REPORT
*                                   .. BREAK; THIS IS BREAK BEFORE
*                                   .. TRANSLATE TABLE IDENTIFIED
         LI,R8    COCECHO1          L/RETURN ADR IF IGNORING EVENT
         LC       MODE,R2           L/EOA-PENDING FLAG
         BCS,4    BRKYC40           B/EOA PENDING; B-ATTN, NOT BREAK
         BAL,R8   CTLX10            BAL/RELEASE INPUT AND OUTPUT BUFFERS
         LC       MODE,R2           L/READ PENDING FLAG
         BCR,1    %+2               B/NO READ PENDING; DON'T GIVE EOT
         BAL,R11  COCECHO1          READ PENDING, GIVE EOT
         LH,R5    COCOC,R2          L/OUTPUT CHARACTER COUNT
         BEZ      BRKYC30           BEZ; NO OUTPUT EXISTED, REPORT
*                                   .. BREAK EVENT
         LB,R5    MODE,R2           L/BREAK COUNT
         CI,R5    2                 C/BREAK COUNT W/2
         BAZ      COCIP01           BAZ; BREAK COUNT < 2, DON'T
*                                   .. REPORT BREAK EVENT
BRKYC30  EQU      %
         FIN
         LI,R8    COCIP01           L/RETURN ADR IF IGNORING EVENT
BRKYC40  LB,R6    LB:UN,R2          L/USER #
         LH,R15   UH:FLG,R6         L/USER FLAGS
         CI,R15   X'80'             C/FLAGS W/TEL-IN-CONTROL BIT
         BAZ      BRKYC1            B/NOT TIC
         CI,R7    E:CEC
         BE       CTLX10            IGNORE EC FOR COMMAND PROCESSOR
         LH,R15   UH:FLG2,R6        L/UH:FLG2
         CI,R15   X'4000'           C/UH:FLG2 W/.4000
         BAZ      CTLX10            BAZ; NO COMMAND PROC BREAK ENTRY POINT
BRKYC1   BAL,R8   COCKIO            RELEASE INPUT & OUTPUT BUFFERS
         DO       TP
         LI,R15   %+4
         LC       MODE5,R2
         BCS,8    COCSNXOF          SKIP ACTIVATION FOR SLAVE LINES.
         FIN
         BAL,R15  COCSACT2          PERFORM ACTIVATION
         LW,R6    7
         B        COCIP94           BRANCH TO RECORD EVENT
*
COCIESC  LB,R12   MODE,R2           SET
         OR,R12   X40                ESCAPE
         STB,R12  MODE,R2             BIT
         B        COCIP01
*
         DO       HALT
ESCH     BAL,R15  COCSHALT          SET OUTPUT HALT FLAG
         B        COCIP01           RETURN TO TOP OF INPUT INT PROC
         FIN
CTLX     LI,R8    COCECHO1          SET TO GIVE EOT IF 2741
CTLX10   LI,R11   COCIP01           L/RETURN ADR
         B        COCKIO            B; DELETE INPUT & OUTPUT BUFS
*
COCIRUB  LC       MODE2,R2
         BCS,4    COCIP01
         LC       MODE3,R2
         BCS,4    COCIP01
         LH,R4    COCII,R2
         BNEZ     COCIP9            BRANCH IF RUBOUT IS VALID
         B        COCIP01
*
ESCQ     LH,R5    COCOC,R2          L/OUTPUT CHARACTER COUNT
         BNEZ     COCIP01           BNEZ; OUTPUT IN PROGRESS, IGNORE
         DO       ESCQST
         LB,R7    LB:UN,R2          L/USER #
         LB,R7    UB:US,R7          L/USER STATE #
         LW,R7    TXSTATES-1,R7     L/TEXT EQUIV OF USER STATE
         STW,R7   COCQST+1          S/TEXT FOR STATE INTO ESC-Q MESSAGE
         LI,R7    COCQST            L/ADR OF TEXTC ESC-Q MESSAGE
         ELSE
         LI,R7    TCBANGS           L/ADR OF TEXTC BANGS
         FIN
         B        SNDMESX           B; SEND MESSAGE, GO TO COCIP01
         DO1      ESCQST=0
TCBANGS  TEXTC    '!!'              DOUBLE BANG
*
         DO       OUTPUTIGNORE
ESCW     EQU      %
         DO       TP
         LC       MODE5,R2
         BCS,8    COCIP01           B/SLAVE LINE
         FIN
         BAL,R13  COCKO             DELETE OUTPUT BUFFERS
         LB,R12   MODE3,R2
         OR,R12   BT31TO0+5         OR/MODE3 W/.10; OUTPUT IGNORE BIT
         STB,R12  MODE3,R2          S/MODE3
         LI,R5    'W'               L/'W'
         B        ECESCXIT          B; SEND 'W\'; GO TO COCIP01
         FIN
*
ESCETB   CW,R2    DUMPLINE          C/LINE # W/AUTHORIZED LINE #
         BNE      COCIP01           BNE; IGNORE
         DUMP     X'C0',X'C0'       DUMP MONITOR, CALL ANLZ
         B        COCIP01           B; GO BACK TO TOP OF INT PROCESSING
*
ESCA     LB,R4    COCTERM,R2        L/TRANS TBL INDEX
         AI,R4    -AAPLX            -ASCII APL TRANS TBL INDEX
         BEZ      %+2               BEZ; WE'RE IN ASCII APL MODE OR
*                                   .. ASCII APL DOESN'T EXIST
         LI,R4    AAPLX             L/ASCII APL TRANS TBL INDEX
         STB,R4   COCTERM,R2        S/0 OR ASCII APL INDEX
         LI,R5    'A'               L/'A'; ECHO 'A\'
ECESCXIT BAL,R15  COCECESC          ECHO ESCAPE SEQUENCE
         B        COCIP01           B; RETURN TO TOP OF INT PROCESSING
BREAK    EQU      %
         DO       HALT
         BAL,R9   COCHLTGO          IF IN HALT MODE, RESTART OUTPUT
         BCS,CC(HLT) COCIP01        IF IN HALT MODE, IGNORE BREAK
         FIN
         LI,R9    BRKYC
         LI,R7    E:CBK
         DO       TP
         LC       MODE5,R2
         BCR,8    IPBRKCT           BR IF MASTER
         BCS,1    COCIP01           BR IF BREAK PENDING
         MTB,0    LB:UN,R2
         BEZ      COCIP01           IGNORE NON-OWNED SLAVE LINES
         LC       MODE2,R2
         BCR,1    %+3               BR IF NOT 2741
         MTB,0    COCTERM,R2        CHECK IF TERM TYPE SET
         BEZ      *R9               NOT YET, PROCESS AS NORMAL BREAK
         LW,R10   R2                SAVE LINE #
         BAL,R1   ECBGBLK           GET A 4 WORD BLOCK
         XW,R10   R2                RESTORE LINE #
         BEZ      COCIP01           NO BUFFER, IGNORE BRK
         LW,R14   BRKWD0            BREAK BLOCK WORD 0
         LB,R5    MODE5,R2
         CI,R5    8
         BAZ      %+3
         MTH,2    14                IF READ DONE, SET TO DO
         LI,R9    COCIP01           BREAK LATER
         LW,15    2                 LINE # TO WORD 2
         STD,14   *10
         BAL,R11  PUTDOLIST2        CHAIN UP REQUEST
         OR,R5    X10               SET BREAK PENDING BIT
         STB,R5   MODE5,R2
         LI,R7    0
         LB,R5    LB:UN,R2          WAKE UP USER IF HE IS ZZZING
         LB,R11   UB:US,R5
         CI,R11   SW
         BNE      %+2
         LI,R7    E:WU
         LB,R5    COCTERM,R2        RESTORE
         LH,R10   COCOTV,R5         TRANSLATE TABLE ADDRESS
         B        *R9
BRKWD0   GEN,8,8,16 1,3,0
         FIN
IPBRKCT  LB,R6    LB:UN,R2          L/USER #
         LB,R6    UB:ACP,R6         L/ASSOCIATED COMMAND PROCESSOR #
         LD,R12   P:NAME,R6         L/COMMAND PROCESSOR NAME
         SD,R12   TCLOGON           C/PROC NAME W/'LOGON'
         BNE      IPBRKCT1          B/NOT LOGON
         MTW,1    COCLBC            COUNT UP BREAKS IN LOGON, AS THEY
         STW,R2   COCLBL            MAY INDICATE A NOISY LINE.
IPBRKCT1 LB,R5    MODE,R2
         AI,R5    1
         CI,R5    3
         BAZ      ESCESC            4 BRKS = CTL Y
         MTB,1    MODE,R2           BUMP BREAK COUNT
         B        *R9
         PAGE
*
*  THE 'ESC' PROC DEFINES THE ESC/ATTN CHARACTERS AND THE
*  ACTION TO TAKE:
*  *  AF(1) IS THE CHARACTER ASSOCIATED WITH THE ESC/ATTN.
*  *  AF(2) IS ONE OF THE FOLLOWING:
*     *  AN ADDRESS OF A ROUTINE TO GO TO.
*     *  A CHARACTER TO BE BUFFERED OR SPECIALLY INTERPRETED.
*
ESC      CNAME
         PROC
         USECT    ESCCHAR:
         DO       NUM(AF)>1
LF       DATA,1   AF(1)
         ELSE
LF       DATA,1   X'FF'
         FIN
         USECT    ESCACT:
         DO       TCOR(AF(2),1)
         DATA,1   AF(2)
         ELSE
         DATA,1   AF(2)-ESCESC+X'80'
 ERROR,4,ABSVAL(AF(2))<ABSVAL(ESCESC)|ABSVAL(AF(2))>ABSVAL(ESCESC)+;
         X'7F'    'ESCAPE ROUTINE NOT IN LEGAL RANGE OF TRANSFER VECTOR'
         FIN
         PEND
*
ESCCHAR: CSECT
ESCACT:  CSECT
         PAGE
         DO       2741CODE
27ESCS   ESC                        DUMMY ENTRY FOR BDR INST
         DO1      3                 SPARE ATTN ENTRIES; USABLE
         ESC                        .. FOR 2741 TERMS ONLY
         ESC      ' ',X'1F'         BLANK-ATTN
         ESC      8,X'31'           BACKSPACE-ATTN
         ESC      'N',X'3F'         N-ATTN
         ESC      'X',CTLX          X-ATTN
         FIN
TTESCS   ESC                        DUMMY ENTRY FOR BDR INST
         DO1      4                 SPARE ESC/ATTN ENTRIES; USABLE
         ESC                        .. FOR ASCII AND 2741 TERMS
         ESC      'O',X'3B'         ESC/ATTN:  O
         ESC      'F',X'30'         ESC/ATTN:  F
         ESC      'L',X'0C'         ESC/ATTN:  L
         ESC      'U',X'34'         ESC/ATTN:  U
         ESC      '(',X'35'         ESC/ATTN:  (
         ESC      ')',X'36'         ESC/ATTN:  )
         ESC      'T',X'37'         ESC/ATTN:  T
         ESC      'S',X'38'         ESC/ATTN:  S
         ESC      'R',X'3E'         ESC/ATTN:  R
         ESC      'C',X'3A'         ESC/ATTN:  C
         ESC      'Y',ESCESC        ESC/ATTN:  Y
         ESC      'B',BREAK         ESC/ATTN:  B
N27ESCS  EQU      BA(%)-BA(ESCACT:)-1 # OF 2741 ATTN'S
         DO1      4                 SPARE ESC ENTRIES; USABLE
         ESC                        .. FOR ASCII TERMS ONLY
         ESC      X'30',ESCESC      ESC-ESC
         ESC      'P',X'33'         ESC-P
         ESC      'E',X'39'         ESC-E
         ESC      'I',5             ESC-I
         ESC      'Q',ESCQ          ESC-Q
         ESC      X'0D',X'3F'       ESC-CARRIAGE-RETURN
         ESC      X'15',X'43'       ESC-LINE-FEED
         ESC      'X',X'32'         ESC-X
         DO1      HALT
         ESC      'H',ESCH          ESC-H
         DO1      ZFLG
         ESC      'Z',X'54'         ESC-Z
         DO1      OUTPUTIGNORE
         ESC      'W',ESCW          ESC-W
         ESC      'A',ESCA          ESC-A
         ESC      X'7C',ESCA        ESC-UPPER-CASE-APL-A
         ESC      X'17',ESCETB      ESC-ETB (CNTRL-W); DUMP MONITOR
         ESC      'D',X'52'         ESC-D
         ESC      'J',X'41'         ESC-J
         USECT    ESCCHAR:          GO BACK TO CHARACTER SECTION
NTTESCS  EQU      BA(%)-BA(TTESCS)-1 # OF ASCII ESC'S
         USECT    COCU:             RETURN TO MAIN COC SECTION
COCIP5B  AI,R11   ESCACT:-ESCCHAR:
         LB,R5    *R11,R4           NEW CHARACTER INTO R5
         OR,R10   BT31TO0+31        OR/FLAGS W/.40000000; ESCAPE FLAG
         LC       *R11,R4
         BCS,8    ESCESC-X'80',R5   GO TO
         LH,R4    COCII,R2          GET INSERTION POINT INTO R4
         CLM,R5   X32X40            SEE IF CHARACTER REQUIRES BUFFERING
         BOL      COCIP5C           B/TRUE
         LC       MODE,R2
         BCS,1    COCIP5D           BRANCH IF READ IS PENDING
         DO       2741CODE
COCIP5C  LC       MODE2,R2
         BCR,1    COCIP9
         B        COCIP93           2741, REPLACE LAST CHAR
COCIP5D  LC       MODE2,R2
         BCR,1    IP930             BRANCH IF NOT 2741
         LI,R7    X'39'
         STB,R7   COCBUF,R4         NULLIFY CHAR AT INSERT POINT
         B        IP930
         ELSE
         B        COCIP5C
COCIP5C  EQU      COCIP9
COCIP5D  EQU      IP930
         FIN
*
         PAGE
         DO       2741CODE=1
*
*                 2741 INITIAL CHAR HANDLING.
*
*                 R5  CHARACTER TO PROCESS
*                 R2  LINE NO.
*
COCIP6   AND,R5   M7
         DO       TP
         LC       MODE5,R2
         BCR,8    %+3
         MTB,0    COCTERM,R2
         BEZ      COCIP65
         LC       MODE2,R2          RESTORE PREV CC
         FIN
         LB,R9    LB:UN,R2
         BEZ      COCIP65           NO USER YET
         BCS,8    COCIP01           IGNORE INPUT FROM DISCONNECTED LINE
         SCS,R5   32
         BEV      COCIP54           BAD PARITY
         AND,R5   M6                SCRUB
         LC       MODE3,R2
         BCR,1    COCIP61           KB NOT LOCKED
*
*   WE'RE GETTING CHARACTERS INPUT WHEN THE KEYBOARD IS
*   SUPPOSEDLY LOCKED.  ONLY HONOR EOA AND EOT; IGNORE
*   ALL OTHERS.
*
         CI,R5    X'3C'             C/CHAR W/EOT
         BE       COCIP6G           BE; PASS IT THRU
         CI,R5    X'34'             C/CHAR W/EOA
         BNE      COCIP01           BNE; IGNORE CHAR
         LI,R5    X'1F'             L/LOWER CASE SHIFT CHAR
COCIP6G  LB,R9    MODE3,R2
         AI,R9    -X'10'
         STB,R9   MODE3,R2          UNLOCK
COCIP61  LH,R7    COCITV,R4
         AND,R4   XFE               SET LC
         CI,R5    X'1F'             LC
         BE       COCIP63           YES
         AI,R4    1
         CI,R5    X'1C'             UC
         BNE      COCIP64           NO
COCIP63  STB,R4   COCTERM,R2
         B        COCIP01
*
COCIP64  CI,R5    X'3C'
         BE       COCIEOT           BRANCH IF CHAR IS ATTN
         CI,R5    X'2D'
         BNE      IP642             BRANCH IF CHAR NOT NEW-LINE
         LB,R4    MODE,R2
         OR,R4    X40               SET EOA PENDING TO IGNORE EOT
         STB,R4   MODE,R2
IP642    LH,R4    COCII,R2
         BEZ      COCIP5F           BRANCH IF NO INPUT
         LB,R4    COCBUF,R4         GET LAST CHARACTER IN INPUT BUFFER
         AI,R4    -X'39'
         BNEZ     COCIP5F           BR IF CHAR IS NOT NULLED ATTN SEQ
         MTH,-1   COCII,R2          BACK UP INSERTION POINT
         B        COCIP5F
*
COCIP65  CI,R5    X'7C'             EOT
         BNE      COCIP66
COCIP65E BAL,R9   EOTACT            TURN LINE AROUND
         LB,R4    COCTERM,R2
         BNEZ     BREAK             KB ASSIGNED,ACT LIKE BRK
         LI,R5    X'40'
         BAL,R9   COCSENDT          SP
         LI,R5    X'5D'
         BAL,R9   COCSENDT          BS
IP681    LI,R11   COCIP01
         B        COCEOT1
*
*                 USER IS LOGGING ON, DETERMINE KEYBOARD TYPE
COCIP66  LI,R4    NOSTARS           LENGTH OF ASTERISK TABLE IN R4
         CB,R5    COB:STAR,R4       C/CHAR W/STAR (*) CODES
         BE       %+3
         BDR,R4   %-2
         B        COCIP01           NO FIND
         AI,R5    0
         BEZ      COCIP01           B/0 CHAR; IGNORE
         SLS,R4   1
         LH,R5    COCITV,R4
         BNEZ     COCIP63           BRANCH IF VALID TRANSLATION TABLE
         B        COCIP01
*
*
COCIEOT  LB,R7    MODE,R2           REMEMBER EOA PENDING STATUS
         BAL,R9   EOTACT            TURN LINE AROUND
         CI,R7    X'40'
         BANZ     COCIP01           IGNORE EOT FOLLOWING NEW-LINE
         BAL,R9   IPBRKCT           INC BRK CT & GIVE CTL Y IF 4
         LH,R4    COCII,R2
*                 DETERMINE THE CURRENT BREAK SET IN EFFECT
         LI,R5    4                 SET EBCDIC EOT IN R5
         BAL,R15  COCACSET          COMPARE ACTIVATION CHARACTER SET W/1,2
         BG       COCIP9            B/ACTIV CHAR SET > 1
IPEOT    LB,R6    COCBUF,R4
         LC       MODE,R2
         BCR,1    COCIP01           B/NO READ PENDING; IGNORE
         AI,R4    0                 +0 TO COCII
         BEZ      IP681             BEZ; NO INPUT BUFS EXIST
         B        COCIP59           B; PROCESS EOT
*
*
EOTACT   LB,R5    MODE,R2
         OR,R5    X40               SET EOA PENDING BIT
         STB,R5   MODE,R2
         LB,R5    MODE3,R2
         OR,R5    X10
         STB,R5   MODE3,R2          LOCK KB
         LB,R5    COCTERM,R2
         AND,R5   XFE               SET TERM TO LOWER CASE
         STB,R5   COCTERM,R2
         B        COCSNDFF          B; SEND .FF TO START LINE
         FIN
 TITLE 'C O C U   -   H A L F - D U P L E X   T U R N A R O U N D'
         DO       HALF%DUPLEX
**************************************************************************
*F*  NAME:    T:COCTA
*F*  PURPOSE: TURN HALF-DUPLEX COC LINES TO OUTPUT MODE.
*F*  DESCRIPTION:  ALL LINES IN THE RANGE OF COCHDFLN THRU COCHDLLN
*F*           ARE CHECKED FOR TURNAROUND STATUS.  THOSE TURNING TO OUTPUT
*F*           ARE CHECKED FOR CLEAR-TO-SEND BEING TRUE.  AFTER CTS HAS
*F*           BEEN TRUE FOR AT LEAST 125 MS, OUTPUT MODE IS SET AND
*F*           A .FF CHARACTER IS TRANSMITTED.  THIS ROUTINE IS CALLED
*F*           FROM CLOCK3 BECAUSE OF COCHDICB.
**************************************************************************
T:COCTA  LH,R8    CO:INTFL          CHECK CLOCK3 LOCKOUT FLAG
         BNEZ     *R11              BNEZ; WE INTERRUPTED COC PROCESSING
         LI,R0    -1                L/INITIAL VALUE FOR LAST LINE STILL
*                                   .. NEEDING TURNAROUND
         BAL,R13  COCDSABL          DISABLE COC INTERRUPTS
         LI,R13   AC(HD)+AC(HDIN)+AC(HDTA) L/HALF-DUPLEX, INPUT MODE, AND
*                                   .. TURNAROUND BITS; VALUE & MASK
*                                   .. FOR CS INSTRUCTION
         XW,R2    COCHDFLN          X/HIGH VALUE W/FIRST LINE # NEEDING
*                                   .. TURN-AROUND
TTI20    LB,R12   MODE6,R2          L/MODE6
         CS,R13   R12               CHECK FOR LINE NEEDING TURNAROUND
         BNE      TTI90             B/DOESN'T NEED TURNING AROUND
         BAL,R6   COCPHYLN          G/PHYSICAL LINE # IN R7, COC # IN R3
         EXU      CO:TSTAT,R3       SENSE TRANSMITTER STATUS
         BCS,2    TTI40             B/CLEAR-TO-SEND TRUE
         LW,R10   R7                PHYSICAL LINE # TO R10
         EXU      CO:STAT,R3        'SENSE RECEIVER STATUS'
         BCS,3    TTI80             B/DSR TRUE; LINE STILL CONNECTED
TTI40    CI,R12   AC(HDTA2)         C/MODE6 W/2ND PHASE TURNAROUND FLAG
         BAZ      TTI60             BAZ; ENTER SECOND PHASE
         AI,R12   -AC(HDIN)-AC(HDTA)-AC(HDTA2) RESET INPUT MODE, TURNING
*                                   .. AROUND, SECOND PHASE TURNINGAROUND
         STB,R12  MODE6,R2          S/MODE6
         BAL,R9   COCSNDFF          XMIT RUBOUT CHAR TO GET LINE GOING
         B        TTI90             B; DONE WITH THIS LINE
TTI60    AI,R12   AC(HDTA2)         SET SECOND-PHASE TURNING AROUND FLAG
         STB,R12  MODE6,R2          S/MODE6
TTI80    LW,R0    R2                L/CURRENT LINE #; SAVE AS LAST LINE
*                                   .. # NEEDING TURNING AROUND
         CW,R2    COCHDFLN          C/CURRENT LINE # W/FIRST LINE #
*                                   .. NEEDING TURNING AROUND; THE FIRST
*                                   .. TIME WE FIND A LINE NEEDING
*                                   .. TURNING AROUND COCHDFLN WILL BE
*                                   .. AN ILLEGALLY LARGE VALUE
         BGE      TTI90             BGE; THIS ISN'T FIRST LINE FOUND
*                                   .. THAT STILL NEEDS TURNING AROUND
         STW,R2   COCHDFLN          S/REAL LINE # OF FIRST LINE STILL
*                                   .. NEEDING TURNAROUND
TTI90    AI,R2    1                 INC LINE #
         CW,R2    COCHDLLN          C/LINE # W/LAST LINE # NEEDING
*                                   .. TURNAROUND
         BLE      TTI20             BLE; KEEP CHECKING
         STW,R0   COCHDLLN          S/LAST LINE #
         AI,R0    0                 CHECK FLAG REGISTER INDICATING IF
*                                   .. ANY LINES STILL NEED TURNAROUND
         BGE      ENABLXIT          BGE; STILL SOME LEFT
         LW,R5    Y1                L/CLOCK3 ONE-SHOT BIT
         STS,R5   COCHDICB          S/ONE-SHOT BIT; CLOCK 3 WILL
*                                   .. DE-LINK COCHDICB FOR US
         B        ENABLXIT          B; ENABLE COC INTERRUPTS, RETURN TO
*                                   .. CLOCK3
         FIN
 TITLE 'C O C U   -   O U T P U T   I N T E R R U P T   R O U T I N E'
************************************************************************
*F*  NAME:    COCOP
*F*  PURPOSE: HANDLE COC OUTPUT INTERRUPTS
*F*  DESCRIPTION:  COCOP PERFORMS THE FOLLOWING BASIC FUNCTIONS:
*F*           *   OBTAINS THE LINE NUMBER OF THE LINE REQUESTING THE
*F*               INTERRUPT.
*F*           *   OBTAINS THE NEXT OUTPUT CHARACTER FOR THIS LINE FROM
*F*               A COC BUFFER.
*F*           *   PERFORMS CASE SHIFT FUNCTIONS IF A 2741-TYPE LINE AND
*F*               REQUIRED.
*F*           *   TRANSMITS THE CHARACTER TO THE COC.
*F*           *   HANDLES DEBLOCKING THE USER IF BLOCKED FOR TERMINAL
*F*               OUTPUT.
*F*           *   HANGS UP THE LINE IF A HANGUP HAS BEEN REQUESTED.
************************************************************************
COCOP    EQU      %
*        OUTPUT INTERRUPT ROUTINE - R3 = COC#
         EXU      CO:OUTRS,R3       OUTPUT RESPONSE - FIND LINE NUMBER
         AND,R7   CO:LNM,R3         &/LINE # W/.7F IF FECP, .3F IF COC
         LD,R4    COD:LPC,R3        R4 =  LOGICAL LINE # OF 1ST LINE IN
*                                   COC CURRENTLY PROCESSING- R5 = LAST#
         LW,R2    R7
         AW,R2    R4                R2 =  LOGICAL LINE TO PROCESS
         CW,R2    R5                CHECK FOR VALID LINE
         BG       COCOP30           BRANCH IF INVALID LINE
*
COCOP05  LH,R11   COCOC,R2          L/OUTPUT CHARACTER COUNT
         BEZ      COCOP30           BRANCH IF INTERUPT IS EXTRANEOUS
         DO       PMONOFF=1
         MTW,1    C:CO
         FIN
         DO       2741CODE=1
         LC       MODE2,R2
         BCR,1    COCOP10           BRANCH IF NOT 2741
         LB,R5    MODE,R2
         AI,R5    -X'40'
         BLZ      COCOP10           BRANCH IF EOA IS NOT PENDING
         STB,R5   MODE,R2           RESET EOA PENDING BIT
         LI,R5    X'34'             SET TO XMIT EOA
         B        COCOP52           BRANCH TO TRANSMIT EOA
         FIN
COCOP10  LH,R4    COCOR,R2          GET RMVL POINT
         BEZ      COCOP20           LINE FINISHED  -  EXIT
         DO       HALT
         LC       MODE6,R2          CHECK HALT FLAG
         BCS,CC(HLT) COCOP58        B/OUTPUT HALTED; STOP TRANSMITTING
         FIN
         LB,R5    COCBUF,R4         GET CHAR
         DO       TP
         CI,R5    COC:SPECHAR       IS IT THE SPECIAL CHAR
         BNE      COCOP10A          NO
         PUSH     7
         BAL,R13  COCDSABL
         BAL,R11  COCGECBW          GET WAIT BLOCK
         BNEZ     COCOP10D          FOUND THE BLOCK
         PULL     7
         LH,R11   COCOC,R2          L/OUTPUT CHARACTER COUNT
         INHIBIT
         BAL,R13  COCENABL
         B        COCOP10A          OUTPUT CHARACTER COUNT
COCOP10D AI,R5    X'100'
         LI,9     X'01'             TYC = NORMAL.
         BAL,R11  COCPECB           POST ECB & FREE BLOCK.
         LH,R11   COCOC,R2          L/OUTPUT CHARACTER COUNT
         PULL     7
         INHIBIT
         BAL,R13  COCENABL
         B        COCOP11
COCOP10A EQU      %
         FIN
         DO       2741CODE=1
         LC       MODE2,R2
         BCR,1    COCOP11           BRANCH IF NOT 2741
         CI,R5    8
         BAZ      OP10A             NOT A 2741 CONTROL CODE
         CI,R5    4
         BAZ      OP10A             NOT A 2741 CONTROL CODE
         CI,R5    X'2D'
         BNE      COCOP11           BRANCH IF CONTROL CODE NOT A CR
OP10A    LB,R6    COCTERM,R2
         CI,R5    X'40'
         BAZ      OPLC              LC CHAR
         BE       COCOP11           BRANCH IF CHAR IS A SPACE
         CI,R6    1
         BANZ     OP2741P           TERMINAL ALREADY UC
         LI,R5    X'1C'             UC SHIFT
         B        OPCS              CASE SHIFT
OPLC     CI,R6    1
         BAZ      OP2741P           TERMINAL ALREADY LC
         LI,R5    X'1F'             LC SHIFT
OPCS     LC       MODE3,R2
         BCR,1    OP2741P           DON'T SET TERM CASE IF KB UNLOCKED
         EOR,R6   X1
         STB,R6   COCTERM,R2        REVERSE TERMINAL CASE
         B        COCOP52           OUTPUT CASE SHIFT CHARACTER
OP2741P  SCS,R5   32
         BOD      %+2
         EOR,R5   X40               SET PARITY ODD IF NOT
         FIN
COCOP11  MTH,-1   COCOC,R2          DECREMENT OUTPUT CHARACTER COUNT
         AI,R11   -2
         BGZ      COCOP35           BRANCH IF MORE CHAR'S IN BUFFER
         BEZ      COCOP40           BRANCH IF LAST CHAR IN OUTPUT BUF'S
************************************************************************
*S*  SCREECH CODE:    13-00
*S*  REPORTED BY:     COC/MINICOC/TPCOC
*S*  MESSAGE:         COC - OUTPUT BUF LINKAGE OR CHARACTER COUNT BAD
*S*  TYPE:            SCREECH
*S*  REGISTERS:       R2  = LOGICAL LINE NUMBER
*S*                   R3  = COC NUMBER
*S*                   R4  = REMOVAL POINT
*S*                   R11 = OUTPUT COUNT, USUALLY -1
*S*  REMARKS:         INCONSISTENT OUTPUT COUNT AND BUFFERS.  MAY BE
*S*                   CAUSED BY CLOBBERED COC TABLES (COCOC, COCOI, COCOR)
*S*                   A BAD FREE BUFFER CHAIN,
*S*                   OR A CLOBBERED OUTPUT CHAIN.
************************************************************************
         SCREECH  X'13'             SCREECH .13
COCOP35  AI,R4    1                 BUMP REMOVAL POINT
         CI,R4    X'F'
         BANZ     COCOP50           BRANCH IF STILL IN SAME BUFFER
         AI,R4    -1                BACK UP R4 TO WITHIN BUFFER
COCOP40  BAL,R6   COCPUTBL          RELEASE, RTN LINK
COCOP50  STH,R4   COCOR,R2
COCOP52  LW,R6    R7
         DO       TP
         CI,R5    COC:SPECHAR+X'100' IS IT THE SPECIAL CHAR
         BE       COCOP05           YES, GET ANOTHER THEN
         FIN
         SLS,R5   8
         OR,R6    R5                MERGE CHAR, LINE #
         EXU      CO:XDATA,R3       XMIT
*                 CHECK IF USER SHOULD BE UNBLOCKED.
         LB,R7    MODE4INIT,R2      L/LINE SPEED INDICATOR FROM MODE4INIT
         AND,R7   M3                &/SPEED W/7
         LB,R7    COB:CPS,R7        L/CHARACTERS PER SECOND
         MW,R7    SL:UB             (CHARS/SEC) / (UNBLOCK LIMIT IN SECS)
         SW,R11   R7                (CHARS Q'D) - (CHARS UNBLOCK LIMIT)
         BNE      COCOP57           BRANCH IF NOT AT UNBLOCK LIMIT
COCOP54  BAL,R9   UNBLOCK           UNBLOCK USER IF STOB OR STOBO
         BNE      COCOP57           B/WASN'T STOB OR STOBO
         LW,R5    CO:OUT,R3         L/ADR OF INTERRUPTED PSD
         LD,R0    *R5               L/PSD AT TIME OF INTERRPUT
         STD,R0   CO:IN0            SAVE FOR ENVIRONMENT PUSH
SCHDEXIT LRP      CO:IN0+1          L/RGSTR PNTR FROM INTERRUPTED PSD
         T:PUSHE  CO:IN0            PUSH ENVIRONMENT
         LI,R13   T:SSE             L/EXIT ADR FOR COCENABL
         LPSD,3   SCHPSD            ARM (CLEAR) ACTIVE INT LEVEL,
*                                   .. ENABLE COC INTS, CLEAR T:COCHC
*                                   .. LOCK-OUT FLAG, GO TO T:SSE
*
*
COCOP20  STH,R4   COCOC,R2          ZERO OUTPUT CHARACTER COUNT
         LC       MODE2,R2
         BCR,8    COCOP25           BRANCH IF LINE NOT REPORTED OFF
         STB,R4   COCTERM,R2        RESET TERM TYPE TO 0
         EXU      CO:RCVDOFF,R3     TURN RECEIVER DATA SET OFF
         EXU      CO:RCVON,R3       AND REINITIALIZE
COCOP25  EXU      CO:XSTOP,R3       CLEAR SCANNER
         DO       HALF%DUPLEX
         LC       MODE6,R2
         BCR,CC(HD) COCOP54         B/NOT HALF-DUPLEX
         LB,R1    MODE6,R2          L/MODE6
         CI,R1    AC(HDTA)
         BAZ      COCOP80           B/NOT TURNING AROUND YET
         OR,R1    LC(HDIN)          SET INPUT MODE
         AND,R1   NLC(HDTA)         RESET TURNING-AROUND
         STB,R1   MODE6,R2          S/MODE6
         EXU      CO:RCVON,R3       TURN RECEIVER ON
         FIN
         B        COCOP54
COCOP30  MTW,1    COCOEC            BUMP OUTPUT ERROR COUNT
         STW,R2   COCOEL            S/LOGICAL OR PHYSICAL LINE #
         STB,R3   COCOEL            S/COC #
COCOP55  EXU      CO:XSTOP,R3       CLEAR SCANNER
COCOP57  LW,R4    CO:OUT,R3
         LPSD,11  *R4               EXIT LEVEL
COCOP58  MTH,-1   COCOC,R2          DEC OUTPUT CHAR COUNT
         B        COCOP55           B; STOP LINE, EXIT
UNBLOCK  LB,R6    LB:UN,R2          L/USER #
         LB,R6    UB:US,R6          L/USER STATE
         AI,R6    -STOBO            - TERMINAL OUTPUT BLOCKED OUT-OF-CORE
         BEZ      %+3               B/STOBO; UNBLOCK
         AI,R6    STOBO-STOB        CHECK FOR STOB
         BNEZ     *R9               B/NOT BLOCKED ON OUTPUT; RETURN
         BAL,R13  COCDSABL          DISABLE COC INTERRUPTS, RESET
*                                   .. INHIBITS IF ON
         LI,R6    E:CUB             L/UNBLOCK EVENT
         BAL,R11  RCE               REPORT COC EVENT
         LCI      0                 L/CC'S OF 0
         B        *R9               RETURN
         DO       HALF%DUPLEX
COCOP80  MTH,1    COCOC,R2          INC OUTPUT CHAR COUNT
         OR,R1    LC(HDTA)          SET TURNING-AROUND
         STB,R1   MODE6,R2          S/MODE6
         LI,R5    RUBOUT            L/RUBOUT CHAR
         B        COCOP52           B; SEND RUBOUT
         FIN
 TITLE 'C O C U   -   A U T O   H A N G U P / C A L L U P'
**************************************************************************
*F*  NAME:    T:COCHC
*F*  PURPOSE: TO PROVIDE LINE HANG-UP, CALL-UP, AND TIMEOUT FUNCTIONS.
*F*  DESCRIPTION:  T:COCHC PROVIDES THE FOLLOWING BASIC FUNCTIONS:
*F*           *   IF A SIGNIFICANT CHANGE IN THE STATUS OF A COC IS NOTED,
*F*               COCINIT IS CALLED.
*F*           *   IF A DIAL-UP LINE HAS A CONNECTION BUT NO USER,
*F*               INITIATE A SESSION.
*F*           *   IF A LINE HAS A USER BUT NO CONNECTION, INITIATE A
*F*               TERMINATION SEQUENCE.
*F*           *   IF A DIAL-UP LINE, CHECK FOR READ TIMEOUT.
*F*           *   IF BUFFERS ARE AVAILABLE, REPORT THIS TO THE SCHEDULER.
**************************************************************************
T:COCHC  MTW,1    CO:INTFL          INC CLOCK3 BY-PASS COUNTER
         LH,R8    CO:INTFL          L/COC INTERUPT STATUS FLAG
         BNEZ     *R11              BNEZ; WE'VE INTERRUPTED COC PROCESSING
         BAL,R13  COCDSABL          DISABLE COC INTERRUPTS
         PUSH     R11               PUSH R11; RETURN ADR
         LI,R3    LCOC              INITIALIZE REG 5 TO LAST 7611 NUMBER
COCHC0   LH,R2    COH:DN,R3         L/DEVICE ADR FOR THIS COC
COCSTIO  TIO,R9   0,R2              TIO COC; SEE IF THIS COC IS RUNNING
         BCS,8    COCHC63           B/ADR NOT RECOGNIZED
         BCR,4    COCHC64           B/DEVICE NOT BUSY; NOT RUNNING
         LD,R6    COD:LPC,R3        RANGE OF LOGICAL LINES ON 7611
         SW,R6    R7
         LCW,R10  R6                LAST PHYSICAL LINE INTO R10
         LW,R2    R7                MOVE LOGICAL LINE # TO R2
COCHC1   LI,R11   2
COCHC2   EXU      CO:STAT,R3        SENSE RECEIVER STATUS
         BCS,3    COCHC5            B/RECEIVER IS INSTALLED AND DATASET
*                                   .. READY IS TRUE
         BDR,R11  COCHC2
         LH,R6    COCOC,R2          L/OUTPUT CHARACTER COUNT
         BEZ      %+3               BEZ; NO CHARACTER Q'D FOR OUTPUT
         BAL,R13  COCKO             DELETE ALL OUTPUT BUFFERS
         STH,R4   COCOC,R2          0/COCOC; IF FECP, WE MAY NOT GET
*                                   .. THE OUTPUT INTERRUPT FROM THE
*                                   .. CHAR XMISSION IN PROGRESS
         LB,R6    LB:UN,R2          USER NUMBER
         BEZ      COCHC8            BRANCH IF NO USER ON THIS LINE
         LC       MODE2,R2
         BCS,8    COCHC8            LINE IS OFF.
         DO       2741CODE
         BCR,1    COCHC26
         STB,R11  COCTERM,R2        DISABLE AUTO LOGON
         FIN
COCHC26  EQU      %
         DO       TP
         LC       MODE5,R2
         BCR,8    COCHC27           REPORT 'OFF' FOR NON-SLAVE LINES.
         BCR,2    COCHC8            IGNORE SLAVE LINES W/ NO OPEN DCB.
         LI,R11   COCHC28E            (GO HERE WHEN DONE PURGING)
         PUSH     16,R3             SAVE REGS FOR KILLIO
         LI,R12   RD:ERRCODE        READ TYC = LINE HANGUP.
         LI,R15   WT:ERRCODE        WRITE TYC = LINE HANGUP.
         B        COCKIOHU          ---> GO PURGE EVERYTHING.
COCHC27  EQU      %                 <NON-SLAVE LINES GET OFF'ED HERE>
         FIN
         DO       TCOUPL=1
         BAL,R11  DECOUPLE%         GO DECOUPLE THE LINE
         LB,R6    MODE4,R2          AND RESET THE COUPLE CONTROL BITS
         AND,R6   MASKS+6           &/MODE4 W/.3F; RESET COUPLE BITS
         STB,R6   MODE4,R2
         FIN
         INHIBIT                    SET INHIBITS
         LB,R6    LB:UN,R2
         LH,R11   UH:FLG2,R6
         CI,R11   X'20'             C/UH:FLG2 W/HANG-UP/LOGOFF BIT
         BANZ     COCHC28E          B/ALREADY LOGGING OFF
         AI,R11   X'20'             SET HANG-UP BIT
         STH,R11  UH:FLG2,R6
         LI,R6    E:OFF             SET TO REPORT 'OFF' EVENT
COCHC28  BAL,R11  RCE               REPORT EVENT
COCHC28E BAL,R13  COCDSABL          DISABLE COC INTERRUPTS
COCHC8   AI,R2    -1                NEXT LOGICAL LINE
         AI,R10   -1                NEXT PHYSICAL LINE
         BGEZ     COCHC1            CONTINUE FOR ALL LINES ON THIS COC
COCHC9   AI,R3    -1                DECREMENT 7611 NUMBER
         BGEZ     COCHC0            BRANCH UNTIL ALL 7611'S PROCESSED
*
         LI,R5    1
         LI,R6    0                 L/0
         STH,R6   CO:INTFL,R5       0/T:COCHC BY-PASS COUNTER
         LH,R1    COCGFLG,R5        L/RH OF COCGFLG
         BEZ      %+2               B/0
         BAL,R11  COCINIT2          BAL/CALL COCG
         LW,R4    COCHPB
         BEZ      HCXIT             BRANCH IF NO COC BUFFERS AVAILABLE
         LI,R6    E:CBA             REPORT BUFFERS AVAIL
         BAL,R11  T:RUE
*                                   .. RETURN WITH INHIBITS OFF
HCXIT    PULL     R13               PULL RETURN ADR
         B        COCENABL          B; ENABLE COC INTERRUPTS, RETURN
*                                   .. TO CLOCK3
*
COCHC5   LC       MODE6,R2
         BCS,CC(UTO) COCHC5E        B/USER TIME-OUT; IGNORE SS-2 AND
*                                   .. HARDWIRE BITS
         DO       TP
         LC       MODE5,R2          DON'T CHECK
         BCS,8    COCHC8            SLAVE LINES
         FIN
         RD,0     0                 READ SENSE SWITCHES
         BCS,4    COCHC8            B/SS2 IS UP
         LB,R8    MODE6,R2
         CI,R8    AC(HW)            C/MODE6 W/HARDWIRE BIT
         BANZ     COCHC8            B/HARDWIRED LINE
COCHC5E  LB,R6    LB:UN,R2
         BNEZ     COCHC7            BRANCH IF USER EXISTS FOR THIS LINE
         DO       2741CODE=1
         LC       MODE2,R2          CHECK FOR 2741 TERMINAL
         BCR,1    COCHC6            BRANCH IF NOT 2741
         LB,R6    COCTERM,R2        CHECK IF KEYBOARD STILL INITIALIZED
         BEZ      COCHC8            DO NOT LOGON IF KEYBOARD TYPE = 0.
         LC       MODE3,R2
         BCR,1    COCHC8            LOGON UNDERWAY IF KEYBOARD UNLOCKED
         FIN
         LC       MODE2,R2
COCHC6   BCR,8    COCHC62           BRANCH IF NOT LOGGING OFF
         LH,R6    COCOC,R2          L/OUTPUT CHARACTER COUNT
         BNEZ     COCHC8            BRANCH IF NOT LOGGED OFF YET
COCHC62  EQU      %
         DO       TP
         LB,R6    MODE5,R2          GET TP SLAVE LINE SWITCHES
         CI,R6    4                 CK FOR 'TP-REQUESTED LINE'
         BAZ      COCHC621          B, IF NOT; REINITIALIZE LINE TBLS
         INT,R5   CO:INTFL          ELSE, GET T:COCHC BYPASS COUNT
         MTH,-1   EOMTIME,R2        DECREMENT TIME LEFT FOR TP-ACQUIRE
         BEZ      COCHC621          B, IF UNACQUIRED; REINITIALIZE FOR TS
         BDR,R5   %-2               DECREMENT AGAIN IF T:COCHC BYPASSED
         B        COCHC8            MOVE ON TO THE NEXT LINE
COCHC621 EQU      %
         FIN
         DO       HALF%DUPLEX
         LC       MODE6,R2
         BCS,CC(HD) COCHC625        B/HALF-DUPLEX
         FIN
         LW,R7    R10               L/PHYSICAL LINE #
         EXU      CO:TSTAT,R3       SENSE TRANSMITTER STATUS
         BCR,2    COCHC8            B/CLEAR TO SEND NOT TRUE
COCHC625 DO1      HALT
         BAL,R9   COCHLTGO          RESTART LINE IF IN HALT MODE
         BAL,R4   COCMINT           INITIALIZE MODE CONTROL BITS
         LI,R6    E:CBK             SET TO REPORT BREAK (CALL'S LOGON)
         B        COCHC28           BRANCH TO REPORT EVENT
COCHC63  LC       COB:SIOS,R3       L/SAVED SIO CC'S
         BCS,8    COCHC9            B/ADR NOT RECOGNIZED NOW OR AT SIO
COCHC64  LI,R9    X'200'            L/FLAG SAYING CLOCK3/T:COCHC CALLING
         STS,R9   COCGFLG           S/FLAG
         B        COCHC9            B; PROCESS NEXT COC
*
*                 TIME OUT USERS HAVING READS PENDING
COCHC7   LC       MODE,R2
         BCR,1    COCHC8            BRANCH IF NO READ IS PENDING
         INT,R5   CO:INTFL          L/T:COCHC BY-PASS COUNT + 1
         MTH,-1   EOMTIME,R2        DECREMENT TIMER
         BEZ      COCHC7C           BEZ; READ HAS TIMED OUT
         BDR,R5   %-2               BDR IF T:COCHC WAS BY-PASSED
         B        COCHC8            B; USER HAS TIME LEFT
COCHC7C  MTH,-1   EOMTIME,R2        MAKE EOMTIME NON-ZERO; OTHERWISE,
*                                   .. BUFFER POINTERS MAY BE RESET
*                                   .. WITHOUT RELEASING BUFFERS
         LC       MODE6,R2
         BCR,CC(UTO) COCHC26        B/NOT USER-CONTROLLED TIME-OUT
**************************************************************************
*E*  ERROR:   23-00
*E*  DESCRIPTION:  ON-LINE TERMINAL READ TIMED OUT
**************************************************************************
         PUSH     (R3,R10)          PUSH R3 -> R10
         LB,R4    COCTERM,R2        L/TERMINAL TYPE
         LH,R10   COCOTV,R4         L/OUTPUT TRANSLATE TABLE ADR
         LCH,R1   COCII,R2          L/COMPLEMENT OF CURRENT INPUT POINTER
         STH,R1   TL,R2             S/-POINTER TO MARK ACTIVATION POINT
         BAL,R15  COCSACTO          SET ACTIVATION RECEIVED, USER TIME-OUT
         LI,R6    E:CIC             L/INPUT COMPLETE EVENT #
         BAL,R11  RCE               REPORT COC EVENT
         PULL     (R3,R10)          PULL R3 -> R10
         B        COCHC8            B; GO ON TO NEXT LINE
         PAGE
**************************************************************************
*F*  NAME:    COCOFF
*F*  PURPOSE: TO PROVIDE INITIAL CLEANUP ON A LINE THAT IS BEING
*F*           HUNG UP.
*F*  DESCRIPTION:  COCOFF IS CALLED BY THE SCHEDULER, AND DOES THE
*F*           FOLLOWING:
*F*           *   RELEASES ANY INPUT AND OUTPUT BUFFERS.
*F*           *   REPORTS ACTIVATION IF A READ IS PENDING.
**************************************************************************
COCOFF   BAL,R13  COCDSABL          DISABLE COC INTERRUPTS
         LB,R4    MODE2,R2
         OR,R4    BT31TO0+8         =.80
         STB,R4   MODE2,R2          SET REPORTED OFF BIT
         PUSH     (R3,R15)          PUSH R3 -> R15
         LB,R4    COCTERM,R2        L/TRANS TABLE #
         LH,R10   COCOTV,R4         L/OUTPUT TRANS TABLE ADR
         BAL,R8   COCKIO            RELEASE IN & OUT BUFS
         LC       MODE,R2           L/MODE
         BCR,1    COCOFF6           B/NO READ PENDING; DON'T ACTIVATE
         BAL,R15  COCSACT2          READ PENDING, SET ACTIVATION RCV'D
COCOFF6  DO1      HALT
         BAL,R9   COCHLTGO          RESTART OUTPUT IF IN HALT MODE
         BAL,R9   UNBLOCK           UNBLOCK THE USER IF STOB/STOBO
         BAL,R13  COCKO             BAL/KILL ALL OUTPUT
         STH,R4   COCOC,R2          0/OUTPUT CHARACTER COUNTER
         PULL     (R3,R15)          PULL R3 -> R15
ENABLXIT LW,R13   R11               L/RETURN ADR
         B        COCENABL          RETURN TO SCHEDULER THRU COCENABL
 TITLE 'C O C U   -   S U M M A R Y'
         END

