MONPROC  SET      1
         SYSTEM   UTS
         LOCAL    HSC
         DEF      BUFF
BUFF     EQU      %
         PCC      0
         PAGE
*                 SYMBOLIC REGISTER DEFINITIONS.
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      EQU      8
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE
*GET BUFFER ROUTINES(INTERNAL)
*(R5)=JIT ADDRESS(JOB INFO TABLE)
*        BAL,SR4  GSC               SYMBIONT CONTEXT BLOCK
*        BAL,SR4  GMB               MONITOR BUFFER
*        RETURN
         REF      SCBPOOLIM
         REF      BUFLIMS
         REF      MPOOLIM
         REF      M17
         REF      MPOOL,CPOOL
         DEF      GSC
         DEF      GMB
*GET SYMBIONT CONTEXT BLOCK BUFFER
GSC      LI,R2    CPOOL             HEAD OF SYMB CONTEXT BUFFER POOL
         LI,1     SCBPOOLIM         SYMB BUFR LIMIT
         B        GB00              CONTINUE
*GET MONITOR BUFFER
GMB      LI,R2    MPOOL             HEAD OF MONITOR BUFFER POOL
         LI,1     MPOOLIM           INDEX TO MPOOL LIMITS
GB00     DISABLE                    DISABLE INTERRUPTS TO BREAK
*                                   BUFFER CHAIN
         LW,D3    0,R2              AVAILABLE BUFFER ADDRESS
         AND,D3   M17
         BEZ      GB01              NONE AVAILABLE
         CLM,14   BUFLIMS,1         CHECK FOR LEGAL BUFFER ADDRESS
         BCR,9    GB05C
SC1900   EQU      %                 SOFTWARE CHECK 19-00 MAY
         DEF      SC1900            BE CALLED FROM IOQ
GB05     SCREECH  X'19'
GB05C    EQU      %
         LW,R0    *D3               NEXT AVAIL BUFFER
         STW,R0   0,R2              TO AVAIL BUFFER
GB01     ENABLE                     ENABLE INTERRUPTS
         AI,D3    0
         B        *SR4              EXIT
         PAGE
*RELEASE BUFFER ROUTINES(INTERNAL
*(R5)=JIT ADDRESS (JOB INFO TABLE)
*(D3)=ADDRESS OF BUFFER TO BE RELEASED
*        BAL,SR4  RSC               CONTEXT BUFFER
*        BAL,SR4  RMB               MONITOR BUFFER
*        RETURN
         DEF      RMB,RSC
*RELEASE CONTEXT BUFFER
RSC      LI,R2    CPOOL             HEAD OF SYMB CONTEXT BUFFER POOL
         LI,1     SCBPOOLIM
         B        RB00              CONTINUE
*RELEASE MONITOR BUFFER
RMB      LI,R2    MPOOL             MONITOR BUFFER POOL HEAD
         LI,1     MPOOLIM
RB00     EQU      %
         AND,14   M17
         CLM,14   BUFLIMS,1         CHECK LEGALITY OF BUFFER
*                                   BEING RELEASED
         BCR,9    %+2
         BCS,9    GB05              BRANCH IF ILLEGAL
         DISABLE
*                                   BUFFER CHAIN
         LW,R0    0,R2              NEXT AVAIL BUFFER
         STW,D3   0,R2              RELEASE BUFFER
         STW,R0   *D3               CHAIN RELEASED TO NEXT AVAIL BUFFER
         B        ENBSR4            ENABLE & EXIT
         REF      ENBSR4
BUFFSZ   EQU      %-BUFF
         END

