         DEF      INSYM
INSYM    EQU      %
*
*
*                 CATALOG NO. 704934 - SIGMA 5/7 BPM M:SYMCR
         SYSTEM   UTS
         DEF      SYMCR
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      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       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
         REF      REQCB,SBSIZE,SNDDX,SSTAT
         REF      SCBESTDA
         REF      SCFBUF,SCCDA,SCBLDA
         REF      SCFQARGS
         REF      SCDQARGS
         REF      SCDBI
         REF      SCDINFO
         REF      SCFINFLG
         REF      SCMODE
         REF      SCRCO
         REF      SCNAME
         REF      SCGCNT
         REF      QFPD4CB
         REF      SCJCO
         REF      SCAIF
         REF      SCSYMX
         REF      NEWQ
         REF      DCT5,XFE
         REF      TJOB
*
*
         REF      RBLIMS            REM BAT TERM DCTX LIMITS
         REF      AIF               * ADD INPUT FILE
         REF      AIFNC             * ADD NON-CONTROL INPUT FILE
         REF      SGCQ              * SYM GHO CALL Q
         REF      Y8                * =X'80000000'
         REF      QFACTP11          * Q FOR ACTIVATION PULL 11
         REF      QFP11NCB          QFACT,PULL 11,NO COMM BUF
         REF      BL:IFS            * BAT LIM: INPUT FIL SLOTS
         REF      RQLDGA
         REF      SSIG              * SYMB SIGNAL CHAR
         REF      Y40               * =X'40000000'
         REF      Y04
         REF      Y07
         REF      M3
         REF      M24
         REF      SUSP              * SUSPEND SYMBIONT
*
          REF      REQDC,SRELBUF
         REF      Y02
         REF      FIN
         REF      TERM
         REF      SYMX,XEOD,M16,M6
         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    8                 INTIALIZE
         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      %
         LH,D3    D4
         SLS,D3   -4
         CI,D3    X'482'           BANG IN BIN
         BNE      TYC-T,4
         LB,R2    SNDDX,R3          FORCE BCD
         LB,R0    DCT5,R2
         AND,R0   XFE
         STB,R0   DCT5,R2           BCD MODE
*        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.
TYC      RES      0
*        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
         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'
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
*
*        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      %
         CW,D4    FIN
         BE       CKFCC1            END OF STREAM
         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,BL:OFS
         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   -4                POINT TO CONTROL INFO
         AI,SR2   4                 DEST=WORD 1 OF SYMB BUF
         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
         AI,R2    4                 ADD 4 BYTES FOR NXT REC CONTROL
         AW,R2    SCDBI,R1
         CI,R2    SBBSIZ-4-140-3    ROOM FOR BLINK,REC,CNTRL BYTES
         BLE      SCREA04-1-SYMCR,R4
         LW,R6    SCFBUF,R1
         AW,R6    R2                POINT TO END OF CUR BUFFER
         B        BUFULL-SYMCR,R4
         STW,R2   SCDBI,R1          UPDATE BUFFER INDEX
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
SCRSIZE  EQU      140               MAX RECORD SIZE
         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      %
         LCI      5
         LM,12    SCFQARGS,R1       FETCH NEWQ ARGS
         LW,SR4   D2
         SLS,SR4  -2
         STW,SR1  *SR4              FLINK TO DATA BUFFER
         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
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

