         DEF      SYMFILS:
SYMFILS: EQU      %
         SYSTEM   SIG7FDP
         TITLE    'SYMBIONT/COOP CLEAN UP BY RECOVERY'
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
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE
*
*                 SYMBIONT CONTROL MODULE CONTAINS ROUTINES TO CLEAN
*                 UP OUTSTANDING SYMBIONT-COOPERATIVE ACTIVITY.
*
*
*
         DEF      SAVSYM1
         REF      BL:IFS,BL:OFS
         REF      SGCBUFSZ,SGCHD,RCVRGFC1,SYMBGUNO
         REF      SYMBGERR
         REF      SYMX,SRET,SCBESTDA,SCDEVTYP,SCSVDGI
         REF      MB:SDI,UH:JIT,UH:AJIT,UB:SWAPI,BAABC
         DEF      SYMFILS
         DEF      COOPFILS
         DEF      SAVSYM
         REF      RRSG
         REF      RDDISK,WRDISK
         REF      SV1
         REF      SH:LNM
         REF      SBSECTS
         REF      RCBUF
         REF      SNDDX,SSTAT,SCNTXT
         REF      SSIG
         REF      SGB
         REF      AIF,AOF,AOFL,AOFNB,AOFP,GIFNC,J:JIT
         REF      SCGCNT,SCGCO
         REF      AIFNC
         REF      SCSYMX
         REF      J:USCDX,SBSIZE,SCBLDA
         REF      SCCDA,SCFBUF,SCPCO,SCRCO,SV:LSIZ
         REF      STB:TYP
         REF      WRDISK1
         REF      SCMISC,NOPGFC,SCFORM,SCFPC
         REF      R:TSTACK
         REF      Y2,JCO2VPA
         REF      MAPSPARE          IN CYCUSR
         REF      JCOVPA,JOVVP,JXBUFVP
         PCC      0
         PAGE
*
PUSH     CNAME    X'0B'
PULL     CNAME    X'0A'
         PROC
LF       EQU      %
TMP      SET      -2
         DO       NUM(AF)>1
         DO       AF(1)<16
         LCI      AF(1)
         ELSE
         LCI      0
         FIN
TMP      SET      0
         FIN
         GEN,8,4,20 NAME+TMP,AF(NUM(AF)),R:TSTACK
         PEND
         PAGE
SAVSYM   EQU      %
         STW,11   SYMFX
         SPACE    3
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                 SET UP SYMBIONT GHOST USER NUMBER, JIT ADDRESS *
*                                       AJIT ADDRESS, SWAP INDEX *
*                 FROM DATA SAVED IN ALLOCAT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SGUNUM   EQU      3                 SYMB GHOST USER NUMBER
         SPACE    3
         LI,R7    SGUNUM            SYMBIONT GHOST USER NUMBER
         LI,SR1   HGPSIZE+1         SAMSJIT AT ALLYTL
         REF      HGPSIZE
         AND,SR1  =X'FFFFFFFE'      BOUND 8
         SLD,SR1  -8                RELATIVE SECTOR NUMBER
         SLS,SR2  -24               WORD DISPLACEMENT INTO SECTOR
         AI,SR1   8                 START AT SECTOR 8
         LI,R1    1
         LB,R2    MB:SDI
         STB,R2   SR1,R1            DCTX OF SYSTEM RAD
         LI,D4    256*4*2           READ TWO SECTORS
         BAL,SR4  RDDISK            GO-READ GRANULE
         B        KRD13
         LW,R1    SR2               WORD DISPLACEMENT INTO SECTOR
         LW,R2    RCBUF,R1          0,SWAPX,SEEK SYMB GHOST JIT
         BNEZ     KRD17
         MTH,0    UH:JIT,R7         SYMB GHOST STARTED
         BNEZ     KRD13-1           YES-USE CORE ADDRESSES
         B        KRD13             NO-DONT SET USER NO.
