         TITLE    'ECBCHECK - M:CHECKECB MONITOR SERVICE'
         PCC      0
         REF      MASKS
MONPROC  SET      1
         SYSTEM   UTS
         DEF ECBCHECK,CNMPROC5,ECBCHCK1
         REF      YFFFF,YF,X1FFFE,M2,M17,XFFF0
         REF      ECBGBLK,ECBFBLK
         REF      J:BASE
         REF      JOVVP,J:JAC,J:DCBLINK
         REF      S:CUN
         REF      U:MISC,UB:NECB
         REF      UH:DL,UH:WL
         REF      E:SL,T:REG
         PAGE
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
BADTIME  EQU      1
BADSTATE EQU      2
BADWAIT  EQU      3
BADSPACE EQU      4
BADECB   EQU      5
BADSPEC  EQU      6
REGMASK  EQU      X'1FFF0'
NOACCESS EQU      3
BREAKBLK EQU      3
ECBFPEVE EQU      BT31TO0+32
ECBFPTIM EQU      BT31TO0+31
WECBFPT  EQU      0
ECBFECB  EQU      2
ECBFECBL EQU      3
*
*        TABLE SYMBOLS FOR ECB
*
ECBP     EQU      BT31TO0+32
ECBW     EQU      BT31TO0+31
ECBI     EQU      BT31TO0+30
ECBU     EQU      BT31TO0+29
NECBW    EQU      NB31TO0+31
NECBI    EQU      NB31TO0+30
WECB     EQU      0
ECBCC    EQU      1
*
*        TABLE SYMBOLS FOR WAIT LIST/DO LIST ECB BLOCK
*
ECBBPRIO EQU      0
ECBBPERM EQU      BT31TO0+24
WECBBPER EQU      0
ECBBLINK EQU      1
ECBBRESL EQU      4
ECBBADDR EQU      1
ECBBP    EQU      ECBP
ECBBW    EQU      ECBW
ECBBI    EQU      ECBI
ECBBU    EQU      ECBU
WECBB    EQU      2
ECBBMULT EQU      10
ECBBC    EQU      BT31TO0+1
ECBBCC   EQU      3
ECBBLENG EQU      4
ECBBECB  EQU      1
*
*        TABLE SYMBOLS FOR U:MISC FOR ECB
*
ECBUWCNT EQU      0
ECBUACT  EQU      BT31TO0+24
ECBUTIME EQU      1
WECBU    EQU      0
         PAGE
*******************************************************************************
*                                                                     *
*        ECBCHECK                                                     *
*          - CHECK EVENT CONTROL BLOCKS (ECB) AS DIRECTED BY          *
*            M:CHECKECB MONITOR PROCEDURE AND PLACE                   *
*            USER INTO WAIT STATE IF REQUIRED                         *
*                                                                     *
********************************************************************************
*                                                                     *
*        ENTRY POINT                                                  *
*          ECBCHECK                                                   *
*                                                                     *
*        INPUT                                                        *
*          R6  - ADDRESS PORTION OF WORD 0 OF FPT                     *
*          R7  - ADDRESS OF WORD 1 OF FPT (PRESENCE BITS)             *
*          R8  - FPT CODE (BYTE 0 OF WORD 0 OF FPT)                   *
*          R11 - RETURN ADDRESS (TRAPEXIT)                            *
*                                                                     *
*        OUTPUT                                                       *
*          CC - INDICATE RESULTS OF PROCESSING                        *
*           1 - ILLEGAL TIME SPECIFICATION                            *
*           2 - IMPROPER STATE OF ECB                                 *
*           3 - INSUFFICIENT PENDING EVENTS TO SATISFY WAIT           *
*           4 - INSUFFICIENT MONITOR WORK SPACE                       *
*           5 - ILLEGAL ECB ADDRESS                                   *
*           6 - NO SPECIFICATION OF ECB/ECBL                          *
*                                                                     *
*        REGISTER USAGE                                               *
*          ALL REGISTERS PRESERVED BY CAL PROCESSING                  *
*                                                                     *
********************************************************************************
         PAGE                                                         *
