MONPROC  SET      1
ANSPROC  SET      1
         SYSTEM   UTS
         DEF      OPNL,OPNLSZ
OPNL     EQU      %
         TITLE    '**** OPNL ****'
         BOUND    8
K2       EQU      2
K7       EQU      X'7'
K0       EQU      X'0'
K1       EQU      X'1'
K3       EQU      X'3'
K40      EQU      X'40'
KFFFF    EQU      X'FFFF'
K1FFFF   EQU      X'1FFFF'
KN1      EQU      -X'1'
KN2      EQU      -X'2'
         PAGE
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE     OPL DEFS
         DEF OPNLBL
         DEF      OPNLA
         DEF      TAPECHK
         DEF      GETAVR
         DEF      RLSBF
         DEF      SKRECR
         DEF      REWTP
         PAGE
         REF      CLEARHI
         REF      AVRNOU
         REF      GETTYP,USECHK2
         REF      UH:DL
         REF      GSBUF
         REF      REEL
         REF      OPNX
         REF      OERX
         REF      DCT4
         REF      DCT3
         REF      DID
         REF      AVRTBL
         REF      AVRFLGS
         REF      ANSFLGS,AVRFNMT
         REF      AVRSID
         REF      CNVBIN,SIXPACK
         REF      MSR01EXIT
         REF      CKLIMIT
         REF      FORMAT,#FORMATS
         REF      GETFLG1
         REF      TB:FLGS,Y0001
         REF      AVRTBLNE
DPT      EQU      AVRTBLNE
         REF      BATAPE
         REF      DOUBLEZERO
         REF      GETFUN
         REF      IOSPIN
         REF      NBATAPE
         REF      PULLEXIT
         REF      PUTSZBF
         REF      READTP
         REF      T:RBUF
         REF      SETBTDQ1
         REF      SETBTDZ
         REF      SETTYC
         REF      Y2
         REF      Y4
         REF      Y02
         REF      Y01
         REF      YFFFE
         REF      OPENER03
         REF      LOCCODEA,LOCCODE
         REF      COMPARE
         REF      MSRMOVE
         REF      GETACNADR,GETFILADR
         REF      CHKFLACN
         REF      SECCHK,SETACOG
         REF      Y03
         REF      MISOVSEG,AVR#
         REF      GETTDEV
         REF      M17
         REF      J:JIT
         REF      Y1
         REF      MOUNT
         REF      S:CUN
         REF      AVRID
         REF      GETTYC,IOCHEK1
         REF      CHKANS0
CACN     EQU      :ACN
         REF      :ACN
         DEF      CBOF
CBOF     TEXT     ':BOF'
CEOF     TEXT     ':EOF'
CEOR     TEXT     ':EOR'
CEOV     TEXT     ':EOV'
THDR1    EQU      HDR1
         REF      HDR1
         DEF      CEOF,CEOR,CEOV
         DEF      TEOF1,TEOV1
TEOF1    TEXT     'EOF1'
TEOV1    TEXT     'EOV1'
         PAGE
*
GETCIS   EQU      %
GETCISA  LI,SR3   0
         LI,R2    BACOS
         LB,R2    *R6,R2
         AI,R2    KN1
         AW,R3    R2
         B        *SR1
CHKANS   EQU      %
         LI,SR1   X'F'
         AND,SR1  ASN,R6
         CI,SR1   X'A'
         B        *SR4
YFBFF    EQU      NB31TO0+27
*
         REF      OPNT2
         DEF      OPNT9
OPNT9    BAL,2    OPNT2
         BAL,R0   CHKANS0
         BAL,R2   SETFN             CLR SNFN FOR ANS
         LI,1     0
         STW,1    16,6
         LI,2     1
         STB,2    *6,5
         B        0,4
         PAGE     OPNLBL
*
OPNLA    EQU      %
         LI,5     BACVI
         BAL,4    OPNT9
         B        OPNLBLA
*
OPNLBL   EQU      %
*
         ANSBAL,R0 CHKANS0
         ANSBAL,SR4 IOCHEK1         IF ANS, CHK FOR POSTING
         LI,R2    X'F0001'          CVOL FLAG FOR PMD-CMD
OPNLBLA  EQU      %
         STW,2    PBD,6
         BAL,R0   CHKFLACN
*
OPNLBLII EQU      %
         BAL,D4   SETBTDZ
         BAL,5    TAPECHK
OPNLLII  EQU      %
         BAL,SR4  GSBUF
         LI,R2    XBUFSIZ
         BAL,SR4  PUTSZBF
         BAL,R3   GETAVR
*
*                                   CLEAR PSL
         AND,R1   YFBFF
         STD,R0   AVRTBL,R2
*
*
         CW,R1    Y4                IS TAPE AT LOGICAL BEG
         BANZ     OPNLBLI3          NO
*
         CW,R1    Y2                DID AVR RECOGNIZE
         BANZ     OPNLBLI9          YES