KRD17    EQU      %
         STH,R2   UH:JIT,R7         CORRECT JIT ADDRESS
         SLS,R2   -16
         STB,R2   UB:SWAPI,R7       SWAP INDEX OF SYMB GHOST
         LW,R2    RCBUF+1,R1        0,SWAPX,SEEK SYMB GHOST AJIT
         BEZ      %+2               NO AJIT
         STH,R2   UH:AJIT,R7        AJIT SEEK ADDRESS
         STW,R7   SYMBGUNO          FILL IN SYMB GHOST USER NUMBER
KRD13    EQU      %
         PAGE
* * * * ****************************************************************
*                 COPY MONITOR RESIDENT SYMBIONT GHOST COMMUNICATION   *
*                 BUFFERS TO SYMFILS AREA                              *
* * * * ****************************************************************
         SPACE    3
         LI,R1    -SGCBUFSZ         SIZE RES MON SYMB COMM BUFFER
         LW,R2    SGCHD+SGCBUFSZ,R1
         STW,R2   SAVSGCBF+SGCBUFSZ,R1
         BIR,R1   %-2               COPY SYMB GHOST COMM BUF TO SAVE BUF
         LI,R1    RCVRGFC1
         STW,R1   WORD1
         BAL,SR4  LNKSGCBF          GO-LINK RECOVERY ENTRY IN SYMB SAVE
         LOCAL    SGCBUF,SGCHD
SGCBUF   EQU      SAVSGCBF
SGCHD    EQU      SAVSGCBF
*
         LI,R1    HOU               HEAD OF USED POINTER
         LB,R1    SGCHD,R1
KRD22    LI,R2    X'FF'
         AND,R2   SGCBUF,R1         FUNCTION CODE
         CI,R2    GIFNC
         BNE      KRD23             NOT INTERESTED
         LW,SR1   SGCBUF+1,R1
         MTB,0    SR1               DA OF CHAIN TO RELEASE
         BNEZ     KRD23             NO
         BAL,SR4  RELSYMS           YES-GO RELEASE THE CHAIN
KRD23    LW,R1    SGCBUF,R1
         LB,R1    R1                ADVANCE THE CHAIN
         BNEZ     KRD22
         B        *SYMFX            RETURN
         PAGE
SAVSYM1  STW,SR4  SVSYM1RT          SAVE RETURN ADDRESS
         LI,3     0                 SAVE LOCKED SYMB'S
         LI,2     1
         LB,7     SNDDX             NUMBER OF SYMS
         AI,7     -2
SYMLP    LB,15    SSIG,7            LOCKS
         CI,15    'L'
         BE       %+3               SYMBIONT IS LOCKED
         CI,D4    2
         BNE      %+4
         STB,7    15,2              POSITION OF SYM IN SSIG
         BAL,11   SV1
         AI,3     1
         BDR,7    SYMLP
         LW,15    3                 NUMBER OF LOCKED SYMS
         BAL,11   SV1
         AWM,3    SYCODE
         LW,15    SGB
         BAL,11   SV1
         LW,15    SYCODE
         BAL,11   SV1
         PAGE
* * * * ****************************************************************
*                 PUT SYMBIONT GHOST COMMICATION BUFFERS IN RECOVER    *
*                 BUFFER. X'10000000'                                  *
* * * * ****************************************************************
         SPACE    3
         MTW,0    SYMBGUNO          SYMB GHOST RUNNING
         BNEZ     KRD18              YES
         LI,R1    8                 NO-
         CW,R1    SYMBGERR             ANY COMM BUF ENTRYS
         BAZ      *SVSYM1RT         NO-DONT SAVE COMM BUF
KRD18    EQU      %
         LCW,R1   SVSGCBFZ          SIZE OF SYMB COMM BUFFER
         LI,R2    SAVSGCBF
         AW,R2    SVSGCBFZ
         LW,D4    *R2,R1
         BAL,SR4  SV1
         BIR,R1   %-2               COPY SYMB GHOST COMM BUF TO RECOVER2
         LW,D4    SVSGCBFZ
         OR,D4    =X'10000000'
         BAL,SR4  SV1               CODE WORD FOR SYMB COMM BUFFER
         B        *SVSYM1RT         RETURN ADDRESS