********************************************************************************
*                                                                     *
*        ENTRY POINT                                                  *
*          ECBCHCK1 - INTERNAL ENTRY TO WAIT UPON 1 ECB               *
*                                                                     *
*        INPUT                                                        *
*          R11 - RETURN ADDRESS                                       *
*           R5 - VIRTUAL ADDRESS OF ECB
*                                                                     *
*        OUTPUT                                                       *
*          CC STORED IN BITS 0-3 OF R5
*                                                                     *
*        REGISTER USAGE                                               *
*          R5 - BITS 0-3 ALTERED
*          ALL REGISTERS PRESERVED                                    *
*                                                                     *
********************************************************************************
         PAGE                                                         *
ECBCHECK EQU      %
CNMPROC5 EQU      ECBCHECK
         LW,R5    S:CUN             FETCH USER'S NUMBER
         LW,R4    R5
         AI,R4    U:MISC            POINT TO USER'S U:MISC
         LI,R2    0                 INITIAL FPT INDEX POINTER
         STW,R2   *R4               CLEAR U:MISC
         LW,R1    ECBFPEVE          'EVENTS' SPECIFIED
         AND,R1   WECBFPT,R7
         BNEZ     ECBC010           YES, DETERMINE VALUE
ECBC005  EQU      %
         LI,R1    1                 NO, DEFAULT = ONE
         B        ECBC015           GO STORE 'EVENTS' VALUE
ECBC010  EQU      %
         AI,R2    1                 BUMP FPT INDEX POINTER
         LW,R1    *R7,R2            FETCH USER SPECIFICATION
         BGZ      ECBC015           VALUE SPECIFIED
         BEZ      ECBC005           NULL, DEFAULT = ONE
         CI,R1    REGMASK           IS IT INDIRECT REGISTER
         BANZ     %+2               NO
         AW,R1    J:BASE            YES, REGISTERS ARE IN TSTACK
         LW,R1    *R1               INDIRECT ADDRESS
         BEZ      ECBC005           NULL, DEFAULT = ONE
ECBC015  EQU      %
         STB,R1   *R4               STORE 'EVENTS' VALUE
         LW,R1    ECBFPTIM          'TIME' SPECIFIED
         AND,R1   WECBFPT,R7
         BNEZ     ECBC017           YES, DETERMINE VALUE
         LI,R1    X'7FFFF'          SET TIME PERIOD TO FOREVER
         STS,R1   0,R4              SINCE USER WANTS NO PERIOD
         B        ECBC030           FINISHED WITH TIME PARAMETER
ECBC017  EQU      %
         AI,R2    1                 BUMP FPT INDEX POINTER
         LW,R1    *R7,R2            FETCH TIME SPECIFICATION
         BGZ      ECBC025           VALUE - GO STORE
         BEZ      ECBC020           ZERO - DEFAULT IS ONE
         CI,R1    REGMASK           IS IT INDIRECT REGISTER
         BANZ     %+2               NO
         AW,R1    J:BASE            YES, REGISTERS ARE IN TSTACK
         LW,R1    *R1               INDIRECT ADDRESS
         BGZ      ECBC025           VALUE, GO STORE
ECBC020  EQU      %
         LI,R1    1                 SET 1.2 INCREMENT
         B        ECBC028           AND STORE IT
ECBC025  EQU      %
         LW,R3    R1                TEST FOR > HALFWORD
         AND,R3   YFFFF
         BEZ      ECBC028           OK, GO STORE
         LI,R10   BADTIME
         B        ECBC100
ECBC028  EQU      %
         LI,R3    ECBUTIME          STORE TIME VALUE
         STH,R1   *R4,R3
         PAGE