*
         LW,R1    Y02
         STD,0    AVRTBL,R2         FLAG DRIVE AS IN USE
         PUSH     1,R0              NO
         BAL,D4   GETTDEV
         LW,R7    R3
         LH,9     AVRID,2           GET USER ID FOR AVR
         OVERLAY  MISOVSEG,AVR#
         BAL,R3   GETAVR
         PULL     1,R3
         BAL,SR4  CHKANS
         BNE      CHKSN
         LW,D4    R2
         MI,D4    6
         AI,D4    AVRFNMT
         LW,SR2   PBD,R6
         CI,SR2   X'F0001'
         BNE      CHKSN1            NOT CVOL, SO SKIP CVI CHK
         LI,R4    18                CHECK VOL SEQ NO.
         LB,SR2   *D4,R4
         LI,R4    BACVI
         CB,SR2   *R6,R4
         BNE      OPNREEL
CHKSN1   EQU      %
         LI,SR2   X'20000'          IS IT BY FILENAME
         CW,SR2   0,R6
         BAZ      CHKSN
         BAL,R0   GETFILADR         YES,CHECK FILENAME
         LW,D2    R7                ANS VOL SEQ NO.
         LI,R3    0                 D2,R3 = DCB F.N.
         BAL,R1   COMKEYC
         BNE      OPNREEL
         BAL,R3   GETAVR
         B        OPNLBLI9
CHKSN    EQU      %
         CW,R0    R3
         BE       OPNLBLI9
OPNREEL  EQU      %
         BAL,R3   GETAVR
         LW,15    2                 SET AVR INDEX FOR TYPR
         BAL,SR4  REEL
*                                   TYPE MESSAGE
         BAL,11   RLSBF
         B        OPNLBLII
OPNLBLI9  EQU     %
         BAL,SR4  CHKANS            BYPASS ACCOUNT CHECK IF ANS.
         BE       OPNLBLI3
         OR,R1    Y4                SET POS TO MIDDLE OF REEL
         STD,R0   AVRTBL,R2
*                                   GET SECTOR BUFFER FOR RECORDS
*
         BAL,SR2  READTP
         BAL,SR4  IOSPIN
         BAL,R0   GETACNADR
         LW,D3    QBUF,R6
         LW,D1    CACN
         CW,D1    *D3
         BNE      OPENERIN
         LI,R3    0
         LI,R2    1
         BAL,SR4  COMPARE
         B        OPENERIN
OPNLBLI3 EQU      %
         LW,R2    S:CUN
         LH,R2    UH:DL,R2
         CI,R2    X'F000'           CHECK FOR BRK,ABRT,ERR,EC
         BANZ     ERSEC1
*
         INT,SR2  PBD,R6            GET PBD. BITS 0-15 = 0
         CI,SR2   KFFFF             IS PBD = -1
         BNE      OPNLLI3           NO. THIS IS NOT LAST TAPE TO BE SRCHD
         CW,SR2   PBD,R6            IS CMD = 0
         BE       OPNLLI3
         BAL,R3   GETAVR            GET TPOS
         STH,R1   SR2               SR2=TPOS,PBD
         CW,SR2   PBD,R6            IS TPOS="MD
         BE       OPNLBI3
OPNLLI3  EQU      %
*
         BAL,SR4  CHKANS
         BNE      OPNLLI31
         BAL,R3   GETAVR
         CW,R1    Y4                DO NOT SKIP TAPE
         BANZ     OPNLLI31          MARK IF THIS IS
         OR,R1    Y4                BEGINNING OF ANS
         STD,R0   AVRTBL,R2         TAPE.
         B        OPNLLI31+1
OPNLLI31 EQU      %
         BAL,SR2  SKFILE            SKIP TO END-OF-FILE
         BAL,SR2  READTP            READ NEXT RECORD
         BAL,SR4  IOSPIN
         LW,D3    QBUF,R6
         LW,D1    *D3
         AI,D3    K1                INCR TO FILE PARAM
         BAL,R4   GETTYC
         CI,R3    X'6'
         BNE      OPNLLI32
         BAL,SR4  CHKANS            IF AN ANS TAPE MARK
         BE       OPNL5CA           WAS FOUND, SEE IF A
*                                   VOLUME SWITCH CAN BE PERFORMED.
OPNLLI32 EQU      %
         CW,D1    THDR1
         BE       OPNLLI33
         CW,D1    CBOF
         BNE      OPNLBLI5
*                                   BOF SENTINAL--DECIDE WHAT TO DO
*                                   ABOUT NEXT FILE
OPNLLI33 EQU      %
         LW,R4    TSTACK            SAVE LAST FPL CODE FOUND
         STW,D1   -2,R4
         LW,D2    Y01
         AND,D2   NXTF,R6
         BNEZ     OPNLBLI6          YES
*                                   NO--IS THIS CORRECT FILE
         LW,R7    D3
         LI,0     BACIS             DONT REQUIRE 1ST VOL IF
         LB,1     *6,1                 CVOL OR IF VOL>1
         CI,1     1
         BG       NTCVOL
         BAL,SR4  CHKANS
         BNE      FILCHK1
         LW,R1    QBUF,R6           FIND VOL. SEQ. NO. IN
         LW,R0    7,R1              VOL SEQ IN BYTE 27-31
         AND,R0   L(X'0F0F0F00')
         CI,R0    X'100'            CHECK FOR VOL 1
         BE       NTCVOL            IF PBD =-1 & VOL SEQ > 1.
         B        FILX
*
OPNLBLI8 EQU      %
         BAL,SR4  CHKANS            BYPASS SECURITY CHECK, FPARAM
         BE       OPNLBLI81         IF ANS.
         LW,R7    D3
         BAL,R0   SECCHK
         B        ERSEC
