*M* ECBCHECK WAIT FOR ECB'S TO BE POSTED (M:CHECKECB SERVICE)
         DEF      ECBCHECK:         XDELTA LABEL FOR ECBCHECK MODULE.
ECBCHECK: EQU     %
*
*P*      NAME:    ECBCHECK
*P*
*P*      PURPOSE: TO CHECK EVENT CONTROL BLOCKS (ECB) FOR COMPLETION
*P*               AND PLACE USER IN WAIT STATE AWAITING COMPLETION
*P*               IF NECESSARY.
*P*
*P*  DESCRIPTION: ECBCHECK BUILDS ENTRIES ON THE USER'S WAIT-LIST
*P*               FOR ECBS SPECIFIED BY THE CALLER BUT NOT YET
*P*               POSTED COMPLETE.  IF NOT ENOUGH SPECIFIED ECBS
*P*               HAVE BEEN POSTED TO SATISFY THE CALLER, THE USER
*P*               IS PLACED IN WAIT STATE UNTIL ENOUGH HAVE BEEN
*P*               POSTED, WHEREUPON ECBPOST REAWAKENS THE USER
*P*               AND ECBCHECK RETURNS.
*P*
*P*
BITS     SET      1                 GET DEFINITIONS OF XN,YN,MN.
         SYSTEM   UTS
         PCC      0
         PAGE
         DEF      ECBCHECK    ENTRY TO PROCESS M:CHECKECB CAL1.
         DEF      ECBCHCK1    ENTRY TO WAIT ON ONE ECB (INTERNAL).
*
         REF      E:SL        = SCHEDULER EVENT TO PUT USER TO SLEEP.
         REF      ECBFBLK     ROUTINE GIVES BACK A FOUR-WORD BLOCK.
         REF      ECBGBLK     ROUTINE GETS A FOUR-WORD BLOCK.
         REF      J:BASE      INPUT ADDRESS OF USER R0 IN TSTACK.
         REF      J:JAC       INPUT ACCESS PROTECTION OF USER'S PAGES
         REF      JHKBIT1     ROUTINE TESTS & GETS 1ST FPT PARAM.
         REF      JHKBIT      ROUTINE TESTS & GETS NOT-1ST FPT PARAM.
         REF      JOVVPA      = WA OF FIRST PAGE IN MAP.
         REF      NB31TO0     MASKS
         REF      T:DOLISTR   (DOLIST ROUTINE JUST GIVES BACK BLOCK)
         REF      U:MISC      OUTPUT BITS 0-7 COUNT OF AWAITED ECBS
*,*                                  BITS 8-31 MAX TIME TO WAIT
         REF      UH:DL       INPUT CHAIN OF THINGS TO DO (INCLUDES
*,*                             DEFERRED ECB POSTINGS)
*,*                           OUTPUT DEFERRED POSTINGS ARE DONE.
         REF      UH:WL       INPUT & OUTPUT CHAIN OF UNPOSTED ECBS
*,*                             WAITED ON.  (ZERO IN & OUT)
         REF      S:CUN       INPUT USER# OF CURRENT USER.
         REF      T:REG       ROUTINE REPORTS SCHEDULER EVENT
         REF      X1FFFE      MASK
         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
BREAKBLK EQU      3
ECBFECB  EQU      2
ECBFECBL EQU      3
*
*        TABLE SYMBOLS FOR ECB
*
ECBP     EQU      BT31TO0+32
ECBW     EQU      BT31TO0+31
ECBI     EQU      BT31TO0+30
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      0
ECBBRESL EQU      4
ECBBADDR EQU      1
ECBBP    EQU      ECBP
WECBB    EQU      2
ECBBMULT EQU      10
ECBBC    EQU      BT31TO0+28
NECBBC   EQU      NB31TO0+28
ECBBCC   EQU      3
ECBBLENG EQU      4
ECBBECB  EQU      1
         PAGE