*
*        MAIN PROCESSING LOOP FOR M:CHECKECB FPT
*
ECBC030  EQU      %
         LI,R12   2                 INDICATE PROCESSING ECB OPTION
         LI,R1    ECBFECB           FETCH ECB SPECIFICATION
         LB,R13   R6,R1             FROM INPUT REGISTER
         BNEZ     ECBC032           GO PROCESS 'ECB'-TYPE PARAMETERS
         LI,R12   1                 INDICATE PROCESSING 'ECBL' OPTION
         LI,R1    ECBFECBL          FETCH ECBL SPECIFICATION
         LB,R13   R6,R1             FROM INPUT REGISTER
         BNEZ     ECBC032
         LI,R10   BADSPEC           NO ECB OR ECBL PARAMETER
         B        ECBC100
ECBC032  EQU      %
         LI,R8    0                 INDICATE NEED TO ALLOCATE ENTRY
         BAL,R0   ECBC800           GET ADDRESS FROM FPT
         LW,R15   R10               HEAD OF LIST
         BAL,R0   ECBC800
         LW,R14   R10               LENGTH OF LIST
         BNEZ     %+2               MUST PROCESS AT LEAST ONCE
         LI,R14   1                 SINCE OPTION WAS PRESENT
         LI,R10   0                 INDICATE TOP OF LIST
ECBC035  EQU      %
         BAL,R0   ECBC820           SELECT NEXT ECB FROM LIST
         BAL,R0   ECBC500           PROCESS ECB
         BDR,R14  ECBC035           NEXT ECB
         BDR,R13  ECBC032           NEXT LIST
         BDR,R12  ECBC040           NEXT LIST-TYPE (ECBL OR DONE)
         B        ECBC050           ALL DONE SEE IF WAIT NEEDED
ECBC040  EQU      %
         LI,R1    ECBFECBL          FETCH ECBL SPECIFICATION
         LB,R13   R6,R1             FROM INPUT REGISTER
         BNEZ     ECBC032           IF PRESENT THEN PROCESS
         PAGE
ECBC050  EQU      %
         AI,R8    0                 IS THERE AN EXTRA BLOCK
         BEZ      ECBC054           NO
         LW,R2    R8                YES, TIME TO LET IT GO
         BAL,R1   ECBFBLK           FREE THE BLOCK
ECBC054  EQU      %
         DISABLE
         LI,R10   0                 COUNT OF USER ECBS
         LI,R9    0                 COUNT ECBS ON WAIT-LIST
         LH,R4    UH:WL,R5          START AT HEAD OF  WAIT-LIST
ECBC056  EQU      %
         SLS,R4   1                 CONVERT FROM DBLWORD TO WORD
         LW,R1    ECBBP             HAS IT BEEN POSTED IN THE INTERIM
         AND,R1 WECBB,R4
         BEZ      ECBC060           NO
ECBC056D EQU      %
         LW,R1    ECBBU             IS IT USER ECB
         AND,R1   WECBB,R4
         BNEZ     ECBC056F          YES
         MTB,-1   UB:NECB,R5        DECREMENT SYSTEM ECB COUNT
ECBC056F EQU      %
         LI,R1    ECBBMULT          FETCH MULTIPLICITY COUNT
         LB,R8    *R4,R1
         LW,R3    R5                POINT R3 TO U:MISC
         AI,R3    U:MISC
ECBC057  EQU      %
         MTB,-1   *R3               SATISFIED THEN GO TO
         BGZ      ECBC058             USER - OTHERWISE
         LI,R10   0                   CONTINUE
         ENABLE
         B        ECBC100
ECBC058  EQU      %
         BDR,R8   ECBC057           CONTINUE MULTIPLICITY COUNT
         B        ECBC064D          CONTINUE
ECBC060  EQU      %
         LW,R8    ECBBADDR,R4       FETCH ADDRESS OF ECB BEING
         AND,R8   MASKS+24          PROCESSED
         LI,R2    0
         LH,R3    UH:DL,R5          IF CHAIN (DL) NULL THEN NOT
         AND,R3   MASKS+12          ELIMINATE FLAGS
         BEZ      ECBC064             POSSIBLE FOR ECB TO BE POSTED