*
*                                   CHECK HEADER OPTION
         BAL,SR4  SETACOG
         BAL,SR1  TRNINFO
         REF      TRNINFO
OPNLBLI81 EQU     %
         BAL,SR4  CHKANS
         BNE      VOLHED9
         BAL,SR4  VOLHEDANS
         CI,SR1   -1
         BE       OPNREEL
1AR      RES      0
         BAL,11   RLSBF
         BAL,SR2  SKFILE            NOT WANTED--SKIP TO FIRST RECORD
         BAL,SR4  IOSPIN
*                                   SET REEL IN USE
         REF      OPNT3
         BAL,D2   OPNT3
         B        SETOPN1A
OPNLBLI6 EQU      %
         BAL,SR4  CHKANS
         BE       OPNLBLI6A
         LW,R7    D3
         LI,D1    K1
         BAL,R4   LOCCODE
         B        OPENERIN
         BAL,0    GETFILADR
         LI,R0    (FNEMAX+3)/4
         XW,R7    D3
         LI,R2    K0
         BAL,SR1  MSRMOVE
         XW,R7    D3
OPNLBLI6C LI,R0   (FNEMAX+3)/4
         LI,R2    KN2
         STB,R0   *R7,R2
*                                   TRANSFER FILE NAME TO DCB
         B        OPNLBLI8
OPNLBLI6A EQU     %                 OPEN NXTF-ANS
         BAL,0    GETFILADR         MOVE NAME INTO DCB
         LW,2     D3
         AND,R7   M17
         LW,3     7
         SLD,2    2
         AI,3     L(17**24+5)
         MBS,2    0
*                    NOW FIND END OF NAME AND SET COUNT
         AI,7     1
         LI,2     17
OPNLBLI6B LB,0    *7,2
         CI,0     C' '
         BNE      %+2
         BDR,2    OPNLBLI6B
         STB,2    *7
         BDR,7    OPNLBLI6C         FIX R7 AND GO FIX VLP
OPNLBLI51 EQU     %
         LI,R5    BACIS
         MTB,1    *R6,R5            INCR CIS
         LI,R7    0                 FORCE R7 NOT= CIS
OPNLBLI2 EQU      %
         BAL,R0   INITAVR7          REW OR REMOVE TAPE
         LI,R1    HAPBD
         MTH,1    *R6,R1
         BNEZ     OPNLBLII
OPNLBI3  EQU      %
         BAL,11   RLSBF
         LI,SR3   K3                COULDNT FIND FILE
         B        OERX
OPNLBLI5 EQU      %                 RECORD WASNT BOF--MAKE FURTHER
*                                   CHECKS
         CW,D1    CEOF              EOF
         BE       OPNLBLI3          YES--CONTINUE SEARCH
         CW,D1    CEOV
         BE       OPNLBLI51
         CW,D1    CEOR
         BE       OPNL5C
         CW,D1    TEOF1
         BE       OPNLBLI3
         CW,D1    TEOV1
         BE       OPNLBLI51
         BAL,11   RLSBF
         LI,10    11
         B        OERX
OPNL5CA  EQU      %
         LI,D1    0
         BAL,R0   SETTYC
         LI,D1    X'20000'
         CW,D1    SNFN,R6
         BAZ      OPNL5C
         LI,R1    1                 OPEN BY ANS FILENAME
         LI,R5    BACVI             REQUIRES A VOLUME
         STB,R1   *R6,R5            SWITCH BACK TO THE
         LI,R7    X'FFFE'           FIRST VOLUME.
         STW,R7   PBD,R6
         B        OPNL5D1
OPNL5C   EQU      %
         LI,D1    K7
         LW,R7    FLP,R6
         BAL,R5   LOCCODEA          TOTAL SN'S TO R1
         B        OPENER03
OPNL5D1  EQU      %
         LI,R5    BACIS
         LB,R7    *R6,R5
         SW,R1    R7
         BLZ      OPNL5D
         AWM,R1   PBD,R6
OPNL5D   EQU      %
         LI,R1    1
         STB,R1   *R6,R5
         LW,D1    Y01
         AND,D1   NXTF,R6
         BEZ      OPNLBLI2          NO--CONTINUE SEARCH
        BAL,D2   GETFUN            DONT REWIND IF UPDATE
         CI,D1    K1
        BNE      OLBLI5A
         BAL,R0   INITAVR7
OPNL5B1  LI,SR3   K2
         B        OERX
OLBLI5A EQU      %
         BAL,SR2  SKFILER
         BAL,SR2  SKFILER
         BAL,0    CHKANS0
         BAL,SR2  SKFILER
         BAL,11   RLSBF
         B        OPNL5B1
*
         PAGE
ERSEC    EQU      %
         BAL,SR2  SKFILE
         BAL,SR4  IOSPIN
ERSEC1   EQU      %
         BAL,11   RLSBF
         B        OPENER03
OPENERIN EQU      %
         BAL,R0   OSAVE             REMOVE OLD VOLUME
        B        OPENER03
INITAVR7 EQU      %
         LI,R5    BACIS             DO REMOVE IF OLD VOLUME NOT
         CB,R7    *R6,R5             SAME AS NEW VOLUME
         BE       INITAVR           IS SAME, SO JUST REW
