*M*  OPN       MERGE M:OPEN FPT INTO DCB, PROCESS ADJUST DCB CAL
MONPROC  SET      1
ANSPROC  SET      1
BITS     SET      1
         SYSTEM   UTS
         PCC      0
OPN:     EQU      %
SYN      SET      1
     SPACE         3
*P*  NAME:         OPN
*P*
*P*  PURPOSE:      MERGE M:OPEN AND ADJUST DCB FPTS INTO DCB AND CALL
*P*                APPROPRIATE OPEN ROUTINE DEPENDING ON DCB
*P*                ASSIGNMENT TYPE.
         SPACE    3
K7       EQU      X'7'
K1       EQU      X'1'
K1FFFF   EQU      X'1FFFF'
KN4      EQU      -X'4'
         SPACE    3
         OPEN     WXBUFSIZ,XBUFSIZ
WXBUFSIZ EQU      X'200'
XBUFSIZ  EQU      X'800'
         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
*
DESC     EQU    17      BYTES 1-3,WD 17,DCB-DESCRIPTORS TEMP STOR IN OPN
TSTF     EQU      16                TEST FILE FLAG IN DCB-WD 16,BIT 12
         SPACE    2
         DEF      OPN:              SYMBOL FOR MODULE PATCHING
         SPACE    2
         REF      DCTSIZ            # ENTRIES IN DCT TABLES
         REF      DCT4              DEVICE TYPE (TB:FLGS INDEX)
         REF      TYPMNSZ           SIZE OF TB:FLGS TABLE
         REF      NB31TO0           TABLE OF BITS RESET
         REF      OH:NM             TEXT DEVICE MNEMONICS
         REF      OV:NMSZ           SIZE OF OH:NM
         REF      SB:RTY            CONVERT RESOURCE TYPE TO DEVICE TYPE
         REF      SV:LSIZ           # STREAM TYPES
         REF      SV:RSIZ           # RESOURCE TYPES
         REF      OPER              CLEAN UP AFTER OPEN ABORT
         REF      DCBNCHK           CHECK IF DCB IS M: OPLABEL
         REF      GETFUNA           CHECK IF DCB FUNCTION OUT/OUTIN
         REF      CHKBIT            CHECK FOR PARAMETER PRESENCE BIT
         REF      GETFUN            GET DCB:FUN
         REF      OPNDEV#           ENTRY # FOR OPEN DEVICE
         REF      PULLEXIT          PULL R0, BRANCH INDIRECT
         REF      PULLEXIT1         PULL R0, ADD 1, BRANCH INDIRECT
         REF      PUSHALL           STORE R5-R11 AND MARKER IN TSTACK
         REF      RESBTD            STORE D1 INTO DCB:UBTD
         REF      SAVRSZ            STORE D1 INTO DCB:RSZ
         REF      OERX              EXIT FROM OPN WITH ERROR
         REF      OPNX              EXIT WITH NO ERROR
         REF      LOCCODE           FIND VLP CODE IN DCB
         REF      LOCCODEB          FIND VLP IN DCB
         REF      J:JIT             TYPE OF USER RUNNING
         REF      J:CPPO            FILE EXTENSION FLAGS
         REF      Y00FF
         REF      Y00FE
         REF      DOUBLEZERO        TWO WORDS OF ZERO
         REF      DOUBLEONE         TWO WORDS OF 1
         REF      SETFUNCN          SET FUNCTION IN DCB
         REF      S:CUN             CURRENT USER NUMBER
         REF      CFUSIZE           # WORDS PER CFU
         REF      CHKFLACN          CHECK THAT DCB HAS VLPS
         REF      SETOPEN           FINAL OPN PROCESSING
         REF      MXFPL             M:XX VLPS
         REF      M:XX              M:XX DCB
         REF      CHKBIT0           CHECK FOR FIRST PARAMETER PRESENCE BIT
         REF      J:DCBLINK         FIRST DCB NAME TABLE
         REF      UH:FLG            STEP RUNNING FLAG
         REF      CHKBIT1           FIND PARAMETER PRESENCE WORD
         REF      OPENER01          REPORT I/O ERR 01-00
         REF      BGRCFU            FIRST CFU
         REF      ACNCFU            ACCOUNT CFU
         REF      GETACNADR         FIND ACCOUNT VLP IN DCB
         REF      GETFILADR         FIND FILE NAME VLP IN DCB
         REF      GETOBTX           ONLINE/BATCH/GHOST TABLE POINTERS
         REF      SB:LTY            STREAM TO DEVICE TYPE CONVERSION
         REF      OPNTPSEG          SEGMENT NAME OF TAPE CODE
         REF      OPNLA#            ENTRY FOR INPUT TAPE OPEN
         REF      OPNLO#            ENTRY FOR OUTPUT TAPE OPEN
         REF      MULSEG            SEGMENT NAME FOR DEVICE OPEN
         REF      OPNFIL            OPEN DISK FILE
         REF      SV:DFTP           DEFAULT TAPE TYPE
         REF      TB:FLGS           DEVICE TYPE FLAGS
         REF,2    JH:LDCF           FEATURE AUTHORIZATION BITS
         REF      SH:SYMT           AUTHORIZED RESOURCES TABLE
         REF      SV:FTYM           NUMBER OF AUTHORIZED RESOURCES
         REF      JB:PRIV           USER PRIVILEGE
         REF      J:ABUF            ADDR OF ASSIGN/MERGE BUFFER
         REF      LOCCODEA          FIND VLP IN DCB
         REF      CHNGNAM           CHANGE FILE NAME
         REF      ER1400            ABNORMAL 14-00
         REF      OPENER            ABNORMAL 03-00
         PAGE
         SPACE    2
         LW,1     0
         B        OPNTV,1