SVSYM1RT DATA     0                 SAVSYM1 RETURN ADDRESS
SYCODE   GEN,8,24 7,2               CODE WORD FOR LOCKED SYMBIONTS
         PAGE
RELSYMS  STW,11   RELSSX
         LI,11    1000
         STW,11   RELSCT
RELSYM2  STW,8    SAVE8S
         BAL,11   RRSG
         LW,8     SAVE8S
         LI,15    4                 ONE WORD TO READ
         BAL,11   RDDISK
         B        *RELSSX
         MTW,-1   RELSCT
         BLEZ     *RELSSX           PREVENT LOOP
         LW,8     RCBUF
         BNEZ     RELSYM2           CONTINUE TO END
         B        *RELSSX
RELSSX   DATA     0
SAVE8S   DATA     0
RELSCT   DATA     0
         PAGE
*
*                 SYMFILS - PACKAGE OUTPUT FILES TO CONTINUE AFTER
*                 RESTART, RELEASE INPUT FILES.
*
SYMFILS  STW,11   SYMFX
         SPACE    3
* * * * ****************************************************************
*                 CYCLE THROUGH ALL  ACTIVE I/O SYMBIONTS. RELEASE     *
*                 INPUT. REQUE OUTPUT.                                 *
* * * * ****************************************************************
         SPACE    3
         LB,R1    SNDDX             NUMBER OF SYMBIONT ENTRIES
KRD1     LB,R2    SSTAT,R1          STATUS CODE FOR SYMBIONT DEVICE
         CI,R2    1                 ACTIVE STATUS
         BE       KRD2              YES
KRD3     BDR,R1   KRD1
         B        *SYMFX            RETURN ADDRESS
KRD2     LH,R6    SCNTXT,R1         DA(SYMBIONT CONTEXT BLOCK)
         SLS,R6   1                 CONTEXT BLOCK ADDRESS
         LB,R2    SYMX,R1
         AND,R2   =X'3'
         CI,R2    2                 OUTPUT SYMBIONT
         BE       KRD4              YES
         CI,R2    1
         BNE      KRD3
*                                   INPUT SYMBIONT
         LW,R2    SCSYMX,R6
         CI,R2    4                 NON CONTROL INPUT FILE
         BANZ     %+3               YES-SKIP JOB CARD TEST
         MTW,0    SCPCO,R6          JOB CARD JOB READ FOR THIS INPUT FILE
         BLEZ     KRD3              NO-NOTHING TO DO
         LI,R2    0
         LW,R4    SCFBUF,R6         ADDRESS OF INPUT BUFFER
         SLS,R4   -2                WORD ADDRESS OF BUFFER
         STW,R2   *R4               FLINK=0 TO INPUT BUFFER
*                                   WRITE SYMBIONT INPUT BUFFER
         LW,SR1   SCCDA,R6          DA OF CURRENT BUFFER
         BAL,SR4  WRDISK            GO-WRITE THE BUFFER TO SYMBIONT AREA
         B        KRD3              ERROR ON WRITE-IGNORE INPUT SYMBIONT
         LB,R2    SNDDX,R1          DCTX FOR INPUT SYMBIONT
         SLS,R2   8
         AI,R2    AIF               ADD INPUT FILE GFC
         STW,R2   WORD1             1ST WORD OF SGCBUF-ADD INPUT FILE
         LW,R2    SCBESTDA,R6       FDA OF FILE
         BEZ      KRD3              NO INPUT FDA
         OR,R2    =X'80000000'      FIN BIT
         STW,R2   WORD2
         LW,R2    SCSYMX,R6
         CI,R2    4                 INPUT NONCONTROL FILE
         BAZ      KRD26             NO
         LW,R2    R1                SYMBIONT INDEX
         SLS,R2   16
         AI,R2    AIFNC             ADD INPUT FILE NONCONTROL
         LW,R3    =X'FF00FF'
         STS,R2   WORD1
         LW,R2    SCGCNT,R6         GRAN COUNT
         STW,R2   WORD4
         BAL,SR4  LNKSGBF1          GO-PUT ENTRY INTO COMM BUF
         B        KRD3
