MONPROC  SET      1
         SYSTEM   UTS
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1,R8   EQU      8
SR2,R9   EQU      9
SR3,R10  EQU      10
SR4,R11  EQU      11
D1,R12   EQU      12
D2,R13   EQU      13
D3,R14   EQU      14
D4,R15   EQU      15
*
         DEF      CNMPROC:          PATCHING DEF
*
         REF      S:CUN,REGMASK,Y8,J:BASE
         SREF     LB:UN             ******SREF*******
         REF      X10
         REF      X100
         REF      M3                MASK
         REF      OUT,YC,CC1SET,CC1RST
*
CNMPROC: RES
         PAGE
*****
*        THIS ROUTINE ACQUIRES OR RELEASES COMMUNICATION LINES
*        ASSOCIATED WITH TRANSACTION PROCESSING. TO ACQUIRE A
*        LINE, THE FOLLOWING CONDITIONS MUST BE MET
*                 1) THE USER MUST HAVE BEEN AUTHORIZED FOR
*                    TRANSACTION PROCESSING.
*                 2) THE SUPPLIED LINE ID MUST BE VALID
*                 3) THE LINE MUST BE IN THE FREE STATE.
*                 4) THE LINE MUST BE TYPE=EITHER OR TYPE=SLAVE
*
*        TO RELEASE A LINE THE FOLLOWING CONDITIONS MUST BE MET.
*                      1) THE LINE MUST CURRENTLY BE OWNED BY
*                         THE REQUESTER.
*                      2) THE LINE'S ASSOCIATED DCB MUST BE CLOSED
*
*        INPUT:   (R6) = LINE ID ADDRESS
*                 (R7) = WA(FPT+1)
*                 (SR1)= FPT CODE
*                 (SR4)= WA(TRAPEXIT)
*        OUTPUT:  CC1=0 IF THE GET/RLS REQUEST WAS SATISFIED
*                 CC1=1 IF THE GET/RLS REQUEST WAS NOT SATISFIED
*****
         REF      DCT23             CONTAINS MOC SLAVE LINE SWITCHES
         REF      X80               TABLE MASK=X'80'
         REF      X40               TABLE MASK=X'40'
         REF      OPNBIT            DCB OPN BIT IN LINE SWITCES=X'20'
         REF      X3                TABLE MASK=X'03'
         REF      M6                TABLE MASK=X'3F'
         SREF     MODE5             CONTAINS COC SLAVE LINE SWITCHES
         REF      TQAUTH            USED TO CK IF USER IS TP-AUTHORIZED
*
         DEF      CNMPROC0          BRANCHED TO FROM TPQ2 MODULE
         DEF      CNMPROC1          BRANCHED TO FROM TPQ2 MODULE
*
SLVLNST  EQU      X3                SYSGEN LINE TYPE MASK FOR LN SWITCHES
CT:SLAVE EQU      X80               CURRENT LINE TYPE = SLAVE BIT
CT:MASTR EQU      X40               CURRENT LINE TYPE = MASTER BIT
         PAGE
*
CNMPROC0 EQU      %
         BAL,SR4  TQAUTH            NO RETURN IF USER NOT TP-AUTHORIZED
*
CNMPROC1 EQU      %
         LW,SR3   S:CUN             GET CURRENT USER#
         LW,R3    R6                MOVE WA(LINE ID) TO INPUT REG
         CW,R3    REGMASK           SEE IF ADDRESS IS A REGISTER
         BANZ     %+2               B, IF NOT
         AW,R3    J:BASE            ELSE, POINT TO USER'S REG VALUE
         BAL,SR4  CNMPROC9          CONVERT LN ID TO DCT INDX OR LN#
         LW,R2    D1                CK RESULT OF CONVERSION
         BEZ      CC1SET            *****ERROR INDICATED
         BLZ      BILNINIT          NEG MEANS BI-PNT LN
*
MULNINIT EQU      %
         LI,R1    HA(DCT23)         POINT TO CNM SLAVE LN FLAGS
         AW,R1    R2
         SLS,R1   1                 R1=> BOUND/FREE BYTE.
         LW,R3    R1                R3=> CNM LN SWITCHES BYTE
         AI,R3    1                 (R3) POINTS TO CNM LN SWITCHES BYTE
         B        CKFPTCD           DETERMINE REQUEST TYPE (RLS OR GET)
*
BILNINIT EQU      %
         AI,R2    -1                CNMPROC9 DID +1 TO MAKE IT NONZERO
         LI,R1    BA(LB:UN)
         AW,R1    R2                R1=> BOUND/FREE BYTE
         LI,R3    BA(MODE5)
         AW,R3    R2                R3=> CNM LN SWITCHES BYTE
*
CKFPTCD  EQU      %
         DISABLE                    **INHIBIT INTERRUPTS
         LB,D1    0,R3              GET CNM LN SWITCHES
         AI,SR1   0                 POKE THE FPT CODE
         BNEZ     RLSLINE           B IF THIS IS A RELEASE REQUEST