OPNTV    EQU      %
         B        MSROPN
         B        OPER              CLEAN UP FROM OPEN ABORT
         B        SETOPEN           ENTER FROM RDERLOG FOR DIAG OPEN
         B        ASSMRG            ASSIGN/MERGE
         B        CHNGNAM           CHANGE FILE NAME
         DATA     0,0               RESERVE TWO SLOTS
         SPACE    3
         SPACE    3
*D*  NAME:         MSROPN
*D*
*D*  REGISTERS:    ALL VOLATILE
*D*
*D*  CALL:         OVERLAY CALL TO OPNSEG,0
*D*
*D*  INPUT:        R6 = DCB ADDRESS
*D*                R7 = ADDR OF PARAMETER PRESENCE WORD OF FPT
*D*
*D*  DESCRIPTION:  IF DCB IS ALREADY OPEN, GIVE I/O ERR 2E.
*D*                CHECK FOR PARAMETER PRESENCE BITS, MOVE INFO
*D*                INTO DCB IF IT IS PRESENT.
*
MSROPNA  REMEMBER
MSROPN   EQU      %
         BAL,R1   PUSHALL
         LI,SR3   X'2E'             OPEN A DCB WHICH IS ALREADY OPEN
         LW,R4    Y002
         AND,R4   FCD,R6            IS DCB ALREADY OPEN
         BNEZ     OERX
*
*E*  ERROR:        2E-00
*E*
*E*  DESCRIPTION:  ATTEMPT TO OPEN A DCB THAT IS ALREADY OPEN
*
         LI,R5    X'DFFFF'
         STS,R4   QBUF,R6           RESET FCN, QBUF, LEAVE SHARE
*
         LI,R4    X'FFFF'
         AND,R4   0,R7              FLAGS FROM FPT
         LI,R5    X'20000'
         LS,R4    -1,R7             PICK UP XFPT FLAG
         CI,R4    X'22000'
         BAZ      %+2
         AI,R7    1                 INCR POINTER IF ADJUST OR EXTENDED
*
         LW,R3    Y004
         CW,R3    0,R6
         BAZ      MSROPN1C          NEVER OPENED BEFORE
         LI,R2    7
         AND,R2   R4                ASN FROM FPT
         BEZ      MSROPN1C          NONE SPECIFIED
         CI,R2    5
         BNE      %+2
         LI,R2    X'A'              CHANGE ANS TAPE ASN VALUE
         LI,R3    X'F'
         CS,R2    0,R6
         BE       MSROPN1C          ASN NOT CHANGING
*
*  ASN CHANGING - ZAP VARIOUS DCB FIELDS
*
         LW,R3    =X'FF80000F'
         AND,R3   0,R6
         STW,R3   0,R6              RESET FLAGS IN WD 0
         LD,SR1   DOUBLEZERO
         LD,SR3   DOUBLEZERO
         LCI      4
         STM,SR1  14,R6             ZAP WORDS 14 THRU
         STM,SR1  18,R6               21
         LW,SR2   =X'0C000080'
         STS,SR1  5,R6              RESET SEQ ID PRESENT, ETC.
*
MSROPN1C BAL,R2   CHKBIT0
         STS,D1   ERA,R6            ERROR ADDRESS IS PRESENT
         BAL,R2   CHKBIT            CHECK FOR ABNORMAL ADDRESS
         STS,D1   ABA,R6            STORE ABNORMAL ADDRESS
         BAL,R2   CHKBIT            CHECK FOR BUFFER ADDRESS
         STS,D1   BUF,R6            STORE BUFFER ADDRESS
         BAL,R2   CHKBIT            CHECK FOR RECORD LENGTH
         BAL,R0   SAVRSZ
         LI,R3    BANRA
         BAL,R2   CHKBIT            CHECK FOR TRIES
         STB,D1   *R6,R3            NUMBER RECOVERY TRIES ALLOWED
         BAL,R2   CHKBIT            CHECK FOR ORGANIZATION
         BAL,R0   MSROPN51
         LI,D2    K7                ACS NOW 3 BITS
         BAL,R2   CHKBIT            CHECK FOR ACCESS
         STS,D1   ACS,R6            STORE FILE ACCESS
         BAL,R2   CHKBIT            CHECK FOR FUNCTION
         BAL,R0   SETFUNC
         BAL,R2   CHKBIT            CHECK FOR GENERATION NUMBER
         NOP                        GEN NOT IMPL.
         BAL,R2   CHKBIT            CHECK FOR SAVE/REL
         BAL,R0   MSROPN52
         LI,D2    K1FFFF            NEW MASK
         BAL,R2   CHKBIT            CHECK FOR USELB
         STS,D1   FPARAM,R6
         BAL,R2   CHKBIT            CHECK FOR TAPE LABEL ADDRESS
         STS,D1   TLB,R6            STORE TAPE LABEL
         LI,R3    BAKEYM
         BAL,R2   CHKBIT
         STB,D1   *R6,R3            MAXIMUM KEY LENGTH
         BAL,R2   CHKBIT
         BAL,R0   MSROPN5A          DEVICE OPTION
         BAL,R2   CHKBIT            BYTE DISPLACEMENT
         BAL,R0   RESBTD
         LI,R3    BACOS             REEL #
         BAL,R2   CHKBIT
         STB,D1   *R6,R3
         BAL,R2   CHKBIT            NEWX
         BAL,R0   SETNEWX
         BAL,SR4  CHKANS1
         B        %+3
         LI,R3    BACONCAT          CONCATINATION
         B        %+2
         LI,R3    BASPARE           SPARE
         BAL,R2   CHKBIT            SPARE
         STB,D1   *R6,R3
         SLS,D3   1
         BAL,R2   CHKBIT            GET FPT VALUE OF RSTORE
         B        LRECL             IS SPECIFIED, INSERT
         B        NRSTOR            NOT, SKIP