ECBC061  EQU      %
         SLS,R3   1                 DW TO WORD
         LH,R1    *R3               IS IT AN ECB BLOCK ON DO-LIST
         AND,R1   MASKS+7
         CI,R1    ECBBECB           IF NOT, SKIP OVER IT
         BE       ECBC061D          GO SEE IF ECB MATCHES
         CI,R1    BREAKBLK          IS A BREAK ON DO-LIST
         BNE      ECBC063           NO, GO TO NEXT BLOCK
         LI,R10   0                 ALLOW BREAK TO END WAIT
         ENABLE
         B        ECBC100           CLEAN-UP WAIT LIST
ECBC061D EQU      %
         LW,R12   ECBBADDR,R3       FETCH ECB ADDRESS FROM DO-LIST ENTRY
         AND,R12  MASKS+24
         CW,R12   R8                DOES IT MATCH PROCESSING ECB
         BNE      ECBC063           IF NOT, FLINK ONWARD
         LW,R1    ECBBP             POST COMPLETE ON WAIT-LIST
         STS,R1   WECBB,R4
         LW,R1    ECBBCC,R3         TRANSFER
         STW,R1   ECBBCC,R4         COMPLETION CODE
         LI,R6    ECBBLINK          FETCH LINK
         LH,R8    *R3,R6
         AI,R2    0                 WAS IT FIRST ENTRY ON CHAIN
         BNEZ     ECBC062           NO
         LW,R14   R8
         LH,R8    UH:DL,R5
         LW,R15   MASKS+12
         STS,R14  R8                PRESERVE FLAGS
         STH,R8   UH:DL,R5          YES, CREATE NEW HEAD
         B        ECBC062B
ECBC062  EQU      %
         LI,R1    ECBBLINK          REMOVE THIS BLOCK FROM DO-LIST
         STH,R8   *R2,R1
ECBC062B EQU      %
         LW,R1    ECBBPERM          DID ENTRY COME FROM POOL
         AND,R1   WECBBPER,R3
         BNEZ     ECBC056D          NO
         LW,R2    R3                FREE THE DO-LIST BLOCK
         BAL,R1   ECBFBLK
         B        ECBC056D          GO PROCESS IT AS POSTED ON WL
ECBC063  EQU      %
         LW,R2    R3                SAVE OLD ENTRY ADDRESS
         LI,R1    ECBBLINK
         LH,R3    *R3,R1            FLINK
         BNEZ     ECBC061           IF NOT END, CONTINUE
ECBC064  EQU      %
         LW,R1    ECBBU             IS IT USER ECB
         AND,R1   WECBB,R4
         BEZ      %+2               NO
         AI,R10   1                 YES,TALLY IT AS USER
         AI,R9    1                 COUNT THE ECBS ON WAIT-LIST
ECBC064D EQU      %
         LI,R1    -2                TELL ECBPOST THAT ECBCHECK INACTIVE
         AND,R1   WECBB,R4
         STW,R1   WECBB,R4
         LI,R1    ECBBLINK          FETCH FORWARD LINK
         LH,R4    *R4,R1
         BEZ      ECBC065           IS IT END
         B        ECBC056           NO, CONTINUE
ECBC065  EQU      %
         LB,R1    UB:NECB,R5        COUNT OF ECBS SYSTEM KNOWS ABOUT
         AW,R1    R10               PLUS COUNT OF USER ECBS IN WAIT LIST
         LW,R4    R5
         AI,R4    U:MISC
         LB,R2    *R4               FETCH POST REQUIREMENT COUNT
         CW,R1    R2                REQUIREMENT COUNT MUST BE AT BEST
         BGE      ECBC068           EQUAL TO INITIATED ECB COUNT
         LI,R10   BADWAIT           INITIATED ECBS TOO SMALL FOR WAIT
         B        ECBC100           TO BE SATISFIED
ECBC068  EQU      %
         LI,R10   0                 INDICATE GOOD EXIT (AFTER WAIT)
         LW,R1    R11               SAVE R11 (RETURN)
         LI,R6    E:SL              REPORT SLEEP EVENT
         BAL,R11  T:REG             STOP
         LW,R11   R1                RESTORE RETURN
         PAGE