*
GETLINE  EQU      %
         LB,SR4   0,R1              GET BOUND VS. FREE INDICATOR
         BNEZ     CC1SETX           *****ERROR IF LINE IS BOUND
         CW,D1    CT:MASTR          CK CURRENT TYPE FOR MASTER
         BANZ     CC1SETX           B, IF MASTER; CAN'T ACQUIRE AS SLV
         AI,R2    0                 CK MULTI VS. BIPOINT
         BGZ      %+4               B, IF MULTIPOINT
         STB,D1   MODE5,R2          RESTORE SWITCH FOR COCMINT CHANGES
         BAL,R4   COCMINT           THEN, INITIALIZE COC LINE TABLES
         LB,D1    MODE5,R2          RETRIEVE MODIFIED SWITCH BYTE
         OR,D1    CT:SLAVE          SAY IT'S A SLAVE LINE.
         B        GET:RLSX          RESTORE BND/FREE & SWITCHES BYTES
*
RLSLINE  EQU      %
         CB,SR3   0,R1              SEE IF CURRENT USER OWNS LN
         BNE      CC1SETX           *****ERROR IF HE DOESN'T
         CW,D1    OPNBIT            SEE IF LINE'S DCB IS OPEN
         BANZ     CC1SETX           *****ERROR IF IT IS
         LW,R4    D1                ASSUME DEFAULT TYPE WILL BE USED
         AI,R2    0
         BGEZ     %+3               B/NOT COC LINE
         LC       MODE5,R2
         BCR,8    CC1SETX           B/MASTER LINE; ILLEGAL
         MTW,0    0,R7              CK TYPE OPTION WORD
         BEZ      SETYPE            0 MEANS DEFAULT TO SYSGEN VALUE
         CW,D1    SLVLNST           ELSE, SEE IF SYSGEN'ED TYPE=EITHER
         BANZ     SETYPE            IF NOT, DON'T HONOR TYPE OPTION
         LW,R4    0,R7              GET SPECIFIED TYPE OPTION
         EOR,R4   SLVLNST           SET CURRENT TYPE BITS APPROPRIATELY
*
SETYPE   EQU      %
         AND,D1   M6                CLEAR 'OLD' CURRENT TYPE BITS
         SLS,R4   6                 ADJUST 'NEW' CURRENT TYPE BITS
         OR,D1    R4                INCLUDE THEM IN THE SWITCHES
         LI,SR3   0                 CLR SR3 TO SET LINE FREE
*
GET:RLSX EQU      %
         STB,SR3  0,R1              SET LINE TO PROPER STATE
         STB,D1   0,R3              RESTORE LINE SWITCHES
         ENABLE                     **UNINHIBIT INTERRUPTS
         B        CC1RST            *****SET CC1=0 TO INDICATE ALL OK
*
CC1SETX  EQU      %
         ENABLE                     **UNINHIBIT INTERRUPTS
         B        CC1SET            ****EXIT W/CC1=1 TO INDICATE ERROR
         PAGE
******
*
*        THIS ROUTINE GETS THE STATUS OF INPUT AND OUTPUT
*        BUFFERS ASSOCIATED WITH A SLAVE COC LINE.
*
*        INPUT:   (R6) = DCB ADDRESS.
*                 (R7) = WA(FPT+1)
*                 (SR1)= FPT CODE
*                 (SR4)= WA(TRAPEXIT)
*
*        OUTPUT:  (SR1)= # OF CHARACTERS INPUT SO FAR TO THE LINE'S
*                          BUFFERS; BIT 0 = 1 IMPLIES THAT AT LEAST
*                          ONE ACTIVATION CHARACTER IS IN THE BUFFERS.
*                 (SR2)= # OF CHARACTERS REMAINING IN THE LINE'S
*                          OUTPUT BUFFERS.
*                 (SR3)=   MAXIMUM # OF CHARACTERS THE USER IS EVER
*                          ALLOWED TO OUTPUT TO THIS LINE.
*                 CC1=0    MEANS THE REQUEST WAS SATISFIED.
*                 CC1=1    MEANS THE LINE ASSOCIATED WITH THE
*                          SUPPLIED DCB DID NOT BELONG TO THE USER
*                          OR THAT THE SUPPLIED DCB WAS CLOSED.
*
******
         REF      Y002              DCB OPEN MASK=X'00200000'
         SREF     COB:CPS           FOR OBTAINING COC BUFFER STATUS
         SREF     COCBUF            FOR OBTAINING COC BUFFER STATUS
         SREF     COCII             FOR OBTAINING COC BUFFER STATUS
         SREF     COCIR             FOR OBTAINING COC BUFFER STATUS
         SREF     COCOC             FOR OBTAINING COC BUFFER STATUS
         SREF     COCOTV            FOR OBTAINING COC BUFFER STATUS
         SREF     COCTERM           FOR OBTAINING COC BUFFER STATUS
         SREF     MODE4             FOR OBTAINING COC BUFFER STATUS
         SREF     SL:TB             FOR OBTAINING COC BUFFER STATUS
         SREF     COCMINT           USED TO REINITIALIZE LINE TABLES
*
         DEF      CNMPROC2          BRANCHED TO FROM TQOV2 OVERLAY
*
CNMPROC2 EQU      %
         LW,R2    Y002              DCB OPEN MASK
         AND,R2   0,R6              CK FOR DCB OPEN
         BEZ      CC1SET            *****ERROR, IF NOT
         BAL,R1   CKOWNER           SEE IF CURRENT USER OWNS LINE
         LI,R8    0                 # INPUT CHARS
         DISABLE
         LH,4     COCIR,R2
         BEZ      STAT20            NO CHARS
         LH,3     COCII,R2          END OF CHARS
         BEZ      STAT20            (CAN'T BE ZERO IF COCIR ISN'T)
         LB,R5    COCTERM,R2        TERMINAL TYPE
         LH,R10   COCOTV,R5         TRANSLATE TABLE ADDRESS
