         DEF      INSYM:            PATCHING DEF
INSYM:   RES
*
*
*M*      INSYM    UNIT RECORD DEVICE TO DISC SYMBIONT (INPUT)
*
*
*
*
*                 CATALOG NO. 704934 - SIGMA 5/7 BPM M:SYMCR
         SYSTEM   UTS
         DEF      SYMCR             * ENTRY NAME(ASOF BPM) USED AT INITIATE
SYMCR    EQU      %
*
SYM%G%LOK%FIXED SET 0               LOCKUP NOT FIXED
*
         PAGE
*
*                             PROGRAM NAME - BATCH MONITOR.
*
         PAGE
*                 SYMBOLIC REGISTER DEFINITIONS.
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R6       EQU      6
SR1,R8   EQU      8
SR2,R9   EQU      9
SR3,R10  EQU      10
SR4,R11  EQU      11
D1,R12   EQU      12
D2,R13   EQU      13
D3,R14   EQU      14
D4,R15   EQU      15
         PAGE
*SCRNDD-CARD READER SYMBIONT-SELF RELOCATING
*GENERALIZE TO WORK FOR MAGNETIC TAPE AND PAPER TAPE READ
*RE-ENTRANT FROM SYMBIONT ACTIVATE ROUTINE
*SYMBIONT CONTEXT BUFFERS ON EVEN STARTING MEMORY LOCATIONS
* (R1) = SYMBIONT CONTEXT BLOCK BASE ADDRESS
*(R2)=SYMBIONT RETURN ADDRESS
*(R3)=SYMBIONT TABLE INDEX
*(R4)=SYMBIONT BASE ADDRESS
*(SR3)=CONTEXT BLOCK ADDRESS
*(TSTACK)=SYMBIONT EXIT
*        B        0,R2
         REF      C:CSC             * COUNTER: SYSTEM COUNT OF SYMBIONT FILE
*,*                                 * ACCESSES. INCLUDES COOP TOO
         REF      REQCB             * REQUEST CORE BUFFER ROUTINE(DATA BLOCK)
         REF      SBSIZE            * SYMBIONT DATA BUFFER SIZE VALUE
         REF     SNDDX              * SYMBIONT NDD TABLE OF INDICES, USED
*,*                                 * TO GET DEVICE DCT INDEX(INPUT)
         REF      SSTAT             * SYMBIONT STATUS TABLE(OUTPUT)ACTIVE,SUSP,E
         REF      SCBESTDA          * SYMBIONT CNTXT DISPLACEMENT TO BEST D.A.
*,*                                 * CONTAINS THE FILE STARTING DISC ADDR
         REF      SCFBUF            * SYMBIONT CNTXT DISPLACEMENT TO FILE BUFFER
*,*                                 * CELL, POINTS AT CURRENT DATA BUFFER
         REF      SCCDA             * SYMBIONT CNTXT DISPLACEMENT TO CURR. D. A.
*,*                                 * CONTAINS DISC ADDR OF CURRENT BLOCK
         REF     SCBLDA             * SYMBIONT CNTXT DISPLACEMENT TO BACK LINK D
*,*                                 * CONTAINS PREVIOUS DISC BLOCK DISC ADDR
         REF      SCFQARGS          * SYMBIONT CNTXT DISPLACEMENT TO FILE QUEUE
*,*                                 * A GROUP OF ARGUMENTS TO NEWQ IN IOQ
         REF      SCDQARGS          * SYMBIONT CNTXT DISPLACEMENT TO DEVICE QUEU
*,*                                 * A GROUP OF ARGUMENTS TO NEWQ IN IOQ
         REF      SCDBI             * SYMBIONT CNTXT DISPLACEMENT TO DATA BYTE I
*,*                                 * CONTAINS CURRENT DATA BLK BYTE INDEX
         REF      SCDINFO           * SYMBIONT CNTXT DISPLACENT TO DEVICE INFO T
*,*                                 * TABLE CONTAINS VARIOUS TEMP VARIABLES.
         REF      SCFINFLG          * SYMBIONT CNTXT DISPLACEMENT TO THE !FIN
*,*                                 * ENCOUNTERED FLAG.
         REF      SCMODE            * SYMBIONT CNTXT DISPLACEMENT TO MODE FLAG.
*,*                                 * CONTAINS RB CC'S VS JOB DATA BLOCKING FLG
         REF      SCRCO             * SYMBIONT CNTXT DISPLACEMENT TO RECORD COUN
         REF      SCNAME            * SYMBIONT CNTXT DISPLACEMENT TO NAME FIELD.
*,*                                 * USED IN !!NCTL FILE NAMING
         REF      SCGCNT            * SYMBIONT CNTXT DISPLACEMENT TO GRANULE COU
         REF      QFPD4CB           * QUE FOR ACTIVATION PULL ???
         REF      SCJCO             * SYMBIONT CNTXT DISPLACEMENT TO JOB CARD CO
