*        PART 2 OF SORTP0
* CATALOG NO 704985-0    SIGMA 5/7 SORT           OVERLAY 0
*  VERSION C00
         SYSTEM   SIG7FDP
         SYSTEM   BPM
PGMSEG0  CSECT    0
*
         PAGE
*
         DEF      SCR1X,SIN21X,SIN122X,SIN2X,SIN24X
         DEF      SIN28X,SIN29X,SIN22X
         REF      SETCD10,SETCD45,SIN145,SIN121,SIN27A
         REF      SIN24,SIN285,SIN295,SCR2
         REF      F:SORTIN,F:SORTOUT
         REF      FIT0,FIT1,FIT2,FIT3,FIT4,FIT5,FIT6,FIT7,BCT0
         REF      TRKSZ,TRKSB,STCAD,PMSRCD
         REF      CPER
         REF      OUTSEQK,OCSEQ,OUTOWNCD
         REF      ILT0,SORTSV
         REF      CNVRT,SEQLNG,SEQRCD
         REF      BNEBC,EBCBN
         REF      SLICEFL
         REF      SC50,OSO,S:OUT
         REF      FWRD,CALLSW
         REF      SIN1R
         REF      PRAMLOC
         REF      ENDSNAP
         REF      KTTL
         REF      KLNGC
         REF      SINTMP,RLKCM
         REF      BLKCTLSY          OUTPUT
         REF      BLKCTLSZ          INPUT
         REF      ANSISWIN          INPUT
         REF      ANSISWOU          OUTPUT
         REF      NUMPGS
         REF      CKDEC,ALLBL,SIN2R,GIL1,ER2
*
         PAGE
*
X0       EQU      0
X1       EQU      1
X2       EQU      2
X3       EQU      3
X4       EQU      4
X5       EQU      5
X6       EQU      6
X7       EQU      7
R0       EQU      8
R1       EQU      9
R2       EQU      10
R3       EQU      11
R4       EQU      12
R5       EQU      13
R6       EQU      14
R7       EQU      15
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
RA       EQU      10
RB       EQU      11
RC       EQU      12
RD       EQU      13
RE       EQU      14
RF       EQU      15
R13      EQU      13
R14      EQU      14
BINEBC   EQU      BNEBC
SETCD4   EQU      SETCD10
*
*
         PAGE
         BOUND    8
*
*
*
*                                                                /VALUES
INCLS    DATA     0
*
OSOHOOK  BAL,5    OUTOWNCD           TO RTN TO PROCESS USER OWN CD
SEQHOOK  BAL,5    OCSEQ              TO SEQ CHK RTN
ANSSW    DATA     0                 HOLD 1 IF USERS DCB IS ANS
         PAGE
SCR1X    RES      0
         LI,6     ENDP01
         STW,6    ENDSNAP            DUMP IN CASE OF ERROR
         STW,9    6                 SAVE FOR INOPD RTN
         LH,9     CALLSW
         BNE       SCR2
         LW,X7    SORTSV+6               AND OUTPUT FILES IF
         BE       SCR2              BUT BYPASS IF NO DCB'S /SIG7-1035/*C4986
          LI,R0   F:SORTIN               THE SORT IS CALLED BY
         BAL,R1    INOPD                  A USER'S PROGRAM
         LI,R0    F:SORTOUT               (AS A SUBROUTINE)
         BAL,R1   INOPD
         STW,X7   SORTSV+6          OUTPUT LABEL ADDRESS IF ANY
         LB,9     *7                 USER LABEL SPEC
         BNEZ     SCR2
         LI,9     0                 CLEAR NO LABEL GIVEN
         STW,9    SORTSV+6          0 FOR OUT HDR/TRLR RTNS TO CHK
         B        SCR2             RETURN TO CO-RES P0
         PAGE
*  THIS REGION TESTS VALIDITY OF INPUT/OUTPUT FILE FORMAT
*                 (A PARAMETER REQUIRED FOR ALL FILES).
SIN21X   RES      0
         LW,5     F:SORTIN
         SLS,5    +28
         SLS,5    -28
* 3=NON BLOCKABLE DEV,B=BLOCKABLE DEV,A=ANSI
         CI,5     X'A'              ANSI
         BE       SINEAAA
         LB,5     *PRAMLOC          GOOD IF NOT CALLED BY PREPROC
         CI,5     X'C6'              FOREIGN FILE
         BNE      SINED
         STW,5    FWRD
         B        SINED
SINEAAA  LW,7     F:SORTIN+5
         SLS,7    +24
         SLS,7    -28               HAS BITS 24-27 IN BITS 28-31
         CI,7     1                 1 FOR ANSI FIXED
         BG       SINEA
         CI,7     0
         BE       SINEC
         LI,7     3                 3 FOR ANSI FIXED IN SWITCH
         STW,7    ANSISWIN
         B        SINED             CHECK OUT TYPE