STAT10   LB,R5    COCBUF,R4         GET NEXT CHAR
         AI,R8    1                 INCREMENT COUNT
         LC       *10,R5
         BCR,2    %+2               BR IF NOT AN ACTIVATION CHAR
         OR,R8    Y8                SET FLAG
         CW,R4    R3
         BE       STAT20            WE HAVE HIT THE END
         AI,R4    1
         CI,R4    X'F'
         BANZ     STAT10            MORE IN THIS BUFFER
         SLS,R4   -1                GET FORWARD LINK
         LH,R4    COCBUF-4,R4
         BNEZ     STAT10
*
STAT20   ENABLE
         LH,R10   COCOC,R2          L/OUTPUT CHARACTER COUNT
         LB,R1    MODE4,R2          L/MODE4
         AND,R1   M3                &/LINE SPEED INDICATOR W/7
         LB,R9    COB:CPS,R1        L/CHARS PER SEC ON LINE
         MW,R9    SL:TB             (CHARS/SEC) X (TERM BLOCK, IN SEC)
         XW,R9    R10               MOVE TO CORRECT REGS
         LI,R1    SR1               OFFSET INTO USER'S REGS
         AW,R1    J:BASE            POINT TO LOCATION OF SR1 VALUE
         LCI      3
         STM,SR1  0,R1              STORE BUFSTAT REGS FOR USER
         B        CC1RST            ****EXIT W/CC1=0 TO INDICATE ALL OK
         PAGE
******
*        THIS ROUTINE CALLS KILLIO TO PURGE INPUT AND/OR OUTPUT BUFFERS
*        ASSOCIATED WITH A SLAVE COC LINE.
*
*        INPUT:   (R6) = DCB ADDRESS.
*                 (R7) = WA(FPT+1);  (FPT+1) = 0 MEANS INPUT & OUTPUT
*                                                BUFFERS ARE TO BE PURGED
*                                              1 MEANS INPUT BUFFERS
*                                                ONLY ARE TO BE PURGED
*                                             -1 MEANS OUTPUT BUFFERS
*                                                ONLY ARE TO BE PURGED
*                 (SR1)= FPT CODE
*                 (SR4)= WA(TRAPEXIT)
*
*        OUTPUT:  CC1=0 MEANS THE REQUEST WAS SATISFIED.
*                 CC1=1 MEANS THAT THE LINE ASSOCIATED WITH THE
*                       SUPPLIED DCB DID NOT BELONG TO THE USER.
*
******
         SREF     KILLIO,KILLOUT,KILLIN,COC  *****SREFS******
         REF      CNMLNDCB          SLAVE LINE DCB MASK = X'803'
         DEF      CNMPROC3
*
CNMPROC3 EQU      %
         LI,R1    CNM3CONT          LOAD EXIT ADR FROM COMMON CODE
*
CKOWNER  EQU      %
         LW,R3    CNMLNDCB          GET MASK FOR SLAVE LINE DCB
         CS,R3    0,R6              SEE IF THIS IS A SLAVE LINE DCB
         BNE      CC1SET            *****ERROR, IF IT ISN'T
         LI,R3    COC               CK IF THIS IS A COC SYSTEM
         BEZ      CC1SET            *****ERROR, IF NOT
         LI,R3    BARNDEV           RNDEV OFFSET INTO DCB
         LB,R2    *R6,R3            GET LINE#+1
         AI,R2    -1
         LW,SR3   S:CUN             GET CURRENT USER#
         CB,SR3   LB:UN,R2          SEE IF CURRENT USER OWNS LINE
         BNE      CC1SET            *****ERROR IF HE DOESN'T
         B        0,R1              EXIT COMMON CODE
*
CNM3CONT EQU      %
         LI,SR4   PURGEXIT          LOAD RETURN ADDRESS
         LW,SR3   0,R7              GET REQUEST INDICATOR FROM FPT
         BEZ      KILLIO            0 MEANS PURGE INPUT & OUTPUT BUFFS
         BLZ      KILLOUT           -1 MEANS PURGE OUTPUT ONLY
         BAL,SR2  KILLIN            1 MEANS PURGE INPUT ONLY
*
PURGEXIT EQU      %
         B        CC1RST            ****EXIT W/CC1=0 TO INDICATE ALL OK
         PAGE