OSAVE    EQU      %
         PUSH     R0                RELEASE VOLUME
         BAL,11   RLSBF
         BAL,R3   GETAVR
         LW,R3    R0                GET SN
         BAL,SR4  SAVRL
         BAL,SR2  OFFREW
         B        PULLEXIT
         REF      SAVRL
INITAVR  EQU      %
         PUSH     1,R0
         BAL,11   RLSBF
INITAVR1 EQU      %
         BAL,SR2  REWTP
         BAL,SR4  IOSPIN
         BAL,R3   GETAVR
         LI,R3    1
         STB,R3   R1
         STD,R0   AVRTBL,R2
         B        PULLEXIT
*
RLSBF    EQU      %
         LW,D3    YFFFE
         AND,D3   QBUF,R6
         XW,D3    QBUF,R6
         AND,D3   M17
         BEZ      *SR4
         LW,R2    SR4               SET RETURN
         LI,R5    0                 REL VIRT & PHYS
         B        T:RBUF
GETAVR   EQU      %
         LI,R2    BADSI             IS TAPE BUSY
         LB,R2    *R6,R2
         AI,R2    NBATAPE
         LD,R0    AVRTBL,R2
         B        0,R3
         TITLE    '**** TAPECHK ****'
DP:TY    EQU      X'10000'          DP TYPE
WDP      EQU      Y0001
FN:OUT   EQU      X'8000'
FN       EQU      X'4000'
ANSI     EQU      X'2000'
DEVICE   EQU      X'1000'
IN       EQU      X'100'
OUT      EQU      X'200'
INOUT    EQU      X'400'
OUTIN    EQU      X'800'
*
*
TAPECHK  EQU      %
         BAL,13   GETFUN
         SLS,12   8                 IN BYTE 2
         AI,12    8                 TRY OUTSNS FIRST
         LI,13    X'F'
         AND,13   0,6               CHK FULL ASN FOR ANS
         CI,13    X'A'
         BNE      %+2
         AI,12    ANSI              FLAG ANS
         CI,13    3
         BNE      %+2
         AI,12    DEVICE            YES
         CI,12    IN+INOUT          NO OUTSNS FOR INS
         BAZ      %+2
         AI,12    -1
         BAL,11   GETTYP
         LC       TB:FLGS,4         TYPE OF DEV
         BCR,4    %+2               NOT DP TYPE
         OR,12    WDP               SET BIT
         LW,7     FLP,6             SET UP 7
SNCHK    EQU      %
         BAL,4    LOCCODE           DOES CODE EXIST
         B        SNCHK2            NO, MEBBE SCRATCH OR INSN
         CI,13    X'FF00'           ANY USEFUL ENTRIES
         BANZ     SNCHK3            YES
         CI,12    DEVICE
         BANZ     SNCHK2A           USE EMPTY VLP FOR DEVICE
         CI,12    ANSI+OUT+OUTIN    ANS MAY BE FILENAME OPEN
         BAZ      OPENER01          MUST BE ANS OR OUT FOR NO SN'S
         CI,12    ANSI
SNCHK2C  EQU      %
         BANZ     SNCHK2B
         REF      OPENER01
SNCHK2A  EQU      %
         LI,2     BACIS             GET CURRENT INDEX
         CB,13    *6,2              IS THERE ROOM FOR A SCRATCH
         BGE      GETSCR            YES
SNCHK2   AI,12    -1
         CB,12    Y06               MORE SN'S TO CHECK
         REF      Y06
         BG       SNCHK             YES
         BL       GETSCRD           NO...AND ALREADY HANDLED ANS
         LI,13    0                 NO VLP TO POST SN'S IN
         CI,12    ANSI              IF ANS,SET FNAME
         BAZ      SNCHK1
SNCHK2B  EQU      %
         LI,0     X'20000'
         BAL,2    SETFN             SET SNFN
         AI,12    FN
         CI,12    OUT+OUTIN
         BAZ      GETSCRD
         AI,12    FN:OUT            FILENAME OUTPUT FLAG
         B        SNCHK2A           OUT, MAY BE PLACE TO PUT SN'S
SNCHK1   EQU      %
         CI,12    DEVICE
         BAZ      OPENER01          MUST BE DVC IF NONE
         CI,12    IN                MUST ALSO NOT BE INPUT
         BANZ     OPENER01
GETSCRD  LI,13    0                 OK, TRY A SCRATCH
GETSCR   BAL,8    GETCISA           SET 2,3 BUT NOT SND
         LW,4     13                SAVE SN CODE
GETSCR1  PUSH     4,2
         LI,3     -1                SCRATCH SER # FLAG
         CI,12    FN
         BAZ      GETSCR2
         CI,12    IN+INOUT
         BAZ      GETSCR2
         LI,R5    HAPBD             PBD TO LAST VOL
         STH,R3   *R6,R5
         LI,3     0                 DO MOUNT IF ANS,FNAME,IN
GETSCR2  EQU      %
         BAL,5    USECHK0           CHECK IT OUT
         PULL     4,2
         CI,4     X'FF'             ANY SLOTS FOR SNS
         BAZ      0,5
         STW,0    *7,3              PUT IN SN
         SW,3     2
         AI,3     -1
         AI,4     X'100'            INCR # USEFUL ENTRIES
         STW,4    *7,3              PUT CODE AWAY
         B        0,5