KRD26    EQU      %
         MTW,0    BL:IFS            ROOM FOR INPUT SYMB ENTRY
         BGZ      KRD15             YES
         LW,SR1   SCBESTDA,R6       FDA OF FILE
         BAL,SR4  RELSYMS           GO-RELEASE SYMB GRANUALS
         B        KRD3
KRD15    EQU      %
         BAL,SR4  LNKSGCBF          GO-LINK 3 WORD ENTRY SYMB GHOST COMM
         MTW,-1   BL:IFS            COUNT THIS INPUT SYMB ENTRY
         B        KRD3
KRD4     EQU      %                 OUTPUT SYMBIONT
         STH,R1   WORD1             SYMBIONT INDEX
         LB,R3    STB:TYP,R1        DEVICE TYPE
         SLS,R3   8
         AI,R3    AOFP              ADD OUTPUT FILE PARTIAL GFC
         STS,R3   WORD1             SYMBX,TYPE,AOFP
         LW,R2    SRET,R1
         LB,R2    R2                SGCHD INDEX ZERO
         BNEZ     KRD5              NO-THERE IS A COMM BUFFER
         LW,R3    SCBESTDA,R6       OUTPUT STARTED
         STW,R3   WORD2
         AND,R3   =X'FFFFFF'
         BEZ      KRD3              NO-NOTHING TO DO
         LW,R2    SCSVDGI,R6
         STW,R2   WORD3             PRI,RBID,SYSID IN WORD3
         BAL,SR4  LNKSGBF1          GO-LINK 3 WORD ENTRY IN SG COMM BUF
         B        KRD3
KRD5     EQU      %                 OUTPUT SYMB SGCBUF INDEX PRESENT
         LW,R5    SGCBUF+1,R2
         BEZ      KRD3              NO FILE TO CONNECT
         CI,R5    -1
         BE       KRD8              FILE NOT YET CONNECTED
         LW,R5    WORD1
         LCI      3
         LM,R2    SGCBUF,R2
         STM,R2   WORD1
         STW,R5   WORD1             SYMBX,TYPE,AOFP
         BAL,SR4  LNKSGBF1          GO-LINK 3 WORD ENTRY SG  BUF
         B        KRD3
KRD8     EQU      %                 UNCHAIN THE ENTRY
         LI,R5    0                 ZERO TAIL REMOVE LAST ENTRY
         LI,R4    HOU               HEAD OF USED
         LB,R3    SGCHD,R4
         CW,R3    R2                FIRST ENTRY IN CHAIN
         BNE      KRD9              NO
         LW,R3    SGCBUF,R2
         LB,R3    R3
         STB,R3   SGCHD,R4          YES-UPDATE HEAD TO SECOND ENTRY
         B        KRD10
KRD9     LI,R6    87                MAX NUMBER OF ENTRYS
         LW,R5    R3                SAVE PREVIOUS INDEX
         LW,R3    SGCBUF,R3
         LB,R3    R3
         BDR,R6   %+2               DONT LOOP FOREVER
         B        KRD3
         CW,R3    R2
         BNE      KRD9+1            FIND ENTRY THAT POINTS TO ENTRY
         LW,R3    SGCBUF,R2
         LW,R4    SGCBUF,R5
         LB,R3    R3
         STB,R3   R4
         STW,R4   SGCBUF,R5         CHAIN AROUND ENTRY TO REMOVE