******
*
*        CNMPROC4 PROCESSES M:MDFLST REQUESTS. ALL OPERATIONS
*        ON A LIST, EXCEPT HALTING AN AUTOMATIC POLLING OPERATION
*        OR CHANGING THE LIST TYPE, REQUIRE THAT THERE BE NO
*        OUTSTANDING I/O REQUESTS ON THE ASSOCIATED LINE.
*        FURTHERMORE, AN AUTOMATIC POLLING OPERATION ON A LINE
*        MUST BE HALTED BEFORE THE ASSOCIATED LIST CAN UNDERGO
*        A TYPE CHANGE.
*
*
*        INPUT:   (R6) = DCB ADDRESS
*                 (R7) = WA(FPT+1)
*                 (SR1)= FPT CODE
*                 (SR4)= WA(TRAPEXIT)
*
*        OUTPUT:  CC=0000 IMPLIES THAT ENTIRE REQUEST WAS SATISFIED
*                 CC=1100 IMPLIES THAT NO PART OF REQUEST WAS SATISFIED
*                 CC=1000 IMPLIES THAT ONLY A REQUESTED HALT OR
*                         LIST TYPE CHANGE WAS SUCCESSFUL.
******
*
         REF      ADR:LIST          OFFSET INTO DCB OF LIST ADDRESS
         REF      ADDRMASK          VIRTUAL ADDRESS MASK=X'1FFFF'
         REF      T:IACU            USED TO CK P/S LIST'S ACCESS CODE
         REF      JOVVP             USED TO CK FOR LIST PG ABOVE MONITOR
         REF      XFFFF             TABLE MASK=X'FFFF'
         REF      AUTORDL           P/S LIST'S AUTO BIT MASK=X'00080000'
         REF      HALTL             P/S LIST'S HALT BIT MASK=X'00040000'
         REF      UH:FLG            USED TO SET PPSWP BIT
         REF      Y4                TABLE MASK=X'40000000'
         REF      YFFFF             TABLE MASK=X'FFFF0000'
*
         DEF      CNMPROC4          BRANCHED TO FROM TPQ2 MODULE
*
OPNCLSL  EQU      X'10000'          P/S LIST'S OPN/CLS BIT MASK
         PAGE
*
CNMPROC4 EQU      %
         LW,R1    ADDRMASK
         AND,R1   ADR:LIST,R6       LOOK FOR A LIST
         PUSH     1,R7              SAVE WA(FPT+1) IN STACK
         LW,R5    R7                SAVE WA(FPT+1) IN R5, TOO
         LW,R7    R1                MOVE LIST ADR TO INPUT REG
         SLS,R7   -9                ISOLATE PG#
         BAL,SR4  T:IACU            GET PG#'S ACCESS CODE
         BCS,2    CC11XX            ****ERR, IF AC=2 OR 3
         BCR,1    CC11XX            ****ERR, IF AC=0;IE., IT MUST=1
         MTB,0    *R1               SEE IF THERE'S ANY I/O OUTSTANDING
         BEZ      CKINEXIN          B, IF NOT & CK INCL/EXCL/INDX OPTIONS
         LI,R7    CC10XX            LOAD LIKELY ERR EXIT ADR
         B        CKAUTORD          DO ANY HALT OR OPN/CLS REQUEST
*
CKINEXIN EQU      %
         LI,R2    7
         AND,R2   0,R5              ISOLATE INDX/EXCL/INCL BITS
         BAL,R7   CKCNFLCT          SEE IF MORE THAN ONE SPECIFIED
         LW,R3    R4                RETURN MEANS NO CONFLICT; SAVE RESULT
         BEZ      CKPOSEPS          B, IF NOTHING SPECIFIED
         MTW,0    0,R5              SEE IF AN ADDRESS WAS SPECIFIED
         BLZ      %+4               B, IF SO & SO INDICATE
         CI,R3    3                 WAS IT AN INDX SPECIFICATION
         BE       CC11XX            *****ERROR, IF SO; NEEDS ADR
         B        CKPOSEPS          ELSE, CK FOR POL/SEL/PSL
         OR,R3    Y8                INDICATE THAT AN ADDRESS WAS SPECIFIED
*
CKPOSEPS EQU      %
         LI,R2    X'38'
         AND,R2   0,R5              ISOLATE POL/SEL/PSL BITS
         SLS,R2   -3                ***SHIFT TO USE AS INDEX
         BAL,R7   CKCNFLCT          SEE IF MORE THAN ONE SPECIFIED
         LW,D2    Y4                GET PP WORD'S REPL BIT MASK
         AND,D2   0,R5              PICK UP ANY REPL SPECIFICATION
         OR,D2    R3                INCLUDE INDX/EXCL/INCL/ADR INFO
         BEZ      CNM4EXIT          B, IF NOTHING HERE TO DO
         CI,R4    0                 ELSE, SEE IF POL/SEL/PSL SPECIFIED
         BE       CC11XX            *****ERROR, IF NOT; MUST HAVE
*
CKADR1   EQU      %
         LI,SR1   0                 INITIALIZE ADR1 SAVE REG
         AI,R5    1                 POINT TO POSSIBLE ADR1 LOC
         CW,D2    Y8                SEE IF INCL OR EXCL ADR INDICATED
         BAZ      CKADR2:3          B, IF NOT
         LI,R2    GETADR1           LOAD EXIT ADDRESS FROM FOLLOWING CODE
*
CKLGLADR EQU      %
         LW,R7    0,R5              GET ADR TO CHECK
         BGEZ     CKREGADR          B, IF NOT INDIRECT ADDRESSING
         CW,R7    REGMASK           SEE IF ADR IS A REG
         BANZ     %+2               B, IF NOT
         AW,R7    J:BASE            ELSE, POINT TO USER'S REG LOC
         LW,R7    0,R7              GET THE USER SUPPLIED ADR