*
SETFN    EQU      %                 SETS DCB:SNFN F/R0
         LI,1     X'20000'
         STS,0    0,6
         B        0,2
*
SNCHK3   CI,12    DEVICE+OUT+OUTIN
         BAZ      SNCHK4            LBLD IN OR INOUT, SPECIAL CHECKS
         BAL,8    GETCISA           SET 2,3-NOT SND
         LI,1     2                 CHECK CIS VS USEFUL ENTRIES
         CB,2     13,1
         BL       USECHK            OK, CHECK IT OUT
         CI,12    IN
         BANZ     ERR56
         SW,3     2                 UNWIND FOR GETCIS
         CI,12    DEVICE
         BANZ     GETSCRD           MUST BE SCRATCH IF DEVICE
         CI,12    ANSI
         BAZ      SNCHK31
         LI,0     X'20000'          IF SNFN IS SET, TREAT AS FN
         CW,0     0,6
         B        SNCHK2C           ELSE AS EXTENDED W/SN'S
SNCHK31  EQU      %
         LI,1     3                 IS THERE ROOM FOR ANOTHER
         CB,2     13,1
         BGE      OPENER01
         B        GETSCR
ERR56    EQU      %
         LI,SR3   X'56'
         B        OERX
*
*
SNCHK4   BAL,8    GETCIS
         LI,1     HAPBD
         LH,4     *6,1              GET PBD
         BEZ      OPENER01
         LI,1     2                 CIS VS CURRENT SIZE
         CB,2     13,1
         BL       SNCHK5            INIT REQUIRED, MEBBE
         CI,4     0
         BG       OPENER01
         SW,3     2                 GO TO FIRST SN
         LI,2     1
         LI,1     BACIS
         STB,2    *6,1
         B        USECHK
*
*
SNCHK5   CI,4     0
         BL       USECHK            PBD NEG
         LB,4     13,1              CURRENT SIZE
         LCW,4    4                 SET PBD TO -# SNS
         LI,1     HAPBD
         STH,4    *6,1              AND INSNINIT
         BAL,R5   USECHK
         LI,R2    HACMD
         MTH,1    *R6,R2            IS CVOL FLAG ON
         STH,R1   *R6,R2            TPOS TO CMD
         BNEZ     INSNIN1           CVOL FLAG OFF
         LI,R0    INSNIN2
         PUSH     1,R0
         BAL,R0   INITAVR1          CVOL FLAG ON.REWIND
INSNIN2  EQU      %
         LI,R0    -1                SEARCH ONLY THIS VOLUME
         STW,R0   PBD,R6            -1 TO CMD AND PBD
         B        OPNLLII           CONTINUE OPEN
INSNIN1  EQU      %
         LH,R1    *R6,R2            WAS TPOS 0 OR 1
         BDR,R1   INSNIN1A          GO IF 2 OR MORE
         CI,D1    ANSI              IF ANS,CHK TPOS 0
         BAZ      OPNLLII
         AI,R1    0
         BL       OPNLLII           ANS BEFORE FIRST FILE
INSNIN1A EQU      %
         MTW,-1   PBD,R6            NO.  THIS VOLUME MUST BE RE-SEARCHED
         B        OPNLLII
         TITLE    '**** USECHK ****'
USECHK   LW,3     *7,3              GET SN
         BEZ      OPENER01
USECHK0 RES 0
         LI,2     DPT
USECHK11 EQU      %                 DO SN OR FN SEARCH OF AVR
         CI,12    FN                DO FN SEARCH IF FN SET
         BAZ      USECHK12
*                    SEARCH FOR FILENAME MATCH
         INT,9    FLD,6             FETCH FNAME ADDRESS
         AW,9     FLP,6
         AND,9    M17
         LB,8     *9
         AI,8     1                 INCLUDE COUNT IN COMPARE
         SLS,9    2                 R9 NOW SET FOR CBS
         STB,8    9
         LW,8     9
         LW,9     2
         MI,9     24                AVRFNMT IS 6 WDS/ENTRY
         XW,8     9
         AI,8     BA(AVRFNMT)-24
         CBS,8    0
         BE       USECHK3
         B        USECHK13
USECHK12 EQU      %
         LD,0     AVRTBL-2,2
         CW,0     3
         BE       USECHK3
         CI,3     -1
         BNE      USECHK13
         CW,1     Y1
         BANZ     USECHK3
         BAL,SR4  CHKANS
         BNE      USECHK13
         AI,R2    -1
         LB,8     ANSFLGS,2
         AI,R2    1
         CI,8     8                 ANS KEYIN BIT
         BANZ     USECHK3
USECHK13 EQU      %
         BDR,2    USECHK11
         BAL,11   GETTYP            SET 4
         BAL,9    USECHK2
         B        NOTPE2            49-02
         B        GOVER
*                 BAL,11            MOUNT 3=REEL,4=TYPE
         PUSH     12
         BAL,SR4  MOUNT
         PULL     12
         LI,2     DPT+BATAPE
USECHK24 EQU      %
         BDR,0    USECHK37          BR IF NOT YC, BRK,ETC
USECHK25 EQU      %
         LI,10    X'14'**7-X'49'**7+NOTPE1+3 ABN1403
         B        NOTPE