KRD10    BNEZ     KRD3              TAIL DID NOT CHANGE
         LI,R4    TOU
         STB,R5   SGCHD,R4          UPDATE TAIL POINTER
         B        KRD3
SYMFX    DATA     0                 RETURN ADDRESS
         PAGE
*
*                 CLOSE ALL CO-OP FILES. (5) =JIT. 11= LINK
*
COOPFILS EQU      %
         STW,11   COOPFX
         LI,R6    X'1FFFF'
         AND,R6   J:USCDX           ADDRESS OF COOP POINTERS
         BEZ      *COOPFX           THERE ARE NO COOP BUFFERS
*
         LI,R4    JCOVPA
         LI,R5    JOVVP-JXBUFVP
         BAL,R2   MAPSPARE
         B        *COOPFX
*
         LI,R6    SV:LSIZ           NUMBER OF POSSIBLE COOP BUFS
         STW,R6   COPCOUNT
COOPLOP  LW,R6    COPCOUNT
         MTW,-1   COPCOUNT          COUNT DOWN THE COOP BUFFERS
         BGEZ     KRD24             PROCCESS ALL COOP BUFFERS
         LC       J:JIT             BATCH JOB
         BCS,X'C' *COOPFX           NO-RETURN
         LW,R1    LSTINDEX          LAST AOF BUFFER INDEX
         LW,R2    SGCBUF+2,R1
         LI,R3    X'FFFF'
         CS,R2    J:JIT             LAST ENTRY OF THIS BATCH  JOB
         BNE      *COOPFX           NO
         LI,R2    AOFL              ADD OUTPUT FILE LAST GFC
         LI,R3    X'FF'
         STS,R2   SGCBUF,R1         CHANGE AOF TO AOFL FOR LAST BATCH FILE
         B        *COOPFX           RETURN
KRD24    LW,R6    *J:USCDX,R6       ADDRSSS OF COOP CONTEXT BLOCK
         BLZ      COOPLOP           STRM NOT OPEN
         CW,R6    Y2
         BAZ      COOPLOP           CNTXT BLK NOT IN SE
         LW,R1    SCDEVTYP,R6
         LC       R1                INPUT COOP FILE
         BCR,8    COOPINFL          YES
         LW,SR1   SCCDA,R6          CURRENT DA
         LI,R4    SBSIZE            COOP BLOCK SIZE
         LW,11    LASOTBLK-1,4
         STW,11   RCBUF-1,4
         BDR,4    %-2
         LW,SR4   SCBLDA,R6         CURRENT BLINK
         CW,SR1   SR4               BLINK UPDATED
         BNE      KRD20             YES-USE IT
         LW,SR4   SCFBUF,R6         NO-GET ADDRESS OF CURRENT BLOCK
         PUSH     16,R0
         LI,R4    JCO2VPA           VIRTUAL WINDOW ADDRESS
         LB,R5    SR4               SPARE BUFFER #
         BAL,R2   MAPSPARE          GO MAP IT
         B        KRD27             ERROR
         PULL     16,R0
         AI,SR4   SBSIZE-1          POINT TO BLINK WORD
         LW,SR4   *SR4              GET BLINK
KRD20    EQU      %
         STW,SR4  RCBUF+SBSIZE-1    BLINK ADDRESS
         LI,R3    SBSIZE+SBSIZE+SBSIZE+SBSIZE  BYTES IN BLOCK
         LI,4     RCBUF
         BAL,SR4  WRDISK1           GO-WRITE BLOCK
         B        *COOPFX           BAD DA
         SPACE    3
* * * * ****************************************************************
*                 RELEASE INPUT COOP GRANUALS. CLOSE OUTPUT COOP WITH  *
*                 'LAST RECORD SUPPLIED BY RESTART'.                   *
* * * * ****************************************************************
         SPACE    3
         LW,SR1   SCBESTDA,R6       FDA
         STW,SR1  WORD2
         LW,R1    SCMISC,R6
         STB,R1   WORD2             COPIES
         LI,R1    X'3F'
         AND,R1   SCDEVTYP,R6       TYPE CODE
         SLS,R1   8
         LC       J:JIT             BATCH JOB
         BCR,X'C' KRD21             YES
         AI,R1    AOFNB             ADD OUTPUT FILE NON BATCH GFC
         STW,R1   WORD1
         B        KRD19