*
CKREGADR EQU      %
         CW,R7    REGMASK           SEE IF ADR IS A REG
         BANZ     %+2               B, IF NOT
         AW,R7    J:BASE            ELSE, POINT TO USER'S REG VALUE
         LW,D3    R7                SAVE ADR IN OUTPUT REG
         SLS,R7   -9                ISOLATE PG#
         CI,R7    JOVVP             SEE IF PG# IS ABOVE MONITOR AREA
         BL       CC11XX            *****ERR IF NOT
         BAL,SR4  T:IACU            GET THIS PG#'S ACCESS CODE
         BCR,1    0,R2              *****RETURN IF AC=0 OR 2
         BCR,2    0,R2              *****RETURN IF AC=1
         B        CC11XX            *****BUT ERR, IF AC=3
*
GETADR1  EQU      %
         LW,SR1   D3                SAVE ADR1
         AI,R5    1                 POINT TO POSSIBLE ADR2 LOC
*
CKADR2:3 EQU      %
         LI,SR2   0                 INITIALIZE ADR2 SAVE REG
         CW,D2    Y4                SEE IF REPL IS INDICATED
         BAZ      CKINDX1           B, IF NOT & CK VALUE OF INDEX
         BAL,R2   CKLGLADR          ELSE, CK ON LEGALITY OF ADR2
         LW,SR2   D3                SAVE ADR2
         AI,R5    1                 POINT TO ADR3 LOC
         BAL,R2   CKLGLADR          CK ON LEGALITY OF ADR3
         LW,SR3   D3                SAVE ADR3
*
CKINDX1  EQU      %
         LI,D1    X'FFFF'
         AND,D1   0,R1              ISOLATE LIST LENGTH
         AI,SR1   0                 POKE ADR1 SAVE REG
         BEZ      CKINDX2           B, IF NONE; CK VALUE OF INDEX
         LW,R2    *SR1              PICK UP SUPPLIED INDEX VALUE
         BLEZ     CC11XX            *****ERROR IF NEG OR =0
         CW,R2    D1                SEE IF IT POINTS PAST LIST
         BG       CC11XX            *****ERROR IF IT DOES
*
CKINDX2  EQU      %
         AI,SR2   0                 POKE ADR2 SAVE REG
         BEZ      ATLAST            B, IF NONE; CAN FINALLY PROCESS
         LW,R3    *SR3              PICK UP SUPPLIED INDEX VALUE
         BLEZ     CC11XX            *****ERROR IF NEG OR =0
         CW,R3    D1                SEE IF INDEX POINTS PAST LIST
         BG       CC11XX            *****ERROR IF IT DOES
         LW,R5    *SR2              PICK UP COMPONENT VALUE
         PAGE
******
*
*        AT THIS POINT   (R1) = LIST ADDRESS
*                        (R2) = VALUE OF INCL/EXCL/INDX INDEX
*                        (R3) = VALUE OF REPL INDEX
*                        (R4) = POL/SEL/PSL INDICATOR
*                        (R5) = COMPONENT VALUE FOR REPL
*                        (D1) = LIST LENGTH
*                        (D2) = INCL/EXCL/INDX/ADRS INDICATOR
******
*
ATLAST   EQU      %
         AI,R1    1                 POINT TO LIST'S CURRENT/START INDICES
         AI,R4    -1                DECREMENT POL/SEL/PSL INDICATOR
         CW,D2    Y4                SEE IF REPL REQUESTED
         BAZ      DOINEXIN          B, IF NOT; HONOR ANY INCL/EXCL/INDX
         AND,R5   XFFFF             ISOLATE COMPONENT VALUE
         LW,SR1   *R1,R3            GET ENTRY TO BE REPLACED
         AND,SR1  YFFFF             ZAP ITS COMPONENT SLOT
         OR,SR1   R5                REPLACE IT WITH NEW COMPONENT
         STW,SR1  *R1,R3            RESTORE ENTRY TO LIST
         CI,R4    2                 SEE IF PSL IS REQUESTED
         BE       REPLPSL           B, IF SO; INCLUDE ENTRY AS POL & SEL
         LW,R6    R4                MOVE R4 TO POL OR SEL FLINK OFFSET REG
         BAL,SR4  INCLUDE           INCLUDE AS POL OR SEL ENTRY
         EXU      %+3,R4            PICK UP OFFSET FOR OPPOSITE ACTION
         BAL,SR4  EXCLUDE           EXCLUDE AS SEL OR POL ENTRY
         B        DOINEXIN          HONOR ANY INCL/EXCL/INDX REQUEST
         LI,R6    1                 SEL FLINK OFFSET INTO ENTRY
         LI,R6    0                 POL FLINK OFFSET INTO ENTRY
*
REPLPSL  EQU      %
         LI,R6    0                 POL FLINK OFFSET INTO ENTRY
         BAL,SR4  INCLUDE           INCLUDE AS ENTRY TO BE POLLED
         LI,R6    1                 SEL FLINK OFFSET INTO ENTRY
         BAL,SR4  INCLUDE           INCLUDE AS ENTRY TO BE SELECTED
*
DOINEXIN EQU      %
         LW,R5    D2                MOVE ACTION INDICATOR TO INDEX REG
         LW,R6    R4                POL/SEL/PSL INDICATOR TO INPUT REG
         CI,R4    2                 SEE IF PSL WAS SPECIFIED
         BL       %+2               B, IF NOT
         LI,R6    0                 ELSE, FORCE INPUT=POL FLINK OFFSET
