*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
 TITLE ' MERGE M:OPEN FPT INTO DCB, PROCESS ADJUST DCB CAL '
OPN:     EQU      %
     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
         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      OPENER0E          REPORT 0E-00  ABNORMAL
         REF      J:BASE            TEMP JIT STORAGE
         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      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      J:DCBLINK         FIRST DCB NAME TABLE
         REF      UH:FLG            STEP RUNNING FLAG
         REF      CHKBIT1           FIND PARAMETER PRESENCE WORD
         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      SH:OPNM           OP LABELS
         REF      YFFF              BITS 0-11
         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
*
*        DONT RUN OPEN ON SLAVE CPU'S
*
         BLOCK                       BACK TO THE MASTER IF NECESSARY
*
         LW,1     0
         B        OPNTV,1
         BOUND    8
SNVLPS   DATA     7,8
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                 RESERVE
         B        MSROPN5           ENTER FROM CALPROC
         PAGE
*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   LW,R1    J:DCBLINK         POINTER TO 1ST DCB NAME TABLE
         B        CAL11N4C          ENTER LOOP
*
CAL11N4  AI,R2    1
         LW,R1    0,R2              1ST WD OF DCB NAME
         LW,R3    R2                SAVE ADDRESS OF NAME
         LB,R4    R1                # OF BYTES IN NAME
         BNEZ     CAL11N5           IT'S A REAL NAME
CAL11N4C LI,R2    X'1FFFF'          IT'S AN END OR A POINTER
         AND,R2   R1                 TO NEXT NAME TABLE
         BEZ      MSROPN6           THE END, NO EXTENSION
         B        CAL11N4           SEARCH THE NEXT TABLE
CAL11N5  SLS,R4   -2
         AI,R4    1                 # OF WDS IN NAME
         AW,R2    R4                POINT TO DCB ADDRESS
         CW,R6    0,R2              IS IT A MATCH
         BNE      CAL11N4           NO, TRY AGAIN
*******  WE HAVE FOUNG THE DCB NAME, NOW CHECK FOR FILE EXTENSION
OPFIND   LCI      2
         LM,D1    0,R3              1ST 2 WDS OF NAME
         SLD,D1   -8
         CI,D1    X'4D47A'          CHK FOR 4 BYTES & M:
         BNE      MSROPN6           NO FILE EXTENSION
         LI,SR1   1                 ASSUME IT IS M:GO
         LH,D1    D2
         CI,D1    X'FC7D6'          IS IT M:GO
         BE       MSROPN6P
         LI,R2    17                # DCBS FOR FILE XTNSN
OPFIND1  CH,D1    SH:OPNM,R2        FIND M:II OPLB
         BE       OPFIND2           WE FOUND A MATCH
         BDR,R2   OPFIND1
         B        MSROPN6           SET NO FILE XTNSN
OPFIND2  RES      0
         SLS,SR1  -1,R2             ALIGN TO J:CPPO
         B        MSROPN6P
*
***      ENTER HERE FROM CALPROC ON FOR M:OPN CALS
MSROPN5  CI,R6    M:XX              IS IT XX
         BNE      OPFIND            ENTER TEST IF NOT
MSROPN6  LI,SR1   0                 NO FILE EXTENSION
         PAGE
MSROPN6P RES      0
         BAL,R1   PUSHALL
         LI,SR3   X'2E'             OPEN A DCB WHICH IS ALREADY OPEN
         LW,R1    0,R6
         CW,R1    Y002              IS DCB ALREADY OPEN
         BANZ     OERX              BAD NEWS
*
*E*  ERROR:        2E-00
*E*
*E*  DESCRIPTION:  ATTEMPT TO OPEN A DCB THAT IS ALREADY OPEN
*
         LI,SR1   0                 GENERAL RESETTER
         LI,SR2   X'DFFFF'          RESET FCN & QBUF
         STS,SR1  QBUF,R6            BUT LEAVE SHARE
         LW,SR3   -1,R7             WD 0 OF FPT
         LI,D4    X'FF000'          ASSUME NOT ADJUST OR XTNDED
*
         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      %+3               SKIP IF NOT ADJST OR XTNDD
         LI,D4    X'FFC00'          PRESENCE BIT ACTIVITY MASK
         AI,R7    1                 INCR POINTER IF ADJUST OR EXTENDED
