*M* SYMFILS CLOSE USER'S OPEN COOPERATIVE FILES AND ACTIVE SYMBIONTS
*P* NAME: SYMFILS
*P* DESCRIPTION:
*P* SAVSYM:  PUT SAVED VALUES FROM ALLOCAT INTO RBBAT JIT, AJIT AND
*P*              SWAP INDEX CORE TABLES.
*P*          MOVE SYMBIONT COMMUNICATION BUFFER AREA
*P*              FROM THE MONITOR TO A BUFFER IN RECOVERY.
*P*          PUT RECOVER ENTRY IN THE SYMBIONT COMMUNICATION BUFFER.
*P*          RELEASE GRANULE CHAIN ASSOCIATED WITH ANY GIFNC
*P*              SYMBIONT COMMUNICATION BUFFER ENTRIES.
*P* SAVSYM1: SAVE LOCKED SYMBIONT DEVICES
*P*               AND THE CONTENTS OF THE SGB TABLE IN THE RECOVER BUFFER.
*P*          PUT SYMBIONT COMMUNICATION AREA FROM RECOVERY INTO RECOVER BUFFER.
*P* RELSYMS: RELEASE SYMBIONT GRANULE CHAIN.
*P* SYMFILS: CLOSE ACTIVE SYMBIONT FILES AT TIME OF CRASH.
*P* COOPFILES: CLOSE COOPERATIVE INPUT FILES.
*P*            PUT 'LAST RECORD SUPPLIED BY RESTART' AS LAST
*P*              BLOCK OF OUT-PUT COOPERATIVE FILES.
*P* LNKSGCBF: PUT A RECOVER GENERATED ENTRY IN THE SYMBIONT COMMUNICATION BUF.
         DEF      COOPFILS
*,*               ENTRY POINT OF ROUTINE TO CLOSE CO-OP FILE AT
*,*               CRASH TIME.
         DEF      SAVSYM
*,*               ENTRY POINT TO COPY MONITOR SGC BUF TO RECOVER BUF.
         DEF      SAVSYM1
*,*               ENTRY POINT OF ROUTINE TO SAVE LOCKED SYMBIONT
*,*               DEVICE AND SAVE SGC BUF.
         DEF      SYMFILS
*,*               ENTRY POINT OF ROUTINE TO CLOSE ACTIVE SYMBIONT
*,*               FILES AT CRASH.
         DEF      SYMFILS:
*,*               PATCHING DEF FOR XDELTA.
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.
*
*
*
         REF      BL:IFS
         REF      BL:OFS
         REF      SGCBUFSZ
         REF      SGCHD
         REF      RCVRGFC1
         REF      SYMBGUNO
         REF      SYMBGERR
         REF      SYMX
         REF      SRET
         REF      MB:SDI
         REF      UH:JIT
         REF      UH:AJIT
         REF      UB:SWAPI
         REF      BAABC
         REF      RRSG
         REF      RDDISK
         REF      WRDISK
         REF      SV1
         REF      SBSECTS
         REF      RCBUF
         REF      SNDDX
         REF      SSTAT
         REF      SSIG
         REF      AIF
         REF      AOF
         REF      AOFL
         REF      AOFNB
         REF      AOFP
         REF      GIFNC
         REF      J:JIT
         REF      AIFNC
         REF      J:USCDX
         REF      SBSIZE
         REF      SV:LSIZ
         REF      STB:TYP
         REF      WRDISK1
         REF      NOPGFC
         REF      R:TSTACK
         REF      JCO2VPA
         REF      MAPSPARE
         REF      JCOVPA
         REF      JOVVP
         REF      JXBUFVP
*
         REF      SCBESTDA
         REF      SCDEVTYP
         REF      SCSVDGI
         REF      SCNTXT
         REF      SCGCNT
         REF      SCGCO
         REF      SCSYMX
         REF      SCBLDA
         REF      SCCDA
         REF      SCFBUF
         REF      SCPCO
         REF      SCMISC
         REF      SCFORM
         REF      SCCOMID           CONCURRENT MODE OUTPUT ID
         REF      S:QUIET,S:SGCSAV
         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      %
         MTW,0    S:QUIET           RBBAT WRITING ITS DATA
         BEZ      KRD29             NO
         LW,R3    =X'FF0000FF'
         LW,R2    S:SGCSAV
         STS,R2   SGCHD             YES-RESTORE SGCHD FROM S:SGCSAV
KRD29    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
         BEZ      %+3               BR IF NO LOCKED SYMBIONTS
         MTB,7    15                BUILD CONTROL WORD
         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
         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
         LCI      3
         LM,R2    SGCBUF+1,R2
         STM,R2   WORD2
         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
         LC       R6
         BCR,2    COOPLOP           CNTXT BLK NOT IN USE
         LW,R1    SCDEVTYP,R6
         LC       R1                INPUT COOP FILE
         BCR,8    COOPINFL          YES
         LI,R4    X'4001'           END OF BLOCK
         LW,SR1   SCDEVTYP,R6
         CW,SR1   =X'204000'        PUNCH OR LIST DEVICE
         BAZ      KRD28             NO
         LW,R4    =X'002B0003'      PRINT UNCOMPRESSED
         CW,SR1   =X'04000000'
         BAZ      %+2
         LW,R4    =X'002D0001'      IRBT COMPRESSED
KRD28    EQU      %
         STW,R4   CONTRWD
         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    SCCOMID,R6        GET COMID
         BEZ      JPC2              NOT COMODE OUTPUT
         SLS,R1   -8                SAVE BYTE 0 OF COMID, IFF COMODE
         OR,R1    =X'80'            MAKE SURE LAST CHUNK FLAG IS SET
         B        %+2
JPC2     LW,R1    SCMISC,R6
         STB,R1   WORD2             COPIES
         LI,R1    X'FF'
         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
         B        KRD19
KRD21    AI,R1    AOF               ADD OUTPUT FILE GFC
KRD19    EQU      %
         STW,R1   WORD1
         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
         LW,R1    SCFORM,R6         FORMS FIELD
         OR,R1    SCCOMID,R6        COMODE ID FIELD
         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,R2    SCCOMID,R6
         BEZ      JPC1              NOT COMODE
         AND,R2   =X'FF'            SAVE BYTE 1 OF COMID IN...
         STH,R2   WORD1             ... BYTE 1 OF WORD 0 OF BUF #2
         LI,R1    X'8000'           SET COMODE FLAG...
         STS,R1   WORD1             (BIT 0 OF JDE, JDE IS ONLY 5 BITS)
JPC1     EQU      %
         LW,R1    SCFORM,R6         FORMS FEILD
         STW,R1   WORD2
         LI,R1    0                 OLD FOVLY FIELD
         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
CONTRWD  DATA     0
         DATA,1   X'81',X'EA',X'C0','*'
         TEXT     '** LAST RECORD SUPPLIED BY RESTART ***  '
         DATA     X'40'
*
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
         LI,R4    TOF               TAIL OF FREE
         CB,R2    SGCHD,R4          TAIL OF FREE ENTRY
         BNE      KRD12             NO
         CI,R3    0                 YES-IT MUST BE END OF CHAIN
         BNE      KRD14             ERROR-NOT AT END OF 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
TOF      EQU      2                 TAIL OF FREE CHAIN
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