*
GETINDX  EQU      %
         LW,R3    R2                GET ANY SUPPLIED INDX VALUE
         CW,D2    Y8                SEE IF USER SUPPLIED AN INDX
         BANZ     %+3               B, IF HE DID
         LB,R3    *R1,R6            ELSE, GET DEFAULT='CURRENT' INDEX
         BEZ      %+3               B, IF VIRGIN LIST
         EXU      %+4,R5            PICK UP APPROPRIATE ROUTINE ADR
         BAL,SR4  *D3               GO TO IT
         LI,R6    1                 SET INPUT REG=SEL FLINK OFFSET
         BDR,R4   GETINDX           LOOP IF PSL WAS ORIGINALLY SPECIFIED
         B        CNM4ALTX          ***EXIT UPON RETURN
         LI,D3    INCLUDE           ROUTINE FOR INCL FUNCTION
         LI,D3    EXCLUDE           ROUTINE FOR EXCL FUNCTION
         LI,D3    DOINDX            ROUTINE FOR INDX FUNCTION
*
DOINDX   EQU      %
         AI,R6    2                 GET OFFSET OF POL/SEL 'START' INDEX
         STB,R3   *R1,R6            REPLACE WITH SUPPLIED OR 'CURRENT'
         AI,R6    -2                RESTORE FLINK OFFSET
         B        INCLUDE           INCLUDE CORRESPONDING ENTRY
         PAGE