*
         LW,D3    0,R7              PRESENCE BITS FOR P OPTIONS
         CW,R1    Y004
         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,SR2   M23               RESET FLAGS
         STS,SR1  0,R6               IN WD 0
         LW,R1    R6
         SLS,R1   2
         AW,R1    L(32**24+14**2)   ZAP WORDS
         MBS,0    8**2               14 THRU 21
         LW,SR2   =X'0C000080'
         STS,SR1  5,R6              RESET SEQ ID PRESENT, ETC.
*
         PAGE
MSROPN1C RES      0                 PROCESS STANDARD OPTIONS(P1-P22)
         LI,R5    EXULIST-1         ACTION LIST START
         B        PLENTER           START P OPTION PROCESSING
         SPACE    3
***      ACTION LIST FOR WHAT TO DO IF A P OPTION IS SPECIFIED
***
EXULIST  STS,D1   ERA,R6            P1, ERROR ADDRESS
         STS,D1   ABA,R6            P2, ABNORMAL ADDRESS
         STS,D1   BUF,R6            P3, BUFFER ADDRESS
         BAL,R0   SAVRSZ            P4, DEFAULT RECORD SIZE
         B        SETNRA            P5, # OF RECOVERY TRIES
         B        MSROPN51          P6, ORGANIZATION
         B        SETACS            P7, ACCESS METHOD
         BAL,R0   SETFUNC           P8, FUNCTION MODE & SHARED USE STATE
         NOP                        P9, GENERATION(NOT IMPLEMENTED)
         B        MSROPN52          P10, DISPOSITION
         STS,D1   FPARAM,R6         P11, FILE PARAMS BUFFER ADDRESS
         STS,D1   TLB,R6            P12, TAPE LABEL BFR ADDRESS
         B        SETKEYM           P13, MAX KEY LENGTH
         B        MSROPN5A          P14, DEVICE INFO
         BAL,R0   RESBTD            P15, BYTE DISPLACEMENT
         B        SETVOL            P16, INDEX TO SN LIST
         B        SETNEWX           P17, UPPER LVL CONTROL INFO
         B        OPN18             P18, SPARE OR CONCATENATION
         B        PLCW              P19, NOT MEANINGFUL
         B        LRECL             P20, # GRANS OR REC SIZE
         B        DENSITY           P21, TAPE DENSITY
         B        XLATE             P22, EBCDIC/ASCII XLATION
         SPACE    3
PLLOOP   LI,D2    X'1FFFF'          MOST USEFUL STORE MASK
         AI,R5    1                 POSITION IN ACTION LIST
         SLD,D3   1                 CHK NEXT P OPTION
         BEV      %-2               GO BACK IF NO ACTION ON THIS 1
         LW,D1    0,R7              APPROPRIATE FPT ITEM
         BGEZ     PLNOI             SKIP IF NOT INDIRECT
         CI,D1    X'1FFF0'          IS IT A REGISTER?
         BANZ     %+2               SKIP IF NOT A REGISTER
         AW,D1    J:BASE            LOC OF REGS IN STACK
         LW,D1    *D1               GET THE INDIRECT
PLNOI    EXU      0,R5              PERFORM THE ACTION
PLENTER  AI,R7    1                 NEXT FPT ITEM
PLCW     CW,D3    D4                CHK FOR ANY MORE ACTION
         BANZ     PLLOOP            LOOP IF MORE TO DO
***               END OF P OPTION PROCESSING
         PAGE
         LI,R5    0                 ASSUME NO SETTINGS TO WD 0
         BAL,R0   CHKASN
*
*  IF ASN=DEVICE, SKIP MOVING OF FLAGS
*  FROM WORD ZERO OF FPT.
*
         CI,SR4   3
         BE       CAL11N9           BYPASS FOR DEVICE
*  MOVE NXTF, NOSEP, CYL, NXTA, TESTF
         STH,R4   D3
         SLS,D3   -2                FLAGS
         LW,D4    Y01
*        OPTION F2, NEXT FILE REQUEST
         STS,D3   NXTF,R6
         STW,R5   DESC,R6           ZAP THE SRCH 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
         LW,SR4   Y0008             TO SET TEST FILE