*
*        CLEAN-UP AND RETURN TO CALLER
*
ECBC100  EQU      %
         DISABLE                    NO INTERRUPTS DURING WL STATE CHANGE
         LH,R4    UH:WL,R5          START AT HEAD
         BEZ      ECBC150           IF HEAD ZERO THEN RETURN TO CALLER
ECBC105  EQU      %
         SLS,R4   1                 DBLWORD TO WORD
         LW,R1    ECBBC             TELL ECBPOST THAT ECBCHECK IS ACTIVE
         STS,R1   WECBB,R4
         LI,R1    ECBBLINK          GO TO NEXT BLOCK
         LH,R4    *R4,R1
         BEZ      ECBC110           IF ZERO, END OF CHAIN
         B        ECBC105           AND SET ECBBC IN IT
ECBC110  EQU      %
         ENABLE
ECBC115  EQU      %
         DISABLE
         LH,R4    UH:WL,R5
         BEZ      ECBC150
         SLS,R4   1                 DBLWORD TO WORD
         LW,R3    ECBBADDR,R4       FETCH ECB ADDRESS
         AND,R3   MASKS+24
         LW,R1    NECBW             RESET WAITING IN ACTUAL ECB
         AND,R1   WECB,R3
         STW,R1   WECB,R3
         LW,R1    ECBBP             IS WL ENTRY POSTED
         AND,R1   WECBB,R4
         BEZ      ECBC120           NO
         LW,R1    ECBP              YES, POST ACTUAL ECB
         STS,R1   WECB,R3
         LW,R1    ECBBCC,R4         AND TRANSFER
         STW,R1   ECBCC,R3          COMPLETION CODE
         B        ECBC122
ECBC120  EQU      %
         LW,R1    ECBI              RETURN ACTUAL ECB TO INITIALIZED
         STS,R1   WECB,R3
ECBC122  EQU      %
         LI,R1    ECBBLINK          FETCH LINK
         LH,R3    *R4,R1
         STH,R3   UH:WL,R5          STORE IN HEAD
         ENABLE                     ALLOW INTERRUPT GAP
         LW,R1    ECBBPERM          IS ENTRY FROM BLOCK POOL
         AND,R1   WECBBPER,R4
         BNEZ     ECBC115           NO
         LW,R2    R4                YES, GIVE BLOCK
         BAL,R1   ECBFBLK           BACK TO POOL
         B        ECBC115
ECBC150  EQU      %
         ENABLE
         LI,R1    0
         STW,R1   U:MISC,R5         CLEAR U:MISC
         LW,R2    R10               TRANSFER ERROR CODE TO R2
         LI,R3    X'F'              MASK FOR CC STORE
         SLD,R2   28                FIND
         LI,R1    -17                 PSD
         AW,R1    TSTACK                IN
         AND,R1   X1FFFE                  STACK
         STS,R2   0,R1              AND STORE CONDITION CODES
         CI,R11   ECBC910           WAS CALL INTERNAL
         BE       *R11              YES
         B        T:SELFDESTRUCT    NO, PERFORM OVERLAY CLEANUP
         PAGE
*
*        PROCESS AN ECB
*
ECBC500 EQU       %
         LW,R4    R2                SAVE FPT INDEX POINTER
         LI,R1    0                 POINT TO FIRST WORD OF ECB
         AND,R10  MASKS+17          REMOVE EXTRANEOUS BITS
ECBC510  EQU      %
         LI,R2    0                 CLEAR R2
         LW,R3    R10               FETCH VIRTUAL ADDRESS OF ECB
         AW,R3    R1                BUMP TO ADDRESS TO CHECK
         SLS,R3   -9                ROUND ADDRESS TO RELATIVE VIRT. PAGE
         CI,R3    JOVVP             IS ADDRESS IN RESIDENT MONITOR
         BL       ECBC590           YES, DON'T ACCEPT
         SCD,R2   -4                DIVIDE BY 16 WITH REMAINDER IN R2
         SCS,R2   5                 DOUBLE AND RIGHT JUSTIFY REMAINDER
         LW,R3    J:JAC,R3          FETCH ACCESS WORD REFERENCING PAGE
         SLD,R2   2,R2              EXTRACT ACCESS CODE
         AND,R2   M2                  FOR PAGE IN QUESTION
         BEZ      ECBC530           ACCESS ZERO, OK
         B        ECBC590           ACCESS CODE NON-ZERO, ERROR