KRD21    AI,R1    AOF               ADD OUTPUT FILE GFC
         STW,R1   WORD1
         LW,R1    SCDEVTYP,R6
         CW,R1    =X'00200000'      PUNCH TYPE DEVICE
         BAZ      KRD19             NO
         LW,R2    SCRCO,R6          YES-NUMBER OF CARDS WRITTEN
         CI,R2    2                 DATA CARDS WRITTEN
         BG       KRD19             YES
         LW,R1    COPCOUNT
         AI,R1    1                 LOGICAL DEVICE INDEX
         LH,R1    SH:LNM,R1         LOGICAL DEVICE TEXT NAME
         AND,R1   =X'FFFF'
         CI,R1    'P1'              PUNCHING FROM CCI
         BNE      KRD19             NO-CANT BE LACE CARDS
         BAL,SR4  RELSYMS           NO-RELEASE THE GRANULE
         B        COOPLOP
KRD19    EQU      %
         LW,R1    SCSVDGI,R6
         STW,R1   WORD3             PRIORITY,RBID,SYSID
         LI,R1    X'FFFF'
         AND,R1   J:JIT             SYS ID FROM JIT
         STS,R1   WORD3
         LI,R2    BAABC+1
         LB,R1    J:JIT,R2
         SLS,R1   -4                PRIORITY
         STB,R1   WORD3             PRIORITY,0,SYSID
         LW,R1    SCGCO,R6          GRAN COUNT
         STW,R1   WORD4
         BAL,SR4  LNKSGBF1          GO-LINK 3 WORD ENTRY IN SG COMM BUF
         STW,R2   LSTINDEX          LAST INDEX OF AOF ENTRY
         LI,R1    X'FF00'
         AND,R1   SCMISC,R6         JDE FIELD
         AW,R1    SCFORM,R6         FORMS FEILD
         AW,R1    SCFPC,R6          FOVLY FEILD
         BEZ      KRD25             NO INFORMATION FOR SECOND ENTRY
         LI,R1    X'FF00'
         AND,R1   SCMISC,R6         JDE FIELD
         AI,R1    NOPGFC            NOP GFC CODE
         STW,R1   WORD1
         LW,R1    SCFORM,R6         FORMS FEILD
         STW,R1   WORD2
         LW,R1    SCFPC,R6          FOVLY FEILD
         STW,R1   WORD3
         BAL,SR4  LNKSGCBF          GO-LINK THIS ENTRY
         LW,R1    LSTINDEX          LAST INDEX OF AOF ENTRY
         LW,R3    R2                INDEX OF SECOND BUFFER
         SLS,R3   16
         STS,R3   SGCBUF,R1         LINK1 OF PREVIOUS AOF ENTRY
KRD25    EQU      %
         MTW,0    SYMBGUNO          SYMB GHOST RUNNING
         BNEZ     COOPLOP           YES
         LI,R1    8
         STS,R1   SYMBGERR          NO-SET COMM BUF PRESENT
         B        COOPLOP
KRD27    PULL     16,R0
         B        COOPLOP
COOPFX   DATA     0
COPCOUNT DATA     0
LSTINDEX DATA     0                 LAST INDEX OF AOF BUFFER
LASOTBLK DATA     0
         DATA     X'002C0501'
         TEXT     '*** LAST RECORD SUPPLIED BY RESTART ***       '
