* CATALOG NO 704985-1  SIGMA 5/7 SORT             OVERLAY 1
*  VERSION C00
         SYSTEM   SIG7FDP
         SYSTEM   BPM
         CSECT    0
*
         PAGE
*
         DEF      ZDCT,PDCT,ALFT,BNAV,SIN315X,SIN35X
         REF      SPECRD,CPER
         REF      CALLSW,WORK,KTT0,CNVRT,KRASC,MASKS,DECSAV
         REF      ZTRANA,ZTRAND,PTRANA,PTRAND
         REF      ATRANA,ATRAND,BNCMPA,BNCMPD,BNABSA,BNABSD
         REF      DEVSTP,EVDEA,EVDED
         REF      BNEBC,EBCBN
         REF      COMPSTOP
         REF      DECTRP,SC50
         REF      SINTMP,RLKCM
         REF      ENDSNAP
         REF      KLNGC
         REF      SRTMIN
         REF      HTBUFIN
         REF      SIN33,SIN3R,ER2,STOR1,KASCL,KTRANI
         REF      STORSAM,BDACPR,SEQEND,TRNIST,TRAPEN
         REF      BMCOM,BFACPR,KSTRTC,KCOM,BHACPR
         REF      PRAMLOC
         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
KTYPC    DATA,4   50
*
         PAGE
*                                                                /VALUES
KTMK     GEN,8,24 64,BA(KTT0)-1
*
SIN315X  RES      0
         AI,X7    9
         LI,6     ENDP11
         STW,6    ENDSNAP            IN CASE OF DUMP
         LB,X6    *PRAMLOC,X7       TRANSLATION PARAMETER
         CI,X6    C'T'
         BE        SIN37             IT IS 'T'
         CI,X6    C'A'              NOT 'C'
         BNE      SIN33             NOT 'A'
         CI,X2    3
         BE       SIN32             BINARY IS LEGAL
         LI,RF    X'D'              ABSVAL MESSAGE
         BAL,R2   ER2
SIN32    AI,X2    4                 IT IS 'A'
         B        SIN33            RETURN TO CO-RES P1
SIN35X   RES      0
         LW,R1    KTRANI            ARE TRANSLATION PARAMETERS REQUIRD
         BE       *SIN3R
         LH,9     CALLSW,1           HAVE TRAN PARAM BEEN READ BY PRE
         BNEZ     *SIN3R
         LI,9     HTBUFIN           ADDR OF BUF READ INTO TRANS
         STW,R1   WORK