NOTLRECL EQU      %
         LI,D2    X'FFFF'
         STS,D1   RSTORE,R6         RT. 16 BITS TO RSTORE
         AND,D1   Y00FF             EXTENDED
         BEZ      %+2               NO
         AW,D1    Y08               YES, SET THE FLAG
         LW,D2    Y08FF             GET MASK
         STS,D1   NLR,R6            AND PUT THE REST IN NLR
NRSTOR   EQU      %
         CI,4     X'22000'          MORE PARAMS IF EXTENDED FPT
         BAZ      ENDP
         BAL,R2   CHKBIT
         BAL,R0   DENSITY           P21...DENSITY
         BAL,R2   CHKBIT
         BAL,R0   XLATE             P22...EBCDIC/ASCII TRANSLATION
*
ENDP     EQU      %
         BAL,SR4  CHKASN
*
*  IF ASN=DEVICE, SKIP MOVING OF FLAGS
*  FROM WORD ZERO OF FPT.
*
         CI,SR4   3
         BE       CAL11N3           BYPASS FOR DEVICE
*  MOVE NXTF, NOSEP, CYL, NXTA, TESTF
         STH,R4   D3
         SLS,D3   -2                FLAGS
         LW,D4    Y01
         STS,D3   NXTF,R6
         LI,R2    0
         STW,R2   DESC,R6           ZAP THE SEARCH OPN MASK
         LW,R2    Y004              RESET NOSEP BIT IF DCB
         LI,R3    X'200'            NOSEP BIT
         AND,R2   FCD,R6            HAS BEEN OPENED BEFORE
         BEZ      %+2
         STS,R2   NOSEP,R6
         LI,R3    X'40000'          NXTA
         LI,D2    X'20000'          CYL
         LI,D4    X'200'            NOSEP
         LI,R5    -3
         CI,R4    X'22000'          IF ADJ DCB OR EXTENDED FPT
         BAZ      %+2
         LI,R5    -7                SKIP EXTRA WORD
         LC       *R7,R5
         BCR,2    %+2
         STS,D2   CYL,R6
         BCR,4    %+2
         STS,D4   NOSEP,R6
         BCR,8    %+2
         LI,R2    X'40000'
         STS,R2   NXTA,R6
*        SET BRS FROM FPT WD 0, BIT 12 TO INDICATE TEST FILE
         LI,R2    -1
         CI,R4    X'22000'
         BAZ      %+2
         LI,R2    -2
         LW,R2    *R2,R7
         BAL,SR4  CHKANS1
         B        NOABCERR
         CW,R2    Y001              ANS FPT BIT
         BAZ      NOABCERR          NO
         LI,R5    X'800'            ANS DCB BIT
         STS,R5   ABCERR,R6
NOABCERR EQU      %
         SLS,R3   1
         STS,R2   TSTF,R6           REALLY BRS, USED HERE FOR TEST FILE FLAG
         AND,R2   R3
         BEZ      CAL11N3           NOT TEST FILE
         LI,D1    1
         BAL,R0   SETFUNCN         FORCE IN MODE FOR TEST FILE
*
*  SEARCH DCB NAME TABLE FOR ADDRESS OF THIS DCB.  IF FOUND,
*  PUT ADDRESS OF TEXTC DCB NAME IN R8 OF PUSHALL IN TSTACK.
*  NAME WILL BE EXAMINED LATER TO DETERMINE IF FILE EXTENSION
*  IS TO BE RESET OR PERFORMED.
*
CAL11N3  LW,R3    J:DCBLINK         POINTER TO FIRST DCB NAME TABLE
         B        CAL11N4C
*
CAL11N4  AI,R2    1
         LW,R3    0,R2              FIRST WORD OF DCB NAME
         LW,D3    R2                SAVE ADDRESS OF NAME
         LB,SR2   R3                BYTE COUNT OF NAME
         BNEZ     CAL11N5           IT'S A REAL NAME
CAL11N4C LI,R2    X'1FFFF'          IS EITHER END OR POINTER TO
         AND,R2   R3                  ANOTHER NAME TABLE
         BEZ      CAL11N9           THE END
         B        CAL11N4           SEARCH THE NEXT TABLE