*,*                                 * FILES PASSED THIS INITIATION.
         REF      SCAIF             * SYMBIONT CNTXT DISPLACEMENT TO ADD INPUT F
*,*                                 * FLAG(MEANS WE HAVE A FILE TO ADD TO RBBAT.
         REF      SCSYMX            * SYMBIONT CNTXT DISPLACEMENT TO SYMX SAVE C
*,*                                 * CONTAINS LOCAL DEFINITION OF SYMX FOR THIS
         REF      NEWQ              * ROUTINE IN MODULE IOQ TO DO PHYSICAL IO.
         REF      DCT5              * DEVICE CONTROL TABLE 5(CONTAINS BCD/BIN FL
         REF      XFE               * =X'000000FE' MASK NOT BCD/BIN FOR DCT5
         REF      TJOB              * =C'!JOB' FOR CC RECOGNIZING
*
*
         REF      RBLIMS            * REM BAT TERM DCTX LIMITS
         REF      AIF               * ADD INPUT FILE GHOST FUNCT. CODE
         REF      AIFNC             * ADD NON-CONTROL INPUT FILE G.F.C.
         REF      SGCQ              * SYM GHO CALL Q ROUTINE(WAKENS RBBAT)
         REF      Y8                * =X'80000000' SETS SCFINFLG
         REF      QFACTP11          * Q FOR ACTIVATION PULL 11 ROUTINE
         REF      QFP11NCB          * QFACT,PULL 11,NO COMM BUF ROUTINE
         REF      BL:IFS            * BAT LIM: INPUT FIL SLOTS
*,*                                 * MODIFIED AND INDICATES RBBAT QUE FULL
         REF      RQLDGA            * COUNTER INDICATES INSYM MAY BUILD FILES NO
*,*                                 * NOT USED NOW BECAUSE IT IS NOT RIGHT
         REF      SSIG              * SYMB SIGNAL CHAR TABLE(I,S,C,L,X,ETC.)
         REF      Y04               * =X'04000000' BYTE 0 COUNT OF 4 FOR MBS
         REF      Y07               * =X'07000000' BYTE 0 COUNT OF 7 FOR MBS
         REF      M24               * =X'00FFFFFF' GENERAL REAL EXTENDED ADDRESS
*,*                                 MASK, USED TO CLEANUP ADDRESSES.
         REF      SUSP              * SUSPEND SYMBIONT ROUTINE.
*
          REF      REQDC            * REQUEST DISC BLOCK ROUTINE, MAY PARK
*,*                                 THE SYMBIONT UNTIL DISC IS AVAILABLE.
         REF      SRELBUF           * SYMBIONT RELEASE BUFFER ROUTINE.
         REF      Y02               * =X'02000000' VALUE 2 IN BYTE 0 USED TO CHE
*,*                                 * DEVICE TYC CODE(LESS THAN 2 IS AOK)
         REF      FIN               * =C'!FIN' USED TO RECOGNIZE CONTROL CARD.
         REF      TERM              * TERMINATE SYMBIONT ROUTINE IN SUSPTERM
         REF      SYMX              * SYMBIONT FLAG TABLE DEFINES SYMBIONT BEHAV
*,*                                 * NCTL,INPUT VS. OUTPUT,ETC.
         REF      XEOD              * =C'!EOD' USED TO RECOGNIZE THE END-OF-DATA
*,*                                 * CONTROL CARD FOR HANDLERS WHO DONT
         REF     M16                * =X'0000FFFF' MASK TO EXTRACT RIGHT HALFWOR
         REF      M6                * =X'0000003F' MASK TO EXTRACT DCTX FROM CDA
         REF      OCQUEUE           * OPERATOR'S CONSOLE MESSAGE QUEUE'R
         SPACE    5
SBBSIZ   EQU      SBSIZE+SBSIZE+SBSIZE+SBSIZE
         PAGE
T        RES      0                 BASE
         LI,R0    1                 SET SYMBIONT
         STB,R0   SSTAT,R3          STATUS ACTIVE
*ONE RECORD A MAXIMUM OF 30 WORDS(120 BYTES)
*ASSUME BUFFER LARGE ENOUGH TO CONTAIN AT LEAST DA+CC+BC+RECORD+EC(32
         BAL,SR4  REQCB             REQUEST SYMBIONT DATA BUFFER
         BAL,9     REG
*        R4=BASE;R3=SYMTABX;D2=SSIG,R3;R1=CNTXT ADDR (ALL FROM SR3)
*                 PRELIMINARY CONTEXT BLOCK INITIALIZATION
*                 PUTS STATIC ARGUMENTS FOR NEWQ IN THEIR PLACES
*
         LW,R6    D3                SAVE BUFFER ADDRESS
         LW,SR4   FQARG1-T,4        ARGUMENTS FOR DISC WRITE
         LW,D1    R6                BUFFER ADDR
         SLS,D1   2                 BA(BUFFER)
         LI,D2    SBSIZE
         SLS,D2   2                 SIZE IN BYTES
         ANLZ,D4  SCREAEA1-T,4      DISC WRITE END ACTION
         LCI      5
         STM,SR4  SCFQARGS,R1       (DISC ADDR SUPPLIED LATER)
*
         LB,SR4   SNDDX,R3          NOW FOR CARD READ ARGS
         OR,SR4   DQARG1-T,4
         LI,D2    SCRSIZE
         LW,D3    R3                SEEK FIELD CONTAINS SYMTABX
         ANLZ,D4  SCREAEA-T,4       END ACTION = SCREND
         LCI      5
         STM,SR4  SCDQARGS,R1       (RECORD BYTE INDEX SUPPLIED LATER)
*
         LB,D2    SYMX,R3
         STW,D2   SCSYMX,R1         SAVE SYMX IN CNTXT BLK
         MTW,-1   SCRCO,R1          INIT FOR NCTL CHECK
*
*
*  START RECORD READ FOR THE FIRST TIME OR AFTER A DISC WRITE.
*
LOOP     EQU      %
*                                   DATA BUF ADDR IN D3 BY NOW
         LW,SR2   SCBLDA,R1         GET BLINK
         STW,SR2  SBSIZE-1,R6       PUT AWAY BLINK
         ANLZ,SR2 SCR10C-SYMCR,R4  SET EXIT TO START RECORD READD
SCR10B   LI,D1    1STDBI+RCCS       * 1ST RECORD POSITION IN BLOCK
         STW,D1   SCDBI,R1          BYTE INDEX TO CURRENT RECORD
SCR10D   EQU      %
         PULL     SR4               SYMBIONT EXIT
         B        *SR2              EXIT
SCR10C   B        SCREA04-SYMCR,R4  START RECORD READ EXIT              934
         PAGE
*CARD READ END ACTION(ALSO FOR CARD IMAGES ON PAPER OR MAGNETIC TAPE)
*(SR4)=EXIT
*(D1 )=TYPE OF COMPLETE,-,REMAINING BYTE COUNT  8,8,16
*(D3 )=CONTEXT BLOCK ADDRESS
*(D4 )=BUFFER BYTE ADDRESS AND BIN FLAG(BIT 6)
         SPACE    5
SCREA00D B        SUSP
SCREND   RES      0
         LW,SR3   D3                SET UP FOR REG
         BAL,9     REG
*        R4=BASE;R3=SYMTABX;D2=SSIG,R3;R1=CNTXT ADDR (ALL FROM SR3)
         CI,D2    'S'               SUSPEND SYMBIONT
         BNE      SCREA00B-SYMCR,R4 NO                                  934
         LCI      4
         STM,D1   SCDINFO,R1        SAVE END ACTION REG'S
         BAL,SR2  SCREA00D-SYMCR,R4 YES,SET SUSPEND RETURN ADDRESS AND  934
*                                   GO TO SUSPENSION EXIT               934
*                                                                       934
*RETURN FROM SUSPEND                                                    934
*                                                                       934
         PLW,11   TSTACK            PUSHED BY SUSP PATH
         LI,R0    1                 SET SYMBIONT                        934
         STB,R0   SSTAT,R3          STATUS ACTIVE                       934
         LCI      4
         LM,D1    SCDINFO,R1        RETRIEVE REGISTERS
         BAL,9    REG
*        R4=BASE;R3=SYMTABX;D2=SSIG,R3;R1=CNTXT ADDR (ALL FROM SR3)
SCREA00B EQU      %                                                     934
         LW,R6    D4                SAVE BA(BUFFER) IN R6
         AND,D4   M24
         MTW,1    SCRCO,R1          BUMP RECORDS READ COUNT
         BNEZ     SCREA00A-T,R4     NOT FIRST ONE READ
         LW,SR1   D4                FIRST RECORD:
         LI,SR2   BA(NCTL)          IS IT
         OR,SR2   Y07               SPECIAL NCTL
         CBS,SR1  0                 CONTROL COMMAND
         BNE      SCREA00A-T,R4     NO
         LI,D1    0
         LW,R1    SR1
         OR,R1    YD69
         CBS,0    BA(NCTL)+7
         BCR,3    SCRSMK-T,R4
         LW,SR1   R1
         LW,SR2   NTO12
         MBS,SR1  0
SCRSMK   EQU      %
         LW,R1    SR3
         STW,D1   SCNAME,R1
         LI,SR2   4                 YES: SET NON-CONTROL
         STS,SR2  SCSYMX,R1         BIT IN SYMX
         B        SCREA04-T,R4      AND READ NEXT RECORD
SCREA00A EQU      %
         LW,SR1   D4
         LW,SR2   D4WD2
         MBS,SR1  0                 1ST 4 CHARS INTO D4
         CI,D2    'X'               TERMINATE FILE
         BNE      SCREA00-SYMCR,R4  NO,CONTINUE
         BAL,D3   SIMFIN-T,4        CLEAR SSIG; PUT FIN IN BUFFER
SCREA00  EQU      %
         LW,R2    SCSYMX,R1
         CI,R2    4                 IF NCTL SKIP ! TEST.
         BANZ     TYC-T,4           YES -> SKIP.
         LH,D3    D4
         SLS,D3   -4
         CI,D3    X'482'           BANG IN BIN
         BNE      TYC-T,4
         LB,R2    SNDDX,R3          FORCE BCD
         CLM,R2   RBLIMS
         BCR,9    TYC-T,4
         DISABLE                     ::::::::INHIBIT:::::::::::
         LB,R0    DCT5,R2
         CI,R0    1
         BAZ      TYC-T,4
         AND,R0   XFE
         STB,R0   DCT5,R2           BCD MODE
         ENABLE                     :::::::::UNINHIBIT:::::::::::
*        ALL OF THAT DCT5 NONSENSE BECAUSE THAT NASTY GUY
*        WON'T TERMINATE HIS BINARY DECKS WITH '!BCD' OR
*        '!EOD',   A !JOB OR !FIN MAY BE LOST FOREVER STILL.
         LCI      3
         PSM,R1   TSTACK
         PSW,11   TSTACK
         LW,7     R2                7  = DCT INDEX
         LI,R1    MSGOP             FWA OF MESSAGE
         BAL,11   OCQUEUE           GO WRITE ERROR MESSAGE
         PLW,11   TSTACK
         LCI      3
         PLM,R1   TSTACK
         MTW,-1   SCRCO,R1
         BAL,9    SCREA00D          GO SUSPEND SYMBOINT
         PLW,11   TSTACK            RESTORE REG 11 FROM STACK
         BAL,9    REG               RESTORE VOLITILE REGISTERS
         LI,9     1                 RESET REG 9
         STB,9    SSTAT,3
         B        SCREA04
TYC      RES      0
         ENABLE                     :::::::::UNINHIBIT:::::::::::
*        CONSTRUCT DATA CONTROL WORD
*        FORMAT = ACTUAL RECORD BC(16),RCC(8),SKIP(8)
*
         LB,D2    D1                SAVE TYC CODES
         AND,D1   M16
         LI,R2    SCRSIZE
         SW,R2    D1                ACTUAL RECORD BYTE COUNT
         CI,R2    4
         BGE      %+2               NEED 4 BYTES FOR CC'S
         LI,D4    0
         SLS,R2   16                POSITION FOR BUFFER
         AI,R2    1                 INSERT SKIP BYTE OF X'01'
         CW,R6    Y02               CHECK FOR BIN
         BAZ      TYC1-T,4          NO
         AI,R2    X'200'
*
TYC1     CW,D4    XEOD              HANDLER DOESN'T
         BE       EODTC-T,4
         CI,D2    1                 NORMAL TYC(=0 OR 1)
         BLE      NORMTC-T,4        YES
         CI,D2    6                 EOD
         BE       EODTC-T,4         YES
         CI,D2    2                 LOST DATA (OR RBT HANGUP)
         BE       SETFIN-T,4
         CI,D2    7                 END OF FILE
         BNE      ERRTC-T,4         NO - ERROR
SETFIN   BAL,D3   SIMFIN-T,4        SIMULATE FIN
         B        SETDCW-T,4
ERRTC    LW,R2    READERR-T,4
         B        SETDCW-T,4
EODTC    AI,R2    X'100'
         REF      NB31TO0           *BASE OF NOT BIT MASK TABLE
         AND,R2   NB31TO0+10        * = NOT X'200' CLEAR ERR BIT
NORMTC   RES      0
SETDCW   RES      0
         AND,R6   M24
         LI,SR1   R2*4              SOURCE
         LW,SR2   R6                DEST=BUFFER
         AI,SR2   -4                MINUS 4 BYTES
         OR,SR2   Y04
         MBS,SR1  0                 SET RECORD CONTROL INFO
*                                   RCC  00=BCD
*                                        01= EOD
*                                        02= BIN
*                                        03= ERR
         PAGE
*                                   R6=BA(BUFFER)
*                                   D4=1ST 4 CHARS
*                                   R1=CONTEXT
*                                   R4=BASE
*                                   R3=SYM INDEX
*        EXAMINE RECORD FOR CONTROL COMMANDS WHICH
*        INFLUENCE TERMINATION OF THIS STREAM AND
*        INITIATION OF A NEW ONE.
         LW,R2    SCSYMX,R1         NON-CONTROL INPUT
         CI,R2    4                 STREAM
         BANZ     TSTNC-T,4         YES-LOOK FOR FIN CC ONLY
         CW,D4    TJOB              IS 'JOB'
         BE       JFCC-SYMCR,R4     YES:  OK
*                                   NO: MAY BE 'RB ' OR 'FIN '
         LB,D1    SNDDX,R3           USER IS REMOTE
         CLM,D1   RBLIMS                   BY VIRTUE OF HIS IOP S.C.
         BCS,9    CKFCC-SYMCR,R4    NO: MAY BE 'FIN'
*                                   YES:
         LW,D3    D4
         SLS,D3   -8                DISCARD VARIABLE CHAR
         CW,D3    TBRB               AND IS IT 'RB'
         BNE      CKFCC-SYMCR,R4    NO: MAY BE 'FIN '
*                                   YES: AND ARE WE PROCESSING
         LI,D4    1                   * A BLOCK OF RB CCS
         XW,D4    SCMODE,R1           *    (MODE ALREADY 1)
         BEZ      JFCC1-SYMCR,R4    NO: ADD OLD FILE IF ANY
         B        NORMAL-SYMCR,R4   YES: THEN PACK LIKE ANY CARD
TBRB     DATA     '!RB'             BANG-R-B
*MESSAGE PRINTED WHEN A !EOD OR !BCD IS OMITTED
MSGOP    TEXTC    ' MISSING !BCD
'
*
*        HERE IT MAY HAVE BEEN A RB CC THROUGH A LOCAL
*        DEVICE, OR A FIN OR ANY OLD DATA. (NOTE RBCCS
*        THROUGH LOCAL DEVICES ARE JUST PLAIN DATA)
CKFCC    EQU      %
*
         LI,D3    0                 * RESET THE BLOCKING
         STW,D3   SCMODE,R1         * SPECIAL CC'S FLAG.
*
         CW,D4    FIN                    '!FIN'
         BNE      NORMTEST-SYMCR,R4 NO: JUST NORMAL DATA
*                                   YES:
CKFCC1   EQU      %
         LW,D1    SCJCO,R1               THERE IS PREVIOUS JOB
         BEZ      TERMIT-SYMCR,R4   NO:   LONE FIN CARD READ
*                                   YES:  ADD IT
         LW,D4    Y8                * SET FIN FOUND FLAG
         STW,D4   SCFINFLG,R1       * FOR GHOST CALL
         B        JFCC1
*
*        THIS IS A NON-CONTROL STREAM...TREAT ALL CARDS
*        LIKE PLAIN DATA EXCEPT 'FIN'.
*
TSTNC    EQU      %
         LB,R2    SNDDX,R3          CHECK FOR BINARY.
         LB,R0    DCT5,R2           FETCH DCTX.
         CI,R0    1                 BINARY ?
         BAZ      TSTNC1
         CW,D4    BINFIN            BINARY '!FIN' ?
         BNE      TSTNC2
         LI,SR2   D4**2
         LW,SR1   R6
         OR,SR2   Y04               MOVE FOUR BYTES.
         MBS,SR1  4                 INTO D4.
         CW,D4    BINFIN+1          ACTUALLY CHECK FOR '!FIN  '
         BNE      TSTNC2
         DISABLE                    *****
         LB,R0    DCT5,R2           RESET BINARY MODE.
         AND,R0   XFE
         STB,R0   DCT5,R2
         ENABLE                     *****
         B        CKFCC1            END OF STREAM.
BINFIN   EQU      %
         DATA     X'48280880',X'14100000'    BINARY '!FIN  '
TSTNC1   EQU      %
         CW,D4    FIN
         BE       CKFCC1            END OF STREAM.
TSTNC2   EQU      %
         LW,D1    SCJCO,R1
         BEZ      1STJOB-T,4        BEGINNING OF STREAM
         B        NORMAL            SOMEWHERE IN THE MIDDLE
*
*        WE MOST ASSUREDLY HAVE A JOB CC
JFCC     EQU      %                 SET MODE TO NOT BLODKING
         LI,D4    0                 RB CCS ANY MORE AND BY THE
         XW,D4    SCMODE,R1         WAY WE SHOULD ADD
         BNEZ     NORMAL-SYMCR,R4   NO: NO PREV JOB
*                                   YES:
JFCC1    EQU      %
         LW,D1    SCJCO,R1          WAS THERE AN UNADDED ONE
         BEZ      1STJOB-SYMCR,R4   NO:   1ST CARDS
         BGZ      %+2-SYMCR,R4      YES: INITIAL NON-JOB FOUND
         MTW,2    SCJCO,R1          NO: SET JOB TO FOUND AND
         MTW,1    SCAIF,R1          YES:  ADD HEEM AFTER
*
         SPACE    5
*                                   BUFFER  FULL
BUFULL   RES      0
*                 (R6) = BA(BUFFER)
SCREA01B STW,R6   SCDINFO+1,R1      SAVE BUFFER ADDR
         AI,R6    -2
         LB,D2    0,R6              FETCH RCC
         STW,D2   SCDINFO,R1        AND SAVE
         LI,R0    X'40'
         STB,R0   0,R6              SET END OF INFORMATION CODE
         PUSH     SR4               SAVE SYMBIONT EXIT                  934
*
*SYMBIONT BUFFER END                                                    934
*AT THIS POINT DATA BUFFER IS FULL AND READY TO BE WRITTEN TO DISC
*OR JOB/FIN CARD HAS BEEN FOUND
*(R3)=SYMTAB INDEX
         B        SCRWR00-T,R4
         PAGE
*-----THIS FUNCTION NOW IN SYMB GHOST-----(RBBAT)----
*IF JOB FILE INFO NOT AVAILABLE,TYPEOUT
*(CR)!!MISSING JOB COMMAND-JOB IGNORED(CR)
*GET PERIPHERAL CODE,NDD,VIA SYMBIONT TABLE INDEX (R3)
*
SCR12    RES      0
*
         SPACE    3
*        (A I F)          ADD INPUT FILE.
*
         SPACE    3
         AI,R4    %-SYMCR           *  ADJUST BASE FOR ACT
         LW,D3    SCSYMX,R1         * USE NC BIT IN SYMX
         CI,D3    4
         BANZ     SCRANC-SCR12,R4
         MTW,-1   BL:IFS
         BGEZ     SCRADD-SCR12,R4
         MTW,1    BL:IFS
         B        QFP11NCB
SCRANC   EQU      %
         LI,D1    SNDDXSIZ
         REF      SNDDXSIZ          * SIZE OF SYMBIONT TABLES IS NUMBER OF SYMBI
*,*                                 * USED TO CHECK BL:OFS FOR NCTL
         REF      BL:OFS            * BATCH LIMIT OUTPUT FILE SLOTS. NCTL FILES
*,*                                 * ARE REALLY FILED AS OUTPUT FILES.
         DISABLE
         CW,D1    BL:OFS
         BLE      SCRANC1-SCR12,R4
         ENABLE
         B        QFP11NCB
SCRANC1  EQU      %
         MTW,-1   BL:OFS
         ENABLE
*
SCRADD   EQU      %
         LW,R4    0,R1              RESTORE SYMB BASE ADDR
         LB,D1    SNDDX,R3          * DCTX
         SLS,D1   8                 **
         STH,R3   D1                * D1 =0,SYMTABX,DCTX,0 8,8,8,8
         AI,D1    AIF
         CI,D3    4
         BAZ      %+2
         AI,D1    AIFNC-AIF
*                                   * D1 = 0,SYMTABX,DCTX,GFC
         LW,D2    SCFINFLG,R1       * FIN/JOB END FLAG
         OR,D2    SCBESTDA,R1       * FILE STARTING DA
         LW,D3    SCNAME,R1
         LW,R2    SCGCNT,R1
         BAL,R4   SGCQ                 : Q VIA GHOST CALLER
         BDR,R4   QFPD4CB
*                 FILE QUEUED FOR GHOST ADD
         LW,R1    SR3               RESTORE CONTEXT BLOCK ADDR
         LI,R4    0
         STW,R4   SCGCNT,R1
         LW,R4    0,R1               AND SYMB BASE ADDR
         AI,D2    0                 FIN FLAG WAS SET
         BLZ      STERM-SYMCR,R4    YES: TERM
         LB,D1    SSIG,R3           SIGNAL CHARACTER
         CI,D1    'L'               LOCK SYMBIONT
         BNE      SCR14-SYMCR,R4    NO,CONTINUE
STERM    RES      0
         LW,D3    SCFBUF,R1         DATA BUFFER ADDR
         SLS,D3   -2
         BAL,11   SRELBUF
         B        TERM              TERMINATE SYM
TERMIT   RES      0                 *
         PUSH     11                * SWITCH FROM END ACTION TO
         B        STERM-SYMCR,R4    * SACT CALL FOR TERM COMPAT.
         PAGE
SCR14    EQU      %
         LW,R6    SCFBUF,R1
         LW,SR2   R6
         LW,SR1   SCDINFO+1,R1      BA OF RECORD TO MOVE
         AI,SR1   -RCCS             * POINT AT CONTROL STRING
         AI,SR2   1STDBI            * DEST= 1ST RCCS POSITION
         OR,SR2   MAXBC-T,4         COUNT
         MBS,SR1  0                 :::::::SLIDE RECORD UP:::::::
         AI,R6    6
         LW,SR1   SCDINFO,R1        RETRIEVE RCC
         STB,SR1  0,R6
         AI,R6    2                 BA(RECORD)
1STENT   RES    0
         MTW,1    SCJCO,R1          COUNT NO JOBS ENTERED
         BAL,SR2  REQDC
         MTW,1    SCGCNT,R1
         STW,SR1  SCBESTDA,R1       STARTING DISC ADDR FOR NEXT INPUT FILE
         STW,SR1  SCCDA,R1          CURRENT DISC ADDR
         BAL,SR2  SCR10B-T,R4
         PAGE
*CARD READ END ACTION
*(CONTINUED)
*        (R6) = BA(RECORD BUFFER)
*
NORMAL   RES      0
         AI,R6    -3                GET ARS
         LB,R2    0,R6
         AW,R2    SCDBI,R1          * INCLUDE CURR POSITION
         STW,R2   SCDBI,R1          * SAVE FOR LATER...
         AI,R2    RCCS+RCCS+SCRSIZE+4+4 * IS THERE ROOM FOR A START AND
         CW,R2    SCBSIZ,R1         *END RCCS,RECORD,BLINK,HASH IN BLOCK
         REF      SCBSIZ            * CNTXT DISP TO BLOCK SIZE
         BLE      SCREA04-1-SYMCR,R4
         LW,R6    SCFBUF,R1
         AW,R6    SCDBI,R1          * INCLUDE CURRENT OFFSET
         AI,R6    RCCS              * PLUS A CONTROL STRING.
         B        BUFULL-SYMCR,R4
         MTW,+RCCS  SCDBI,R1        * INCLUDE THE RCCS
SCREA04  LCI      5                 LOAD
         LM,12    SCDQARGS,R1       ARGS FOR DEVICE I/O
         AW,13    SCFBUF,R1
*                                   * R1 = EAI (CONTEXT BLOCK ADDR)
*                                   * R12= FCN,PRI,NRT,DCTX(2,FF,4,SNDDX)
*                                   * R13= BUFFER ADDRESS
*                                   * R14= BYTE COUNT (SCRSIZE)
*                                   * R15= SEEK (SYMTABX FOR IRBT HNDLR)
SCREA04A EQU      %
         AI,SR4   -1                ADJUST EXIT FOR NEWQ'S RETURN+1
         B        NEWQ              QUEUE REQUEST AND EXIT SYMBIONT
*                                   * R0 = EA (SCREND)
SCREAEA  B        SCREND-T,R4       READ EA  ADDR.
SCREAEA1 B        SCRWREA-T,R4      DISC WRITE EA ADDR
         PAGE
*                 FIRST JOB CC FOUND (OR NOT AS THE CASE MAY BE)
*
*
NORMTEST EQU      %                 *
*                                   * ITS ANOTHER DATA CARD
*                                   *TO BE BLOCKED
         MTW,0    SCJCO,R1          * DO WE HAVE A JOB CARD
*                                   *BEHIND WHICH TO BLOCK
         BGZ      NORMAL-SYMCR,R4   * YES,(NORMALLY) PASS IT ON
         BLZ      SCREA04-SYMCR,R4  * NO,GOBBLE CARDS TILL WE DO
         MTW,-2   SCJCO,R1          *  (SET JOB FOUND FLAG TO
*                                   *      REMAIN NEGATIVE)
*        PUSH     SR4               *  (FAKE OUT THE FUTURE PULL
*                                   *    IN SCR10B SUBR)
*        B        1STENT-SYMCR,R4   *  AND PRETEND THAT WE
*                                   *  FOUND THE 1ST JOB CC.
*   ( BY FALLING THROUGH)
*
*                 R6=BUF
*                 R2=ARS
1STJOB   RES      0                 SAVE  SYMBIONT EXIT
         PUSH     SR4
         B        1STENT-T,R4
         SPACE    5
*
*        VARIOUS CONSTANTS OF VALUE TO SYMBIONT
*
MAXBC    GEN,8,24 SCRSIZE+4,0
D4WD2    GEN,8,24  4,15*4
         PAGE
READERR  GEN,16,8,8  80,3,1
FQARG1   GEN,8,8,8,8  1,X'FF',3,0
DQARG1   GEN,8,8,8,8  2,X'FF',3,0
NCTL     TEXT     '!!NCTL '
YD69     GEN,8,24 69,0
NTO12    GEN,8,24 4,D1**2
*
*
*
         DEF      SCRSIZE           * SO DSCIO CAN HELP IOQ COMPUTE THE
*,*                                 ARS OF THOSE FUNNY RBT RECORDS
SCRSIZE  EQU      140               MAX RECORD SIZE
RCCS     EQU      4                 * RECORD CONTROL STRING IS
*                                   *  BC  BC  RCC  SKIP   -BYTES
         REF      1STDBI            * 1ST DATA BYTE INDEX
         REF      SYSACCT           * =C':SYS    '
BASYSACCT EQU   SYSACCT+SYSACCT+SYSACCT+SYSACCT
         REF      HASHPRIM          * =16777213
         PAGE
*
*SET UP TO WRITE DISC FILE BLOCK
*ASSUME BUFFER SIZE NEVER EXCEEDS GRANULE SIZE
SCRWR00  EQU      %
         MTW,1    C:CSC
         LI,SR1   0
         LW,D2    SCAIF,R1          DISC WRITE FOLLOWON FLAG
         BNEZ     SCRWR01-T,4
         LW,SR1   SCCDA,R1          CUR DISC ADDR
         AI,SR1   1                 *GET SECOND HALF
         CI,SR1   1                 * ALREADY GOT
         BANZ     SCRWR01-SYMCR,R4  * NUP,USE ODD ADDR
*                                   * YUP,GET ANOTHER
TRYGRA   RES      0                 ARE WE LOW ON SPACE
         LW,11    RQLDGA
         CI,11    40
         DO       SYM%G%LOK%FIXED
         BG       GRA-SYMCR,4       OK TO GO
         ELSE
         B        GRA-SYMCR,4       * TEMP UNTIL LOCKUP FIXED
         FIN      SYM%G%LOK%FIXED
         BAL,SR2  QFACTP11
         BAL,9    REG
         B        TRYGRA-SYMCR,R4
GRA      RES      0
         BAL,SR2  REQDC
         MTW,1    SCGCNT,R1
SCRWR01  EQU      %
         LI,R2    BASYSACCT         *  BA(=C':SYS    ')
         LI,R13   0                 * ZAP HASH ACCUMULATER
         LI,R12   8                 * 8 BYTES IN ACCOUNT
         LB,R14   0,R2              * FETCH A BYTE TO HASH
         AW,R13   R14               * INCLUDE IT
         SCS,R13  +6                * SPIN THE HASH
         AI,R2    1                 * NEXT BYTE
         BDR,R12  %-4               *...
         AI,R13   1                 * C1 STREAM IS INDEX 1
         SCS,R13  +6                * SPIN IT
         LI,R12   4                 * AND SOME NAME BYTES
         LI,R2    R15*4             *
         LW,R15   SCNAME,R1         *
         LB,R14   R15,R2            * NEXT BYTE TO
         AW,R13   R14               *              HASH
         SCS,R13  +6                * SPIN THE HASH
         AI,R2    1                 * NEXT
         BDR,R12  %-4               *      ...
         DW,R12   HASHPRIM          * A REDUCING FACTOR
*                                    HOW ABOUT 16777213
         LW,R14   SCGCNT,R1         * POSITION OF BLOCK IN FILE
         STB,R14  R12               * POS,HASH  8,24
         LW,R2    SCFBUF,R1         * BA OF BLOCK IN MEM
         SLS,R2   -2                *   (TO A WA)
         STW,R14  SBSIZE-2,R2       * TO WORD 254
         STW,SR1  0,R2              * FLINK THE BLOCK
         LCI      5
         LM,12    SCFQARGS,R1       FETCH NEWQ ARGS
         INT,SR1  SCCDA,R1
         AND,SR1  M6                ISOLATE DCTX FROM SEEK ADDR
         OR,12    SR1               AND DROP INTO R12  FOR NEWQ
*                                   * R0 = EA (SCRWREA)
*                                   * R1 = EAI (CNTXT BLK ADDR)
*                                   * R12=FCN,PRI,NRT,DCTX
*                                   * R13= BUFFER ADDR
*                                   * R14= BYTE COUNT(SBSIZE)
*                                   * R15= SEEK ADDR
         PULL     SR4               RESTORE SYMBIONT EXIT
         B        SCREA04A          QUEUE DISC WRITE AND EXIT
         PAGE
*
*DISC WRITE END ACTION
*WRITE DIRECT WITH NO CHECK READ
*CO-OP WILL CATCH BAD DISC BLOCK
*
*                 (R12) = TYC,-,ARS
*                 (R14) = CONTEXT BLOCK ADDR
*                 (R15) = BUFFER ADDRESS(BA)
*                 (SR4) -- HAS EXIT AS PER E.A.
*                   MUST BE PUT IN STACK AS PER SACT CALL
*
*                 THEN MUST ADD JOB NOW IF ANY (FLAG=0)
*
SCRWREA  RES      0
         LW,10    14
         BAL,9     REG
*        R4=BASE;R3=SYMTABX;D2=SSIG,R3;R1=CNTXT ADDR (ALL FROM SR3)
         AND,15   M24               ISOLATE BUFFER ADDR
         LW,R6    15
         SLS,R6   -2                MAKE WORD ADDR
         LW,0     0,6               FORWARD LINK
         BEZ      %+2-SYMCR,R4
         XW,R0    SCCDA,R1          NOW CURRENT DISC ADDR
         STW,R0   SCBLDA,R1         SAVE OLD CDA FOR BLINK
         STW,R0   SBSIZE-1,R6
         PSW,11   TSTACK
         LI,R0    0
         XW,R0    SCAIF,R1          RESET DISC WRT FOLLOWON TO RD CRDS
         BEZ      LOOP-T,4
*
         B        SCR12             CONTINUE OR QUIT
         PAGE
*
*        MISCELLANEOUS SUBROUTINES
*
*        REG ROUTINE - PUTS NEEDED VALUES IN REGISTERS
*                 ENTRY:  BAL,9  WITH CNTXT BLK ADDR IN R1O
*
         DEF      REG               * REGISTER RESTORE SUBROUTINE.
REG      LW,4     *10
         LB,3     4
         LB,13    SSIG,3
         LW,1     10
         B        *9
*
*
*        SIMFIN - CALLED BY SCREA WHEN STREAM IS TO BE X'ED
*                 BY CHOICE OR BY FORCE. RETURN IN SR2.
*
SIMFIN   LW,D4    FIN
         STB,D4   SSIG,R3           CLEAR SSIG
         LI,SR1   D4*4              SOURCE BYTE ADDR
         LW,SR2   R6                BA(BUFFER)
         AND,SR2  M24
         OR,SR2   Y04               COUNT
         MBS,SR1  0                 MOVE FIN IMAGE TO BUFFER
         B        *D3
         END