*
*
USECHK3  AI,2     -1
         BL       USECHK13
         LD,R0    AVRTBL,R2
         CW,R1    Y00FF             NOU
         REF      Y00FF
         BAZ      OKDP1
         CI,12    DP:TY             DP TYPE ALLOW MULTIPLE OPENS
         BAZ      USECHK11
OKDP1    RES      0
         AI,R2    BATAPE            GET DCT INDEX
         LB,R1    DCT3,R2
         AI,R2    NBATAPE
         CI,R1    X'20'             DEVICE PARTITIONED FLAG
         BAZ      USECHKDG    NO--- DEVICE PARTITIONED
         LW,R1    S:CUN       YES-- GET USER #
         CW,R1    DID
         BNE      USECHK11    NO--- USER ALLOWED PARTITIONED DEVICE
USECHKDG EQU      %           YES-- CONTINUE
         LI,1     BADSI
         LI,4     BATAPE
         AW,4     2
         STB,R4   *6,1
         LB,1     DCT5,4            SET DCT5 MOD FROM DCB FOR REQCOM
         AND,1    NB31TO0+1
         LI,0     X'20000'
         AND,0    MOD,6
         BEZ      %+2
         AI,1     1
         STB,1    DCT5,4
         REF      DCT5
         REF      DHHIT1
         BAL,11   DHHIT1
         BANZ   USECHK45
         LH,9     AVRID,2
         BEZ      USECHK33
         INT,0    J:JIT             IF BATCH, MIGHT BE REAL ID
         BCS,12   USECHK32          ID=UN IF ONLINE OR GHOST
         CW,1     9                 IS THIS PREMOUNT BY ID
         BE       USECHK33          YES, PUT USER # IN
USECHK32 CW,9     S:CUN
         BNE      USECHK11
USECHK33 EQU      %
         LB,11    ANSFLGS,2
         AND,11   NB31TO0+3         CLR READ ONLY FLAG
         STB,11   ANSFLGS,2
         AI,2     BATAPE
         BAL,11   GETTYP
         CB,4     DCT4,2            IS IT OK TYPE
         BE       USECHK52
USECHK37 EQU      %
         AI,2     -BATAPE
         B        USECHK11
USECHK52 EQU      %
         CI,12    DP:TY
         BCS,4    %+3               NOT FOR DEVICE PACK
         BAL,15   PROTCHKL
*
         BG       USECHK24          NG-TRY ANOTHER
     BAL,9     USECHK2
         B        NOTPE2            49-02
         B        GOVER
         CI,12    DP:TY
         BCS,4    USECHK35
*                    IF NOT CVOL, RESET FSN
         MTW,0    PBD,R6
         BLZ      USECHK35
         LW,0     FSN,R6
         AND,0    YFFFE
         STW,0    FSN,R6
USECHK35 EQU      %
         BAL,11   CLEARHI           AND CLEAR-X'80'
         AI,2     -BATAPE
         LW,1     S:CUN
         STH,1    AVRID,R2          SET ID HERE
*                    CHK OUT DENS AND CC IN CASE NS TAPE
         CI,12    DP:TY
         BANZ     USECHK44          DEVICE PK/DP
         BAL,SR2  GETFLG1
         BCR,8    USECHK47          NOT DUAL DENS
         LI,1     X'80'
         AND,1    ACS,R6            LO DENS FLAG
         AI,1     X'100'            SET DENSITY FLAG
         LB,0     AVRFLGS,R2
         AND,0    NB31TO0+8
*
         LI,SR4   USECHK46
         B        DOCCMS1           UPDATE TABLES AND DO MODESET
USECHK47 EQU      %
         LW,11    Y04
         REF      Y04
         CW,11    ACS,R6
         BANZ     ABN1412           LO DENS ON NON-NS DRIVE
USECHK46 EQU      %
         BAL,SR4  DOCCSET           HANDLE CC IF NS DRIVE, ELSE RETURN
         REF      DOCCSET
         REF      DOCCMS1
USECHK45 EQU      %
         CI,12    IN+DP:TY
         BANZ     USECHK43          CHK   DP
         LB,11    ANSFLGS,2
         CI,11    4                 IS READ ONLY SET
         BAZ      USECHK4           NO
*                    MUST DO PROTCHK IF NOW AT LOAD POINT...
*                     PROTCHK DOES LP CHECK
         BG       OPENER03          NO GOOD-GIVE ERROR 14 00
         LD,0     AVRTBL,2
         OR,1     BT31TO0+16        SET REMOUNT FLAG FOR TYPR
         STD,0    AVRTBL,2
         BAL,15   PROTCHKL
         BLE      USECHK4           CHECKS OUT OK
         BDR,0    OPENER03          PROTECT VIOLATION 14 00
         B        USECHK25          BREAK, ABORT, ETC  14 03
USECHK4  EQU      %
         LD,0     AVRTBL,2          RESTORE SN TO R0
         B        0,5
*
USECHK43 CI,12    DP:TY
         BAZ      USECHK4
USECHK44 RES      0
         MTH,0    AVRNOU,2          SET?
         BGZ      USECHK4
         MTH,1    AVRNOU,2          FIRST TIME ONLY
         B        USECHK4
*        ERRORS
ABN1412  LI,SR3   X'14'**7+X'12'-X'49'**7+NOTPE1    1412 CODE
         B        NOTPE