*
COOPINFL EQU      %
         LW,SR1   SCDEVTYP,R6
         LC       SR1
         BCS,4    COOPLOP
         LW,SR1   SCCDA,R6          CURRENT DA
         BAL,11   RELSYMS
         LW,SR1   SCCDA,R6          CURRENT DA
         AI,8     -SBSECTS
         BAL,11   RRSG
         B        COOPLOP
         PAGE
*        BAL,SR4  LNKSGCBF          LINK SYMB GHOST COMM BUFFER
*
LNKSGBF1 EQU      %
         MTW,0    BL:OFS            ROOM FOR OUTPUT SYMB ENTRY
         BGZ      KRD16             YES
         LW,R2    SR4               SAVE RETURN
         LW,SR1   =X'FFFFFF'
         AND,SR1  WORD2             FIRST DISC ADDRESS
         BAL,SR4  RELSYMS           GO-RELEASE SYMB GRANUALS
         B        *R2
KRD16    EQU      %
         MTW,-1   BL:OFS            COUNT THIS OUTPUT SYMB ENTRY
LNKSGCBF EQU      %
         LB,R2    SGCHD             INDEX OF FREE BUFFER HEAD
         BEZ      KRD11             LINK AFTER RES MON SGCBUF SZ
         LW,R3    SGCBUF,R2
         LB,R3    R3
         STB,R3   SGCHD             UPDATE HEAD OF FREE CHAIN
KRD12    LCI      4                 FOUR WORD ENTRIES
         LM,R7    WORD1
         STM,R7   SGCBUF,R2         COPY WORD1,2,3 INTO SGCBUF
         LI,R4    TOU               TAIL OF USED
         LB,R3    SGCHD,R4          TAIL SGCHD INDEX
         BEZ      KRD7              NO USED CHAIN
         LW,R7    SGCBUF,R3
         MTB,0    R7
         BNEZ     KRD14             ERROR-TAIL NOT POINTING TO LAST ENTY
         STB,R2   R7                CHAIN IN NEW USED ENTRY
         STW,R7   SGCBUF,R3
         STB,R2   SGCHD,R4          UPDATE TAIL OF USED POINTER
KRD6     LW,R3    SGCBUF,R2
         LI,R4    0
         STB,R4   R3
         STW,R3   SGCBUF,R2         MAKE SURE TAIL CHAIN POINTER ZERO
         STW,R4   WORD1             ZERO
         STW,R4   WORD2                  THEM
         STW,R4   WORD3                       ALL
         STW,R4   WORD4
         B        *SR4              RETURN
KRD7     STB,R2   SGCHD,R4          TAIL OF USED-POINTER
         LI,R4    HOU               HEAD OF USED
         MTB,0    SGCHD,R4
         BNEZ     KRD14             ERROR-HEAD AND TAIL OUT OF SYNC
         STB,R2   SGCHD,R4          HEAD OF USED-POINTTER
         B        KRD6
KRD11    LW,R2    SVSGCBFZ          INDEX TO FREE ENTRY
         LW,R3    SVSGCBFZ
         AI,R3    4                 COUNT THIS FOUR WORD ENTRY
         CI,R3    X'FF'             MAX INDEX SIZE FOR BYTE
         BGE      KRD14             ERROR-TO MANY ENTRYS
         STW,R3   SVSGCBFZ          UPDATE TO INCLUDE THIS ENTRY
         B        KRD12
KRD14    EQU      %                 ERROR-IN SYM GHOST COMM BUF
         LI,R3    4
         STS,R3   SYMBGERR
         B        *SR4
TOU      EQU      1                 TAIL OF USED IN SGCHD
HOU      EQU      3                 HEAD OF USED IN SGCHD
         PAGE
WORD1    DATA     0                 SYMBIONT GHOST COMMUNICATION BUFFER
WORD2    DATA     0
WORD3    DATA     0
WORD4    DATA     0
SAVSGCBF RES      258               SYMBIONT GHOST COMMUNICATION BUFFERS
SVSGCBFZ DATA     SGCBUFSZ          SIZE OF SYMB COMM BUF INCLUDE RECV
         END