******
*
*        THE INCLUDE & EXCLUDE ROUTINES HAVE THE SAME INPUT:
*
*        (R1) = WA(LIST+1)
*        (R3) = INDEX VALUE OF INCOMING ENTRY (ENTRY TO BE IN-
*               CLUDED OR EXCLUDED
*        (R6) = OFFSET INTO ENTRY DETERMINING WHETHER WE DEAL
*               WITH A POL FLINK OR A SEL FLINK
*        (D1) = LIST LENGTH
*
******
*
INCLUDE  EQU      %
         LI,D4    INCLOOP1          LOAD CKLOOPND EXIT ADR
         LW,SR2   R1                GET WA(LIST+1)
         LW,D3    *SR2,R3           LOAD INCOMING LIST ENTRY
         LI,R7    1                 INITIALIZE COUNTER
*
INCLOOP1 EQU      %
         LW,SR1   *SR2,R7           GET A LIST ENTRY
         LB,SR3   SR1,R6            GET POL OR SEL FLINK
         BEZ      CKLOOPND          B, IF NOT CURRENTLY INCLUDED
         CI,SR3   X'FF'             SEE IF THIS IS A DUMMY SLOT
         BE       CKLOOPND          B, IF SO; CONTINUE LOOKING
         LW,R0    R7                SAVE INDEX OF 1ST LIST ENTRY
         CW,R3    R7                CK NEW INDEX AGAINST 1ST IN RING
         BE       *SR4              B, IF EQUAL; NEW IS ALREADY INCLUDED
         BG       INCONT1           B IF NEW GREATER; MORE TO DO
         STB,R7   D3,R6             NEW POINTS TO 1ST
         LI,D4    INCLOOP2          LOAD CKLOOPND EXIT ADR
*
INCLOOP2 EQU      %
         LW,SR1   *SR2,R7           GET A LIST ENTRY
         LB,SR3   SR1,R6            GET POL OR SEL FLINK
         CW,SR3   R0                SEE IF THIS FLINK POINTS TO 1ST
         BNE      CKLOOPND          B, IF NOT & KEEP LOOKING
         STB,R3   SR1,R6            ELSE, MAKE LAST POINT TO NEW
*
INEXCLX1 EQU      %
         STW,SR1  *SR2,R7           RESTORE OLD LIST ENTRY TO LIST
*
INEXCLX2 EQU      %
         STW,D3   *SR2,R3           RESTORE INCOMING LIST ENTRY TO LIST
         B        *SR4              *****RETURN TO CALLER
*
INCONT1  EQU      %
         LI,D4    INCLOOP3          LOAD CKLOOPND EXIT ADR
*
INCLOOP3 EQU      %
         LW,SR1   *SR2,R7           GET A LIST ENTRY
         LB,SR3   SR1,R6            GET POL OR SEL FLINK
         BEZ      CKLOOPND          B, IF NOT CURRENTLY INCLUDED
         CI,SR3   X'FF'             SEE IF THIS IS A DUMMY SLOT
         BE       CKLOOPND          B, IF SO; CONTINUE LOOKING
         CW,SR3   R0                SEE IF FLINK POINTS TO 1ST
         BE       INCONT2           B, IF SO; WE'RE AT LIST END
         CW,R3    SR3               CK NEW AGAINST CURRENT FLINK
         BG       CKLOOPND          B, IF BIGGER; KEEP LOOKING
         BE       *SR4              B, IF EQUAL; ENTRY ALREADY INCLUDED
         STB,SR3  D3,R6             NEW GETS CURRENT FLINK
         STB,R3   SR1,R6            CURRENT THEN POINTS TO NEW
         B        INEXCLX1          RESTORE OLD & NEW ENTRIES TO LIST
*
INCONT2  EQU      %
         STB,R3   SR1,R6            OLD LAST POINTS TO NEW LAST
         STB,R0   D3,R6             NEW LAST POINTS TO 1ST
         B        INEXCLX1          RESTORE OLD & NEW ENTRIES TO LIST
*
CKLOOPND EQU      %
         AI,R7    1                 BUMP COUNTER
         CW,R7    D1                CK AGAINST LIST LENGTH
         BLE      *D4               B, IF END OF LIST NOT REACHED
         STB,R3   D3,R6             ELSE, POINT NEW TO SELF; HE'S ALONE
         AI,R6    2                 BUMP TO START FLINK LOC
         STB,R3   *SR2,R6           SET START FLINK
         AI,R6    -2                BACK TO CURRENT FLINK LOC
         B        INEXCLX2          RESTORE NEW LIST ENTRY TO LIST
         PAGE
*
EXCLUDE  EQU      %
         LW,SR2   R1                GET WA(LIST+1)
         LW,D3    *SR2,R3           LOAD INCOMING LIST ENTRY
         LI,R7    1                 INITIALIZE COUNTER
*
EXCLOOP  EQU      %
         LW,SR1   *SR2,R7           GET A LIST ENTRY
         LB,SR3   SR1,R6            GET POL OR SEL FLINK
         CW,SR3   R3                SEE IF IT POINTS TO INCOMING ENTRY
         BE       EXCLCONT          B, IF SO & FIX ITS FLINK
         AI,R7    1                 ELSE, BUMP COUNTER
         CW,R7    D1                SEE IF END OF LIST REACHED
         BG       *SR4              ***EXIT, IF SO;ELEMENT ALREADY EXCL'D
         B        EXCLOOP           ELSE, KEEP LOOKING
*
EXCLCONT EQU      %
         LB,D4    D3,R6             GET INCOMING ENTRY'S FLINK
         STB,D4   SR1,R6            MOVE TO ENTRY POINTING TO INCOMING
         LI,SR3   0
         STB,SR3  D3,R6             MARK INCOMING ENTRY AS EXCLUDED
         AI,R6    2                 GET POL OR SEL 'START' INDEX OFFSET
         LB,SR3   *SR2,R6           GET POL OR SEL 'START' INDEX
         CW,SR3   R3                DOES IT POINT TO INCOMING ENTRY
         BNE      INEXCLX1          B, IF NOT; RESTORE ENTRIES TO LIST
         STB,D4   *SR2,R6           ELSE, REPLACE W/INCOMING ENTRY'S FLINK
         B        INEXCLX1          RESTORE ENTRIES TO LIST
         PAGE
*
CKAUTORD EQU      %
         PULL     1,R6              RETRIEVE WA(FPT+1)
         LW,R3    AUTORDL           GET MASK FOR LIST'S AUTO RD BIT
         DISABLE                    **INHIBIT INTERRUPTS
         AND,R3   0,R1              SEE IF AN AUTO READ IS IN EFFECT
         BEZ      CKOPNCLS          B, IF NOT & HONOR OPN/CLS REQUEST
         LW,R3    X100              ELSE, GET MASK FOR PP WORD'S HALT BIT
         AND,R3   0,R6              SEE IF HALT WAS SPECIFIED
         BNEZ     SETHALT           B, IF SO
         LI,R7    CC11XXA           *****ELSE, LOAD ERR EXIT AD
         B        CKAUTOX           ENABLE & GET OUT
*
SETHALT  EQU      %
         LW,D2    HALTL             GET LIST'S MASK FOR HALT BIT
         STS,D2   0,R1              SET BIT TO INDICATE HALT REQUESTED
*
CKOPNCLS EQU      %
         LI,R3    X'C0'             GET MASK FOR PP WORD'S OPN/CLS BITS
         AND,R3   0,R6              ISOLATE OPN/CLS SPECIFICATION BITS
         SLS,R3   -6                ***SHIFT TO USE AS INDEX
         LI,D2    OPNCLSL           GET LIST FLAGS' OPN/CLS BIT MASK
         EXU      %+2,R3            LET THE TABLE DECIDE WHAT TO DO
         B        SETOPNCLS         SET UP LIST'S OPN/CLS FLAG
         B        CKAUTOX           NEITHER REQUESTED
         LI,D1    0                 OPN REQUESTED
         LI,D1    -1                CLS REQUESTED
         B        CKAUTOX           BOTH REQUESTED; IGNORE REQUEST
*
SETOPNCLS EQU     %
         STS,D1   0,R1              SET OPN/CLS FLAG APPROPRIATELY
*
CKAUTOX  EQU      %
         LW,R3    S:CUN             GET CURRENT USER #
         LH,D1    UH:FLG,R3         GET USER FLAGS
         OR,D1    X10               SET PPSWP BIT
         STH,D1   UH:FLG,R3         RESTORE USER FLAGS
         ENABLE                     **UNINHIBIT INTERRUPTS
         B        0,R7              *****RETURN TO CALLER
         PAGE
*
CKCNFLCT EQU      %
         EXU      %+2,R2            LET THE TABLE DECIDE
         B        0,R7              *****RETURN TO CALLER
         LI,R4    0                 NOT SPECIFIED
         LI,R4    1                 POL OR INCL SPECIFIED
         LI,R4    2                 SEL OR EXCL SPECIFIED
         B        CC11XX            *****ERROR IF CONFLICT
         LI,R4    3                 PSL OR INDX SPECIFIED
         B        CC11XX            *****ERROR IF CONFLICT
         B        CC11XX            *****ERROR IF CONFLICT
         B        CC11XX            *****ERROR IF CONFLICT
*
CC11XX   EQU      %
         PULL     1,R7              TIDY UP STACK
*
CC11XXA  EQU      %
         LW,D1    YC                CC=1100
         B        OUT               ***EXIT ALTCP
*
CC10XX   EQU      CC1SET            ***CC=1000; EXIT ALTCP
*
CNM4ALTX EQU      %
         AI,R1    -1                POINT BACK TO LIST FLAGS
*
CNM4EXIT EQU      %
         BAL,R7   CKAUTORD          CK PP WORD'S OPN/CLS BITS
         B        CC1RST            CC=0000; EXIT ALTCP
         PAGE
******
*       THIS ROUTINE CONVERTS A SLAVE LINE'S EBCDIC LINE ID
*       TO A LINE NUMBER OR TO A DCT INDEX AS APPROPRIATE
*
*   CALL: BAL,SR4 CNMPROC9
*  INPUT: (R3) = POINTER TO LINE ID
*
* OUTPUT: (D1)     =  DCT INDEX IF MULTI-POINT LINE
*                   = 0 IF LINE'S IDENTITY CAN'T BE DETERMINED
*                 = LINE#+1 IF BI-POINT LINE. BIT 0 IS SET TO INDICATE
*                     THAT (D1) = A LINE NUMBER AS OPPOSED TO
*                     A DCT INDEX VALUE.
*
******
         REF      DCTSIZ,DCT16,M8
         SREF     LCOC,COD:LPC      ******SREFS********
*
         DEF      CNMPROC9
*
CNMPROC9 EQU      %
         PUSH     5,R7
         LW,SR2   *R3               GET EBCDIC LINE ID
         LB,SR1   SR2               THIS BYTE SHOULD BE 'M' OR 'C'
         CI,SR1   C'M'
         BE       CKDCT16           B IF MULTI-PNT LINE
         CI,SR1   C'C'              ELSE CK FOR BI-PNT LINE
         BE       CKCODLPC          B IF IT IS
*
CNM9ERRX EQU      %
         LI,D1    0                 ELSE LOAD D1 TO INDICATE ERROR
*
CNM9EXIT EQU      %
         PULL     5,R7
         B        *SR4               EXIT
*
CKDCT16  EQU      %
         LI,R7    C'O'
         STB,R7   SR2               MAKE ID CONFORM TO DEVMNE IN DCT16
         LI,R7    DCTSIZ            GET LENGTH OF DCT
         LD,SR3   DCT16,R7          GET DEV MNEMONIC
         AND,SR3  M8                ZAP NON-EBCDIC BYTES 0-2
         CD,SR1   SR3               CK FOR A MATCH
         BE       %+3               B IF WE HAVE ONE
         BDR,R7   %-4               ELSE KEEP LOOKING
         B        CNM9ERRX          TAKE ERROR EXIT IF NOT FOUND
         LW,D1    R7                MOVE THE DCT INDX TO OUTPUT REG
         B        CNM9EXIT          DONE, SO EXIT
*
CKCODLPC EQU      %
         LI,R7    COC               CK IF THIS IS A COC SYSTEM
         BEZ      CNM9ERRX          *****ERROR, IF NOT
         LI,R7    -3                WILL CONVERT 3 CHARS. TO HEX
         LI,SR4   0                 INITIALIZE ACCUMULATOR REG
*
GETEBC   EQU      %
         LB,SR3   SR2+1,R7          GET A BYTE OF EBCDIC
         AI,SR3   -C'0'             ASSUME 0-9 & STRIP F BITS
         BGEZ     %+3               B MEANS IT WAS AT LEAST X'F0'
         AI,SR3   C'0'-C'A'+X'A'    OTHERWISE CONVERT TO HEX 10, 11 ETC
         BLZ      CNM9ERRX          ERROR IF HEX# NOT IN 0-15 RNG
         CI,SR3   16                CK UPPER BOUND
         BGE      CNM9ERRX          ITS AN ERROR
         SCS,SR3  -4                POSITION HEX DIGIT
         SCD,SR3  4                 AND MOVE TO ACCUMULATOR
         BIR,R7   GETEBC            GO GET ANOTHER EBCDIC BYTE
*
*
*      AT THIS POINT A CHECK MUST BE MADE TO INSURE THAT
*      THE GIVEN LINE NUMBER IS FOR AN EXISTENT LINE.
*
*
*
         LI,R7    LCOC              GET # OF CONTROLLERS-1
         CLM,SR4  COD:LPC,R7        SEE IF LINE FALLS WITHIN BOUNDS
         BCR,9    VALIDLN           B IF IT DOES
         AI,R7    -1
         BLZ      CNM9ERRX          B IF WE'VE GONE TOO FAR
         B        %-4               ELSE COMPARE W/ NEXT SET OF BOUNDS
*
VALIDLN  EQU      %
         AI,SR4   1                 BUMP TRUE LN# TO INSURE NON-0 VALUE
         OR,SR4   Y8                SET BIT 0 TO INDICATE LINE #
         LW,D1    SR4               MOVE TO OUTPUT REG
         B        CNM9EXIT          AND EXIT
         END