*
NOTPE0   BAL,10   NOTPE
GOVER    RES      0
NOTPE1   BAL,10   NOTPE
NOTPE2   BAL,10   NOTPE
NOTPE    AI,10    X'49'**7-NOTPE1
         SCS,10   -7
         BAL,5    DETAPE
         REF      DETAPE
         B        OERX
*
PROTCHKL EQU      %
         LI,0     2                 INITIALIZE ABORT REG
         PUSH     7,15
         PUSH     12
         BAL,SR4  PROTCHK
         REF      PROTCHK
         BAL,R3   GETAVR
         AND,R1   NB31TO0+16        CLR REMOUNT FLAG
         STD,R0   AVRTBL,R2
         PULL     12
         PULL     7,15
         LCW,8    8                 SET CC=GR IF BAD RETURN
         B        *15
         PAGE
FILCHK1  EQU      %
         LI,D1    9                 CHECK IF FIRST VOL. 9 IS FIXED CODE
         BAL,R4   LOCCODE           FIND (D1) CODE IN R7 LIST.DISP TOR3
         B        FILX              CANT BE BOF
         SLS,R3   2                 BTD OF DISPL
         AI,R3    2                 BTD OF VOL
         LB,R4    *R7,R3            VOL NO.
         CI,R4    1                 IS IT FIRST VOL
         BG       FILX              NO
NTCVOL   EQU      %
         BAL,SR4  CHKANS
         BNE      NTCVOL1
         BAL,R0   GETFILADR         DCB FILE NAME ADDRESS TO R7.
         LW,D2    QBUF,R6
         LI,R3    3
         LI,R4    21
NTCVA2   EQU      %
         AI,R4    -1                NOW FIND TERMINATING BLANK
         LB,D4    *D2,R4
         CI,D4    C' '
         BE       NTCVA2
         SW,R4    R3
         BGZ      %+2
         LI,R4    17
         STB,R4   *D2,R3
         LW,D4    R7                REGISTER SET-UP FOR COMPARISON
*                                   D4    = DCB FILENAME
*                                   D2,R3 = SENTINEL FILENAME
         B        NTCVOL2
NTCVOL1  EQU      %
         LI,D1    K1
         BAL,R4   LOCCODE
         B        FILX
         BAL,R0   GETFILADR
         LW,D4    R7
         LW,D2    D3
         SLS,R3   K2
*                                   SET UP FOR FILE COMPARISON--HAVE
*                                   SET UP D3,R3,D4,R4
NTCVOL2  EQU      %
         BAL,R1   COMKEYC
         BE       OPNLBLI8
FILX     EQU      %
         BAL,SR2  SKFILE
        B        OPNLBLI3
         PAGE
*
*
*
VOLHED9  EQU      %
         LI,D1    9
         LW,R7    QBUF,R6
         AI,R7    1
         BAL,R4   LOCCODE           GET TO FILE INFO.
         B        1AR
         SLS,R3   2
         AI,R3    K2
         LI,R1    BACVI
         LB,R2    *R7,R3
         STB,R2   *R6,R1
         LI,D3    K1FFFF                TLABEL OPTION
         AND,D3   TLB,R6
         BEZ      1AR
         LB,R4    *D3
         BEZ      1AR
         AI,R3    K2
         LB,R2    *R7,R3
         STB,R2   *D3
         BEZ      1AR
         CW,R2    R4
         BLE      PSH1
         STB,R4   *D3
PSH1     EQU      %
         LB,D2    *D3
         SLS,D2   -2
         BAL,R2   CHKADR            VALIDATE ADDRESSES
         BNE      TRNABRT           BAD ADDRESR
         REF      TRNABRT
         LB,R2    *D3
         REF      CHKADR
         LW,R7    QBUF,R6
         BAL,SR4  PUTSZBF           PUT USER HEADER SZ AND ADR IN DCB
         LI,R0    K40
         BAL,D4   SETBTDQ1
         BAL,SR2  READTP            READ IN HEADER
         LW,D3    R7
         LI,D4    K1FFFF
         STS,D3   QBUF,R6
         B        1AR
*
*
         PAGE
SETOPN1A EQU      %
*                                   CLEAR PARTS OF DCB FOR FILES
         LI,2     SETOPNA           SET RETURN
         LD,R0    DOUBLEZERO
         BAL,SR4  CHKANS
         BNE      SETOPN1
         STW,R0   BCDA,R6           DO NOT CLEAR FSN, LRCSZ OR SETID
         LW,R1    YFFFE             IN ANS DCB.
         STS,R0   FSN,R6
         LI,R1    K1FFFF
         STS,R0   LRCSZ,R6
         STW,R0   BLKCNT,R6
         B        SETOPN2
         REF      SETOPN1,SETOPN2
SETOPNA  BAL,0    SETOPN
         REF      SETOPN
         LW,D2    Y03
         STS,D1   TRN,R6            CLR NXT & TRN
         B        OPNX
*
*
*
SKRECR   EQU      %
         LI,SR3   4
         DEF      SKRECR1,SKFILER,SKFILE
SKRECR1  EQU      %
         BAL,R3   GETAVR
         B        TAPEOP
SKFILER  EQU      %
         LI,SR3   6
         BAL,R3   GETAVR
         AI,R1    KN1
         B        TAPEOP
SKFILE   EQU      %                 SKIP FILE FORWARD
         DEF      SKFILE1
SKFILE1  EQU      SKFILE
         LI,SR3   7