*        TEST FILE SPECIFICATION
         STS,SR3  TSTF,R6           CALLED BRS, BUT TEST DURING OPEN
         CW,SR3   Y0008             IF IT'S A TEST,
         BAZ      %+5
         LI,D1    1                 FORCE FUNCTION TO INPUT
         LI,D2    X'20000'
         STS,D1   SHARE,R6          RESET SHARE FLAG
         BAL,R0   SETFUNCN
         CW,SR3   Y001              CHK ABCERR FOR ANS TAPE
         BAZ      %+2               SKIP IF NOT
*        BLOCK COUNT ERROR SEVERITY FOR ANS TAPES(ABCERR)
         LI,R5    X'800'            ABCERR BIT
         CW,SR3   Y002              CHECK FOR CYLINDER
         BAZ      %+2               SKIP IF NOT CYLINDER
*        REQUEST FOR CYLIDER ALLOCATED DEVICE GRANULES
         AI,R5    X'20000'          TO SET CYLINDER
         CW,SR3   Y004              CHK FOR NOSEP
         BAZ      %+2               SKIP IF NOT NOSEP
         AI,R5    X'200'            TO SET NOSEP
*        REQUEST NO SEPARATION OF DATA & INDEX GRANULES
         STS,R5   NOSEP,R6          NOSEP, CYL, & ABCERR
         SLS,SR3  -5                ALIGN FOR NEXT ACCOUNT
         LI,SR4   X'40000'          SET OR RESET
*        NEXT ACCOUNT SPECIFICATION
         STS,SR3  NXTA,R6            NEXT ACCOUNT INDICATOR
CAL11N9  RES      0
         SPACE    2
         LW,R2    R4                MOVE NEW ASN
         CI,R4    X'23FF'           CHK ADJUST DCB OR
         BAZ      SETFUN            NO VLPS OR ASN - GET OUT
*
         LW,R1    R4                SAVE FLAGS
         AND,R2   M3                EXTRACT NEW ASN, IF ANY
*        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       MSROPN10          YES, LEAVE CYL ALONE
         CI,R5    X'20000'          WAS CYL ON IN THE FPT?
         BANZ     MSROPN09          YES, LEAVE IT ON
         AI,R3    DCBCYLBIT         NO, ZAP IT
MSROPN09 STS,R2   ASN,R6
         PAGE
*
*  MERGE VARIABLE LENGTH PARAMETERS INTO DCB
*
*          CHK TO SEE IF THERE IS A VLP
*
MSROPN10 CI,R4    X'2000'           IS IT THE M:ADJUST
         BAZ      SETFUN3           BRANCH IF NOT
         CI,R4    X'4000'           ARE THERE ANY VLP'S?
         BAZ      MSROPN7P          NO VLPS PRESENT
MSROPN12 RES      0
         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
         LI,R2    -4
         CI,D1    1
         BNE      MSROPN20          NOT FILE NAME
         LW,D3    *TSTACK,R2
         BEZ      MSROPN20          NO FILE EXTENSION
         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
*E*      ERROR:   49-03
*E*      DESCRIPTION:  NOT ENUF ROOM IN DCB'S VLP FOR SERIAL# LIST
MSROPN49 LW,SR3   L(X'06000049')    ERROR 49-03
         CLM,D1   SNVLPS            IS IT 7 OR 8
         BCR,9    OERX              ERROR IF SO
         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        MSROPN29          IT IS- MAKE SURE THIS ONE GOT IN
*
         BAL,R4   LOCCODEB          IS IT IN DCB
         B        MSROPN29          NO - MAKE SURE THIS ONE GOT IN
         LI,D1    0                 YES - ALSO MOVE FPT INFO TO
         B        MSROPN21            OTHER VLP CODE IN DCB
MSROPN29 LW,R7    *D3               NO DCB VLP - ONLY RESET WORKS.
         CI,R7    X'FF00'
         BAZ      MSROPN30          O.K.
         BIR,R2   MSROPN49          IF R2 STILL NEGATIVE, ABORT.
*
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
         CW,D2    Y00FF
         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 LI,R4    -4
         LW,D2    *TSTACK,R4
         BEZ      MSROPN44          SKIP IF NO EXTENSION
         LB,R4    D2
         BEZ      MSROPN44          SKIP IF NAME NOT SPECIFIED
         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
         AND,D2   M17               GET RID OF THE Y01
         STS,D1   J:CPPO            TURN OFF FILE EXTENSION