SINEA    CI,7     3                 3 FOR ANSI VAR
         BNE      SINEB
         LI,7     2                 2 FOR ANSI BLOCKED VAR
         STW,7    ANSISWIN
         LI,7     4                 4 FOR BLK-CTL-FIELD INPUT
         STW,7    BLKCTLSZ          (MAY BE CHANGED IF UTS GIVES IT)
         B        SINED
SINEB    CI,7     4                 4 FOR ANSI UNDEFINED
         BNE      SINEC
         LI,7     1                 1 FOR ANSI UNDEFINED
         STW,7    ANSISWIN
         B        SINED
SINEC    LI,7     18                 ANSI DEC OR UNSPEC
         B        SC50              ABORT
SINED    LW,7     F:SORTOUT
         SLS,7    +28
         SLS,7    -28
         CI,7     X'A'               A FOR ANSI
         BNE      SINEI
         LW,7     F:SORTOUT+5              WORD 5 OUT DCB
         SLS,7    +24
         SLS,7    -28               HAS BITS 24-27 IN BITS 28-31
         CI,7     1                 1 FOR ANSI FIXED
         BG       SINEE
         CI,7     0
         BE       SINEG
         LI,7     3                 3 FOR ANSI FIXED IN SWITCH
         STW,7    ANSISWOU
         B        SINEI