*F*      NAME:    ECBCHECK
*F*      PURPOSE: ECBCHECK PROCESSES THE M:CHECKECB CAL, CHECKING
*F*               EVENT CONTROL BLOCKS FOR COMPLETION AND PLACING
*F*               THE USER IN WAIT STATE IF NOT ENOUGH ECBS HAVE
*F*               BEEN POSTED YET.
*F*  DESCRIPTION: ECBCHECK CONVERTS THE FPT OF AN M:CHECKECB CAL INTO
*F*               A SET OF ENTRIES ON THE USER'S WAITLIST (UH:WL)
*F*               WHICH POINT TO EVENT CONTROL BLOCKS IN THE USER'S
*F*               SPACE.  IF ENOUGH ECBS HAVE BEEN POSTED COMPLETE
*F*               ALREADY, ECBCHECK CLEARS THE WAITLIST AND RETURNS
*F*               TO THE USER.  OTHERWISE, THE COUNT OF ECBS STILL
*F*               NEEDING TO BE POSTED IS PLACED IN THE USER'S U:MISC
*F*               WORD AND THE USER IS PUT TO SLEEP TO AWAIT WAKEUP
*F*               BY ECBPOST.
*F*   REFERENCE:  CPV/BP REFERENCE MANUAL FOR STRUCTURE OF THE
*F*               M:CHECKECB FPT.
*
*D*      NAME:    ECBCHECK
*D*
*D*      REGISTERS: R11 PRESERVED ALL OTHERS ZAPPED.
*D*      CALL:    BAL,R11 ECBCHECK
*D*               (ECBCHECK EXPECTS TO BE IN AN OVERLAY)
*D*      INTERFACE: ECBFBLK, ECBGBLK, T:REG, T:SELFDESTRUCT
*D*      ENVIRONMENT: MASTER MAPPED.
*D*               RETURNS ENABLED.
*D*      DATA:    UH:WL IS THE HEAD OF A CHAIN OF FOUR-WORD BLOCKS
*D*                 THESE BLOCKS HOLD THE STATUS OF ECB'S LISTED
*D*                 BY THE USER IN THE CAL1 FPT WHICH ARE NOT YET
*D*                 POSTED COMPLETE.
*D*      INPUT:   R6 = ADDRESS PORTION OF FPT WORD 0.
*D*               R7 => FPT + 1.
*D*               R8 = FPT CODE (BYTE 0 WORD 0 OF FPT).
*D*               R11= RETURN ADDRESS.
*D*               J:JAC IS ACCESS PROTECTION OF USER'S PAGES.
*D*      OUTPUT:  BACK 17 OR 18 WORDS IN STACK IS USER'S PSD.
*D*                 CC IN IT IS SET TO INDICATE FINAL STATUS:
*D*                 0 OKAY.
*D*                 1 ILLLEGAL TIME SPECIFICATION.
*D*                 2 SOME ECB IS IN IMPROPER STATE.
*D*                 3 NOT ENOUGH ECBS TO SATISFY WAIT.
*D*                 4 CAN'T GET ENOUGH FOUR-WORD BLOCKS.
*D*                 5 ILLEGAL ECB ADDRESS.
*D*                 6 NO ECBS SPECIFIED AT ALL.
*D*
ECBCHECK EQU      %
         AI,R7    -1                PREPARE FPT POINTER FOR JHKBIT.
         BAL,R1   JHKBIT1           GET P1 (# EVENTS AWAITED). USE R14
         BGZ      %+2                *GOT P1.  -------> GO IF >0.
         LI,R2    1                  **NO P1. (OR P1.LE.0) ..SET TO 1.
         LW,R10   R2            R10= # EVENTS AWAITED.
*********
         LI,R2    X'7FFFE'
         BAL,R1   JHKBIT            GET PARAM#2 (MAX TIME TO WAIT)
         BNEZ     ECBC010           GOT P2. ---> NONZERO.
         AI,R2    1                 NO P2; SET =7FFFF. P2=0; SET =1.
         B        ECBC015
ECBC010  EQU      %
         CI,R2    X'F0000'          USER SPECIFIED P2; SEE IF TOO BIG.
         BAZ      ECBC015           ---> OKAY.
         LI,R10   BADTIME           'TIME > 65535'.
         B        ECBC150           ---> BAD NEWS. NOTHING ON WAITLIST
ECBC015  EQU      %
         LW,R12   R2            R12= TIME TO WAIT.
*********
         AND,R6   M16               R6= #ECB(16-23), #ECBL(24-31).
         BNEZ     ECBC020           ---> OKAY.
         LI,R10   BADSPEC           'NO ECBS SPECIFIED'.
         B        ECBC150           ---> BAD NEWS. NOTHING ON WAITLIST
ECBC020  EQU      %
         LW,R3    S:CUN             R3= NUMBER OF CURRENT USER.
         LI,R2    0                 R2= 0 SINCE NO SPARE 4-WD BLK YET.
*
*  R2    ZERO OR ADDRESS OF SPARE FOUR-WORD BLOCK.
*  R3    NUMBER OF CURRENT USER.
*  R6    (16-23) #ECB SPEC    (24-31) #ECBL SPEC    FROM USER FPT
*  R7 => FIRST ECB OR ECBL WORD IN FPT. (ALSO SIGN BIT SET FOR BIR)
* R10    NUMBER OF EVENTS TO WAIT FOR COMPLETION OF.
* R12    TIME TO WAIT IF EVENTS HAVEN'T HAPPENED.
* R11    RETURN ADDRESS TO CALLER. (PROBABLY TRAPEXIT)
*
         CI,R6    X'FF00'           ANY ECB SPECIFICATION...
         BAZ      ECBC040           ---> NO ECB SPEC; TRY FOR ECBL.
ECBC032  EQU      %
         BAL,R0   ECBC800           R14<- WA(ECB AREA) FROM FPT.
         LW,R15   R14               R15 => ECB AREA.
         BAL,R0   ECBC800           R14 = # OF ECBS.
*                                     (IF USER SAID ZERO, HE MEANT 1)
ECBC035  EQU      %
         LW,R4    R15               R4  => ECB.
         BAL,R0   ECBC500           PROCESS ECB.
         AI,R15   2                 ADVANCE TO NEXT ECB.
         BDR,R14  ECBC035           ---> NEXT ECB.
         AI,R6    -X'100'
         CI,R6    X'FF00'           ANY MORE ECB...
         BANZ     ECBC032           ---> YES.
ECBC040  EQU      %
         CI,R6    X'FF'             ANY ECBL SPECIFICATION...
         BAZ      ECBC050           ---> NO ECBL SPEC; GO TO WAIT.
ECBC042  EQU      %
         BAL,R0   ECBC800           R14<- WA(ECBLIST AREA) FROM FPT.
         LW,R15   R14               R15 => ECBLIST AREA.
         BAL,R0   ECBC800           R14 = # OF ECBS.
*                                     (IF USER SAID ZERO, HE MEANT 1)
ECBC045  EQU      %
         LW,R4    *R15              R4  => ECB.
         BAL,R0   ECBC500           PROCESS ECB.
         AI,R15   1                 ADVANCE TO NEXT ECB POINTER.
         BDR,R14  ECBC045           ---> NEXT ECB POINTER.
         BDR,R6   ECBC042           ---> NEXT ECB POINTER BLOCK.
         B        ECBC050
         SPACE    3
ECBC800  EQU      %                 EXTRACT NEXT ITEM FROM FPT.
         LW,R14   0,R7              FETCH NEXT WORD OF FPT.
         BGEZ     ECBC802           ---> READY TO USE.
         CI,R14   X'1FFF0'          INDIRECT.  THRU REGISTER...
         BANZ     %+2               ---> NO.
         AW,R14   J:BASE            YES.  ADJUST IT.
         LW,R14   *R14              GO INDIRECT.
ECBC802  EQU      %
         BIR,R7   *R0               RETURN INCREMENTING FPT POINTER.
         PAGE
*F*      NAME:    ECBCHCK1
*F*      PURPOSE: ECBCHCK1 AWAITS THE POSTING OF ONE ECB, PLACING
*F*               THE USER IN WAIT STATE IF IT HAS NOT BEEN POSTED.
*F*  DESCRIPTION: ECBCHCK1 EXAMINES THE CALLER-SPECIFIED ECB; IF IT
*F*               HAS BEEN POSTED COMPLETE, THE CALLER IS RETURNED
*F*               TO; OTHERWISE A WAITLIST (UH:WL) ENTRY IS MADE
*F*               FOR THE ECB AND THE USER IS PUT TO SLEEP UNTIL
*F*               ECBPOST REAWAKENS HIM.
*
*D*      NAME:    ECBCHCK1
*D*
*D*      REGISTERS: SR3 RETURNS ERROR CODE OR 0.
*D*               R1,R4 CLOBBERED BY DESTRUCT. OTHERS PRESERVED.
*D*               ALL OTHERS PRESERVED.
*D*      CALL:    BAL,R11 ECBCHCK1
*D*               (ECBCHCK1 EXPECTS TO BE IN AN OVERLAY)
*D*      INTERFACE: ECBFBLLK, ECBGBLK, T:REG, T:SELFDESTRUCT
*D*      ENVIRONMENT: MASTER MAPPED.
*D*               RETURNS ENABLED.
*D*      DATA:    UH:WL MAY BE USED TO HOLD THE ADDRESS OF A FOUR-WORD
*D*                 BLOCK POINTING TO THE ECB IF IT ISN'T YET POSTED.
*D*      INPUT:   R5 = VIRTUAL ADDRESS OF ECB TO BE WAITED ON.
*D*               R11= RETURN ADDRESS.
*D*               J:JAC IS ACCESS PROTECTION OF USER'S PAGES.
*D*      OUTPUT:  SR3(R10) INDICATES STATUS OF REQUEST.
*D*                  ZERO MEANS OKAY. VARIOUS ERROR CODES INDICATE
*D*                  ECB IN BAD STATE, NO 4-WORD BLOCKS, OR ILLEGAL
*D*                  ECB ADDRESS.
*D*
ECBCHCK1 EQU      %
         PUSH     15,R11            SAVE CALLER'S REGS ALL BUT R10.
         LI,R10   1                 R10= # EVENTS AWAITED (1).
         LI,R12   X'7FFFF'          R12= TIME TO WAIT (INFINITE).
         LW,R3    S:CUN             R3= NUMBER OF CURRENT USER.
         LI,R2    0                 R2= 0 SINCE NO SPARE 4-WD BLK YET.
         LW,R4    R5                R4 = ECB ADDRESS.
         LI,R0    ECBC050           RUN WAITLIST & WAIT , AFTER
         BAL,R11  ECBC500           SETTING UP ECB.
*
ECBC910  EQU      %                 BACK END... R10 HAS COMP CODE.
         AI,R10   ECBERRTBL         CONVERT CC TO ERROR CODE.
         LW,R10   *R10
         PULL     15,R11            RESTORE CALLER'S REGS.
         DESTRUCT                   ---> RETURN TO CALLER.
*
ECBERRTBL DATA    0                 0 CC MEANS OK.
         DATA     X'0200004A'       4A-01 IMPOSSIBLE.
         DATA     X'0400004A'       4A-02 ECB IS IN IMPROPER STATE.
         DATA     X'0600004A'       4A-03 IMPOSSIBLE.
         DATA     X'0800004A'       4A-04 CAN'T GET A 4-WORD BLOCK.
         DATA     X'0A00004A'       4A-05 ILLEGAL ECB ADDRESS.
*E*      ERROR:   4A-02
*E*      MESSAGE: ECB IN WRONG STATE ON M:CHECK W/ ECB.
*E*      ERROR:   4A-04
*E*      MESSAGE: NO MONITOR WORKSPACE TO HONOR M:CHECK W/ ECB.
*E*      ERROR:   4A-05
*E*      MESSAGE: WRONG ACCESS CODE FOR ECB ON M:CHECK W/ ECB.
         PAGE
*
*    ALL ECBS ARE ON WAITLIST; RUN THROUGH ONCE AGAIN DISABLED.
*  R3    USER NUMBER.
*  R2    ZERO OR ADDRESS OF SPARE 4-WORD BLOCK.
* R10    NUMBER OF EVENTS TO WAIT FOR COMPLETION OF.
* R12    TIME TO WAIT IF EVENTS HAVEN'T HAPPENED.
*    R11 MUST BE PRESERVED.
*
ECBC050  EQU      %
         AI,R2    0                 IS THERE AN EXTRA BLOCK...
         BEZ      %+2               ---> NO.
         BAL,R1   ECBFBLK           YES. FREE IT NOW.
         DISABLE                    ***  DISABLE FROM HERE TO REG ***
         LH,R4    UH:WL,R3          START AT HEAD OF WAIT-LIST.
ECBC056  EQU      %
         SLS,R4   +1                R4 = WA(WAITLIST BLOCK)
         LW,R13   WECBB,R4          R13= FLAG WORD FROM BLOCK.
         CW,R13   ECBBP             HAS IT BEEN POSTED IN INTERIM...
         BAZ      ECBC060           ---> NO.
         LI,R1    ECBBMULT
         LB,R15   *R4,R1            GET WAITED-ON COUNT OF ECB.
         SW,R10   R15               REMOVE FROM GLOBAL WAIT COUNT.
         BLEZ     ECBC100Z          ---> QUIT. ENOUGH HAVE HAPPENED.
ECBC060  EQU      %
         AND,R13  NECBBC            TELL ECBPOST THAT ECBCHECK IS
         STW,R13  WECBB,R4            INACTIVE.
         LW,R4    ECBBLINK,R4       GET NEXT WAIT-LIST BLOCK.
         AND,R4   M16
         BNEZ     ECBC056           ---> MORE BLOCKS.
         STB,R10  R12               DONE. COMBINE WAITCOUNT & TIME,
         XW,R12   U:MISC,R3           AND PUT WHERE POST CAN FIND.
         LW,R10   R11               SAVE RETURN ADDRESS.
         LI,R6    E:SL              REPORT SLEEP EVENT.
         BAL,R11  T:REG             SLEEP.
         LW,R11   R10               RESTORE RETURN ADDRESS.
         XW,R12   U:MISC,R3         REPLACE U:MISC.
*  FALL THROUGH TO ZERO-R10-AND-RETURN.
         PAGE
*
*        CLEAN-UP AND RETURN TO CALLER
*
ECBC100Z EQU      %                 (E.P. FOR NORMAL BUMPOUT RETURN)
         LI,R10   0                 'O.K.'
ECBC100E EQU      %                 (E.P. FOR ABN NEEDING ENABLE)
         ENABLE                     **  ALLOW INTERRUPTS  **
ECBC100  EQU      %                 (E.P. FOR EVERYONE)
         LW,R3    S:CUN             R3= USER NUMBER.
ECBC115  EQU      %
         LH,R2    UH:WL,R3
         BEZ      ECBC150
         DISABLE
         SLS,R2   1                 R2 = WA(4-WORD WAITLIST BLOCK).
         LW,R5    ECBBADDR,R2       R5 = WA(ECB).
         LW,R1    WECB,R5           R1 = FLAGWORD OF ACTUAL ECB.
         AND,R1   NECBW               RESET WAITING IN ACTUAL ECB.
         LW,R4    WECBB,R2          R4 = FLAGWORD IN 4-WORD BLOCK.
         CW,R4    ECBBP               IS WL BLOCK POSTED...
         BAZ      ECBC120           ---> NOT POSTED.
         OR,R1    ECBP                POSTED.  POST ACTUAL ECB.
         LW,R4    ECBBCC,R2         R4 = COMPLETION CODE(4-WD BLOCK).
         STW,R4   ECBCC,R5            TRANSFER TO ACTUAL ECB.
         B        ECBC122
ECBC120  EQU      %
         OR,R1    ECBI               RETURN ACTUAL ECB TO INITIALIZED.
ECBC122  EQU      %
         STW,R1   WECB,R5            REPLACE FLAGWORD IN ACTUAL ECB.
         LW,R5    ECBBLINK,R2       FETCH LINK.
         STH,R5   UH:WL,R3          STORE IN HEAD
         ENABLE                     ALLOW INTERRUPT GAP
         LW,R1    ECBBPERM          IS ENTRY FROM BLOCK POOL
         AND,R1   WECBBPER,R2
         BNEZ     ECBC115           NO
         BAL,R1   ECBFBLK           YES, GIVE BLOCK BACK TO POOL.
         B        ECBC115
ECBC150  EQU      %                 ** WAITLIST IS NOW EMPTY.
         CI,R11   ECBC910
         BE       *R11              ---> GO NOW IF CALL WAS INTERNAL.
         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
         DESTRUCT                   NO, PERFORM OVERLAY CLEANUP.
         PAGE
*
*    PROCESS AN ECB.
*  R2    ZERO OR ADDRESS OF SPARE FOUR-WORD BLOCK.
*  R3    USER NUMBER (S:CUN).
*  R4    VIRTUAL ADDRESS OF ECB.
*  R0    LINK REGISTER.
* R10    NUMBER OF EVENTS TO WAIT FOR COMPLETION OF.
*    R6,R7,R11,R12,R14,R15 MUST BE PRESERVED.
*
ECBC500  EQU      %
         AND,R4   M17               R4 = ADDRESS OF ECB.
         CI,R4    JOVVPA            IS ADDRESS TOO LOW...
         BL       ECBC590           ---> YES. DON'T ACCEPT.
         LW,R5    R4
         AI,R5    1                 START WITH SECOND WORD OF ECB.
ECBC510  EQU      %
         SLS,R5   -9                GET PAGE NUMBER.
         LI,R1    3
         AND,R1   R5                GET PAGE# WITHIN J:JAC BYTE.
         SCS,R5   -2                GET J:JAC BYTE# (4 PAGES/BYTE)
         LB,R1    L(X'C0300C03'),R1 GET ACCESS PROTECT MASK FOR PAGE.
         CB,R1    J:JAC,R5          IS ACCESS NONZERO...
         BANZ     ECBC590           ---> YES, BAD NEWS.
         SCS,R5   +11               GET BACK WA(PAGE).
         CS,R5    R4                CROSSED A PAGE BOUND...
         BE       ECBC600           ---> NO. DONE CHECKING.
         BDR,R5   ECBC510           ---> YES. CHECK OTHER PAGE TOO.
ECBC590  EQU      %
         LI,R10   BADECB            'ILLEGAL ECB ADDRESS'.
         B        ECBC660           ---> FREE SPARE BLOCK & BAD NEWS.
ECBC600  EQU      %
         LW,R5    M24               (SET FOR SELECTIVE COMPARES)
         LH,R1    UH:WL,R3          FIRST TRY FOR ALREADY ON WAITLIST.
         BEZ      ECBC610           ---> NO WAITLIST SO CAN'T BE ON.
ECBC605  EQU      %
         SLS,R1   1                 GET WA(WAITLIST BLOCK).
         CS,R4    ECBBADDR,R1       IS THIS THE BLOCK FOR OUR ECB...
         BNE      ECBC607           ---> NO.
         LI,R5    ECBBMULT          YES.
         MTB,1    *R1,R5            INCREMENT MULTIPLICITY COUNT.
         B        *R0               -----> RETURN.
ECBC607  EQU      %
         LW,R1    ECBBLINK,R1       GET FLINKED BLOCK.
         AND,R1   M16
         BNEZ     ECBC605           ---> MORE WAITLIST TO LOOK AT.
ECBC610  EQU      %
         DISABLE                    ***   DISABLE SETTING UP WL ENTRY
         LW,R8    WECB,R4           GET FLAGWORD FROM ECB.
         CW,R8    ECBP              IS IT ALREADY POSTED....
         BANZ     ECBC650           ---> YES, COUNT IT POSTED.
         CW,R8    ECBI              HAS IT BEEN INITIALIZED...
         BANZ     ECBC617           ---> YES.
         LI,R10   BADSTATE          'ECB IN IMPROPER STATE'.
         B        ECBC660           ---> FREE SPARE BLOCK & BAD NEWS.
ECBC617  EQU      %
         LH,R1    UH:DL,R3          LOOK FOR IT ON DO-LIST.
         LI,R13   0
ECBC621  EQU      %
         AND,R1   M12               ANY (MORE) DOLIST ENTRIES...
         BEZ      ECBC624           ---> NO.
         SLS,R1   +1                YES. CONVERT ADDRESS TO WA.
         LH,R9    *R1               GET TYPE OF
         AND,R9   M7                  DO-LIST BLOCK.
         CI,R9    ECBBECB           IS IT AN ECB BLOCK...
         BE       ECBC623           ---> YES. COMPARE ADDRESS.
         CI,R9    BREAKBLK          NO. IS A BREAK ON DO-LIST...
         BE       ECBC659           ---> YES. GO BACK TO USER  N O W.
ECBC622  EQU      %
         LW,R13   R1
         LW,R1    ECBBLINK,R1       GET FORWARD LINK.
         B        ECBC621
ECBC623  EQU      %
         CS,R4    ECBBADDR,R1       DOES DOLIST BLOCK HAVE SAME ECB
         BNE      ECBC622           ---> NO.
         OR,R8    ECBP              POST ECB COMPLETE.
         AND,R8   NECBI
         AND,R8   NECBW
         STW,R8   WECB,R4
         LW,R8    ECBBCC,R1         TRANSFER COMPLETION CODE
         STW,R8   ECBCC,R4          TO ECB.
         LI,R4    7                 CHANGE TO 'SPECIAL'
         LW,R5    M7                DO-LIST ENTRY
         SLD,R4   +16
         STS,R4   0,R1
         LI,R4    T:DOLISTR         GOING TO T:DOLISTR TO RELEASE
         STW,R4   1,R1              ITSELF.  (WE CAN'T YET)
         B        ECBC650
ECBC624  EQU      %
         AI,R2    0                 NEED TO ALLOCATE BLOCK...
         BNEZ     ECBC633           ---> NO, GOT ONE ALREADY.
         BAL,R1   ECBGBLK           YES.  GET ONE.
         BNEZ     ECBC610           ---> GOT ONE, ADDRESS IN R2.
         LI,R10   BADSPACE          'NO MONITOR WORKSPACE AVAIL'.
         B        ECBC660           ---> FREE SPARE BLOCK & BAD NEWS.
ECBC633  EQU      %
         LW,R1    ECBBC             SAY ECBCHECK IS ACTIVE,
         STW,R1   WECBB,R2          AND SET INTO BLOCK.
         STS,R4   ECBBADDR,R2       BLOCK <- VIRTUAL ADDR OF ECB.
         LW,R1    ECBCC,R4
         STW,R1   ECBBCC,R2         BLOCK <- CURRENT COMPLETION CODE.
         LI,R9    1
         LI,R1    ECBBMULT
         STB,R9   *R2,R1            THIS ECB AWAITED ONCE (SO FAR).
         LH,R9    UH:WL,R3          CHAIN BLOCK TO WAITLIST.
         STW,R9   ECBBLINK,R2
         SLS,R2   -1
         STH,R2   UH:WL,R3
         LI,R2    0                 SAY BLOCK HAS BEEN USED.
         LW,R1    WECB,R4
         OR,R1    ECBW              SET ECB AS WAITING
         AND,R1   NECBI               AND NOT INITIALIZED.
         STW,R1   WECB,R4
         ENABLE
         B        *R0               RETURN.
ECBC650  EQU      %
         ENABLE
         BDR,R10  *R0               -1 TO WAITCOUNT; GO IF MORE WAITS.
ECBC659  EQU      %
         LI,R10   0                 'O.K.'
ECBC660  EQU      %
         AI,R2    0                 IS THERE A SPARE BLOCK...
         BEZ      ECBC100E          ---> NO. ENABLE & RETURN TO USER.
         BAL,R1   ECBFBLK           YES. FREE IT FIRST (ENABLE)
         B        ECBC100           ---> AND THEN RETURN TO USER.
         END
		 