*
         PAGE
MSROPN44 CI,R1    X'2000'           IS IT M:ADJUST
         BAZ      SETFUN            BR IF NOT ADJUST DCB FPT
*
MSROPN7P CI,R1    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
         PAGE
SETFUN3  CI,R4    X'3FF'            NORMAL M:OPEN
         BANZ     MSROPN12          THERE IS SOMETHING
SETFUN   EQU      %
         BAL,D2   GETFUN
         BNEZ     SETFUN1           USER SPECIFIED FUNCTION
         LI,D1    1                 MAKE IT INPUT
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)
*
         LI,SR3   1                 IN CASE ASN IS BAD
         AI,R2    -4
         BLEZ     OPNVEC,R2         GO TO APPROPRIATE ROUTINE
*
*E*  ERROR:        01-00
*E*
*E*  DESCRIPTION:  ILLEGAL ASN SPECIFIED IN DCB OR FPT
*
         B        OERX              BAD ASN
         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
*
SETNEWX  LI,D2    X'FFFF'
         SLD,D1   8
         STS,D1   WRDL0,R6
         B        PLENTER           PROCESS MORE P OPTIONS
*
LRECL    EQU      %
         BAL,SR4  CHKANS1
         B        NOTLRECL
         SLD,D1   17
         STS,D1   LRCSZ,R6
         B        PLENTER           PROCESS MORE P OPTIONS
*
NOTLRECL CI,SR4   1                 IGNORE PARAMETER IF
         BNE      PLENTER             NOT FILE.
         LI,D2    X'FFFF'           STORE MASK
         STS,D1   RSTORE,R6         LO ORDER 16 BITS TO RSTORE
         AND,D1   Y00FF             CHK FOR EXTENDED
         BEZ      %+2               SKIP IF NOT
         AW,D1    Y08               SET THE FLAG FOR XTNDD
         LW,D2    Y08FF             STORE MASK
         B        MSROPN53          GO DO IT
*
CHKANS1  EQU      %
*                      RETURNS SKIPPING IF DCB WILL BE ANS AFTER
*                         FPT MERGE
         PUSH     SR4
         BAL,R0   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
         LI,SR4   X'7'
         AND,SR4  R4
         BNEZ     *R0
         LI,SR4   X'F'
         AND,SR4  ASN,R6
         B        *R0
         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
         BAL,D2   GETFUNA
         BANZ     OPNLO             OUTPUT TAPE
         B        OPNLA             INPUT TAPE
         SPACE    2
CJAUTH2  BDR,R1   CJAUTH1           CONTINUE CHECKING
CJAUTH3  EQU      %                 OPEN OF COMMON JOURNAL OK
*
         BAL,R0   CHKFLACN
         BAL,R0   GETACNADR         A(ACCOUNT)
         LCI      2
         LM,D1    0,R7              ACCOUNT NAME
         BAL,R0   GETFILADR         A(FILE NAME)
         SLS,R7   2                 BYTE ALIGN
         LB,R4    0,R7              BYTE COUNT
         AI,R4    1                 INCLUDE TEXTC COUNT
         STB,R4   R7                SETUP FOR CBS LATER
**************    LOOK FOR COMMON JOURNALS IN THE CFU'S
         LI,R3    CFU#CJ**8         JOURNAL CFU FUNCTION
         LI,R2    BGRCFU            START OF CFU'S
SCANCONT CW,R3    0,R2              IS IT A JOURNAL CFU
         BAZ      NOMATCH           SKIP IF NOT
         LI,R4    4                 HA(ACCT) IN CFU
         LH,R4    *R2,R4            ACCOUNT INDEX
         CD,D1    *ACNCFU+13,R4     CHK THE ACCOUNT
         BNE      NOMATCH           NOT THIS ONE
         LI,R4    5                 HA(NAME) IN CFU
         LH,SR3   *R2,R4            ADDRESS OF FILE NAME
         SLS,SR3  2                 BYTE ALIGN
         LW,SR4   R7
         CBS,SR3  0                 CHK FILE NAMES
         BNE      NOMATCH           NOT THIS ONE