SINEE    CI,7     3                  3 FOR ANSI VAR
         BNE      SINEF
         LI,7     2                 2 FOR ANSI VAR IN SWITCH
         STW,7    ANSISWOU
         LI,7     4                 4 FOR BLK-CTL-FIELD-OUTPUT
         STW,7    BLKCTLSY          (MAY BE CHANGED IF UTS PASSES SIZE
         B        SINEI
SINEF    CI,7     4                 4 FOR ANSI UNDEFINED
         BNE      SINEG
         LI,7     1                 1 FOR ANSI UNDEFINED IN SWITCH
         STW,7    ANSISWOU
         B        SINEI
SINEG    LI,7     18                 ANS DEC OR UNSPEC
         B        SC50
SINEI    RES      0
         BAL,9    GIBLF             GET INPUT BLOCKING FACTOR
         LI,5     3
         BAL,9    CKDEC             CHECK FOR VALID DIGITS
         B        SETCD5            BAD DIGIT
         BAL,9    GOBLF             GET OUTPT BLOCKING FACTOR
         LI,5     3
         LI,7     X'FF'
         BAL,9    CKDEC             CHECK VALID DIGITS
         B        SETCD5             INVAL DIGIT IN OUT-BLK
         PAGE
*
*  THIS REGION TESTS THE VALIDITY OF THE FORWARD SPACE FILE PARAMETER
*                 (THIS IS AN OPTIONAL PARAMETER.)                     R
SIN12    LI,X5    25
         LI,X7    6                                                    R
         BAL,R1   ALLBL             TEST FOR BLANKITEM                 R
         B        SIN121
*
         BAL,R1   GFSP1             GO GET NUMBER TO FORWARD SPACE
         LI,X5    4                 COUNT       /FIRST FOUR DIGITS.
         BAL,R1   CKDEC             CHECK FOR ILLEGAL DECIMAL DIGITS
         B        SETCD6            INVALID DIGIT IN FORWARD SPACE FILE
         BAL,R1   GFSP2             GO GET LAST TWO DIGITS
         LI,X5    2
         BAL,R1   CKDEC
         B        SETCD6            INVALID DIGIT IN FORWARD SPACE FILE
         B        SIN121           RETURN TO CO-RES P0
*
         PAGE                                                          R
*                                                                      R
*  THIS REGION TESTS THE VALIDITY OF THE SLICE SIZE PARAMETER          R
*                 THIS IS AN OPTIONAL PARAMETER.                       R
SIN122X  LI,X5    14                                                   R
         LI,X7    6                                                    R
         BAL,R1   ALLBL             TEST FOR BLANK ITEM                R
         B        SIN14             YES BYPASS TEST
*                                                                      R
         BAL,R1   GSSP1             GO GET SLICE SIZE                  R
         LI,X5    4                 FIRST FOUR DIGITS                  R
         BAL,R1   CKDEC             CHECK FOR ILLEGAL DECIMAL DIGITS   R
         B        SETCD12           INVALID DIGIT IN SLICE SIZE        R
         BAL,R1   GSSP2             GET LAST TWO DIGITS                R
         LI,X5    2                                                    R
         BAL,R1   CKDEC                                                R
         B        SETCD12           INVALID DIGIT IN SLICE SIZE        R
*                                                                      R
         PAGE
*
*  THIS REGION TESTS THE VALIDITY OF THE OUTPUT FILE LOGICAL RECORD
*                 LENGTH. (THIS IS AN OPTIONAL PARAMETER.)             R
SIN14    LI,X5    35
         LI,X7    4                                                    R
         BAL,R1   ALLBL             TEST FOR BLANK ITEM                R
         B        SIN145            YES, BYPASS TEST
*
         BAL,R1   GOLRL             GET LOGICAL RECORD LENGTH
         LI,X5    4
         BAL,R1   CKDEC             CHECK FOR BALID DIGITS
         B        SETCD8            INVALID DIGIT IN OUTPUT LRL
         CI,6     1                 MIN ALLOWED SIZE
         BL       SETCD4
         B        SIN145           RETURN TO CO-RES P0
         PAGE
*
*  THIS REGION SETS USER FORMATTED INPUT FILE VALUES--BLOCKING
*       FACTOR, RECORD TYPE, AND READ DIRECTION.
*
SIN2X    RES      0
         LI,X6    X'100'
         LW,X4    =C'UFV '          SET UP FOR OPEN INPUT FILE
         LB,5     *PRAMLOC
         CI,5     X'FA'             FOR MANAGE
         BNE      SIN22
         LW,4     =C'BFFM'          MANAGE DEBLOCKER
         B        SIN23
SIN22    RES      0
         LW,5     F:SORTIN           SEE WORD 0 OF DCB FOR DEV-TYP
         AND,5    =X'F'
         CI,5     3
         BLE      SIN225
         LW,9     ANSISWIN
         LW,4     =C'BVAR'
         CI,9     2                 ANS BLK-VAR
         BE       SIN23
         LW,4     =C'UFV '
         CI,9     3                 ANS  FIXED
         BE       SIN224
         B        SIN23
SIN224   RES      0
         LW,4     =C'BFF '          BLOCKED ASSUME
         LI,6     0
         B        SIN23
SIN225   BAL,9    GIBLF             GET INPUT BLKING
         AND,6    =X'F0F0F00'
         CI,6     X'100'
         BLE      SIN229            DEFAULT TO 1
         LW,4     =C'BFF '
         B        SIN23
SIN229   RES      0
         LI,6     X'100'            DEFAULT TO 1 IF USER DIDNT SPECIFY
SIN23    STW,X4   BCT0+19           SAVE INPTU FILE OPEN PARAMETER
*
         SLS,X6   -8                SET INPUT FILE'S BLOCKING FACTOR
         STW,X6   CNVRT             RIGHT JUSTIFIED IN CNVRT
         BAL,R1   EBCBN             GO:  CONVERT EBCDIC TO BINARY
         LW,X6    CNVRT+1           INPUT BLOCKING FACTOR (BINARY)
SIN235   RES      0
         STW,X6   BCT0+18           INPUT BLOCKING FACTOR
*
         PAGE
*
*  THIS REGION SETS USER FORMATTED OUTPUT FILE VALUES.
*
         BAL,R1   GOBLF             GET OUTPUT FILE'S BLOCKING FACTOR
         SLS,X6   -8
         STW,X6   CNVRT             RIGHT JUSTIFIED IN CNVRT
         BAL,R1   EBCBN             GO:  CONVERT EBCDIC TO BINARY
         LW,X6    CNVRT+1           OUTPUT FILE'S BLOCKING FACTOR
         STW,X6   BCT0+17               AS A BINARY INTEGER
         LW,9     ANSISWOU          IS IT ANSI
         CI,9     0                  NO
         BNEZ     SIN24             YES, GET OUT
         CI,6     0                 DID USER SPECIFY BLOCKING
         BNEZ     SIN24             YES GET OUT
         MTW,1    BCT0+17           NO SO DEFAULT TO ONE
         B        SIN24            RETURN TO CO-RES P0
*
         PAGE
SIN24X   RES      0
         LH,6     BCT0+24,1          OUT LOG REC LEN IN WORDS
         SLS,6    2                 TO BYTES
*
*
         LI,5     38                 SEE RIGHT MOST BYTE
         LB,R1    *PRAMLOC,X5           RECORD LENTH SPECIFIED
         CI,R1    C' '
         BE       SIN26             NO USE INPIT
         MTW,1    BCT0+29           SET ON TO SHOW USER WANTS OUT/SIZE
*
* CODE DELETED
         BAL,R1   GOLRL             GET OUTPUT REC LENGTH  /SIG7-1344/*D4985
         STW,X6   CNVRT                 LOGICAL RECORD LENGTH
         BAL,R1   EBCBN             GO:  CONVERT EBCDIC TO BINARY
         LW,X6    CNVRT+1
         LI,X7    0
         CW,X6    RLKCM
         BGE      SIN25B            NOT LESS               /SIG7-4622/*F4985
         LI,5     23                                       /SIG7-4622/*F4985
         LB,R1    *PRAMLOC,X5                              /SIG7-4622/*F4985
         CI,R1    'S'                IS SEQ CHK SPEC       /SIG7-4622/*F4985
         BE       SIN25A                                   /SIG7-4622/*F4985
         B        SIN25B                                   /SIG7-4622/*F4985
* IF AT SIN25A, SEQ CHK IS SPECIFIED AND OUTPUT            /SIG7-4622/*F4985
* RECORD LENGTH IS LESS THAN INPUT
* RECORD LENGTH. RLKCM WILL NOT HAVE THE OUTPUT            /SIG7-4622/*F4985
* RECORD LENGTH IN ALL OTHER CONDITIONS BECAUSE            /SIG7-4622/*F4985
* SIN33 WILL CAUSE A ABORT IF THE KEY IS                   /SIG7-4622/*F4985
* BEYOND OUTPUT RECORD LENGTH. SEE SIDR 1344.              /SIG7-4622/*F4985
SIN25A   STW,6    RLKCM                                    /SIG7-4622/*F4985
SIN25B   SLD,6    -2                                       /SIG7-4622/*F4985
         SLS,X7   -30
         STH,6    BCT0+24,1         OUT  LOG REC LEN
         STH,7    BCT0+25,1          OUT BYTE INCR
         SLS,6    2                 TO BYTES
*
SIN26    LH,5     BCT0+24,1
         SLS,5    2                 TO BYTES
         AH,5     BCT0+25,1         PLUS OUT INCR
         AI,5     8                 UP FOR PSEUDO CTL (2) WRDS
         STW,5    SEQLNG            BYTE LEN FOR OUT SEQ-CHK HOLD AREA
         PAGE
*
*  THIS REGION COMPUTES INPUT AND OUTPUT FILE BUFFER LENGTHS AND
*       SETS THEM INTO BCT0.
*
         LW,5     ANSISWOU
         CI,5     0                 NOT ANSI
         BEZ      SIN26A
         LW,9     F:SORTOUT+3
         SLS,9    -19               TO  WORDS
         MTW,0    9                 IS BLKL SPEC, IF NOT USE CTL/CARD
         BEZ      SIN26A
         MTW,1    9                  UP ONE WORD
         STH,9    BCT0+30,1          OUT BUFFER LEN
         B        SIN26B
SIN26A   AH,6     7,1               ADD BYTE OUT INCR
         MTH,0    BCT0+17,1         WAS BLKING GIVEN ON .BLOCK          CRSRTP01
         BEZ      SETCD5A           NO SO GIVE MESSAGE                  CRSRTP01
         MH,6     BCT0+17,1         OUT REC LEN X OUT BLK FACTOR
         AI,7     3
         SLS,7    -2                TO WORDS
         STH,7    BCT0+30,1         OUT BUFFER LEN
SIN26B   LW,5     ANSISWIN           IN ANSI SW
         CI,5     0                 NOT ANSI
         BEZ      SIN26C
         LW,9     F:SORTIN+3
         SLS,9    -19               TO  WORDS
         MTW,0    9                 IS BLKL SPEC, IF NOT USE CTL/CARD
         BEZ      SIN26C
         MTW,1    9                  UP ONE WORD
         STH,9    BCT0+30           IN BUFFER LEN
         B        SIN26D
SIN26C   LH,6     BCT0+24           INPUT REC LEN
         SLS,X6   2
         AH,6     BCT0+25           INPUT BYTE INCR
         MTH,0    BCT0+18,1         WAS BLKING GIVEN ON .BLOCK          CRSRTP01
         BEZ      SETCD5A           NO SO GIVE MSG                      CRSRTP01
         MH,X6    BCT0+18,X1            TIMES INPUT BLOCKING FACTOR
         AI,X7    3
         SLS,X7   -2
         STH,7    BCT0+30             INPUT BUFFER LENGTH
SIN26D   LI,6     3
         LB,X6    BCT0+19,X6
         CI,X6    C'M'
         BNE      SIN27A
         LI,X6    512
         STH,6    BCT0+30
         STH,6    BCT0+30,1
         B        SIN27A           RETURN TO CO-RES P0
         PAGE
*
*
* THIS REGION SETS THE SLICE COUNT AS BINARY INTO BCT0+13 AND THE
* MAX FILE SIZE AS BINARY INTO BCT0+12
*
SIN28X   RES      0
         LI,6     3
         LW,7     *PRAMLOC,6             GET 2 HIGH DIGITS
         AND,7    =X'FFFF'
         STW,7    CNVRT
         BAL,9    EBCBN
         LW,7     CNVRT+1
         MI,7     10000
         STW,7    BCT0+12           PARTIAL VALUE
         LI,6     4
         LW,7     *PRAMLOC,6         GET LAST 4 DIGITS
         STW,7    CNVRT
         BAL,9    EBCBN
         LW,7     CNVRT+1
         AWM,7    BCT0+12           TOTAL MAX FILE SIZE
         LI,6     6
         LW,7     *PRAMLOC,6        LEFT 3 DIGITS
         AND,7    =X'FFFFFF'
         STW,7    CNVRT
         BAL,9    EBCBN
         LW,7     CNVRT+1
         MI,7     1000
         STW,7    BCT0+13           PARTIAL VALUE
         LI,6     7
         LW,7     *PRAMLOC,6
         SLS,7    -8                 SHIFT
         STW,7    CNVRT
         BAL,9    EBCBN
         LW,7     CNVRT+1
         AWM,7    BCT0+13            TOTAL FORWARD SPACE SIZE
         B        SIN285            RETURN TO CO-RES P0
         PAGE
SIN29X   RES      0
         LI,7     23
         LB,7     *PRAMLOC,7         IS SEQ CHK SPEC
         CI,7     X'E2'
         BNE      SIN29             NO
         SLS,9    2                 MEM  ADDR TO BYTES
         STW,9    SEQRCD            MEM HOLD FOR SEQ REC COMP (PREV)
         LW,7     SEQLNG
         AI,7     4                 UP 1 WORD THE LENGTH
         AWM,7    9                 UP BEGIN OF MEM ADDR
         SLS,9    -2                TO WORDS
         SLS,8    2                 NUM OF BYTES AVAIL
         AI,8     -4                DECR BY 1 WORD
         SW,8     SEQLNG             REDUCE BY AVAIL BYTES
         SLS,8    -2                TO WORDS
SIN29    STW,9    FIT7              FIRST WORD OF DYN MEM (IN BUF)
         STW,8    BCT0+11           NUMBER OF WORDS OF DYNAMIC MEMORY
         STW,9    BCT0+10           FIRST WORD ADDRESS OF DYNAMIC
         SLD,8    -32               SET 8=0 AND 9=WORDS AVAILABLE
         LH,7     BCT0+30           INPUT BUF SIZE IN WORDS
         AND,7    =X'FFFF'
         LH,5     BCT0+30,1         OUT BUF SIZE IN WORDS
         AND,5    =X'FFFF'
         CW,7     5                 IN SIZE TO OUT SIZE
         BL       SIN29A            OUTPUT IS BIGGER RESERVE ITS AREA
         SH,9     BCT0+30           LESS IN BUF SIZE (WORDS)
         SH,9     BCT0+30           DOUBLE BUFFERED
         B        SIN29B            DONE RESERVING BIGGER INPUT AREA
SIN29A   RES      0
         SH,9     BCT0+30,1         OUT BUF LENGTH IN WORDS
         SH,9     BCT0+30,1         DOUBLE BUFFERED
SIN29B   RES      0
         CI,9     0                  ANY AREA LEFT
         BLEZ     SETCD45            NO SO ERROR
         STW,9    BCT0+11           AVAIL WORDS FOR INTER CALC
         STW,7    9                 SAVE  IN BUF SIZE FOR LATER
         LW,7     BCT0+10           BEG OF DY MEM (IN BUF ADDR-WORDS)
         AH,7     BCT0+30           BUF IN LEN TO GET ALT IN BUF ADDR
         STW,7    FIT7+1            BEG OF IN BUF 2 ADDR
         LW,7     BCT0+10           BEG OF MEMORY ADDR IN WORDS
         SLS,7    2
         STW,7    BCT0+15           BEGIN OUT BUF ADDR BYTE
         SLS,7    -2
         AH,7     BCT0+30,1         INCR ADDR GET BUF 2 OUT ADDR
         SLS,7    +2
         STW,7    BCT0+16           OUT BUF 2 ADDR BYTE
         LW,7     BCT0+10           BEGIN OF MEMORY IN WORDS
         CW,9     5                 9= IN BUF SIZE 5= OUT BUF SIZE
         BL       SIN29C            OUT IS GREATER USE IT
         AH,7     BCT0+30           UP ADDR FOR 2 BIGGER IN BUFS
         AH,7     BCT0+30
         B        SIN29D
SIN29C   RES      0
         AH,7     BCT0+30,1         UP ADDR FOR 2 BIGGER OUT BUFS
         AH,7     BCT0+30,1
SIN29D   RES      0
         LW,9     BCT0+11           AVAIL WORDS FOR INTER CALC
         STW,7    BCT0+10           RESET BEGIN MEM FOR INTER-CALC
         B        SIN295           RETURN TO CO-RES P0
*
         PAGE
*
*  THIS REGION SETS ALL OPTION INDICATORS TO REFLECT THE OPTIONS
*       REQUESTED IN THE SORT SPECIFICATIONS.
*
SIN22X   RES      0
         LI,6     0
         LI,5     22
         LB,X7    *PRAMLOC,X5
         CI,7     X'F0'             IS WORD = EBCDIC 0
         BE       SIN220
         OR,6     =X'400000'         SET FLAG
*
SIN220   LI,5     23
         LB,X7    *PRAMLOC,X5
         CI,X7    C'S'              IS SEQUENCE CHECK DESIRED
         BNE      SIN220A
         LW,5     SEQHOOK           SEQ HOOK PUT IN OUT CONTROLLER
         STW,5    OUTSEQK           OWN CODE, SO INSERT SEQ CHK HOOK
         STW,5    S:OUT+2
         B        SIN221
SIN220A  AI,6     X'10000'          SET FLAG
SIN221   STW,6    BCT0+28
         LW,5     OSO                 ANY OUT OWN CODE PRES
         BEZ      %+3               NO
         LW,5     OSOHOOK           STORE HOOK IN OUTPUT CONTROLLER
         STW,5    S:OUT+1
         LI,5     12                 INDEX
         LB,5     *PRAMLOC,5          SEE HEADER OPTION POS 13
         CI,5     X'40'              BLANK
         BE       *SIN2R               EXIT OK
         CI,5     X'C6'             F
         BE       *SIN2R               EXIT
         CI,5     X'F1'
         BL       SIN23C            ERROR
         CI,5     X'F9'
         BLE      *SIN2R            EXIT
SIN23C   LI,7     14                ERROR NOT BLANK,F,1-9
         B        SC50
*                                                          /SIG7-1883/*D49850
* CODE DELETED
         PAGE
*
*  THIS ROUTINE TAKES USER SUPPLIED FILE PARAMETERS IN DCB FORMAT
*        AND CREATES A FILE PARAMETER TABLE FOR A M:DEVICE REQUEST.
*        AFTER EXECUTING THE M:DEVICE REQUEST, THIS ROUTINE BUILDS
*        A FILE PARAMETER TABLE FOR A M:OPEN REQUEST AND EXECUTES
*        IT.  THIS ROUTINE LEAVES THE DCB IN THE CLOSED STATE WHEN
*        IT EXITS.
*
*  ON ENTRY TO INOPD:
*        REGISTER:  6=THE WORD ADDRESS OF THE FPT
*                   7=THE WORD ADDRESS OF THE USER SUPPLIED DCB
*                   8=THE WORD ADDRESS OF THE SORT'S DCB
*                   9=THE RETURN ADDRESS
*
*  ON EXIT FROM INOPD:
*        REGISTER:  6=THE WORD ADDRESS OF THE END OF THE FPT+1
*                   7=THE WORD ADDRESS OF THE END OF THE CALLER'S DCB+1
*
         PAGE
*
*
INOPDR   DATA     0
*
INOPD    STW,R1   INOPDR            SAVE RETURN ADDRESS
*
         STW,R0   RE                SORT'S DCB
         STW,R0   INCLS
         OR,RE    =X'22000000'      M:DEVICE -MODE- CALL CODE
         LI,RF    0                 OPTION WORD OF FPT
         LI,13    X'F'              MASK
         AND,13   *7                DCB WORD 0
         CI,13    3                 DEV TYPE
         BNE      INOP3
         LI,RD    X'20000'          TEST:  IS THE USER SPECIFIED
         AND,RD   *X7                      MODE EBCDIC OR BINARY
         BE       INOP1             EBCDIC:
         AI,RF    X'10'             BINARY:  TURN ON BINARY SETTING
*
INOP1    LI,RD    X'4000'           TEST:  DID THE USER SPECIFY
         AND,RD   *X7                      FBCD FORMAT
         BE       INOP2             NO:
         AI,RF    X'20'             YES:  TURN ON FBCD SETTING
*
INOP2    LI,RD    X'200'            TEST:  DID THE USER SPECIFY
         AND,RD   *X7                      PACKED BINARY FORMAT
         BNE      INOP3             YES:
         AI,RF    X'40'             NO:   TURN ON UNPACKED BINARY SETTING
*
INOP3    CAL1,1   RE                EXECUTE M:DEVICE DCB,MODE REQUEST
*
         OR,R0    =X'14000000'      M:OPEN REQUEST CODE
         STW,R0   *X6               STORE IN WORD 0 OF THE FPT
         STW,X6   RC
         AI,X6    1                 STEP FPT POINTER
         STW,X6   RA                SAVE ADDRESS OF FPT FLAG WORD
         AI,X6    1                 STEP FPT POINTER
         LI,8     X'3F8'               SET FLAGS 3-9 ON
         LI,2     X'F'
         AND,2    *7                SEE USERS DCB ASN
         CI,2     10                A FOR ANS
         BNE      INOP4
         MTW,1    ANSSW             FLAG FOR ANS
         OR,8     =X'10000000'       SET P4 ON
         LI,2     3
         LW,3     *7,2              GET BLKL
         SLS,3    -17
         STW,3    *6                STORE AS FIRST OPTION
         AI,6     1                 UP FPT POINTER
INOP4    RES      0
         LI,2     2
         LW,3     *7,2              GET NRA IN USERS DCB
         SLS,3    -24
         CI,3     0
         BEZ      INOP5              NOT GIVEN
         OR,8     =X'8000000'        SET P5 ON
         STW,3    *6                  STORE AS NEXT OPTION
         AI,6     1                 UP FPT POINTER
INOP5    RES      0
         MTW,0    ANSSW             IS IT ANS
         BEZ      INOP6
         OR,8     =X'4000000'       SET  P6 ON
         LI,2     5
         LW,3     *7,2               GET FMT
         AND,3    =X'F0'
         SLS,3    -4
         STW,3    *6                  STORE AS NEXT OPTION
         AI,6     1                 UP FPT POINTER
INOP6    RES      0
         LI,2     X'F'
         AND,2    *7
         CI,2     3
         BE       INOP61
         LI,2     20
         LB,3     *7,2
         AND,3    =X'C0'
         BEZ      INOP61             NO  FIL1 PARAM GIVEN
         OR,8     =X'400000'        P10 ON
         SLS,3    -6
         STW,3    *6                  STORE AS NEXT OPTION
         AI,6     1                 UP FPT POINTER
INOP61   RES      0
         OR,8     =X'40000'         SET  P14 ON
         LI,X3    1
         LB,2     X'2B'             MON FLAG               /SIG7-2171/*F4985
         SLS,2    -4                                       /SIG7-2171/*F4985
         CI,2     6                                        /SIG7-2171/*F4985
         BE       INOP10            UTS                    /SIG7-2171/*F4985
         CI,2     7                  7 FOR CP-V
         BE       INOP10
         LI,X2    X'FFFF'           GET USER DCB'S DSI
         AND,X2   *X7,X3
INOP65   AI,2     X'10000'
         STW,X2   *X6               STORE DSI PARAMETER
         AI,X6    1                 STEP FPT POINTER
         LI,2     X'F'              MASK
         AND,2    *7                GET USERS DCB  ASN
         MTW,0    ANSSW
         BEZ      INOP69
         LI,2     5                 SET F10-F12 ON FOR ANS
         OR,8     2
         B        INOP7
INOP69   RES      0
         OR,8     2                 SET F11-F12 ON
INOP7    RES      0
         MTW,0    ANSSW
         BEZ      INOP8
         AI,8     X'1000'           SET P20 ON
         LI,2     18
         LW,3     *7,2               GET USER LRCSZ
         SLS,3    -17
         STW,3    *6                STORE  NEXT PARAM
         AI,6     1                  UP FPT POINTER
*
INOP8    STW,R0   *RA               STORE FPT FLAGS
         LB,X3    *X7               GET USER DCB TOTAL WORDS (TTL)
         AW,X3    X7                END LOCATION OF DCB+1
         AI,X7    22                LENGTH OF FIXED PORTION
         SW,X7    X3                LENGTH OF VARIABLE PARAMETERS AS A
         SW,X6    X7                END OF M:OPEN FPT  /NEGATIVE INTEGER
*
INOP9    LW,X2    *X3,X7
         STW,X2   *X6,X7
         BIR,X7   INOP9
         STW,X3   X7
*
         CAL1,1   *RC               EXECUTE M:OPEN REQUEST
*
         M:CLOSE  *INCLS,(PTL)      POSIT AT LABEL         /SIG7-1069/*C4986
         LI,3     0
         STW,3    ANSSW             SET OFF
*
         B        *INOPDR
*
INOP10   RES      0
         LI,2     X'F'              MASK
         AND,2    *7                WHAT IS DEVICE TYPE
         CI,2     1                 IS IT A FILE
         BNE      INOP10A           NO
         LW,2     =X'00400000'      SEE BIT 9 FCI WORD 0                CRSRTP01
         AND,2    *7                                                    CRSRTP01
         CI,2     0                                                     CRSRTP01
         BE       INOP12            NOT ON                              CRSRTP01
         LI,3     5                 INDEX
         LI,2     X'7F00'           MASK
         AND,2    *7,3              GET RNDEV
         B        INOP65+1
INOP10A  RES      0
         LW,2     =X'00400000'        SEE BIT 9 FCI WORD 0
         AND,2    *7
         CI,2     0
         BE       INOP12            BIT 9 OFF NEVER OPENED
         LI,2     X'10000'          CHECK BIT 15
         AND,2    *7,3              WORD 1 OF DCB
         CI,2     0
         BNE      INOP11
         LI,2     X'7F00'           GET BITS 17-23
         AND,2    *7,3
         OR,2     =X'00018000'          SET BITS 15/16 ON
         B        INOP65+1
*
* CODE DELETED
INOP11   LI,2     X'FFFF'
         AND,2    *7,3              GET TEXT FROM 16-31
         B        INOP65+1
*
INOP12   RES      0
         LI,2     X'10000'
         EOR,2    *7,3
         STW,2    INOP13            SAVE REVERSED BIT 15
         LI,2     X'FFFF'
         AND,2    *7,3              GET R HALF WRD 1 ONLY
         OR,2     INOP13             BRING IN ON OR OFF BIT 15
         B        INOP65+1
*
INOP13   DATA     0                 HOLD COMPLEMENTED BIT 15
         PAGE
*
GIBLF    LI,X5    1                 GET INPUT FILE'S BLOCKING FACTOR
         LW,X6    *PRAMLOC,X5           LEFT JUSTIFIED INTO X6
         SLS,X6   8
         B        *R1
*
GOBLF    LI,X5    2                 GET OUTPUT FILE'S BLOCKING FACTOR
         LW,X6    =X'FFFFFF00'          LEFT JUSTIFIED INTO X6
         AND,X6   *PRAMLOC,X5
         B        *R1
*
GFSP1    LI,X5    6                 GET FIRST 4 CHARS OF FORWARD SPACE
         LW,X6    *PRAMLOC,X5       FILE PARAMETER INTO X6
         AI,X5    1
         B        GIL1
*
GFSP2    LI,X5    7                 GET LAST 2 CHARACTERS OF FORWARD
         LW,X6    *PRAMLOC,X5       SPACE FILE PARAMETER LEFT
         SLS,6    8                 GET COL 30-31 LEFT JUST/SIG7-6404/*F4985
         AND,X6   =X'FFFF0000'          JUSTIFIED INTO X6
         B        *R1
*
GSSP1    LI,X5    3                 GET FRIST TWO CHARS OF             R
         LW,X6    *PRAMLOC,X5       SLICE SIZE PARAM INTO X6           R
         LI,X5    4                                                    R
         LW,X7    *PRAMLOC,X5                                          R
         SLD,X6   16                                                   R
         B        *R1                                                  R
*                                                                      R
GSSP2    LI,X5    4                 GET LAST FOUR CHARS OF             R
         LW,X6    *PRAMLOC,X5       SLICE SIZE PARAM INTO X6           R
         SLS,X6   16                                                   R
         B      *R1                                                    R
*                                                                      R
*
GOLRL    LI,X5    8                 GET OUTPUT FILE'S LOGICAL
         LW,X6    *PRAMLOC,X5           RECORD LENGTH INTO X6
         AI,5     1
         LW,7     *PRAMLOC,5
         SLD,6    24
         B        *9
*
*
*                 ILLEGAL DECIMAL DIGIT IN INPUT/OUTPUT BLOCKING FACTOR
SETCD5   LI,RF    X'5'
         BAL,R2   ER2
         LI,R1    SIN12
         B        SIN12
SETCD5A  RES      0                                                     CRSRTP01
         LI,15    X'5'                                                  CRSRTP01
         BAL,10   ER2               PRINT MSG                           CRSRTP01
         B        SIN26D                                                CRSRTP01
*                 ILLEGAL DECIMAL DIGIT IN FORWARD SPACE FILE
SETCD6   LI,RF    X'6'
         BAL,R2   ER2
         LI,9     SIN121
         B        SIN121
*                 ILLEGAL DECIMAL DIGIT IN INTERMEDIATE RECORD LENGTH
*                 ILLEGAL DECIMAL DIGIT IN OUTPUT LOGICAL RECORD LENGTH
SETCD8   LI,RF    X'8'
         BAL,R2   ER2
         AI,R1    1
         B        *R1
*                 ILLEGAL DECIMAL DIGIT IN SLICE SIZE.                 R
SETCD12  LI,RF    X'13'                                                R
         BAL,R2   ER2                                                  R
ENDP01   RES      0
         B        SIN14
*                                                                      R
         PAGE
*
         END