CAL11N5  SLS,SR2  -2
         AI,SR2   1                 # WORDS IN NAME
         AW,R2    SR2               POINT TO DCB ADDRESS
         CW,R6    0,R2              IS IT THIS DCB
         BNE      CAL11N4           NO
         LW,R3    TSTACK
         STW,D3   -4,R3             YES - SAVE ADDRESS OF NAME
CAL11N9  RES      0
         SPACE    2
         LW,R2    R4                MOVE NEW ASN
         CI,R4    X'2000'
         BANZ     MSROPN08          BR IF ADJUST DCB
*
         CI,R2    X'3FF'
         BAZ      SETFUN            NO VLPS OR ASN - GET OUT
*
MSROPN08 AND,R2   M3                SCRUB ALL BUT NEW ASN
*        IF ASN CHANGES, ZAP CYL BIT IF NOT SPECIFIED IN OPEN FPT
         BEZ      MSROPN10          ASN NOT SPECIFIED
         CI,R2    5                 ANS FPT CODE
         BNE      %+2
         LI,R2    X'A'              ANS DCB CODE
         LI,R3    X'F'
         CS,R2    ASN,R6            IS ASN THE SAME IN FPT AS DCB
         BE       MSROPN09          YES, LEAVE CYL ALONE
         LI,R5    -3
         LC       *R7,R5            WAS CYL SPEC IN FPT
         BCS,2    MSROPN09          YES, LEAVE IT ON
         AI,R3    DCBCYLBIT         NO, ZAP IT
MSROPN09 STS,R2   ASN,R6
*
*  MERGE VARIABLE LENGTH PARAMETERS INTO DCB
*
MSROPN10 AW,R7    R1                POINT TO VLPS
         CI,R4    X'2000'
         BAZ      %+3               BR IF NOT ADJUST DCB FPT
         CI,R4    X'4000'
         BAZ      MSROPN7P          NO VLPS PRESENT
         LW,R1    R4                SAVE FLAGS
         LI,D1    X'1FFFF'
         AND,D1   FLP,R6
         BEZ      MSROPN44          NO VLPS IN DCB
         LW,SR1   R7                SAVE START OF FPT VLPS
*  R7 POINTS TO NEXT VLP CONTROL WORD
MSROPN11 LB,D1    *R7               GET CODE
         BEZ      MSROPN31          SKIP NULL CODE
         CI,D1    1
         BNE      MSROPN20          NOT FILE NAME
         LI,R2    -16
         STB,D1   *TSTACK,R2        REMEMBER THAT FILE NAME WAS SPECIFIED
*
MSROPN20 STW,R7   D3                SAVE FPT POINTER
         BAL,R4   LOCCODEB          SEARCH DCB FOR THIS CODE
         B        MSROPN25          DIDN'T FIND IT
*
MSROPN21 LI,R4    2                 MOVE INFO FROM FPT TO DCB
         LW,R5    R3
         SLS,R5   2
         AI,R5    -1
         LB,R0    *D3,R4            FPT # WORDS USED
         CB,R0    *R7,R5            DCB # WORDS RESERVED
         BLE      MSROPN22          OK
         CLM,D1   SNVLPS            IS IT 7 OR 8
         BCS,9    MSROPN22-1        SKIP IF NOT
         LW,SR3   =X'06000049'      ERROR 49-03
         B        OERX
         LB,R0    *R7,R5            NOT ENOUGH ROOM
MSROPN22 AI,R5    -1
         STB,R0   *R7,R5            SET # WORDS USED IN DCB
*
         LI,R2    1
         AI,R0    0
         BEZ      MSROPN25          NOTHING TO MOVE
MSROPN24 LW,D2    *D3,R2
         STW,D2   *R7,R3            MOVE WORDS FROM FPT TO DCB
         AD,R2    DOUBLEONE
         BDR,R0   MSROPN24
*
MSROPN25 CLM,D1   SNVLPS            IS THIS X'07' OR X'08'
         BCS,9    MSROPN30          NO
         EOR,D1   M4                CHANGE VLP CODE TO THE OTHER
         LW,R7    SR1               POINTER TO FPT VLP LIST
         BAL,R4   LOCCODE           SEARCH FPT FOR OTHER CODE
         B        %+2               NOT PRESENT
         B        MSROPN30          IT IS - NOTHING MORE TO DO
*
         BAL,R4   LOCCODEB          IS IT IN DCB
         B        MSROPN30          NO - NOTHING MORE TO DO
         LI,D1    0                 YES - ALSO MOVE FPT INFO TO
         B        MSROPN21            OTHER VLP CODE IN DCB
*
MSROPN30 LW,R7    D3                RESTORE FPT POINTER
MSROPN31 LW,D2    0,R7              PICK UP LAST CONTROL WORD
         LI,D3    X'FF'
         AND,D3   0,R7
         AW,R7    D3                POINT TO THE
         AI,R7    1                   NEXT CONTROL WORD
         CI,D2    X'10000'
         BAZ      MSROPN11          MORE TO GO
*
         CI,R6    M:XX              IS THIS M:XX
         BNE      MSROPN41          NO
         LW,SR4   MXFPL+1           YES - ERASE THE FETCH
         AND,SR4  MASKS+29            SIGNATURE
         STW,SR4  MXFPL+1