ECBC530  EQU      %
         CI,R1    1                 CHECKED BOTH ECB WORDS
         BE       ECBC600           YES
         LI,R1    1                 NO, GO CHECK
         B        ECBC510             SECOND WORD
ECBC590 EQU       %
         LI,R10   BADECB
         B        ECBC100
ECBC600  EQU      %
         LW,R2    R4                RESTORE FPT INDEX POINTER
         LW,R4    R10               A(ECB) INTO XR
         LW,R1    ECBW              IS ECB ALREADY WAITING
         AND,R1   WECB,R4
         BEZ      ECBC610           NO
         LH,R3    UH:WL,R5          YES,IF NOT
ECBC602  EQU      %                   ON CURRENT
         BNEZ     ECBC605             WAIT LIST
ECBC603  EQU      %                   THEN STATE
         LI,R10   BADSTATE
         B        ECBC660
ECBC605  EQU      %
         SLS,R3   1                 GENERATE WORD ADDRESS
         LW,R1    ECBBADDR,R3       FETCH ECB REFERENCED IN ENTRY
         AND,R1   MASKS+24
         CW,R1    R4                DOES IT MATCH
         BE       ECBC680           YES
         LI,R1    ECBBLINK          NO, CONTINUE TO NEXT ENTRY
         LH,R3    *R3,R1
         B        ECBC602
ECBC610  EQU      %
         AI,R8    0                 NEED TO ALLOCATE ENTRY
         BEZ      ECBC611           YES
         LW,R3    R8                USE THE ONE ALREADY OWNED
         B        ECBC613           RETURN TO INITIALIZATION
ECBC611  EQU      %
         LW,R3    R2                YES, SAVE R2 AND
         BAL,R1   ECBGBLK             GO GET A BLOCK
         BNEZ     ECBC612           GOT ONE
         LI,R10   BADSPACE          NO
         B        ECBC100
ECBC612  EQU      %
         XW,R2    R3                REINSTATE FPT INDEX POINTER
         LW,R8    R3                SAVE BLOCK ADDRESS IN CASE NOT USED
ECBC613  EQU      %
         DISABLE
         LW,R1    ECBP              IS ECB POSTED
         AND,R1   WECB,R4
         BEZ      ECBC615           NO, STILL A CANDIDATE
         ENABLE                     YES, COUNT IT AS BEING DONE
         B        ECBC650
ECBC615  EQU      %
         LW,R1    ECBI              HAS ECB BEEN INITIALIZED
         AND,R1   WECB,R4
         BNEZ     ECBC617           YES, OK
         ENABLE
         B        ECBC603           NO, BAD STATE
ECBC617  EQU      %
         LW,R1    ECBBC             TELL ECBPOST THAT ECBCHECK IS ACTIVE
         STS,R1   WECBB,R3
         LW,R1    R5                SAVE USER NUMBER
         LW,R5    MASKS+24          STORE VIRTUAL ADDRESS OF ECB
         STS,R4   ECBBADDR,R3
         LW,R5    R1                RESTORE USER NUMBER
         LW,R1    ECBCC,R4          SAVE CURRENT
         STW,R1   ECBBCC,R3         COMPLETION CODE
         LH,R8    UH:WL,R5          FETCH CHAIN HEAD
         LI,R1    ECBBLINK          PUT HEAD VALUE IN OUR ENTRY
         STH,R8   *R3,R1
         LI,R8    1
         LI,R1    ECBBMULT          INITIALIZE MULTIPLE USAGE COUNT
         STB,R8   *R3,R1
         LW,R1    ECBU              TRANSFER ECBU VALUE FROM
         LS,R1    WECB,R4           USER ECB
         STS,R1   WECBB,R3          TO WAIT LIST ENTRY
         SLS,R3   -1                GENERATE DOUBLEWORD ADDRESS OF BLOCK
         STH,R3   UH:WL,R5          MAKE THIS BLOCK FIRST
         LI,R8    0                 INDICATE BLOCK USED
         LW,R1    ECBW              SET ECB AS WAITING
         STS,R1   WECB,R4
         LW,R1    NECBI             RESET INITIALIZED STATE
         AND,R1   WECB,R4
         STW,R1   WECB,R4
         ENABLE                     INTERRUPTS OK
         B        *R0               RETURN