********          WE FOUND THE JOURNAL CFU FOR THIS JOURNAL
         LI,R3    X'1FFFF'
         STS,R2   11,R6             SAVE THE CFU LOCATION
         LW,R3    Y00FE             ARE THERE 127 USERS ALREADY
         CS,R3    0,R2
         BE       OPENER0E          REPORT 0E-00 ERROR
*E*      ERROR:   0E-00
*E*      DESCRIPTION:  TOO MANYY USERS OF A CFU
*
         MTH,2    *R2               UP THE USE COUNT
         LI,D1    2
         BAL,R0   SETFUNCN          SET FUNCTION
         LW,D4    Y002
         STS,D4   FCD,R6            SET DCB OPEN
         B        OPNX              AND RETURN
*
NOMATCH  AI,R2    CFUSIZE           TRY THE NEXT CFU
         CW,R2    ACNCFU+13         HAVE WE HIT THE END?
         BL       SCANCONT          KEEP GOING
         B        OPENER            IT'S AN 03-00
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        PLENTER           PROCESS MORE P OPTIONS
MSROPN51 LI,D2    X'70'
         SLS,D1   4
         B        MSROPN53
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
         STS,D1   DSI,R6            SET DSI FIELD
         LW,R3    Y004
         LI,R2    3
         CI,R4    7                 IF THERE'S NO ASN  IN THE FPT
         BANZ     %+2               DONT CHANGE DCB'S
         AI,R3    X'F'              BUT ALWAYS RESET FCI (Y004)
         STS,R2   ASN,R6
         B        PLENTER           PROCESS MORE P OPTIONS
*
SETNRA   LI,R3    BANRA             RETRIES BYTE ADDRESS
SETN     STB,D1   *R6,R3            SET THE OPTION
         B        PLENTER           PROCESS MORE P OPTIONS
*
SETACS   LI,D2    7                 STORE MASK FOR ACCESS
         B        MSROPN53          GO DO IT
*
SETKEYM  LI,R3    BAKEYM            MAX KEY LENGTH BYTE ADDRESS
         B        SETN
*
SETVOL   LI,R3    BACOS             REEL# INDEX BYTE ADDRESS
         B        SETN
*
OPN18    LI,R3    BACONCAT  CONCATINATION IF ANS TAPE
         BAL,SR4  CHKANS1           SEE IF IT'S ANS TAPE
         LI,R3    BASPARE           SPARE SPACE IF NOT ANS
         B        SETN
*
         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
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
         LI,SR3   1                 ADDRESS OF INDEX TO 1ST ENTRY
         AW,SR3   J:ABUF             IN ASSIGN/MERGE RECORD
         AI,R6    0                 IS THERE AN M:GO DCB
         BEZ      ASM4              SKIP IF NO M:GO DCB
         LI,D1    1                 CODE 01 = FILE NAME
         BAL,R5   LOCCODEA          IS IT ALREADY ASSIGNED
         B        %+2               NO
         B        ASM4              NAME ALREADY IN M:GO
         LW,R7    TSTACK            ADDR FOR FPT
         AI,R7    3                  +1
         LCI      8                 BUILD FPT
         LM,SR4   GOFPT             SKELETON ADJUST FPT
         INT,R5   J:JIT             SYSID
         SLS,R5   8                 ALIGN TO 1ST 2 CHAR POSNS
         OR,R0    R5                INSERT IT
ASM2     LI,R3    X'1FFFF'          RESET ERR ADDR FOR 49-03 TO ABORT
         AND,R3   ERA,R6
         LW,R2    GONOSN
         STS,R2   ERA,R6
         PUSH     10,SR3            FPT OR STUFF TO STACK
         BAL,SR4  MSROPNA           ADJUST M:GO DCB
         PULL     10,SR3            JUSTIFY STACK
         STS,R3   ERA,R6            RESTORE ERA
*
ASM4     LW,R7    *SR3              INDEX TO NEXT A/M ENTRY
         BEZ      PULLEXIT          PULL R0/B *R0
         AW,7     J:ABUF            ADDR OF ENTRY
         LW,SR3   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
*
         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
         B        ASM2              DO THE ADJUST
*
*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
         DATA     3**24+'G'         FOR FILE NAME
         DATA,1   2,0,0,0
GONOSN   DATA     X'7FE0000'
         END