*
MSROPN41 BAL,SR4  DCBNCHK           IS DCB NAME M: OPLABEL
         B        MSROPN44          NO - CAN'T DO FILE EXTENSION
         LI,R4    -16
         LB,R4    *TSTACK,R4
         CI,R4    1                 WAS A FILE NAME IN VLP LIST
         BNE      MSROPN44          NO -
         LW,R4    S:CUN
         LH,R4    UH:FLG,R4
         CI,R4    X'4000'           RESET FILE EXTENSION IF NOT STEP
         BAZ      MSROPN43
         CI,R1    X'2000'           DON'T RESET FILE EXTENSION IF IT IS
         BANZ     MSROPN44            THE ASSIGN/MERGE ADJUST DCB CAL
*
MSROPN43 LI,D1    0
         STS,D1   J:CPPO            TURN OFF FILE EXTENSION
*
MSROPN44 LW,R4    R1                RESTORE FLAGS
         CI,R4    X'2000'
         BAZ      SETFUN            BR IF NOT ADJUST DCB FPT
*
MSROPN7P CI,R4    X'1000'           ARE THERE ANY DEVICE OPTIONS
         BAZ      OPNX              NO - GET OUT
*
*  MERGE DEVICE ORIENTED INFO FROM ADJUST DCB FPT
*
         BAL,R2   CHKBIT1           TABS
         B        %+2
         B        OPNPDV2
         LCI      4
         LM,SR3   1,7
         STM,SR3  15,6
         AI,R1    3
OPNPDV2  EQU      %
         SLS,D3   1
         BEV      OPNPDV3
         LW,D1    *7,R1
         STW,D1   21,6              SEQUENCE ID
         LW,R3    Y04
         STS,R3   5,6
         AI,R1    1
OPNPDV3  EQU      %
         LI,R3    4*19
         BAL,R2   CHKBIT
         STB,D1   *6,R3             DATA TAB
         LI,D2    X'E0000'
         BAL,R2   CHKBIT
         B        %+2
         B        %+3
         SLS,D1   24
         STS,D1   14,6              COUNT TAB
         BAL,R2   CHKBIT
         B        %+2
         B        OPNPDV5
         LI,D2    X'1FFFF'
         STS,D1   19,6              HEADER ADR
         LB,D1    D1
         LI,R3    4*20
         STB,D1   *6,R3             AND HEADER TAB
OPNPDV5  EQU      %
         LI,D2    X'E0000'
         BAL,R2   CHKBIT
         B        %+2
         B        %+3
         SLS,D1   17
         STS,D1   10,6              LINES PER PAGE
         LW,D2    Y00FE
         BAL,R2   CHKBIT
         B        %+2
         B        %+3
         SLS,D1   17
         STS,D1   19,6              SPACE
         BAL,R2   CHKBIT
         B        %+2
         B        OPNDV7            NO Q BITS
         LW,D4    D1
         SLS,D4   9
         LW,R3    D1
         BAL,R2   CKBTGP
         LI,D2    X'8000'           BIT 16
         SLS,D1   25-16
         STS,D1   0,6               DRC
         BAL,R2   CKBTGP
         LI,D2    X'20000'          BIT 14
         SLS,D1   26-14
         STS,D1   0,6               BCD
         BAL,R2   CKBTGP
         LI,D2    X'200'            BIT 22
         SLS,D1   27-22
         STS,D1   0,6               PACK
         BAL,R2   CKBTGP
         LW,D2    Y08               BIT 4
         SLS,D1   28-4
         STS,D1   5,6               SEQ
         BAL,R2   CKBTGP
         LI,D2    X'4000'           BIT 17
         SLS,D1   29-17
         STS,D1   0,6               FBCD
         BAL,R2   CKBTGP
         LI,D2    X'100'            BIT 23
         SLS,D1   30-23
         STS,D1   0,6               VFC
         BAL,R2   CKBTGP
         LI,D2    X'4000'           BIT 17
         SLS,D1   31-17
         STS,D1   1,6               L
*
OPNDV7   LW,D2    Y00FE
         BAL,R2   CHKBIT
         B        %+2
         B        %+3               NOT PRESENT
         SLS,D1   17
         STS,D1   FVA,R6            FVA - STARTING LINE #
*
         B        OPNX              RETURN TO CALLER
         SPACE    2
CKBTGP   EQU      %
         SLS,D4   1
         BEV      3,R2
         LW,D1    R3
         B        0,R2
SETFUN   EQU      %
*                                   SET IT TO INPUT
         BAL,D2   GETFUN
         BNEZ     SETFUN1           USER SPECIFIED FUNCTION
         LI,D1    K1
SETFUN1  EQU      %
         LCW,D2   D1
         AND,D1   D2                CLEAR EXTRA BITS
         BAL,R0   SETFUNCN          STORE IT
*
         LI,R2    X'F'
         AND,R2   ASN,R6
         CI,R2    3
         BE       SETFUN4