SKFILE2  EQU      %
         BAL,R3   GETAVR
         AI,R1    K1
         B        TAPEOP
OFFREW   EQU      %                 OFF-LINE REWIND
         LI,SR3   9
         B        REWTP1
         DEF      OFFREW
REWTP    EQU      %                 REWIND TAPE
         LI,SR3   8
REWTP1   EQU      %
         BAL,R3   GETAVR
         AND,R1   YFFFF
         REF      YFFFF
TAPEOP   EQU      %
         STD,R0   AVRTBL,R2
         B        DONEWQ
         REF      DONEWQ
         DEF      WRTEOF
WRTEOF   LI,SR3   3
         B        SKFILE2
MODSET   LI,SR3   FCMC              DO MODE SET COMMAND FOR NS TAPE
         REF      FCMC              CODE DEFINED IN TAPE HANDLER
         B        DONEWQM
         REF      DONEWQM
         DEF      MODSET
         REF      COMKEYC
         PAGE
VOLHEDANS  EQU    %
         PUSH     SR4
         LW,R1    QBUF,R6
         SLS,R1   2
         AI,R1    21
         ANSBAL,SR4 SIXPACK         CONVERT HDR1:SETID
         LI,R1    BADSI
         LB,R1    *R6,R1
         AI,R1    -BATAPE
         XW,R2    AVRSID,R1
         BEZ      VOLHED2
         CW,R2    AVRSID,R1
         BE       VOLHED2
         LI,SR1   -1
         B        PULLEXIT
VOLHED2  EQU      %
         LW,R1    QBUF,R6
         LCI      2
         LM,R0    6,R1              FILE SECTION NUMBER TO...
         SLD,R0   24
         LI,R1    0
         BAL,SR4  CNVBIN
         LI,R2    BACVI
         STB,R1   *6,R2              ..CVI
         LW,R1    QBUF,R6           GET FILE SEQUENCE NUMBER FROM
         LCI      2                 SENTINEL AND CONVERT TO BINARY.
         LM,R0    7,R1
         SLD,R0   24
         LI,R1    0
         BAL,SR4  CNVBIN
         LW,R2    R1
         LI,R3    K1FFFF
         STS,R2   FSN,R6            STORE FSN
         AND,R3   TLB,R6
         BEZ      %+3
         LI,R2    0                 SET 0 IN USER'S HEADER BUFFER
         STB,R2   *R3
         PUSH     1,R5
GETSENT  EQU      %
         BAL,SR2  READTP            READ SENTINEL
         BAL,SR4  IOSPIN
         BAL,R4   GETTYC
         CI,R3    6                 WAS IT A TAPE MARK
         BNE      GETSENT1
         BAL,SR2  SKFILER           YES, BACKSPACE FILE.
         BAL,SR4  IOSPIN
         PULL     1,R5
         LI,SR1   0
         B        PULLEXIT
X50000001 DATA    X'50000001'
THDR2    TEXT     'HDR2'
TUHL1    TEXT     'UHL1'
         REF      YFF
GETSENT1 EQU      %
         LW,D3    QBUF,R6
         LW,R2    *D3
         CW,R2    THDR2
         BNE      GETSENT2
         AI,D3    1                 ITS HDR2. GET TO FORMAT
         LB,R3    *D3               GET RECFM
         LI,R2    #FORMATS
         CB,R3    FORMAT,R2         LEGAL FORMAT
         BE       %+3
         BDR,R2   %-2
         B        ABN3005           UNRECOGNIZED FORMAT
         REF      ABN3005
         SLS,R2   4
         LI,R3    X'70'
         STS,R2   FMT,R6            SET FORMAT
         LCI      2
         LM,R0    *D3               BLKSIZE
         SLD,R0   8
         AND,R1   YFF
         BAL,SR4  CNVBIN
         SCD,R0   -15
         LW,R1    YFFFE
         STS,R0   BLKSZ,R6          BLOCK SIZE
         AI,D3    1                 POINT TO LOG REC SIZE
         LCI      2
         LM,R0    *D3               GET LOG REC SIZE
         SLD,R0   16
         AND,R1   YFF
         BAL,SR4  CNVBIN            CONVERT TO BINARY
         SCD,R0   -15
         LW,R1    YFFFE
         STS,R0   LRCSZ,R6          LOGICAL RECORD LENGTH
         B        GETSENT
GETSENT2 EQU      %
         CW,R2    TUHL1
         BNE      GETSENT
         LI,R3    K1FFFF            ITS A USER HEADER
         AND,R3   TLB,R6            DOES USER WANT IT
         BEZ      GETSENT
         LW,R7    R3
         LI,D4    80
         BAL,R0   CKLIMIT
         BCS,3    BADUSLBL
         SLS,R3   2                 YES, TRANSFER IT TO HIS BUFFER
         LI,R2    80
         STB,R2   0,R3
         AW,R3    X50000001         COUNT+DISPLACEMENT
         LW,R2    QBUF,R6
         SLS,R2   2
         MBS,R2   0                 R2=SENTINEL BUFFER
*                                   R3=COUNT,USER BUFFER
         B        GETSENT
BADUSLBL LW,SR3   ULBLBAD
         B        MSR01EXIT
ULBLBAD  DATA     1**25+X'30'
*
OPNLSZ   EQU      %-OPNL
         END