SIN35    BAL,9    SPECRD
         LW,9     *WORK             HAVE ALL TRAN PARAM BEEN READ
         CW,R1    =C'!EOD'
         BE       *SIN3R
         LI,5     16
         LW,6     *WORK,5           KTT0 REL LOCATION
         SLS,X6    -8                RIGHT JUSTIFIED
         STW,X6   CNVRT
         BAL,R1   EBCBN             CONVERT TO BINARY
         LW,X7    CNVRT+1
         CI,X7    193
         BLE      SIN36
         LI,X7    7                 TRANS TABLE LOC ERR    /SIG7-1162/*C4986
         B        SC50              GO ABORT               /SIG7-1162/*C4986
*
SIN36    AW,7     KTMK
         LW,6     WORK
         SLS,X6   2                 CONVERT SOURCE TO BYTE ADDRESS
         MBS,X6   0
         B        SIN35
*
*
SIN37    STW,X6   KTRANI
         CI,X2    3
         BL       SIN32
         LI,RF    X'C'              TRANSLATION ERROR MESSAGE
         BAL,R2   ER2
         B         SIN32
         PAGE
*
*
*  THIS REGION GENERATES THE CODE FOR ZONED DECIMAL KEYS
*       REQUIRING TRANSLATION.
*
ZDCTR    DATA     0
*
ZDCT     STW,X5   ZDCTR             SAVE RETURN ADDRES
         LI,X5    0
         BAL,R0   TRNIST           *LI,X6    0    LI,RA    0
         LD,RA    ZTRAN            *BAL,R0   ZTRANA/BAL,R0   ZTRAND
         BAL,R1   TRAPEN
         AWM,5    KASCL
         B        *ZDCTR            EXIT
*
*  THIS REGION GENERATES THE CODE FOR PACKED DECIMAL KEYS
*       REQUIRING TRANSLATION.
*
PDCTR    DATA     0
*
PDCT     STW,X5   PDCTR             SAVE RETURN ADDRESS
         LI,X5    0
         BAL,R0   TRNIST           *LI,X6    0    LI,RA     0
         LD,RA    PTRAN            *BAL,R0   PTRANA/BAL,R0   PTRAND
         BAL,R1   TRAPEN
         AWM,5    KASCL
         B        *PDCTR
*
         PAGE
*
*  THIS REGION GENERATES THE CODE FOR ALPHANUMERIC KEYS
*       REQUIRING TRANSLATION
*
ALFTR    DATA     0
*
ALFT     STW,X5   ALFTR
         LI,X5    0
         BAL,R0   TRNIST           *LI,X6    0     LI,RA    0
         LD,RA    ATRAN            *BAL,R0   ATRANA/BAL,R0   ATRAND
         BAL,R1   TRAPEN
         AWM,5    KASCL
         B        *ALFTR
*
         PAGE
*
*  THIS REGION GENERATES THE CODE FOR BINARY KEYS
*       TO BE SORTED ON THEIR ABSOLUTE VALUES.
*
BNAVR    DATA     0
*
BNAV     STW,X5   BNAVR             SAVE RETURN ADDRESS
         LI,X5    0                 INITIALIZE WORD COUNTER
         LW,X6    KSTRTC
         SLS,X6   -2               RELATIVE WORD POSITION
         STW,X6   SINTMP+2
         LI,X7    1
         AND,X7   KSTRTC           DOES KEY START ON A HALF/FULL WORD
         BNE      BNAV2            NO: BYPASS SEQUENCE TEST/BOUNDARY
         LI,X7    1                YES: SEE IF THE KEY CONTAINS AN
         AND,X7   KLNGC                 EVEN NUMBER OF BYTES.
         BNE      BNAV2            NOT AN EVEN NUMBER OF BYTES
         LW,X7    KLNGC            AN EVEN NUMBER
         LI,X6    2
         AND,X6   KSTRTC           IS KEY ON A WORD BOUNDARY
         BNE      BNAV1            NO: HALF WORD
         CI,X7    8                IS KEY A DOUBLE-WORD KEY
         BE       BNAV4            YES: DOUBLE WORD
         CI,X7    4                IS KEY A FULL-WORD KEY
         BE       BNAV5            YES: FULL-WORD
BNAV1    RES      0
         BE       BNAV6            YES: HALF-WORD
         PAGE
*
*  THIS REGION GENERATES THE CODE FOR THOSE KEYS NOT MEETING THE
*        CRITERIA FOR A NATURAL HARDWARE SEQUENCE.
*
BNAV2    RES      0
         BAL,R0   TRNIST           *LI,X6   0     LI,RA   0
         LD,RA    BMACOM           *BAL,R0    BNABSA/BAL,RO  BNABSD
         BAL,R1   TRAPEN
         AWM,5    KASCL
         B        *BNAVR
*
*  THIS REGION GENERATES CODE FOR DOUBLE-WORD KEYS.
*
BNAV4    LW,6     BMCOM             *LCI 2
         BAL,R1   STORSAM
         LW,X6    SINTMP+2
         OR,X6    BDACOM           *LM,RC   0,X4
         BAL,R1   STORSAM
         LW,X6    BDACOM+1         *LM,RE   0,X5
         OR,X6    SINTMP+2          RELATIVE WORD POSITION
         BAL,R1   STORSAM
         LW,X6    BDACOM+2         *LAD,RA   RC
         BAL,R1   STORSAM
         LW,X6    BDACOM+3         *LAD,RC   RE
         BAL,R1   STORSAM
         LD,RA    BDACPR
         BAL,R1   TRAPEN
BNAV3    BAL,R0   SEQEND
         B        *BNAVR
*
*  THIS REGION GENERATES CODE FOR FULL-WORD KEYS.
*
BNAV5    LW,X6    BFACOM           *LAW,RA   0,X4
         OR,X6    SINTMP+2
         BAL,R1   STORSAM
         LW,X6    BFACOM+1         *LAW,RC   0,X5
         OR,X6    SINTMP+2
         BAL,R1   STORSAM
         LD,10    BFACPR            CW,10     12   CW,12     10
         BAL,R1   TRAPEN
         B        BNAV3
*
*  THIS REGION GENERATES CODE FOR HALF WORD KEYS.
*
BNAV6    LW,X6    KSTRTC
         SLS,X6   -1
         STW,X6   SINTMP+2          HALF-WORD RELATIVE STARTING POSITION
         OR,X6    KCOM             *LI,X6    0
         BAL,R1   STORSAM
         LW,X6    BHACOM           *LAH,RA   *X4,X6
         BAL,R1   STORSAM
         LW,X6    BHACOM+1         *LAH,RC   *X5,X6
         BAL,R1   STORSAM
         LD,RA    BHACPR           *CH,RA     RC /CH,RC     RA
         BAL,R1   TRAPEN
         B        BNAV3
*
         PAGE
*
*
*
*
*
*  THE FOLLOWING PAGES CONTAIN THE SKELETON KEY COMPARISON SEQUENCES
*       GENERATED BY SIN3 AND THE TABLES FROM WHICH THEY ARE CREATED.
*
*  ALL THE SEQUENCES ASSUME THAT ENTRY IS MADE VIA A BAL,R1     AF(1)
*       WITH THE FOLLOWING REGISTERS SET AS:
*        REGISTER:  4=THE WORD ADDRESS OF THE PREDICTED WINNER
*                   5=THE WORD ADDRESS OF THE PREDICTED LOSER
*
*  ON EXIT FROM THIS SEQUENCE:
*        REGISTER:  4 IS UNCHANGED
*                   5 IS UNCHANGED
*                   CONDITION CODE 4=1 IF AN EXCHANGE IS NECESSARY
*                                   =0 IF AN EXCHANGE IS NOT NECESSARY
*  THE SPECIFIC SEQUENCES FOLLOW:
*
         PAGE
*
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR ZONED
*       DECIMAL KEYS.REQUIRING NO TRANSLATION.
*
* ODD
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE
*
*        LI,X6    0           LI,X6    0      AF(1)=REL BYTE LOC OF KEY
*        PACK,0   *4,6       PACK,0  *5,6   CF(2)= KEY LENGTH IN BYTES
*        BCS,8    DECTRP     BCS,8    DECTRP
*        DST,0    DECSAV      DST,0    DECSAV CF(2)=KEY LENGTH IN BYTES
*        PACK,0   *X5,X6      PACK,0   *X4,X6 CF(2)=KEY LENGTH IN BYTES
*        BCS,8    DECTRP     BCS,8    DECTRP
*        DC,0     DECSAV     DC,0     DECSAV  CF(2)=KEY LENGTH IN BYTES
*        BE       %+2         BCR,X3   %+2    GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
* EVEN
*
*
*        LI,6     0          LI,6     0   (LENGTH)
*        LI,7     0          LI,7     0   (LENGTH)
*        BAL,8    DEVSTP     BAL,8    DEVSTP
*        BAL,8    EVDEA (ASC)BAL,8    EVDED (DESC)
*        BE       %+2        BCR,3    %+2
*        BNE      *9         BCS,3    *9
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR PACKED
*       DECIMAL KEYS REQUIRING NO TRANSLATION.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE
*
*        LI,X6    0           LI,X6    0      AF(1)=REL BYTE LOC OF KEY
*        DL,0     *X5,X6      DL,0     *X4,X6 CF(2)=KEY LENGTH IN BYTES
*        BCS,8    DECTRP     BCS,8    DECTRP
*        DC,0     *X4,X6      DC,0     *X5,X6 CF(2)=KEY LENGTH IN BYTES
*        BCS,8    DECTRP     BCS,8    DECTRP
*        BE       %+2         BCR,X3   %+2    GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
         PAGE
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR ZONED
*       DECIMAL KEYS REQUIRING KEY TRANSLATION.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE
*
*        LI,X6    0           LI,X6    0      AF(1)=KEY LENGTH
*        LI,RA    0           LI,RA    0      AF(1)=KEY DISPLACEMENT
*        BAL,R0   ZTRANA      BAL,R0   ZTRAND
*                                             RETURN HERE IF KEYS ARE
*                                             EQUAL--OTHERWISE EXIT.
*
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR PACKED
*       DECIMAL KEYS REQUIRING KEY TRANSLATION.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE
*
*        LI,X6    0           LI,X6    0      AF(1)=KEY DISPLACEMENT
*        LI,10    0           LI,10    0     AF(1)= KEY DISPLACEMENT
*        BAL,R0   PTRANA      BAL,R0   PTRAND
*                                             RETURN HERE IF KEYS ARE
*                                             EQUAL--OTHERWISE EXIT.
*
         PAGE
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR ALPHANUMERIC
*       KEYS REQUIRING NO TRANSLATION
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         PARTIAL WORD KEYS
*
*        LI,X7    0           LI,X7    0      PART WORD MASK
*        LW,X6    0,X5        LW,X6    0,X4   AF(1)=REL WORD LOC OF KEY
*        CS,X6    0,X4        CS,X6    0,X5   AF(1)=REL WORD LOC OF KEY
*        BE       %+2         BCR,X3   %+2    GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR ALPHANUMERIC
*       KEYS REQUIRING KEY TRANSLATION.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE
*
*        LI,X6    0           LI,X6    0      AF(1)=KEY LENGTH
*        LI,RA    0           LI,RA    0      AF(1)=KEY DISPLACEMENT
*        BAL,R0   ATRANA      BAL,R0   ATRAND
*                                             RETRUN HERE IF KEYS ARE
*                                             EQUAL--OTHERWISE EXIT
*
         PAGE
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR BINARY
*       KEYS TO BE SORTED IN ALGEBRAIC SEQUENCE.  EACH BINARY KEY
*       IS EXAMINED TO DETERMINE WHETHER OR NOT IT FULLFILLS THE
*       REQUIREMENTS FOR USE OF NATURAL HARDWARE COMMANDS IN ITS
*       COMPARISON.  THESE REQUIREMENTS ARE:
*                1.  THE BEGINNING BYTE OF THE KEY MUST FALL ON A  HALF-
*                    HALF-WORD OR ON A WORD BOUNDARY AND THE KEY   WORD
*                    MUST BE EXACTLY 2 BYTES IN LENGTH, OR,        CRI-
*                                                                  TERIA
*                2.  THE BEGINNING BYTE MUST FALL ON A WORD BOUND- FULL-
*                    ARY AND THE KEY MUST BE EXACTLY 4 BYTES IN    WORD
*                    LENGTH, OR                                    CRI-
*                                                                  TERIH
*                3.  THE BEGINNING BYTE MUST FALL ON A WORD BOUND- DOUB-
*                    ARY AND THE KEY MUST BE EXACTLY 8 BYTES IN    LE-
*                    LENGTH--THE SEQUENCE CANNOT ASSUME THAT THE   WORD
*                    KEY BEGINS ON A DOUBLE-WORD BOUNDARY.         CRI-
*                                                                  TERIA
         PAGE
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR BINARY
*       KEYS MEETING THE HALF WORD CRITERIA
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         HALF-WORD KEYS
*
*        LI,X6    0           LI,X6    0      AF(1)=REL H-W LOC OF KEY
*        LH,RA    *X5,X6      LH,RA    *X4,X6 LOAD PREDICTED LOSER
*        CH,RA    *X4,X6      CH,RA    *X5,X6 COMPARE WITH PARTMER
*        BE       %+2         BCR,3    %+2   GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         FULL-WORD KEYS
*
*        LW,RA    0,X5        LW,RA    0,X4   AF(1)=REL WORD LOC OF KEY
*        CW,RA    0,X4        CW,RA    0,X5   AF(1)=REL WORD LOC OF KEY
*        BE       %+2         BCR,3    %+2   GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         DOUBLE-WORD KEYS
*
*        LCI      2           LCI      2      SET CONDITIONS FOR LM
*        LM,RA    0,X5        LM,RA    0,X5   LOAD PREDICTED LOSER
*        LM,RC    0,X4        LM,RC    0,X4   LOAD PREDICTED WINNER
*        CD,RA    RC          CD,RC    RA     COMPARE KEYS
*        BE       %+2         BCR,3    %+2   GO TO NEXT SEQUENCE
*        BNE      *R1         BCS,X3   *R1    EXIT IF NOT EQUAL
*
*  ALL ALGEBRAIC BINARY KEYS NOT MEETING THE CRITERIA (1--3  ABOVE)
*       FOR DIRECT HARDWARE SEQUENCES WILL BE COMPARED AS SHOWN
*       BELOW.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         MISCELLANEOUS SIZES
*        LI,X6    0           LI,X6    0      BYTE COUNT
*        LI,RA    0           LI,RA    0      SOURCE BYTE DISPLACEMENT
*        BAL,R0   BNCMPA      BAL,R0   BNCMPD GO COMPARE KEYS
*                                             RETURN HERE IF KEYS ARE
*                                             EQUAL--OTHERWISE EXIT
*
*       NOTE:  BYTE COUNT OCCUPIES THE LOW ORDER 8 BITS OF REGIS-
*              TER 6 AND SOURCE BYTE DISPLACEMENT OCCUPIES THE LOW
*              ORDER 19 BITS OF REGISTER RA (10).
*
         PAGE
*
*  THIS IS THE SKELETON COMPARISON SEQUENCE GENERATED FOR BINARY
*       KEYS TO BE SORTED ON THEIR ABSOLUTE VALUES.  KEYS IN THIS
*       CATEGORY ARE GROUPED ACCORDING TO THE SAME CRITERIA AS
*       THEIR ALGEBRAIC COUNTERPARTS.
*
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         HALF-WORD KEYS
*
*        LI,X6    0           LI,X6    0      AF(1)=REL H-W LOC OF KEY
*        LAH,RA   *X4,X6      LAH,RA   *X4,X6
*        LAH,RC   *X5,X6      LAH,RC   *X5,X6
*        CH,12    10          CH,10    12
*        BE       %+2         BCR,X3   %+2
*        BNE      *R1         BCS,X3   *R1
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         FULL-WORD KEYS
*
*        LAW,RA   0,X4        LAW,RA   0,X4    AF(1)=REL WORD LOC OF KEY
*        LAW,RC   0,X5        LAW,RC   0,X5    AF(1)=REL WORD LOC OF KEY
*        CW,RC    RA          CW,RA    RC
*        BE       %+2         BCR,X3   %+2
*        BNE      *R1         BCS,X3   *R1
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         DOUBLE WORD KEYS
*
*        LCI      2           LCI      2
*        LM,RC    0,X4        LM,RC    0,X4    AF(1)=REL WORD LOC OF KEY
*        LM,RE    0,X5        LM,RE    0,X5    AF(1)=REL WORD LOC OF KEY
*        LAD,RA   RC          LAD,RA   RC
*        LAD,RC   RE          LAD,RC   RE
*        CD,RC    RA          CD,RA    RC
*        BE       %+2         BCR,X3   %+2
*        BNE      *R1        BCS,X3   *R1
*
*  THOSE BINARY KEYS NOT FITTING INTO ONE OF THE PREVIOUS CATEGORIES
*       WILL BE COMPARED AS SHOWN BELOW.
*
*   ASCENDING SEQUENCE   DESCENDING SEQUENCE         MISCELLANEOUS SIZES
*
*        LI,X6    0           LI,X6    0      AF(1)=KEY LENGTH
*        LI,RA    0           LI,RA    0      AF(1)=REL BYTE LOC OF KEY
*        BAL,R0   BNABSA      BAL,R0   BNABSD
*                                             RETURN HERE IF KEYS ARE
*                                             EQUAL--OTHERWISE EXIT
*
         PAGE
*
*  THESE ARE THE SKELETON COMMAND CONSTANT FROM WHICH THE PRECEEDING
*       COMPARISON SEQUENCES ARE BUILT
*
*
*
ZTRAN    BAL,R0   ZTRANA
         BAL,R0   ZTRAND
*
PTRAN    BAL,R0   PTRANA
         BAL,R0   PTRAND
*
*
*
ATRAN    BAL,R0   ATRANA
         BAL,R0   ATRAND
*
*
*
BHACOM   LAH,RA   *X4,X6
         LAH,RC   *X5,X6
*
BFACOM   LAW,RA   0,X4
         LAW,RC   0,X5
*
BDACOM   LM,RC    0,X4
         LM,RE    0,X5
         LAD,RA   RC
         LAD,RC   RE
*
BMACOM   BAL,R0   BNABSA
ENDP11   RES      0
         BAL,R0   BNABSD
         PAGE
*
         END