*
*  FOR ASN NOT DEVICE, CONVERT DSI FIELD IF NECESSARY FROM TEXT
*  OR OPLABEL TO DEVICE TYPE.
*
         LW,R3    Y004
         CW,R3    0,R6
         BANZ     SETFUN4           DO NOTHING IF ALREADY CONVERTED
         LW,D1    DSI,R6
         LW,R3    DSI,R6
         EOR,R3   Y0001
         CI,R3    X'18000'
         BAZ      KRD1              DIAGNOSTIC OPEN
         LI,R3    X'18000'
         CS,R3    D1
         BNE      6G2               NOT TEXT
         LI,R4    OV:NMSZ
         LI,D2    X'FFFF'
         LH,R3    OH:NM,R4
         CS,D1    R3
         BE       6G4               FIND
         AI,R4    -1
         BGEZ     %-4
         LI,D1    X'FF'             ILLEGAL OPLB
         B        6G2
6G4      LI,D1    0
         CI,R4    LAXOP             LOGICAL OPLBX
         BGE      LAXI
         LB,R3    J:JIT
         SLS,R3   -6
         LW,R3    GETOBTX,R3        OB:-TX
         LB,R4    *R3,R4            GET ASSIGNMENT
         CI,R4    DCTSIZ
         BLE      6G5               DEVICE
         AI,R4    -LAX
         BG       6GL               LOGICAL
         AI,R4    -DCTSIZ-1+LAX     RATX
         LB,D1    SB:RTY,R4         DEVICE
         LI,R4    0                 RAT=0
         B        %+2               DEVICE+RAT
6G5      LB,D1    DCT4,R4
         AI,D1    X'80'
6GX      RES      0
         SLS,D1   8
         AW,D1    R4
6G2      RES      0
         LI,R3    X'3F00'
         AND,R3   D1                TYPE CODE
         SLS,R3   -8
         LC       TB:FLGS,R3        LISTING TYPE DEVICE
         BCS,8    KRD1              NO
         BCR,4    KRD1              NO
         OR,D1    BT31TO0+15  YES-SET LISTING BIT
KRD1     EQU      %
         LI,R4    BARNDEV
         STB,R3   *R6,R4            SAVE DEVICE TYPE
         LI,D2    X'1FFFF'
         STS,D1   DSI,R6
         LB,R3    TB:FLGS,R3
         AND,R3   =X'C4'
         CI,R3    X'80'
         BNE      NOT7T             DEVICE NOT 7T TAPE
         LI,R3    X'20200'          DEFAULT PACKED,BIN FOR 7T
         STS,R3   0,R6
NOT7T    RES      0
SETFUN4  CI,R2    X'A'
         BE       MSRLBT            TREAT ANS LIKE LABELLED TAPE
*
         LI,D2    X'EF7FF'
         AND,D2   ASN,R6            CLEAR EXT AND PRIV
         STW,D2   ASN,R6
*
*  GO TO APPROPRIATE ROUTINE DEPENDING ON ASN:
*    DISK FILE:        OPNFIL
*    LABELLED TAPE:    MSRLBLT
*    DEVICE:           OPENDEV
*    COMMON JOURNAL:   OPNVEC
*    ILLEGAL ASN:      OPENER01 (I/O ERR 01-00)
*
         AI,R2    KN4
         BLEZ     OPNVEC,R2         GO TO APPROPRIATE ROUTINE
         B        OPENER01
*
*E*  ERROR:        01-00
*E*
*E*  DESCRIPTION:  ILLEGAL ASN SPECIFIED IN DCB OR FPT
*
*
SETNEWX  LI,D2    X'FFFF'
         SLD,D1   8
         STS,D1   WRDL0,R6
         B        *R0
*
LRECL    EQU      %
         BAL,SR4  CHKANS1
         B        NOTLRECL
         SLS,D1   17
         LI,D2    X'E0000'
         STS,D1   LRCSZ,R6
         B        NRSTOR
*
CHKANS1  EQU      %
*                      RETURNS SKIPPING IF DCB WILL BE ANS AFTER
*                         FPT MERGE
         PUSH     SR4
         BAL,SR4  CHKASN
         CI,SR4   5
         BGE      PULLEXIT1         ANS
         B        PULLEXIT          NOT ANS
         SPACE    2
CHKASN   EQU      %      RETURNS FPT:ASN IF NON-ZERO, ELSE RETURNS
*                                   DCB:ASN
         PUSH     SR4
         LI,SR4   X'7'
         AND,SR4  R4
         BNEZ     PULLEXIT
         LI,SR4   X'F'
         AND,SR4  ASN,R6
         B        PULLEXIT
         SPACE    3
MSRLBT   EQU      %
         LW,D1    0,6
         AND,D1   NB31TO0+23        CLEAR FCI
         STW,D1   0,6
         LI,1     BADEVTP
         LB,4     *6,1              TYPE
         AND,4    M6
         CI,R4    TYPMNSZ
         BGE      BADTAPE           ILLEGAL TYPE - USE DEFAULT
         LC       TB:FLGS,4         KIND OF DEVICE
         BCR,8    %+2               NOT TAPE
         BCR,4    DTAPE
BADTAPE  LI,R4    X'80'+SV:DFTP     DEFAULT TAPE TYPE
         STB,4    *6,1              TYPE
DTAPE    RES      0
MSRLBT1  BAL,D2   GETFUNA
         BANZ     OPNLO             OUTPUT TAPE
         B        OPNLA             INPUT TAPE
         SPACE    2
         B        OPENER01          ASN=0, I/O ERR 01-00
         B        OPNFIL            DISK FILE
         B        MSRLBT            LABELLED TAPE
         B        OPENDEV           DEVICE