ECBC650  EQU      %
         LW,R4    R5
         AI,R4    U:MISC
         MTB,-1   *R4               DECREMENT POST REQUIREMENT COUNT
         BGZ      *R0               RETURN
         LI,R10   0                 ALL DONE, GO BACK TO USER
ECBC660  EQU      %
         LW,R2    R8                IF THERE IS A BLOCK LEFT OVER
         BEZ      ECBC100           NOW IS THE TIME TO FREE IT
         BAL,R1   ECBFBLK           FREE THE BLOCK
         B        ECBC100
ECBC680  EQU      %
         LI,R1    ECBBMULT          INCREMENT MULTIPLICITY COUNT
         MTB,1    *R3,R1
         B        *R0               RETURN
         PAGE
*
*
*        EXTRACT NEXT ITEM FROM FPT
*
ECBC800  EQU      %
         AI,R2    1                 BUMP FPT INDEX POINTER
         LW,R10   *R7,R2            FETCH NEXT WORD OF FPT
         BGEZ     ECBC802           POSITIVE - READY TO USE
         CI,R10   REGMASK           IS IT INDIRECT REGISTER
         BANZ     %+2               NO
         AW,R10   J:BASE            YES, MAKE IT RELATIVE TO USER'S REGS
         LW,R10   *R10
ECBC802  EQU      %
         B        *R0               RETURN
         SPACE    2
         SPACE    2
*
*        DETERMINE NEXT ECB ADDRESS
*
ECBC820  EQU      %
         AI,R10   0                 HEAD OF LIST
         BEZ      %+2               YES, DON'T INCREMENT
         AW,R15   R12               INCREMENT LIST POINTER
         CI,R12   2                 IF ECB-LIST,THEN DONE
         BNE      %+3               AFTER INCREMENTING
         LW,R10   R15               OTHERWISE,FOR ECBL-LIST MUST
         B        *R0               OBTAIN CONTENTS OF LIST ITEM
         LW,R10   *R15
         B        *R0
         PAGE
ECBCHCK1 EQU      %
         PUSH     1,R11             SAVE CALLER
         LI,R11   ECBC910           STOP HERE AT EXIT
         PUSH     3,R0              SIMULATE ENVIRONMENT
         PUSH     16,R0             SAVE REGS
         LW,R10   R5                POINT TO ECB
         LW,R5    S:CUN             USER NUMBER
         LW,R4    R5
         AI,R4    U:MISC            POINTER TO U:MISC
         LI,R1    X'7FFFF'          NULLIFY TIME
         STW,R1   *R4
         LI,R1    1                 SET 'EVENTS' TO 1
         STB,R1   *R4
         LI,R8    0                 INDICATE NEED TO ALLOCATE BLOCK
         BAL,R0   ECBC500           PROCESS ECB
         B        ECBC050           WAIT IF NECESSARY
ECBC910  EQU      %                 RETURN HERE AT EXIT
         PULL     16,R0             RESTORE REGS
         LI,R2    -1
         AW,R2    TSTACK
         AND,R2   X1FFFE
         LB,R2    *R2               FETCH CONDITION CODES
         AND,R2   XFFF0
         STB,R2   R5                RETURN CC FROM STACK
         PULL     1,R2
         LI,R11   -2
         MSP,R11  TSTACK
         PULL     1,R11
         B        T:SELFDESTRUCT    RETURN
         END

