         DEF      OUTSYM:           FOR XDELTA SYMBOL
OUTSYM:  EQU      %
*
*
*M*      OUTSYM   SYMBIONT FILE TO DEVICE XFER ROUTINE
*
*
*P*      NAME:    OUTSYM
*P*
*P*      PURPOSE: TRANSFERS SYMBIONT OUTPUT RECORDS FROM
*P*               SYMBIONT OUTPUT FILES TO THEIR TARGET
*P*               DEVICE
*P*
*P*               RESPONDS TO SYMBIONT KEYINS OF THE FORM:
*P*               SYYNDD,% WHERE % IS ONE ALPHA CHARACTER
*P*               AS DESCRIBED BELOW
*P*
*P*      DESCRIPTION:
*P*               OUTSYM IS INITIATED EITHER BY RBBAT (DIRECTLY
*P*               OR VIA REMOTE PROCESSING) OR THE OPERATOR
*P*               USING THE SYYNDD,I KEYIN.  WHEN IT IS STARTED
*P*               IT REQUESTS AN OUTPUT FRROM RBBAT VIA THE
*P*               GOF RBBAT CALL.  RBBAT RETURNS THE STARRTING
*P*               DISC ADDRESS OF THE FILE WHICH OUTSYM READS
*P*               AND OUTPUTS THE FIRST RECORRD ON THE TARGET
*P*               DEVICE.  FROM THIS POINT ON IT IS ENTIRELY
*P*               I/O DRIVEN SINCE EACH I/O SPECIFIES OUTSYM
*P*               AS ITS END-ACTION.  DEVICE I/O CONTINUES UNTIL
*P*               THE DISC BLOCK IS EXHAUSTED AT WHICH TIME
*P*               OUTSYM USES THE CURRENT BLOCK'S FLINK TO FETCH
*P*               THE NEXT BLOCK.  THIS PROCESS CONTINUES UNTIL
*P*               A BLOCK WITH A ZERO FLINK IS REACHED WHERE-
*P*               UPON OUTSYM EITHER EXITS VIA TERM OR ASKS RBBAT
*P*               FOR ANOTHER FILE DEPENDING ON THE SETTING OF
*P*               A BIT IN IT'S SYMX TABLE.
*P*
*P*               OUTSYM PROCESSES THE FOLLOWING KEYINS - WHERE
*P*               THE BASIC FORMAT IS AS DESCRIBED ABOVE:
*P*
*P*      %        FUNCTION
*P*
*P*      I        INITIATE PROCESSING
*P*      S        SUSPEND PROCESSING
*P*      C        CONTINUE FROM SUSPEND
*P*      R        BACKUP 14 GRANULES AND RESTART
*P*      A        BACKUP TO LAST TOF PRINT ONE PAGE AND SUSPEND
*P*      Q        BACKUP AS FAR AS POSSIBLE AND RETURN THE IN
*P*               PROGRESS FILE TO RBBAT - THEN LOCK
*P*      L        LOCK (STOP PROCESSING AFTER CURRRENT FILE UNTIL
*P*               RE-INITIATED BY THE OPERATOR
*P*
*P*               OUTSYM CAN BE RUN IN ONE OF TWO MODES
*P*               DETERMINED BY OPERATOR KEYIN OR SYSGEN
*P*               THEY ARE:
*P*                          KEEP - WHERE THE WHOLE FILE IS KEPT
*P*                          INTACT UNTIL PRINTED THEN DELETED
*P*
*P*                          DELETE - WHERE GRANULES ARE DELETED
*P*                          AS THEIR RECORRDS ARE USED KEEPING
*P*                          A 14 GRANULE OVERLAP
*P*
*P*               THE ONLY FUNCTIONAL DIFFERENCE BETWEEN THE MODES
*P*               IS THAT IN KEEP MODE THE 'Q' KEYIN WILL RE-QUEUE
*P*               THE WHOLE FILE, WHILE IN DELETE MODE IT WILL BACK
*P*               UP 14 GRANULES AND RE-QUEUE THE FILE FROM THAT POINT
*P*
*P*      REFERENCE:
*P*               THE SYMBIONT TABLES, CRITICAL TO UNDERSTANDING
*P*               OUTSYM ARE DOCUMENTED IN THE DATA BASE TECH MANUAL
*
*
         PSR      0                 *DONT LIST SUPPRESSED CODE
         PCC      0                 *DONT LIST CONTROL INFO
*
         SYSTEM   UTS
*
*
*
         DEF      SYMPPRTY          START UP ENTRY POINT FROM SACT
         DEF      OSDEA             DEVICE END ACTION ADDRESS
         DEF      OSFEA             FILE END ACTION ADDRESS
         DEF      BADDA2            ENTRY POINT TO LOG DISC BLOCK BAD AND
*,*                                 TELL OPERATOR
         DEF      OS%EA             BACKWARD DISPLACEMENT AT WHICH TO
*,*                                 ENTER OS%REG AT END ACTION
         DEF      OSDEA0            ENTRY POINT TO CHECK SIGNAL CHARS
         DEF      OS%UDAP           DISC ADDRESS STACK UPDATER
         DEF      OSDEA00           ENTRY POINT TO PROCESS NEXT RECORD
         DEF      OSDEA0A           PROCESS Q SIGNAL ENTRY POINT
         DEF      OSDEA00A          ABORT IF NOT END OF BLOCK - OTHERWIS
*,*                                 CONTINUE TO NEXT BLOCK ENTRY
         DEF      OSDEA5            SET UP AND DO DEVICE IO
         DEF      OSDEA51           DO DEVICE I/O (REGISTERS ALREADY SET
*,*                                 UP)
         DEF      OSFEA4            DISC READ SUCCESSFUL - DISC POINTERS
*,*                                 UPDATED ENTRY POINT
         DEF      OS1D              SETUP AND DO FILE I/O
         DEF      OS09A             DECIDE TO CONTINUE OR TERM BASED ON
*,*                                 FIRST DA ENTRY POINT
         DEF      OS%REG            SET UP OUTSYM REGISTERS SUBROUTINE
*
*
         REF      YFF               MASK
         REF      Y008              FLAG BIT
         REF      Y01               FLAG BIT
         REF      Y02               FLAG BIT
         REF      Y2                FLAG BIT
         REF      M17               MASK
         REF      MASKS             MASKS
         REF      BT31TO0           TABLE BITS
         REF      NB31TO0           TABLE NBITS
         REF      M24               MASK
         REF      M3                MASK
         REF      OCDCT             * USED TO REPORT       30874-F00
         REF      DCT%MASK          MASKS DCTX OUT OF DISC ADDRESS
*
         REF      SCDEVTYP          OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 FLAGS, DEVICE TYPE 24,8
         REF      SCFLDA            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 FORWARD LINK DISC ADDRESS
         REF      SCBLDA            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 BACKWARD LINK DISC ADDRESS
         REF      SCBESTDA          OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 NUMBER OF COPIES, EARLIEST DISC
*,*                                 ADDRESS OF FILE NOT YET DELETED 8,24
         REF      SCFQARGS          OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 FIVE WORD AREA FROM WHICH NEWQ REGS
*,*                                 ARE LOADED - FC,PRIO,NRT,0 8,8,8,8
         REF      SCFBUF            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 BUFFER WORD ADDRESS
         REF      SCBSIZ            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 BYTE SIZE OF SPOOL
         REF      SCCDA             OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 CURRENT DISC ADDRESS
         REF      SCFEA             OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 FILE SIDE END ACTION ADDRESS
         REF      SCDQARGS          OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 FIVE WORD AREA FROM WHICH NEWQ REGS
*,*                                 ARE LOADED - 0,PRIO,NRT,DCT 8,8,8,8
         REF      SCDBI             OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 BYTE INDEX TO CURRENT RECORD IN BLOCK
         REF      SCDBC             OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 BYTE COUNT OF CURRENT RECORD
         REF      SCSVDGI           OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 RBSWITCHED,HASP,PARTIAL,PRIO,RBID,
*,*                                 SYSID - 1,1,1,5,8,16
         REF      SCTYC             OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 GENERAL TEMP USES
         REF      SCSWIT            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 RBSWITCH CODE, PLACE TO CALL TO DO
*,*                                 I/O - 8,24 - USUALLY ADDRESS OF NEWQ
         REF      SCTOFDA           OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 TWO WORDS - DISC ADDRESS AND BYTE
*,*                                 POINTER TO WHERE LAST TOP-OF-FORM IS
         REF      SCBUPPT           OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 TWO WORDS - DISC ADDRESS AND BYTE
*,*                                 POINTER TO PAGE ABORT BACKUP POINT
         REF      SCBUPPTS          OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 TWO WORDS - DISC ADDRESS AND BYTE
*,*                                 POINTER TO LAST RECORD USED TO SET
*,*                                 UP SCBUPPT
         REF      SCGCNT            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 NUMBER OF GRANULES REMAINING
         REF      SCRTRY            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 RETRY COUNTER FOR BLINK FAILUES
         REF      SCBUDA            OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 EARLIEST UNDELETED GRANULE FOR FILES
*,*                                 IN DELETE MODE
         REF      SCDALST           OUTSYM CONTEXT BLOCK DISPLACEMENT
*,*                                 START OF GRANULE LIST FOR R KEYIN
         REF      SCDALSZ           LENGTH OF SCDALST
*
         REF      SNDDX             INPUT: SYMBIONT TABLE - DCT INDEX
         REF      SSIG              I/O: SYMBIONT TABLE - SIGNAL CHARACTER
*,*                                 USED TO TRANSMIT KEYINS TO OUTSYM.
*,*                                 MODIFIED TO PREVENT RE-USE OF OLD
*,*                                 SIGNALS
         REF      SYMX              INPUT: SYMBIONT TABLE - FLAGS - BIT0=
*,*                                 TERMINATE ON EOF, BIT1=LISTING DEVICE
*,*                                 BIT2=XEROX 1200, BIT3=KEEP GRANULES
*,*                                 TILL DONE THEN ADD BACK TO RBBAT TO
*,*                                 DELETE, BIT5=WRITE 0 LENGTH MESSAGE
*,*                                 ON EOF
         REF      SSTAT             OUTPUT: SYMBIONT TABLE - STATUS - SET TO
*,*                                 ONE TO SHOW OUTSYM ACTIVE
         REF      SRET              I/O: SYMBIONT TABLE - RETURN POINT
*,*                                 COMBUF INDEX FOR GOF CALLS IS KEPT IN
*,*                                 BYTE 0
         SREF     MXSTRM            HIGHEST REMOTE PROCESSING SYMB INDEX
*
         REF      GOF               RBBAT GHOST FUNCTION CODE FOR GET
*,*                                 OUTPUT FILE
         REF      AOFP              RBBAT GHOST FUNCTION CODE FOR RETURN
*,*                                 PARTIAL OUTPUT FILE TO QUEUE
         REF      SGCBUF            BASE OF RBBAT COMBUFS
         REF      @SGCBUF           LB INSTRUCTION ANLZ'ED TO GET BA(COMBUF)
*
         SREF     SSSBIT            RB:FLAG SUSPEND BIT SET WHEN REMOTE
*,*                                 PROCESSING SYMBIONTS SUSPEND
         SREF     RB:FLAG           OUTPUT: REMOTE PROCESSING FLAGS - SSSBIT
*,*                                 SET WHEN OUTSYM SUSPENDS FOR RB DEV
*
         REF      BL:OFS            INPUT: REMAINING OUTPUT FILE SLOTS IN RBBAT
*,*                                 USED TO DETERMINE WHETHER AOFP CAN BE
*,*                                 DONE AT A GIVEN TIME
         REF      TSTACK            TO PUSH AND PULL
         REF      C:CSC             OUTPUT: COUNT OF SYMBIONT - COOP DISC I/O'S
         REF      TIME              INPUT: TIME USED TO ERRLOG DISC BLOCK BADS
*
         REF      REQCB             CALLED: TO GET A SYMBIONT BUFFER
         REF      RELCB             CALLED: TO RELEASE A SYMBIONT BUFFER
         REF      RSG               CALLED: TO RELEASE A SYMBIONT GRANULE
         REF      NEWQ              CALLED: TO DO DISC I/O (AND USUALLY,
*,*                                 VIA SCSWIT, DEVICE I/O)
         REF      CHKDA             CALLED: TO CHECK DISC ADDRESSES BEFORE
*,*                                 READING DISC
         REF      PULLEXIT          CALLED: TO PULL A REGISTER AND BRANCH
*,*                                 INDIRECT IT
         REF      SGCQ              CALLED: TO CALL RBBAT FOR GOF AND AOFP
         REF      SGCRA             CALLED: TO RELEASE RBBAT COMBUFS ON
*,*                                 COMPLETION OF GOF CALLS
         REF      TERM              CALLED: TO TERMINATE OPERATION
         REF      SUSP              CALLED: TO SUSPEND OPERATION
         REF      ERRLOG            CALLED: TO LOG DISC BLOCK BADS IN
*                 NOT USING OCQUEUE ANY MORE
*,*                                 MESSAGE ON THE OC
         REF      SWTINIT           ADDRESS OF RBSWITCH INITIALIZER
*,*                                 CALLED WHEN RBSWITCH BIT (BIT0 OF
*,*                                 SCSVDGI) IS SET
         REF      SWTEND            ADDRESS OF RBSWITCH TERMINATOR
*,*                                 CALLED AT END-OF-FILE WHEN RBSWITCH
*,*                                 BIT (BIT0 OF SCSVDGI) IS SET
         REF      QFACTP11          CALLED: TO QUEUE THE SYMBIONT FOR ACTIVATION
*,*                                 PULL R11, AND EXIT
         REF      QFP11NCB          CALLED: TO QUEUE THE SYMBIONT FOR ACTIVATION
*,*                                 SAVE SGCQ INFO, PULL R11 AND EXIT
*,*                                 WHEN A RBBAT COMBUF IS NOT AVAILABLE
         REF      QFPD4CB           CALLED: TO QUEUE THE SYMBIONT FOR ACTIVATION
*,*                                 SAVE SGCQ INFO, DECREMENT R4, PULL R11
*,*                                 AND EXIT WHEN A RBBAT COMBUF IS NOT
*,*                                 AVAILABLE
         SREF     OCPSEND           CALLED: TO SEND ONE DATA BLOCK TO A XEROX
*,*                                 1200 OCP
         SREF     OCPFEA            TESTED AGAINST SCDEA TO TELL WHETHER
*,*                                 OCPIO IS IN CONTROL
         SREF     OS%MLBFI          CALLED: (SOMEDAY) TO MULTI-BUFFER
*,*                                 DISC I/O
*
*
SYMPPRTY EQU      %
         PAGE
RELOC    SET      0                 SET TO ONE FOR RELOCATABLE OUTSYM
*
*
*C*
*C*      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*C*
*C*      NOTE, CHANGES FOR E01 AND F00 PROHIBIT SETTING
*C*        RELOC TO 1.
*C*
         DO       RELOC
R4       FNAME
         PROC
         DO1      1-SCOR(CF(2),R4)
*        ERROR,1  'ILLEGAL USE OF BASE REGISTER'
         PEND     4
         PCC      0
         FIN
         OPEN     BASE
         OPEN     B,BNEZ,BE,BNE,BEZ,BG,BCR
         OPEN     BLEZ,BLE,BAL
         OPEN     BCS,BSNE,BGE,BGEZ
         OPEN     BSE,BL,BLZ,LW,LM,OR,ANLZ
         OPEN     BIR,BDR,BANZ,BAZ,BGZ
BASE     SET      SYMPPRTY
BNEZ     CNAME    X'693'
BNE      CNAME    X'693'
B        CNAME    X'680'
BEZ      CNAME    X'683'
BE       CNAME    X'683'
BCR      CNAME    X'68',1
BLEZ     CNAME    X'682'
BLE      CNAME    X'682'
BAL      CNAME    X'6A',1
ANLZ     CNAME    X'44',1
BCS      CNAME    X'69',1
BSNE     CNAME    X'681'
BGE      CNAME    X'681'
BGEZ     CNAME    X'681'
BSE      CNAME    X'691'
BL       CNAME    X'691'
BLZ      CNAME    X'691'
LW       CNAME    X'32',1
OR       CNAME    X'49',1
LM       CNAME    X'2A',1
BIR      CNAME    X'65',1
BDR      CNAME    X'64',1
BANZ     CNAME    X'694'
BAZ      CNAME    X'684'
BGZ      CNAME    X'692'
BG       CNAME    X'692'
         PROC
         LOCAL    IFE,A
IFE      SET      'INSTRUCTION FORMAT ERROR'
 DO RELOC*((TCOR(S:IFR(AF(1)),BASE))=0=0)&(CS(BASE)=CS(S:IFR(AF(1))))
A        SET      AF(1)-BASE
   ERROR,,(AFA(1)=0=0)|(AF(2)=0=0)|((NAME(2)=0)&(CF(2)=0=0)) IFE
         ERROR,,(AFA(1)=0=0) 'NO AFA ALLOWED'
         ERROR,,(AF(2)=0=0) 'NO INDEX ALLOWED'
         ERROR,,((NAME(2)=0)&(CF(2)=0=0)) 'ILLEGAL CF'
LF       GEN,1,7+4*(1-NAME(2)),4*NAME(2),3,3,14 0,NAME(1),CF(2);
         ,4,0,A
         ELSE
LF       GEN,1,7+4*(1-NAME(2)),4*NAME(2),3,3+14 AFA(1);
         ,NAME(1),CF(2),AF(2),AF(1)
         FIN
         PEND
         CLOSE    BASE
*
*
LSBR     CNAME                      LOAD SYMBIONT BASE REGISTER
         PROC
         DO       RELOC=0
LF       EQU      %
         ELSE
         DO       SCOR(AF(1),EA)
LF       LW,4     *R14
         ELSE
LF       LW,4     *SR3
         FIN
         FIN
         PEND
*
LSCP     CNAME                      LOAD SYMBIONT CONTEXT POINTER
         PROC
LF       LW,1     SR3
         PEND
*
*
         DO       RELOC
LIEA     CNAME                      LOAD IMMEDIATE INTERNAL
         PROC                       END ACTION ADDRESS
LF       LI,CF(2) AF-SYMPPRTY       GET ABSOLUTE ADDRESS
         AW,CF(2) R4                AND BASE
         AND,CF(2) M17              DELETE SYMX
         PEND
         FIN
*
         PAGE
*
*        MODULE: OUTSYM                          CP-V A00 RON RILEY
*
*        GENERAL NAMEING CONVENTION
*                 OS PREFIX FOR SYMBIONT LABELS.
*                 OSF - FOR FILE SIDE PROCEDURE.
*                 OSD - FOR DEVICE SIDE PROCEDURE.
*                  ENDING IN A DIGIT- MODULE GLOBALS.
*                  ENDING IN A LETTER- LOCALS.
*                 ...EA... - IMPLIES END ACTION.
*                 ...DA    - IMPLIES DISC ADDRESS.
*                 SC PREFIX FOR SYMBIONT CONTEXT BLOCK.
*                   F AND D MEANING AS ABOVE.
*
*                 OTHER LETTERS SHOULD BE OBVIOUS.
*
*        REGISTER CONVENTION
*                 REGISTERS DEFINED ARE USED AND ARE VOLATILE.
*                 SR3(R10) CONTAINS PROCESS FUNCTIONS CONTEXT POINTER
*                          (SC...).
*                 R1 USUALLY CONTAINS SC FOR INDEXING EASE.
*                 R4  CONTAINS SYMBIONT BASE ADDRESS FOR RUN-TIME
*                          RELOCATION.
*                 R0 USUALLY CONTAINS SC FLAGS FROM SCDEVTYP.
*                 D2(R13) USUALLY CONTAINS CURRENT SIGNAL CHARACTER.
*                    A,B,C,I,L,P,Q,R,S,X
*                 R3 CONTAINS SYMB TABLE INDEX FOR PROCESS FUNCTION.
*                 SR1(R8) TYPICALLY CONTAINS SOME DISC ADDRESS(DA)
*                 SR2(R9) IS USED AS THE SUBGLOBAL LINK REG.
*                 SR4(R11) CONTAINS THE SYMB EXIT UNLESS THIS IS
*                   IN THE STACK(BIRD IN BUSH), IN WHICH CASE IT
*                   MAY BE USED AS THE GLOBAL LINK REG.
*                 D3(R14) TYPICALLY CONTAINS THE DATA BUFFER WA.
*                 ALL OTHER REGISTERS AND THOSE MARKED 'TYPICALLY'
*                  AND 'USUALLY' MAY BE USED AS TEMPS AS CONVENIENT.
*
*
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
         DO1      RELOC=0
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
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
*
BASCBANC EQU      SCDBI+SCDBI+SCDBI+SCDBI   -- SMK 10/1/73 CHNGD
NORMTYC  EQU      Y01               *NORMAL COMPLETION
BUFABTTYC EQU     X'10'             * IRBT REDO-THE-BUFFER TYC.
PGABRTTYC EQU     X'11'             * LP REDO-THE-PAGE TYC.
HUTYC    EQU      2                 *HUNG UP COMPLETION
BUTOG    EQU      Y01               *BACKUP TOGGLE SIGNAL
1STDBI   EQU      4                 * 1ST DATA BYTE INDEX
RESTOREBIT EQU    X'100'            *
XTRABGETBIT EQU   X'400'            * SC FLAGS
SPILLBIT EQU      X'200'            *
W        EQU      X'20000'          * OBSCURE STH CC MOD
EOSB     EQU      X'40'             *END OF SYMBIONT BLOCK RCC
1EOF%FLAG EQU     X'800'            *FLAG FORCES TERM AFTER 1
*                                      FILE IF SET
LIST     EQU      4                 *X'40' BIT IN TB:FLGS IS
*                                     LISTING DEVICE BIT
DELFLAG  EQU      Y008              * RELEASE GRANULES FLAG
TYPMSK   EQU      X'FF'             *WIDTH OF SCDEVTYP TYPE FIELD
PAGE     EQU      4                 *CC2 FROM X'40' IN SKIP BYTE IS TOF
*                     (FOR TWO REASONS: POSS NOVFC&VARIABLE VFC CONVENTIONS)
RESSPLPFBIT EQU   X'1000'           * SCDEVTYP SAYS IS RESTORE OR SPOOL
IMRESPFBIT EQU    X'2000'           *               IS IMAGE OR RESTORE
ALGNBIT  EQU      BT31TO0+21    Y001
WEOFBIT  EQU      BT31TO0+23    Y004
CPYBIT   EQU      BT31TO0+22     Y002
NWEOFBT  EQU      NB31TO0+23
NCPYBT   EQU      NB31TO0+22
NALGNBT  EQU      NB31TO0+21
DLCKBIT  EQU      BT31TO0+20     Y0008
NDLCKBT  EQU      NB31TO0+20
M19      EQU      MASKS+19
PRTBIT   EQU      Y2
         PAGE
*SYYNDD-CARD PUNCH/PRINTER/TYPEWRITER SYMBIONT-SELF RELOCATING
*RE-ENTRANT FROM SYMBIONT ACTIVE ROUTINE
*HAVE ASSUMED SYMBIONT CONTEXT BUFFERS START ON EVEN MEMORY LOCATIONS
*(R3)=SYMBIONT SYMTAB INDEX
*(R4)=SYMBIONT BASE ADDRESS
*(SR3)=CONTEXT BLOCK ADDRESS
*(TSTACK)=SYMBIONT EXIT       (BIRD IN BUSH).
*        B        0,R2              ENTRY FROM SACT.
         SPACE    5
         LI,R1    1                 ONE TO CONTEXT BLOCK INDEX
         STB,R1   SSTAT,R3          SET SYMBIONT STATUS ACTIVE
*
*
OS0      EQU      %
         BAL,SR2  OS%REG            CONTEXT BLOCK ADDRESS
         LW,SR1   SCFLDA,R1         DISC FILE ENDED
         BNEZ     OS2
         XW,SR1   SCBLDA,R1         SET BLINK ZERO
         CI,D2    X'C0'             ALIGN MODE PENDING     24666-F00
         BNE      OS01               NOPE.                 24666-F00
         CW,0     ALGNBIT           IN THIS CONTEXT BLK    24666-F00
         BAZ      OS01               NOPE                  24666-F00
         STW,SR1  SCBLDA,R1         RESET THIS             24666-F00
         LW,SR1   R0                 GET CONTROL WORD      24666-F00
         B        OSDTOF              AND SUSPEND          24666-F00
OS01     CI,SR1   0                 WAS BLINK 0            24666-F00
         BEZ      OSEND             YES QUIT               24666-F00
*
         LB,R14   SYMX,R3
         CI,R14   4                 WRITE EOF
         BAZ      OSEND
         LW,R8    SCBESTDA,R1
         MTB,-1   R8
         BNEZ     OSEND1A
         LW,R2    SCDBI,R1
         OR,R0    WEOFBIT
         STW,R0   SCDEVTYP,R1
         LI,R0    0                 * EOF= 0 BYTE COUNT
         STW,R2   SCBUPPTS,R1
         B        OSDEA5            * Q THE WEOF
*
*
OSEND    EQU      %
         LI,R8    0
         XW,R8    SCCDA,R1          EMPTY CONTEXT
         BEZ      OS02C
***************************************************
         LW,R8    SCBESTDA,R1       COPIES MEAN NOT DONE
         MTB,-1   R8
         BEZ      OSEND1
OSEND1A  EQU      %
         STW,R8   SCBESTDA,R1
         OR,R0    CPYBIT
         STW,R0   SCDEVTYP,R1
         B        OSDF
*********************************************
OSEND1   EQU      %                 EOF GRAN RELEASE
         CW,R0    DELFLAG
         BANZ     OSEND1C
***************************************************
OSEND1B  EQU      %                 RELEASE WHOLE FILE BY CALLING RBBAT
         LI,R12   X'12'
         LI,R13   X'3F'             FILE IS DELETED BY ADDING BACK
         SLD,R12  +24               WITH DELETE PRIO (X'12').
         STS,R12  SCSVDGI,R1         (PRESERVE RBSWITCH BIT).
         BAL,R9   OS%AOFP
         B        OSEND2
****************************************************
OSEND1C  EQU      %                 RELEASE RECOVERY STACK
         LW,R8    YFF
         BAL,R9   OS%RSG1
         CW,R8    YFF
         BNE      %-3
****************************************************
OSEND2   EQU      %                 RELEASE SYMBIONT BUFFER
         LSCP
         BAL,R9   OS%RLCB
         B        OS%TERM0          WRITE END OF FILE IF NEEDED
******************************************************
OSEND3   EQU      %                 GO TO SWTEND IF NEEDED
         LW,R9    SCSVDGI,R1
         BGEZ     OS02B
         BAL,R9   *SWTEND
********************************************************
OS02B    EQU      %
*
*                           *THE DISC FILE CAN BE ENDED
*                                   * BECAUSE WE NEVER HAD ONE
         BAL,SR2  OS%REG            * SETUP REGISTERS
         CI,R0    1EOF%FLAG         * ARE WE AN EOF TERM ON 1 FILE STREAM
         BANZ     TERM              YES, TERMINATE
*                                   NO, CHECK LOCK       & GOF
*                                   *SIGNAL SAYS TO
         CI,D2    'L'               LOCK SYMB.
         BE       TERM              YES, TERMINATE EXIT
         LI,D2    'I'
         STB,D2   SSIG,R3
         AND,R0   M19
         STW,R0   SCDEVTYP,R1
         SPACE    3
*
*GET SYMBIONT OUTPUT DISC FILE
*
*                                   ENTERED AT BASE AND
*                 DISK FILE ENDED AND RECOVERY STACK EMPTIED
*                 AND NOT LOCKED AND THUS WE GET A NEW OUTFILE
*
OS02C    EQU      %
         LB,D1    SNDDX,R3          * DCTX
         SLS,D1   8                 *
         AI,D1    GOF               *  D1=0,SYMTABX,DCTX,GFC 8,8,8,8
         STH,R3   D1                *
         LI,D2    -1                * RECOVERY FLAG(MARKED)
         BAL,D3    OS%SGCQ                COMPUTE SRET
*                                   *BEFORE LOSING R4
*
         EQU      %                 BACK VIA ACTIVE Q
         LB,R1    R2                * BUF #
         LW,D1    SGCBUF+2,R1       * MISC ARGS(PRI,RBID,SYSID 8,8,16)
         LW,SR1   SGCBUF+1,R1       * COPIES,SDA 8,24
         LW,R2    R10
         STW,R8   SCBESTDA,R2
         STW,R12  SCSVDGI,R2        BESTDA PRECEEDS SRET
         LW,R12   SGCBUF+3,R1
         STW,R12  SCGCNT,R2
         STW,R1   SRET,R3           * CLEAR BUF #(IN CASE RCVR)
*
*        R1                         * BUF TO UN-Q
         ANLZ,D1  @SGCBUF           * ADD-EM-UP *
         BAL,R4   SGCRA             * RELEASE ANSWER BUF *
         LSCP                       * RES SYMBIONT CONTEXT POINT
         LSBR                       * RESTORE CLOBBERED SYMB
         LI,D2    1STDBI            *---- TOP OF BUFFER IS
         STW,D2   SCRTRY,R1
         STW,D2   SCBUPPT,R1        *---- FIRST BACKUP OFFSET
         STW,SR1  SCBUPPT+1,R1      *---- FDA IS FIRST BACKUP DA
         LI,R2    NEWQ
         STW,R2   SCSWIT,R1
*                                   * BASE ADDRESS FOR BASE REG
         INT,R5   SCSVDGI,R1        * DID RBBAT SAY SWITCH THIS ONE
         BCR,8    %+2               * NOPE , CONTINUE
         BAL,SR4  *SWTINIT          *YES, THEN SETUP.
*
OSDF     EQU      %
         LI,R12   0
         MTB,-1   R8
         BNEZ     OSDF1
         LC       SYMX,R3
         BCS,1    OSDF1             'KEEP' FLAG
         LW,R12   DELFLAG
OSDF1    EQU      %
         LW,D2    DELFLAG           * MASK FOR ZAP
         STS,D1   SCDEVTYP,R1       * MUST NOT DELETE N-TH COPY
OS09A    EQU      %
         AND,SR1  M24               * SENSE FILE RETURNED
         BEZ      OS%TERM0A
         BAL,R9   OSCLST
         STW,R15  SCBLDA,R1
         STW,R15  SCTOFDA,R1
         STW,R15  SCTOFDA+1,R1
*
         LC       SYMX,R3           * THERE IS A FILE SO
         BCR,8    %+3               * COPY THE SINGLE EOF
         LI,D2    1EOF%FLAG         * TERM FLAG TO CONTEXT
         STS,D2   SCDEVTYP,R1       * IF IT'S SET
OS2      EQU      %
         LI,R9    1STDBI
         STW,R9   SCDBI,R1
         PAGE
*SET UP DISC FILE READ CONTROL BLOCK IN CONTEXT BLOCK
*(SR1)=DISC FILE ADDRESS
*                                   (BIRD IN BUSH.)
*
OS1      EQU      %
         AND,R8   M24
         STW,SR1  SCCDA,R1          FILE DISC ADDRESS TO CONTEXT CUR
*
*
         BAL,R9   OS%RLCB
*        U=R0,R1,R2,R14(D3)  REQCB
OS11     BAL,SR4  REQCB             REQUEST CORE BUFFER FOR FILE DATA   935
         LSCP                       CONTEXT BLOCK ADDRESS
         STW,D3   SCFBUF,R1         CORE BUFFER ADDRESS TO SC
         LW,R0    SCDEVTYP,R1       ***FETCH UP FLAGS
         CI,R0    XTRABGETBIT
*                                   IS IT SPILL,RESTORE OR IMAGE
         BAZ      OS12              *NONE OF ABOVE
*
*
*        INITIALIZE THE MULTI BUFFER LIST
*
         BAL,SR2  OS%MLBFI          * MULTI BUF INIT
*        I= R1(SCP),SR3(SCP),R4(SBR)
*        O=       THE MULTI BUF LIST IS MADE TO EXIST IN CNTXT
*        U= SR4,D1,D2,D3,D4(R11-R15)
*        NON-VOLATILE : R5-SR3(R5-R10)
*        MAY RESTORE R1 AND R4 FROM SR3.
*
         PAGE
*SET UP TO READ DISC GRANULE
*
OS12     EQU      %                 *
         LW,SR1   SCCDA,R1          PICK UP NEW CURRENT D A
         BAL,SR4  CHKDA             INSURE FLINK OK
         LI,SR4   C'3'              SET CODE FOR ELLA      30874-F00
         BCR,8    BADDA2             B IF CHKDA FAILED     30874-F00
         MTW,1    C:CSC
OS1D     LCI      5                 *NUMBER OF NEWQ ARGS
         LM,R12   SCFQARGS,R1       *
         LH,R9    R15
         AND,R9   DCT%MASK
         OR,R12   R9
         SLS,R13  2                 * WA TO BA
         AND,R13  M24               * AND CLEAN
*
*        ALL REGS VOLATILE EXCEPT R5-SR4(R11)
         LI,R2    NEWQ              * IOQ ENTRY.
         BAL,SR2  OSDEA53           * QUEUE DISC ACCESS
         LI,SR4   X'240F6'          SET SCREECH CODE       30874-F00
*C*      IF FILE DEVICE IS DOWN, WE COULD SATURATE OPS     30874-F00
*C*       CONSOLE AS WE RIP THRU CLEANING OUT SYMBIONT     30874-F00
         B        SC3B                                     30874-F00
         PAGE
*
*DISC READ END ACTION
*(R6)=BUFFER ADDRESS
*(SR1)=DCB ADDRESS
*(SR3)=CONTEXT BLOCK ADDRESS
*(SR4)=EXIT                         (BIRD IN HAND.)
OSFEA    EQU      %
         LSBR     EA                RESTORE SYMBIONT BASE ADDRESS
         BAL,SR2  OS%REG-EA         *
         SPACE    5
*
         BAL,SR2  OS%UDAP           * UPDATE DA POINTERS
         LI,SR2   4
         STW,SR2  SCRTRY,R1
*                                   * AOK RETURN
*
         B        OSFEA4
         PAGE
*
OS%RSG   EQU      %                 * U=R0,SR1,SR4,D3,D4,R2
*                                   *  (NOTE:BIRD IN BUSH.)
         LC       SYMX,R3
         BCS,2    *R9               LEAVE LIST ALONE FOR OCP
         LW,R8    SCCDA,R1
         CI,R8    1
         BCS,5    *R9
         LW,R0    SCDEVTYP,R1
         CW,R0    DLCKBIT
         BAZ      OS%RSG1
         AND,R0   NDLCKBT
         LW,R14   SCDALST+SCDALSZ-1,R1
         BEZ      OS%RSG1A
         CW,R8    R14
         BNE      *R9
         STW,R0   SCDEVTYP,R1
         B        *R9
OS%RSG1A EQU      %
         STW,R0   SCDEVTYP,R1
OS%RSG1  EQU      %
         LI,R14   SCDALSZ
         AI,R1    SCDALST+SCDALSZ
         AI,R1    -1
         XW,R8    0,R1
         BEZ      %+2
         BDR,R14  %-3
         LW,R14   0,R1
         LSCP
         STW,R14  SCBUDA,R1
         AI,R8    0
         BLEZ     *R9
         CW,R8    SCBUDA,R1
         BE       *R9
         LW,R0    SCDEVTYP,R1
         CW,R0    DELFLAG
         BAZ      *R9
         STW,R8   SCBUPPTS,R1       * REMEMBER DA WE'RE ABOUT TO REL.
         EOR,R8   SCTOFDA+1,R1
         AND,R8   NB31TO0+1         * ABOUT TO RELEASE TOFDA GRAN...
         BNEZ     OS%RSG3           ---> NO.
         STW,R8   SCTOFDA+1,R1      * YES. MAKE PAGETOP BE BESTDA.
OS%RSG3  EQU      %
         LW,R11   PRTBIT
         STS,R11  SCSVDGI,R1
         MTW,-1   SCGCNT,R1
         LW,R11   SCBESTDA,R1
         LB,R11   R11
         STB,R11  R14
         STW,R14  SCBESTDA,R1
OS%RSG2  EQU      %
         LW,R8    SCBUPPTS,R1       * GET GRANULE TO RELEASE.
         BAL,R11  RSG
         LSCP
         AI,R8    0
         BNEZ     *R9
         STW,R9   SCBUPPTS+1,R1
         BAL,R9   QFACTP11
         LW,R9    SCBUPPTS+1,R1
         B        OS%RSG2
         SPACE    5
*
*SYMBIONT RETURN FROM DATA ERROR
*CONSTRUCT ERROR MESSAGE IN DATA BUFFER FOR TYPE OUT AND SUSPEND
BADDA1   EQU      %
         MTW,-1   SCRTRY,R1
         BLEZ     %+3
         STW,R0   SCBLDA,R1
         B        OS12
*                                   * '...BLK BAD 2'
         LI,SR4   C'2'              BAD BLINK CODE TO ELLA 30874-F00
*                                   AND TO OPS CONSOLE     30874-F00
*
BADDA2   EQU      %                 *
         LSCP                       CONTEXT BLOCK ADDRESS
         LW,D3    SCCDA,R1          *---- CDA FOR ERRL W3
         STB,SR4  D3                *---- ERR TYPE TO ERRL W3 B0
         LI,3     1EOF%FLAG         NEED TO TERM THIS SYMB 31051-F00
         STS,3    SCDEVTYP,R1       NOW                    31051-F00
         LI,SR4   X'1B04'           ELLA CODE & SIZE       30874-F00
         LB,R3    *SR3              *---- RESTORE SYMTABX
         LB,D1    SNDDX,R3          *---- DCTX FOR ERRL W1 B3
         STH,SR4  D1                *----  CODE AND COUNT TO W1 B0-1
         LI,D4    0                 CLEARING               30874-F00
         XW,D4    SCBESTDA,R1       BEST DISK ADDRESS      30874-F00
         LI,R6    R12               POIT TO MESSAGE        30874-F00
         BAL,R5   ERRLOG             AND GO LOG IT         30874-F00
         LB,R5    D3                REMEMBER CODE          31051-F00
         LB,R7    SNDDX,R3
         LW,D2    SR3               GET CONTEXT BLK ADDR   30874-F00
         AI,D2    X'1A'             LAY MSG IN IT          30874-F00
         LW,R6    D2                 USE AS INDEX ALSO     30874-F00
         SLS,D2   2                 MAKE A BYTE ADDRESS    30874-F00
         LI,D3    X'2C'              AND A BYTE COUNT      30874-F00
         LB,D4    SNDDX,R3            FOR THIS DEVICE      30874-F00
         LI,D1    X'02FF'           CODE PRIO FOR NEWQ     30874-F00
         SLS,D1   16                                       30874-F00
         AI,D1    OCDCT             MSG TO OPS CONSOLE     30874-F00
         LW,R2    SCSVDGI,R1        GET SYSID              30874-F00
         LI,R1    4                                        30874-F00
LOGIT1   SLD,R2   -4                                       30874-F00
         SLS,R3   -28               EXPAND TO EBCDID       30874-F00
         LB,R0    HBCD,R3                                  30874-F00
         SLS,4    -8                ALIGN                  30874-F00
         STB,R0   R4                 AND ADD               30874-F00
         BDR,R1   LOGIT1              TIL ALL DONE         30874-F00
         LCI      4                                        30874-F00
         LM,R0    LOGMSG3+5         LAST PART OF MSG       30874-F00
         SLS,R5   8                 MOVE CODE OVER         31051-F00
         OR,R5    LOGMSG2           APPEND C/R             31051-F00
         LCI      6                                        30874-F00
         STM,R0   5,R6              PUT IN CONTEXT BLOCK   30874-F00
         LCI      5                                        30874-F00
         LM,R0    LOGMSG3           FIRST PART OF MSG      30874-F00
         STM,R0   0,R6              INTO CONTEXT BLOCK     30874-F00
         LW,R1    R10               ADD END ACTION         30874-F00
         BAL,R0   DUMPIT            TELL THE OPERATOR      30874-F00
         BAL,SR2  EA0               GET REGISTERS BACK     30874-F00
         B        OSEND2            RELEASE THIS JUNK      30874-F00
DUMPIT   BAL,SR4  NEWQ              HOLD UP A BIT          30874-F00
         NOP      0                                        30874-F00
         B        PULLEXIT                                 30874-F00
LOGMSG3  TEXT     ' DISK BLOCK & OUTPUT BAD FOR SYSID '    31051-F00
LOGMSG2  DATA     X'40400015'                              31051-F00
HBCD     TEXT     '0123456789ABCDEF'                       31051-F00
         PAGE
*
*
SC3B     EQU      %
         LI,R4    0
         LSCP
         XW,R4    SCBESTDA,R1       DON'T SEE THIS FILE AGAIN.
         SCREECH  X'3B',0
*
*
*S*      SCREECH:         3B-00
*S*
*S*      REPORTED BY:     OUTSYM
*S*
*S*      TYPE:            FULL RECOVERY
*S*
*S*      MESSAGE:         COOP PASSED OUTSYM BAD DATA
*S*
*S*      REGISTERS:       R11 CONTAINS THE TYPE OF PROBLEM:
*S*                                 ' 6' = FILE DEVICE DOWN 30874-F00
*S*                                 BUT OUTSYM GOT STARTED 30874-F00
*
         PAGE
*
*SYMBIONT SUCCESSFUL DISC READ RETURN
*
*LP RECORD=132 BYTES MAX.(FORMATTED-1ST BYTE CONTROL,UNFORMATTED 1ST
*BYTE CHARACTER),LP AUTOMATICALLY INCLUDES TRAILING SPACES ON SHORT
*RECORDS.
*TY RECORD=80 BYTES(ONE LINE) ARBITRARY MAX.(FORMATTED-CONTROL BYTES
*MAY BE THRU OUT RECORD),SHORT RECORDS NO PROBLEM
*CP RECORD=120 BYTES FIXED FOR BINARY,80 BYTES FIXED FOR BCD,SHORT
*RECORDS MUST BE ZERO FILLED FOR BINARY,SPACES FILLED FOR BCD
         SPACE    5
OSFEA4   BAL,R9   QFACTP11
         BAL,SR2  OS%RSG            * RELEASE CURR(AFTER LSCP)
         BAL,SR2  OS%REG            * LOAD SPEC REGS
         BNEZ     OSDEA0
*
*        THE BIRD IS NOW IN THE BUSH.
*
         LI,R2    1STDBI+2
         LW,R14   SCFBUF,R1
         LB,R11   *R14,R2
         DO       RELOC
         AND,R11  %+1-SYMPPRTY,R4
         ELSE
         AND,R11  %+1
         FIN
         CI,R11   X'88'             X'88' IN FC SAYS DONT BLINK CHK NEXT
         BNE      OS0
         LI,R11   -1
         STW,R11  SCBLDA,R1
         B        OS0
         PAGE
*PUNCH,PRINT,OR TYPE RECORD ON DEVICE END ACTION
*
         SPACE    5
OSDEA    LSBR     EA                LOAD SYMBIONT BASE REG
         BAL,SR2  OS%REG-EA         * AND ALL THE LITBLE REGS.
*
*        CHECK RECORD OUTPUT COMPLETION TYPE
*
         STW,R12  SCTYC,R1          *
         LW,D3    R15               * EA BUF TO EVEN REG.
         LW,D4    BUTOG             * BACKUP TOGGLE BIT
         CS,D3    R0                * IS SAME-SAME
         BE       OSDEAB            * YES-YES
         STS,R14  R0
         AND,R0   NCPYBT
         STW,R0   SCDEVTYP,R1
         LCI      2                 * 2 WORD ENTRY
         LM,D3    SCBUPPTS,R1       *SAVED BACKUP POINT
         STM,D3   SCBUPPT,R1        * DEFINE BACKUP POINT.
OSDEAB   EQU      %                 *
         CW,R12   Y02               * IS NORMAL
         BL       OSDEA0            * NO, ERROR
         LB,D3    R12               * SIMPLIFY TYC
         CI,D3    HUTYC             * RBT OR IRBT HUNG UP.
OSDEAQ1  BE       OSDEAQ3
         CI,D3    PGABRTTYC         * RE-DO CURRENT PAGE...
         BE       OSDEABUP          ---> YES.
         CI,D3    BUFABTTYC         * IRBT RE-DO LAST BUFFER...
         BNE      OSDEA0            ---> NO.
         AND,R0   NWEOFBT
         CW,R0    CPYBIT
         BAZ      OSDEAQ2
         LI,R7    SCBESTDA+SCBESTDA+SCBESTDA+SCBESTDA
         MTB,1    *R1,R7
OSDEAQ2  EQU      %
         LW,R8    SCBUPPT+1,R1
         LW,R9    SCBUPPT,R1
OSDBU    EQU      %
         AND,R0   NCPYBT
         STW,R0   SCDEVTYP,R1
         STW,R9   SCDBI,R1
         STW,R9   SCBUPPT,R1
         STW,R8   SCBUPPT+1,R1
         LI,R15   -1
         XW,R15   SCBLDA,R1
         CW,R8    SCCDA,R1
         BE       OSDBUC
         LW,R15   DLCKBIT
         STS,R15  SCDEVTYP,R1
         B        OS1
OSDBUC   EQU      %
         AI,R15   0
         BEZ      OSDEA0
         STW,R15  SCBLDA,R1
*
*
OSDEA0   EQU      %
         BAL,R9   OS%REG
*
*        DEV E A & A O K  SO CHECK SIGNALS
*                                   (AND BIRD IS IN HAND)
*
         CI,D2    'S'               SUSPEND SYMBIONT
         BE       OSMS0               YES,SUSPEND EXIT
         CI,D2    'Q'               * REQUEUE PARTIAL FILE SIGNAL
         BNE      OSDEA0CA            * NO, CHECK 'A'
*                                   YES,
OSDEA0A  EQU      %
         BAL,SR2  OS%AOFP           * PUT THAT FILE BACK
         CI,R3    MXSTRM
         BLE      OSEND2
         LI,R12   'L'               MTB WONT WORK ENTERED
         STB,R12  SSIG,R3           IN DIFFERENT WAYS
         B        OSEND2
OSDEAQ3  EQU      %
         LW,R9    WEOFBIT           IF HANGUP OR DOWN DONT
         STS,R9   SCDEVTYP,R1       WRITE EOF
         B        OSDEA0A
*
OSDEA0CA EQU      %
         CI,D2    'A'               * CHECK FOR 'A'-ALIGN
         BNE      OSDEA0CR          * NOPE, CHECK-'R'
*
         LC       SYMX,R3
         BCR,4    OSDEA00
         OR,R0    ALGNBIT           * REMEMBER
         STW,R0   SCDEVTYP,R1       * FOR LATER.
         MTB,-1   SSIG,R3           MAKE A NON ALPH
OSDEABUP EQU      %                   (FOR REDO-THE-PAGE TYC)
         LW,R9    SCTOFDA,R1
         LW,R8    SCTOFDA+1,R1
         BNEZ     OSDBU
OSDBU1STA EQU     %
         LW,R8    SCBESTDA,R1
OSDBU1ST EQU      %
         LI,R9    1STDBI
         B        OSDBU
*
OSDEA0CR EQU      %                 CHECK 'R'
         CI,D2    'R'               IS     'R' RECOVERY REQUESTED
         BNE      OSDEA0CX            NO,CHECK          X
         AND,R0   NALGNBT
         STW,R0   SCDEVTYP,R1
         LC       SYMX,R3
         BCS,2    OSDBU1STA         NO BACKUP LIST FOR OCP
         MTB,1    SSIG,R3           MAKE R NON ALPH
         LW,R8    SCBUDA,R1
         BEZ      OSDBU1STA         NO LIST YET
         BAL,R9   OSCLST
         STW,R8   SCBUDA,R1
         B        OSDBU1ST
OSCLST   EQU      %
         LI,R15   0
         LC       SYMX,R3
         BCS,2    *R9               NO LIST FOR OCP
         AI,R1    SCDALST-1
         LI,R14   SCDALSZ
         STW,R15  *R14,R1
         BDR,R14  %-1
         LSCP
         B        *R9
OSDEA0CX EQU      %                 SYMBIONT WRITE END ACTION
*                                   SHECK 'X'
         CI,D2    'X'               TERMINATE SYMBIONT FILE
         BE       OSEND1B
OSDEA00  EQU      %
*
*        NO SIGNALS    SO PROCESS NEXT ...
*
         DO       RELOC
         LIEA,R2  OCPFEA            DOES END ACTION
         ELSE
         LI,R2    OCPFEA
         FIN
         CW,R2    SCFEA,R1          POINT TO OCP
         BNE      %+2               NOPE
         BAL,R14  OCPSEND           YES-SEND BLOCK OR RECORD
         LW,D3    SCFBUF,R1         DATA BUFFER ADDRESS
         LW,R2    SCDBI,R1          DATA BYTE INDEX
         AI,R2    +1                *
         LB,R0    *D3,R2            * GATHER BYTE COUNT
         AI,R2    +1                * AND ADVANCE TO RCC.
         LB,D1    *D3,R2            RECORD CONTROL CODE
         CI,D1    X'80'             SPECIAL CODE
         BGE      OSDEA02              *YES, IT IS SPEC SYMB CODE
         CI,D1    X'58'             I/O FUNCTION CODE
*        FC=      4(PRINT OR PUN), 5(PRINT OR PUN)
*                 6(FORMAT PRINT), 7(FORMAT PRINT)
*                 0,1,2,3 (DPD PRINT WITH FORMAT)
         BAZ      OSDEA21              *YES, IT IS
*
OSDEA00A EQU      %
*                                   * FOR RECOVERY
         CI,D1    EOSB              BLOCK INFORMATION END
         BE       OS0               --CHNGD  SMK 10/1/73
*
*CORE BUFFER DATA ERROR-PROBABLY DUE TO BAD DISC READ
*
*                                   * '...BLK BAD 4'
OSDEA0X  EQU      %
         LI,SR4   C'4'              BAD RCC CODE TO ELLA   30874-F00
         B        BADDA2            AND TO OPS CONSOLE     30874-F00
OSDEA01  LI,SR4   C'5'              BAD SCDBI CODE TO ELLA 30874-F00
         B        BADDA2            AND TO OPS CONSOLE     30874-F00
         PAGE
OSDEA02  EQU      %
         CI,D1    X'86'             * SPCL IS BANNER
         BL       OSDEA0X
         BE       OSDEA1D           * YEP,
         LI,SR2   -1                *---- NO BLINK CHK IS NEG DA
         STW,SR2  SCBLDA,R1         *----  ... MARKED IN CONTEXT
         CI,D1    X'88'             *---- 88 IS PREFIX BANNER FOR DPD
         BNE      OSDEA2            *---- NOPE MUST NOT BE BANNER
OSDEA1D  EQU      %                 =
*
         STW,R2   SCBUPPTS,R1
         MTW,-2   SCBUPPTS,R1
         LI,D1    3                 *
         LI,R6    SCDQARGS+SCDQARGS+SCDQARGS+SCDQARGS
         STB,R12  *R1,R6
         LW,SR2   SCCDA,1           *---- FETCH CDA FOR BACKUP
         LI,R6    BASCBANC          *
         AI,R2    +1                * ADVANCE TO SK
         LB,D1    *D3,R2            * FETCH
         AI,R2    +1                * ADVANCE TO REP CNT
         LB,D2    *R1,R6            * IN BETWEEN
         BNEZ     OSDEA1A           * YEP CONTINUE
         LB,D2    *D3,R2            * NOPE START
         AND,D1   M3                *(IGNORE FLAGS)
         AW,R2    D1                * POINT AT REAL REC
         AI,R2    -1                * (CORR FOR COUNT)
         MTB,1    SR2               *---- SET 1ST BANNER TIME
         LW,R15   Y01               LOSING TOF AT IRBT     31059-F00
         STS,R15  SCBUPPT+1,R1      SOMETIMES              31297-F00
         B        OSDEA1B                                  31059-F00
*
OSDEA1A  EQU      %                 *
         AI,R2    +1                * TEMP ADVANCE
         LB,D4    *D3,R2            * TO FETCH SVFC
         AI,R2    -2                * (BACK OFF FOR RITE SK)
         LC       *D3,R2            * ((FUDGE HERE FOR ODD LPP --
         BCR,1    %+4               *    GO IF EVEN LPP
         CI,D2    2                 *
         BNE      %+2               *    ALSO GO IF NOT LAST LINE
         AI,D4    -1                *  ELSE CHANGE DSP VFC TO SSP))
         AND,D1   M3                *(IGNORE FLAGS)
         AW,R2    D1                * ADVANCE TO PVFC
         STB,D4   *D3,R2            * SVFC REPLS PVFC
*
OSDEA1B  EQU      %                 *
         AI,D2    -1                * MORE REPS
         BEZ      OSDEA1C           * NOPE CLEAN UP
         STB,D2   *R1,R6            * YEP DOIT
         STW,SR2  SCBUPPTS+1,1      *----CDA TO BCKUP PT SV
         STW,R0   SCDBC,R1          * NEWQ SETUP
         LCI      5                 *
         LM,R12   SCDQARGS,R1       *
         LW,R13   SCFBUF,R1         * WA TO BA
         SLS,R13  +2                *
         AND,R2   M24               *----CLEAN DBI FOR ADD
         AW,R13   R2                * BUFF + DBI :=> REC
         B        OSDEA51           * *=*JOIN UP*=*
OSDEA1C  EQU      %                 *
         STB,D2   R2                *----REP COUNT SAVED IN DBI BY 0
         AW,R2    R0                * ADVANCE TO NEXT REC
         STW,R2   SCDBI,R1          *
         B        OSDEA0            * AND FROM THE TOP
         PAGE
*
*MESSAGE-SUSPEND SYMBIONT END ACTION
*
OSMS0    EQU      %
         CI,R3    MXSTRM
         BG       %+4
         LI,R9    SSSBIT
         LB,R2    SNDDX,R3
         STS,R9   RB:FLAG,R2
         LC       SYMX,R3
         BCS,2    %+2
         BAL,R9   OS%RLCB
         PLW,R11  TSTACK
         BAL,SR2  SUSP              * SET SUSPEND RET ADDR AND
*                                   EXIT TO SUSPEND SYMBIONT
*
*RETURN FROM SUSPEND                (BIRD IN BUSH)
*
         LI,R11   1                 CONTEXT BLOCK INDEX AND STATUS CODE
         STB,R11  SSTAT,R3          SET SYMBIONT STATUS ACTIVE
         LC       SYMX,R3
         BCS,2    OSDEA0
         LW,R11   DLCKBIT
         STS,R11  SCDEVTYP,R1
         LI,R11   -1
         STW,R11  SCBLDA,R1
         B        OS11
         PAGE
*DEVICE END ACTION
*(CONTINUE)
*
OSDEA2   EQU      %
OSDEA21  EQU      %
*
         LI,R6    7
         AND,R6   R12
         LC       SYMX,R3
         BCR,2    %+3
         LI,R6    1
         B        OSDFCN
         BCS,4    %+2
         AI,R6    8
         REF      SYMTRAN
         LB,R6    SYMTRAN,R6
OSDFCN   EQU      %
         LI,R7    SCDQARGS+SCDQARGS+SCDQARGS+SCDQARGS
         STB,R6   *R1,R7
         AI,R2    1                 INCR DATA BYTE INDEX
         LB,R7    *R14,R2
         AND,R7   M3
         AW,R7    R2
         LW,R15   SCDBI,R1
         CI,R6    3
         BNE      OSTOFCK
         LB,R13   *R14,R7
         CI,R13   X'F1'             TOF VCF CHAR
         BE       OSTOFCK1
OSTOFCK  EQU      %
         LC       *D3,R2            * THIS IS TOF
         BCR,PAGE OSDEA3B           * NOPE
OSTOFCK1 EQU      %
         LW,R8    SCDEVTYP,R1
         CW,R8    ALGNBIT
         BAZ      OSDEA3A
         LW,D1    SCTOFDA,R1                               24666-F00
         BEZ      OSDEA3A                                  24666-F00
         LW,R13   SCCDA,R1
         CW,R13   SCTOFDA+1,R1
         BNE      OSDTOF
         LI,R13   X'FFFF'
         CS,R12   SCDBI,R1
         BE       OSDEA3B
OSDTOF   EQU      %
         SW,R8    ALGNBIT
         STW,R8   SCDEVTYP,R1
         B        OSMS0
OSDEA3A  EQU      %
         LW,SR1   SCCDA,R1          * CURR DISC
         STW,R15  SCTOFDA,R1
         STW,SR1  SCTOFDA+1,R1      * DEFINES TOF
OSDEA3B  EQU      %
         STW,R15  SCBUPPTS,R1
         STW,R7   SCDBI,R1
         CW,R7    SCBSIZ,R1
         BGE      OSDEA01             YES,CORE BUFFER ERROR
*                                   * '...BLK BAD 5'
*                                   *NO,
OSDEA5   EQU      %
*
         LW,R3    SCCDA,R1          * SAVE POSS BACKUP
         STW,R3   SCBUPPTS+1,R1     *----CURRENT DA TO BACKUP POINT SAVE
*
         STW,R0   SCDBC,R1          * REC BYTE COUNT
         CI,R0    1                  * WE GET S/C79 FROM A LOT OF
         BNE      %+3                * 1-BYTE TOF'S IN A ROW, SO SLOW
         BAL,SR2  QFACTP11           * DOWN HERE AS ONLY DECENT CURE.
         BAL,SR2  QFACTP11           *  REALLY NEEDED 2 TSM
         LCI      5
         LM,R12   SCDQARGS,R1       * NEWQ ARGS
         SCS,R13  -2                ***
         AW,R13   SCFBUF,R1         *** BUF+WORD OFFSET
         SCS,R13  2                 ***  TO BYTE ADDRESS
         AWM,R14  SCDBI,R1          * UPDATE FOR NEXT REC
*
OSDEA51  ANLZ,SR2  OSDEAQ1          *DEV DOWN DO A 'Q'
OSDEA52  LW,R2    SCSWIT,R1         * IOQ OR SITCHER ENTRY POINT
OSDEA53  BAL,SR4  0,R2              * REQUEST IO(NOW OR EVENTUALLY)
         B        QFACTP11          * PULL BIRD AND 'Q' ON ACT
         B        PULLEXIT          * BIRD FROM BUSH AND LEAVE
*
OS%TERM0A EQU     %
         LC       SYMX,R3
         BCR,8    TERM              THIS SEEMS WEIRD BUT IS RIGHT FOR RP
         LI,R13   1EOF%FLAG
         STS,R13  SCDEVTYP,R1
OS%TERM0 EQU      %                 *
         LW,R0    WEOFBIT
         CW,R0    SCDEVTYP,R1
         BANZ     OSEND3
         LB,R12   SYMX,R3           * REMOTE AND NEEDS EOF
         CI,R12   4
         BAZ      OSEND3
         LCI      4
         LM,R12   SCDQARGS,R1       * USING ANY FC
         LI,R14   0
         ANLZ,SR2  OSDEA0AL         * FOR DEV DOWN
         BAL,R0   OSDEA52           * SET EA ADDR AND QUE
         LSBR     EA                * AGAIN
         BAL,SR2  OS%REG-EA         * WITH THE REGS
         LB,R12   R12               * CHK TYC
         CI,R12   BUFABTTYC         * FOR REDO-THE-BUFFER.
OSDEA0AL BNE      OSEND3
         B        OS%TERM0          *
         PAGE
*        UTILITY OUTSYM SUBROUTINES
         SPACE    3
*        L=SR2, OS%REG-EA: SR3 FROM R14 AND
EA0      EQU      %
         LW,SR3   R14               *
         PSW,R11  TSTACK
OS%REG   EQU      %                 *
EA       EQU      %-EA0
OS%EA    EQU      EA
*                 OS%REG: SETUP R1(SCP),R3,D2,R0
         LSCP                       *
         LB,R3    *SR3              *
         LB,D2    SSIG,R3           *
         LW,R0    SCDEVTYP,R1       *
         LI,R2    TYPMSK            * WIDTH OF DEVICE TYPE
         AND,R2   R0                * SET CC AND FETCH DEV TYP
         B        *SR2              *
*
*        OS AOFP  INTERNAL ADD OUTPUT FILE PARTIAL
*                 L=SR2  , BIRD IN HAND , USES SCTYC TO PRES LINK
*
OS%AOFP  EQU      %                 *
         STW,SR2  SCTYC,R1          * SAVE LINK
         MTW,-1   BL:OFS            * FETCH AN ENTRY
         BGEZ     %+4               * YES, I GOT ONE
         AI,R4    %-2-SYMPPRTY      * NO, WERNT NONE (SET RET)
         MTW,+1   BL:OFS            * (CORRECT IT)
         B        QFP11NCB          * WAIT ON ACTQ FOR SLOT
*
         LI,D1    TYPMSK            *
         AND,D1   SCDEVTYP,R1       * DEVICE TYPE.
         SLS,D1   +8                *
         AI,D1    AOFP              * D1 = 0,0,TYPE,GFC 8,8,8,8
         STH,R3   D1                * D1 = 0,SYMTX,TYPE,GFC 8,8,8,8
         LI,R13   0
         XW,R13   SCBESTDA,R1
         LW,D3    SCSVDGI,R1        * D3 = SAVED GHO INFO 32
         LW,R2    SCGCNT,R1
         BAL,R4   SGCQ                : CALL GHOST VIA QUEUE
         BDR,R4   QFPD4CB
         LSBR                       *RESTORE BASE ADDR
         BAL,SR2  OS%REG            * AND ALL THE REGS
*
         LW,SR2   SCTYC,R1          * RESTORE LINK
         B        *SR2              * AND RETURN
*
*
OS%UDAP  EQU      %                 *OUTSYM : UPDATE DISC ADDRESS POINTERS
*                 L=SR2;I-R1=SCP,R12=TYC;U-R0,R6
*                 OUTPUT: TYC,FLINK,BLINK UPDATED
*                         BLINK CHECKED UNLESS NEGATIVE
*                         RETURN+1  BAD BLINK COMPARE
*                         RETURN+2  AOK OR NEG BLINK
*
         LW,R6    SCFBUF,R1         *ADDR OF BLOCK IN CORE
         STW,R12  SCTYC,R1          *SAVE TYC
         LW,R0    0,R6              NEXT DISC BLOCK ADDRESS
         STW,R0   SCFLDA,R1         SAVE FLINK
         LW,R0    SCCDA,R1          GET CUR
         XW,R0    SCBLDA,R1         SAVE FLINK, GET PREV FOR BLINK CHK
         BLEZ     *SR2
*
*                                   * '...BLK BAD 2'
         LW,R6    SCBSIZ,R1         * LOOK AT BUFFER LAST
         SLS,R6   -2                * WORD FOR BLINK TO
         AW,R6    SCFBUF,R1         * CHECK. (SCFBUF)+(SCBSIZ)-1
         CW,R0    *M24,R6           (FOR S9 REAL EXT ADDR)
         BNE      BADDA1            GO RETRY OR ABORT
         B        *SR2              NORMAL RETURN
*
*
OS%RLCB  EQU      %                 RELEASE SPOOL
         LI,R14   0
         XW,R14   SCFBUF,R1
         BEZ      *R9
         PLW,R11  TSTACK
         B        RELCB
*
*                 SEGREGATED BECAUSE BAL BEATS ANLZ,B BOTH SPEED AND SIZE.
OS%SGCQ  EQU      %                 ::Q FOR GHO GOF::
         STW,D3   SCGCNT,R1
         BAL,R4   SGCQ
         BDR,R4   QFP11NCB          - - -NO COMM BUFS: TRY
*                                       AGAIN AT ACT.- - -
         LW,R2    R10
         LW,D3    SCGCNT,R2
         AI,R1    -SGCBUF           * ADDR TO #
         STB,R1   D3                *   BUF # SAVED IN SRET
         STW,D3   SRET,R3           *   GHO DOES THE Q
*                                   * PTR TO SACT CALL IS IN BUSH.
         B        PULLEXIT          * LEAVE FOR NOW
         END