OPNVEC   RES      0                 COMMON JOURNAL
*
*        DCB ASN = 4, COMMON JOURNAL TYPE
*
CFU#CJ   EQU      16                JOURNAL CFU TYPE
*
*
*        CHECK FOR AUTHORIZATION OF COMMON JOURNAL
*
         LB,R2    JB:PRIV           GET USER PRIVILEGE
         CI,R2    X'C0'             'C0' OR GREATER IS OK
         BGE      CJAUTH3           SO NO NEED TO CHECK
         LI,R2    X'F0000'+'CJ'     LOOK FOR 'CJ'
         LI,R1    SV:FTYM           AS AUTHORIZABLE RESOURCE
CJAUTH1  CH,R2    SH:SYMT,R1
         BNE      CJAUTH2           NOT FOUND YET
*
*        'CJ' IS A RESOURCE...IS THIS USER AUTHORIZED
*
         LI,R2    JH:LDCF           GET AUTHORIZATION HALFWORD
         LH,R2    0,R2              FROM JIT
         SLS,R2   0,R1              POSITION THIS BIT
         CI,R2    X'8000'           IS 'CJ' AUTHORIZED
         BANZ     CJAUTH3           YES
*E*
*E*      ERROR:   14-00
*E*      DESCRIPTION:  THIS USER IS NOT AUTHORIZED FOR THE COMMON
*E*               JOURNAL.
*E*
         B        ER1400            RETURN ABN 14-00
*
CJAUTH2  BDR,R1   CJAUTH1           CONTINUE CHECKING
CJAUTH3  EQU      %                 OPEN OF COMMON JOURNAL OK
*
         BAL,R0   CHKFLACN
         BAL,R0   GETFILADR         A(FILENAME)
         XW,R7    KBUF,R6           AND SAVE IN KBUF
         PUSH     R7                TEMPORARILY
         BAL,SR1  SCANJRNLCFU       LOOK FOR JRNL IN CFUS
         LI,SR1   0                 NOT FOUND RETURN
         PULL     R7                FOUND RETURNS HERE
         STW,R7   KBUF,R6           RESTORE KBUF
         AI,SR1   0                 DID WE FIND IT
         BEZ      OPENER            NO, OPEN ERROR
         LI,D4    X'1FFFF'
         STS,D3   11,R6             SAVE CFU ADDRESS
         MTH,2    *D3               INCREMENT USE COUNT
         LI,D1    2
         BAL,R0   SETFUNCN          SET FUNCTION
         LW,D4    Y002
         STS,D4   FCD,R6            SET DCB OPEN
         B        OPNX              AND RETURN
*
*        SCAN THE CFU'S FOR A COMMON JOURNAL CFU
*
SCANJRNLCFU EQU   %
         LI,R2    BGRCFU            START OF CFU'S
*
SCANCONT EQU      %
         LI,R7    2
         LB,R3    *R2,R7
         CI,R3    CFU#CJ            JOURNAL CFU TYPE
         BE       JRNLFND           YES
NOMATCH  EQU      %
         AI,R2    CFUSIZE
         CW,R2    ACNCFU+13
         BL       SCANCONT          NOT DONE YET
         B        *SR1              NOT FOUND EXIT
*
JRNLFND  EQU      %
         PUSH     2,R1
         BAL,R0   GETACNADR         A(ACCOUNT)
         PULL     2,R1
         LW,D1    0,R7              ACCT NAME
         LW,D2    1,R7
         LW,R5    KBUF,R6           A(FILENAME)
         SLS,R5   2
         LB,R4    0,R5              BYTE COUNT
         AI,R4    1
         STB,R4   R5                SET UP FOR CBS
         LI,R7    4
         LI,R4    5
         LH,R3    *R2,R7            DW INDEX TO ACCT
         CD,D1    *ACNCFU+13,R3
         BNE      NOMATCH           NOT THIS JRNL CFU
         LH,SR3   *R2,R4
         SLS,SR3  2                 BA(FILENAME
         LW,SR4   R5
         CBS,SR3  0                 CHECK FILENAMES
         BNE      NOMATCH           NOT THIS JRNL CFU
         LW,D3    R2                CFU ADDR TO R14
         AI,SR1   1
         B        *SR1              FOUND CFU RETURN
*
SETFUNC  CI,D1    X'200'            CHK P BIT
         BAZ      SETFUNCN          NOT ON
         LW,R2    D1
         LI,R3    X'100'
         SLD,R2   9
SHARE    EQU      7
         STS,R2   SHARE,R6          STUFF THE S BIT
         B        SETFUNCN
*
*
MSROPN52 LI,D2    3
         SLD,D1   30                REL/SAVE
MSROPN53 STS,D1   FIL1,R6
         B        *R0
MSROPN51 LI,D2    X'70'
         SLS,D1   4
         DO       ORG=FIL1
         B        MSROPN53
         ELSE
         STS,D1   ORG,R6
         B        *R0
         FIN
DENSITY  SCS,D1   -6                P21...DENSITY
         LW,D2    Y04
         B        MSROPN53
*
XLATE    SLS,D1   7                 P22...TRANSLATION
         LI,D2    X'80'
         B        MSROPN53
         SPACE    2
MSROPN5A EOR,D1   Y0001             P14...DEVICE TYPE
         LI,D2    X'1FFFF'
         STS,D1   DSI,R6            SET DSI FIELD
         CI,R4    7                 IF THERE'S NO ASN  IN THE FPT
         BANZ     *R0               ....
         LI,R2    3                 SET ASN TO 3(DEVICE)
         LW,R3    =X'0040000F'      RESET FCI(Y004)
         STS,R2   ASN,R6
         B        *R0
         SPACE    3
*
LAXOP    EQU      OV:NMSZ-SV:LSIZ
LAX      EQU      DCTSIZ+SV:RSIZ+2
LAXI     AI,R4    -LAXOP
6GL      LB,D1    SB:LTY,R4
         AI,R4    LAX
         LW,3     Y004
         STS,3    0,6               SET FCI
         B        6GX               PUT IT AWAY
*
Y08FF    GEN,8,8,16 8,X'FF',0
         BOUND    8
SNVLPS   DATA     7,8
OPNLA    OVERTO   OPNTPSEG,OPNLA#
OPNLO    OVERTO   OPNTPSEG,OPNLO#
OPENDEV  OVERTO   MULSEG,OPNDEV#
         PAGE
*D*
*D*      NAME:    ASSMRG
*D*
*D*      REGISTERS: ALL VOLATILE
*D*
*D*      CALL:    OVERLAY CALL TO OPNSEG,3
*D*
*D*      INPUT:   R6 = ADDR. OF M:GO DCB (OR 0)
*D*
*D*      DESCRIPTION:  IF THERE IS AN M:GO DCB IT IS INITIALIZED.
*D*
ASSMRG   EQU      %
         PUSH     SR4               SAVE RETURN
         AI,R6    0                 IS THERE AN M:GO DCB
         BEZ      ASM2              NO
         LI,D1    1                 CODE 01 = FILE NAME
         BAL,R5   LOCCODEA          IS IT ALREADY ASSIGNED
         B        %+2               NO
         B        ASM2              NAME IN M:GO-IGNORE IT
         LW,R7    TSTACK            ADDR FOR FPT
         AI,R7    2                   +1
         LCI      8                 BUILD FPT
         LM,D1    GOFPT
         INT,R1   J:JIT
         SLS,R1   8
         AI,R1    'G'
         MTB,3    R1                LENGTH OF FILE NAME
         PUSH     8,D1              FPT TO TSTACK
         BAL,SR4  MSROPNA           ADJUST M:GO DCB
         PULL     8,D1              CLEAR FPT OUT OF TSTACK
*
*
*
ASM2     LW,R4    J:ABUF            ADDR OF ASSIGN/MERGE RECORD
         AI,R4    1                 ADDR OF INDEX TO 1ST ENTRY
*
ASM4     LW,R7    0,R4              GET INDEX TO NEXT A/M ENTRY
         BEZ      PULLEXIT          PULL R0/B *R0
         AW,7     J:ABUF            ADDR OF ENTRY
         LW,R4    R7                REMEMBER IT
         AI,R7    1                 ADDR. OF TEXTC NAME IN A/M RECORD
         LI,R1    J:DCBLINK         ADDR OF DCB NAME TABLE ADDRESS
*
ASM5     LW,R1    0,R1              LINK TO NEXT DCB NAME CHAIN
         BEZ      ASM4              NONE-GET NEXT A/M ENTRY
*
ASM6     AI,R1    1                 ADDR OF 1ST DCB NAME
ASM6A    LB,R5    *R1               LENGTH OF DCB NAME IN DCB TABLE
         BEZ      ASM5              NONE-MUST BE LINK
         LW,R2    R5                BYTE COUNT
         SLS,R2   -2
         AI,R2    2                 TO POINT TO NEXT ENTRY AND FPT+1
         CB,R5    *R7               IS A/M NAME LENGTH = DCB NAME LENGTH
         BNE      ASM8              NO
ASM7     LB,SR4   *R7,R5            LOAD FROM A/M RECORD
         CB,SR4   *R1,R5             AND COMPARE WITH DCB TABLE
         BNE      ASM8              NO MATCH
         BDR,R5   ASM7              CHECK ALL CHARACTERS
*
*  FOUND MATCHING ENTRIES
*
         AW,R7    R2                ADDR OF A/M FPT+1
         AI,R2    -1                TO GET DCB ADDR
         LW,R6    *R1,R2
         PUSH     R4                SAVE INDEX TO NEXT A/M ENTRY
         BAL,SR4  MSROPNA           ADJUST DCB
         PULL     R4                RESTORE INDEX
         B        ASM4              AND GO GET NEXT A/M RECORD ENTRY
*
*NO MATCH
*
ASM8     AW,R1    R2                POINT TO NEXT NAME IN DCB TABLE
         B        ASM6A             AND SEE IF IT MATCHES THIS A/M FPT
*
*FPT TO INITIALIZE M:GO
*
GOFPT    DATA     0
         DATA     X'E009'
         DATA     X'01000000'
         DATA     2                 OUT
         DATA,1   1,0,1,1           FILE NAME PRESENT
         RES      1                 FOR FILE NAME
         DATA,1   2,0,0,0
         DATA,1   7,1,0,0
         END

