* CATALOG NO 704985-1  SIGMA 5/7 SORT             OVERLAY 1             P1  0000
*  VERSION C00                                                          P1  0001
         SYSTEM   SIG7FDP                                               P1  0002
         SYSTEM   BPM                                                   P1  0003
PGMSEG1  CSECT    0                                                     P1  0004
*                                                                       P1  0005
         PAGE                                                           P1  0006
*                                                                       P1  0007
         DEF      SCR1,RLTMP,SIN33B,BMCOM
         DEF      AX5M,BDACPR,BFACPR,BHACPR,BHCOM,ER2,KCOM,KSTRTC
         DEF      MSREC,SCR3,SEQEND,SIN3R,SIN33,SREC,STORSAM
         DEF      TOURN,TRAPEN,TRAPNE,TRNIST,VGN03,VGN07,VGN09,VGN10
         REF      BCT0,CPER,DEVSTP,ILLDEC,FCT0,FCT4,RLKCM,SIN1R         P1  0009
         REF      MASAD,DECSV,STT0,CNVRT,KRDSC,KRASC,MASKS,EVDEA        P1  0010
         REF      EVDED,BNEBC,EBCBN,DECTRP,KLNGC,RWMOV                  P1  0011
         REF      DECSAV,BNCMPA,BNCMPD
         REF      SINTMP,INPORD,CRSF                                    P1  0013
         REF      ENDSORT
         REF      COMSTOPA,COMSTOPD
         SREF     ZDCT,PDCT,ALFT,BNAV
         SREF     SCR2X,SIN315X,SIN33X,SIN35X,VGENX
         SREF     S:INPUT
         PAGE                                                           P1  0014
*                                                                       P1  0015
X0       EQU      0                                                     P1  0016
X1       EQU      1                                                     P1  0017
X2       EQU      2                                                     P1  0018
X3       EQU      3                                                     P1  0019
X4       EQU      4                                                     P1  0020
X5       EQU      5                                                     P1  0021
X6       EQU      6                                                     P1  0022
X7       EQU      7                                                     P1  0023
R0       EQU      8                                                     P1  0024
R1       EQU      9                                                     P1  0025
R2       EQU      10                                                    P1  0026
R3       EQU      11                                                    P1  0027
R4       EQU      12                                                    P1  0028
R5       EQU      13                                                    P1  0029
R6       EQU      14                                                    P1  0030
R7       EQU      15                                                    P1  0031
SR1      EQU      8                                                     P1  0032
SR2      EQU      9                                                     P1  0033
SR3      EQU      10                                                    P1  0034
RA       EQU      10                                                    P1  0035
RB       EQU      11                                                    P1  0036
RC       EQU      12                                                    P1  0037
RD       EQU      13                                                    P1  0038
RE       EQU      14                                                    P1  0039
RF       EQU      15                                                    P1  0040
R13      EQU      13                                                    P1  0041
R14      EQU      14                                                    P1  0042
PRAMLOC  EQU      SIN1R+1                                               P1  0043
BINEBC   EQU      BNEBC                                                 P1  0044
KTYPC    DATA,4   50                                                    P1  0045
*                                                                       P1  0046
         PAGE                                                           P1  0047
*                                                                /VALUESP1  0048
INITBL   DATA,4   0,0,MASKS,50,0,0                         /SIG7-4137/*EP1  0049
*                                                                       P1  0050
KORDC    DATA     0                                                     P1  0051
KSTRTC   DATA     0                 STARTING BYTE OF KEY                P1  0052
KNUM     DATA     0                                                     P1  0053
TCMP     DATA,1   C'Z',C'P',C'A',C'B'                                   P1  0054
TRANVEC  DATA,4   ZDEC,PDEC,ALPH,BINA,ZDCT,PDCT,ALFT,BNAV               P1  0055
KLNTBL   DATA,1   31,16,255,8,31,16,255,8                               P1  0056
*                                                                       P1  0057
         PAGE                                                           P1  0058
*                                                                       P1  0059
SCR1R    DATA     0                                                     P1  0060
SCR1     STW,X5   SCR1R             SAVE RETURN ADDRESS                 P1  0061
         LI,5     ENDP1
         STW,5    ENDSORT
         LW,5     KRASC                                    /SIG7-4137/*EP1  0062
         STW,5    INITBL                                   /SIG7-4137/*EP1  0063
         LW,5     KRDSC                                    /SIG7-4137/*EP1  0064
         STW,5    INITBL+1                                 /SIG7-4137/*EP1  0065
SCR3     RES      0                 RETURN FROM MODUALE P1A
         BAL,X5   SIN3              GENERATE KEY COMPARISON ROUTINE     P1  0069
         LW,X5    CPER                                                  P1  0070
         BNE      *SCR1R                                                P1  0071
SCR4     RES      0
         BAL,X5   VGEN              GENERATE STT0-LOAD CORE             P1  0075
         B        *SCR1R            RETURN TO SEGMENT 0                 P1  0076
*                                                                       P1  0077
         PAGE                                                           P1  0078
*                                                                       P1  0079
*                                                                       P1  0080
*                                                                       P1  0081
*  THIS ROUTINE GENERATES TWO KEY COMPARISON ROUTINES.  ONE FOR         P1  0082
*       COMPARISONS IN THE SENSE (ASCENDING/DESCENDING) REQUESTED       P1  0083
*       IN THE SORT KEY SPECIFICATIONS AND THE OTHER IN THE EXACT       P1  0084
*       OPPOSITE SENSE.                                                 P1  0085
*                                                                       P1  0086
*  AT ENTRY TO THIS ROUTINE                                             P1  0087
*        REGISTER:  5=THE RETURN ADDRESS                                P1  0088
*                                                                       P1  0089
*  ON EXIT THE COMPARE SEQUENCE HAS BEEN GENERATED                      P1  0090
*                                                                       P1  0091
         PAGE                                                           P1  0092
*                                                                       P1  0093
*                                                                       P1  0094
SIN3R    DATA     0                                                     P1  0095
*                                                                       P1  0096
KASCL    DATA     0                 ADDR OF BEG OF AC SEQ               P1  0097
KDSCL    DATA     0                 ADDR OF BEG OF DEC SEQ              P1  0098
KMSKWD   DATA     0                 ADDR OF BEG MASK TABLE              P1  0099
CURKEY   DATA     0                 MASK NEEDED SWITCH 0 NEEDED         P1  0100
KMSKND   DATA     0                 MASK NEEDED SW 0 NEEDED             P1  0101
CKNUM    DATA     0,0                                                   P1  0102
*                                                                       P1  0103
SIN3     STW,X5   SIN3R             SAVE RETURN ADDRESS                 P1  0104
         LCI      6                                                     P1  0105
         LM,X2    INITBL            INITIALIZE SIN3 CONSTANTS           P1  0106
         STM,X2   KASCL                                                 P1  0107
         BAL,R1   GNSKY             GO GET NUMBER OF SORT KEYS          P1  0108
         SCS,X6   16                RIGHT JUSTIFIED                     P1  0109
         STW,X6   CNVRT                                                 P1  0110
         BAL,R1   EBCBN             GO CONVERT TO BINARY                P1  0111
         LW,X6    CNVRT+1                                               P1  0112
         STW,X6   KNUM              NUMBER OF SORT KEYS                 P1  0113
         STW,X1   CKNUM             SET FOR FIRST KEY                   P1  0114
*                                                                       P1  0115
         PAGE                                                           P1  0116
*                                                                       P1  0117
*  INITIALZATION FOR SIN3 IS COMPLETE.  BEGIN LOOPING ON KEY PARAMETERS.P1  0118
*                                                                       P1  0119
SIN31    LW,X7    CURKEY                                                P1  0120
         LI,2     0                                        /SIG7-4137/*EP1  0121
         STW,2    KMSKND                                   /SIG7-4137/*EP1  0122
         LW,R2    CKNUM                                                 P1  0123
         STW,R2   CNVRT+1                                               P1  0124
         BAL,X5   BINEBC            CONVERT KEY NUMBER TO EBCDIC        P1  0125
         LW,X5    CNVRT+1                                               P1  0126
         STH,X5   EOB+1                                                 P1  0127
         STH,X5   EOC+1
         STH,X5   EOD+1
         STH,X5   EOE+1                                                 P1  0128
         STH,X5   EOF+1                                                 P1  0129
         LB,R2    *PRAMLOC,X7       KEY TYPE                            P1  0130
         LI,X2    3                 BYTE INDEX                          P1  0131
SIN312   LB,R1    TCMP,X2                                               P1  0132
         CW,R1    R2                                                    P1  0133
         BE       SIN315            YES:                                P1  0134
         BDR,X2   SIN312            NO:                                 P1  0135
         LB,R1    TCMP              IS DATA TYPE Z                      P1  0136
         CW,R1    R2                                                    P1  0137
         BE       SIN315                                                P1  0138
         LI,RF    X'B'              DATA TYPE MESSAGE                   P1  0139
         BAL,R2   ER2                                                   P1  0140
SIN315   RES      0
         LW,X6    CRSF              CHECK IF CO-RESIDENT
         BEZ      SIN315X           NO. GO TO P1A
SIN33    STW,X2   KTYPC                                                 P1  0141
         LW,X5    CURKEY                                                P1  0142
         AI,X5    1                                                     P1  0143
         BAL,R1   GKSTR             GET STARTING BYTE LOCATION          P1  0144
         STW,X6   CNVRT                                                 P1  0145
         BAL,R1   EBCBN             CONVERT TO BINARY                   P1  0146
         LW,X6    CNVRT+1                                               P1  0147
         CW,X6    RLKCM                                                 P1  0148
         BLE      %+3                                                   P1  0149
         LI,RF    X'E'              START MESSAGE                       P1  0150
         BAL,R2   ER2                                                   P1  0151
         AI,6     7                 ADJ FOR 2 ADDED WORDS  /SIG7-2254/*DP1  0152
         STW,X6   KSTRTC                                                P1  0153
         LW,X5    CURKEY                                                P1  0154
         AI,X5    5                                                     P1  0155
         BAL,R1   GKLNG             GET KEY LENGTH                      P1  0156
         SCS,X6   24                RIGHT JUSTIFIED                     P1  0157
         STW,X6   CNVRT                                                 P1  0158
         BAL,R1   EBCBN             CONVERT TO BINARY                   P1  0159
         LW,X6    CNVRT+1                                               P1  0160
         STW,X6   KLNGC                                                 P1  0161
         AW,X6    KSTRTC                                                P1  0162
         AI,6     -8                                       /SIG7-2254/*DP1  0163
         LW,R2    CRSF              CHECK IF CO-RESIDENT
         BEZ      SIN33X            NO. GO TO P1A
SIN33B   RES      0                 RETURN FROM P1A
         CW,X6    RLKCM                                                 P1  0164
         BLE      %+3                                                   P1  0165
         LI,RF    X'F'              LENGTH MESSAGE                      P1  0166
         BAL,R2   ER2                                                   P1  0167
         LW,X5    KTYPC             KEY LENGTH                          P1  0168
         LW,X6    KLNGC              KEY LENGTH                         P1  0169
         CB,X6    KLNTBL,X5         COMPARE AGAINST MAXIMUM VALUE       P1  0170
         BLE      %+3               LESS THAN OR EQUAL TO MAXIMUM VALUE P1  0171
         LI,RF    X'F'              GREATER THAN MAXIMUM--ILLEGAL       P1  0172
         BAL,R2   ER2                   CONDITION--PRINT MESSAGE        P1  0173
         LW,X5    CURKEY            BASE BYTE LOC FOR KEY PARAMETERS    P1  0174
         AI,X5    8                     FOR THIS KEY+8 = ORDER BYTE LOC P1  0175
         LB,X6    *PRAMLOC,X5       ORDER (A OR D)                      P1  0176
         LI,X7    1                 SET FOR DESCENDING                  P1  0177
         CI,X6    C'D'              IS KEY AN ASCENDING KEY             P1  0178
         BE       SIN34             NO:  DESCENDING                     P1  0179
         LI,X7    0                 YES:  ASCENDING   SET X7            P1  0180
SIN34    STW,X7   KORDC             SET KORDC =0 IF ASCEND, =1 IF DESC  P1  0181
         LW,X6    KTYPC                                                 P1  0182
         LW,X5    TRANVEC,X6                                            P1  0183
         BAL,X5   *X5                                                   P1  0184
*                                       ROUTINE                         P1  0185
         LI,X5    10                                                    P1  0186
         AWM,X5   CURKEY            INCREMENT PARAMETER BASE            P1  0187
         MTW,1    CKNUM             COUNT KEY                           P1  0188
         MTW,RF   KNUM              IS THIS THE LAST KEY                P1  0189
         BNE      SIN31             NO:  GO TO NEXT KEY                 P1  0190
*                                                                       P1  0191
*  THIS REGION FINISHES THE COMPARE SEQUENCE AFTER ALL KEY PARAMETERS   P1  0192
*       HAVE BEEN PROCESSED.                                            P1  0193
*                                                                       P1  0194
         LI,5     0                                        /SIG7-2254/*DP1  0195
         STW,5    KORDC                                    /SIG7-2254/*DP1  0196
         LW,6     BFCOM                                    /SIG7-2254/*DP1  0197
         AI,6     1                                        /SIG7-2254/*DP1  0198
         LW,9     KASCL
         STW,9    COMSTOPA
         LW,9     KDSCL
         STW,9    COMSTOPD
         BAL,R1   STORU1AI                                 /SIG7-2254/*DP1  0199
         LW,6     BFCOM+1                                  /SIG7-2254/*DP1  0200
         AI,6     1                                        /SIG7-2254/*DP1  0201
         BAL,R1   STORU1DI                                 /SIG7-2254/*DP1  0202
         BAL,R0   SEQEND                                   /SIG7-2254/*DP1  0203
         LW,X5    CRSF              CHECK IF CO-RESIDENT
         BEZ      SIN35X            NO. GO TO P1A
         B        *SIN3R            EXIT                                P1  0204
         PAGE                                                           P1  0205
*                                                                       P1  0206
*                                                                       P1  0207
VGENR    DATA     0,0                                                   P1  0208
*                                                                       P1  0209
VGEN     STW,X5   VGENR             SAVE RETURN ADDRESS                 P1  0210
         LW,X5    CRSF              CHECK IF CO-RESIDENT
         BEZ      VGENX             NO. GO TO P1A TO INITIALIZE TOURN.
         LI,X1    1                                                     P1  0211
         LH,X6    BCT0+4            SORT       RECORD LENGTH            P1  0212
         LH,2     BCT0+15           INPUT BYTE INCR
         CI,2     0
         BE       VGEN001
         AI,6     4
         B        %+2
VGEN001  AI,6     3
         STW,X6   SREC                                                  P1  0214
         LW,X6    MASAD             MASS RECORD STORAGE ADDRESS         P1  0215
         STW,X6   MSREC                                                 P1  0216
         LH,X6    BCT0+1,X1         NUMBER OF RECORDS IN TOURNAMENT     P1  0217
         STW,X6   TOURN                                                 P1  0218
         LI,X2    0                 STT0 INDEX                          P1  0219
*                                                                       P1  0220
VGN01    LI,6     17
         LW,X7    MSREC             RECORD'S ADDRESS IN MASS STORAGE    P1  0222
         SLS,X7   2                     AS A BYTE ADDRESS               P1  0223
         AI,7     8                  PLUS 2 WORDS          /SIG7-2254/*DP1  0224
         MTW,1    INPORD                                                P1  0225
         LW,8     INPORD             CREATE LOW ORDER KEY  /SIG7-2254/*DP1  0226
         STW,8    *MSREC,1                                 /SIG7-2254/*DP1  0227
         BAL,11   S:INPUT                                               P1  0228
         STW,7    10                                                    P1  0229
         CI,7     0                                                     P1  0230
         BG       %+3                                                   P1  0231
         STW,7    8                                                     P1  0232
         OR,7     =X'80000000'                                          P1  0233
         STW,7    FCT0+17
         STW,8    12                                                    P1  0235
         LW,11    MSREC                                                 P1  0236
         AI,11    2                                                     P1  0237
         SLS,11   2                                                     P1  0238
         BAL,9    RWMOV                                                 P1  0239
         BAL,R1   VGN10                                                 P1  0240
         STH,R0   RLTMP                                                 P1  0241
         LI,X7    0                                                     P1  0242
         STH,X2   X7                FIRST ENTRY ORDINATE AND            P1  0243
         SLS,X7   1                     RECORD'S MASS MEMORY ADDRESS    P1  0244
         AW,X7    MSREC                 INTO ONE WORD AND THEN          P1  0245
         STW,X7   *STT0,X2              INTO STT0                       P1  0246
         AW,X7    SREC              ADDRESS OF SECOND RECORD OF THE     P1  0247
         STW,X7   *MSREC                PAIR INTO FIRST RECORD          P1  0248
         LW,7     FCT0+17
         AND,7    =X'7FFFF'                                             P1  0250
         BE       VGN07                                                 P1  0251
         LW,X7    SREC              NO:  SET NEXT RECORD'S ADDRESS      P1  0252
         AWM,X7   MSREC                 INTO MSREC FOR SECOND READ      P1  0253
         LW,X7    MSREC                                                 P1  0254
         SLS,X7   2                                                     P1  0255
         AI,7     8                  PLUS 2 WORDS          /SIG7-2254/*DP1  0256
         MTW,1    INPORD                                                P1  0257
         LW,8     INPORD            CREATE LOW ORDER KEY   /SIG7-2254/*DP1  0258
         STW,8    *MSREC,1                                 /SIG7-2254/*DP1  0259
         BAL,11   S:INPUT                                               P1  0260
         STW,7    10                                                    P1  0261
         CI,7     0                                                     P1  0262
         BG       %+3                                                   P1  0263
         STW,7    8                                                     P1  0264
         OR,7     =X'80000000'                                          P1  0265
         STW,7    FCT0+17
         STW,8    12                                                    P1  0267
          LW,11   MSREC                                                 P1  0268
         AI,11    2                                                     P1  0269
         SLS,11   2                                                     P1  0270
         BAL,9    RWMOV                                                 P1  0271
         BAL,R1   VGN10                                                 P1  0272
         STH,R0   RLTMP,X1                                              P1  0273
         LW,R0    RLTMP                                                 P1  0274
         STW,R0   *MSREC            STORE RECORD LENGTH IS OF BOTH RECRDP1  0275
         LW,X7    SREC                                                  P1  0276
         AWM,X7   MSREC                                                 P1  0277
         LW,7     FCT0+17
         AND,7    =X'7FFFF'                                             P1  0279
         BE       VGN09                                                 P1  0280
         LW,X4    *STT0,X2          NO:  PREDICTED WINNER'S ADDRESS     P1  0281
         LW,X5    *X4                    PREDICTED LOSER'S ADDRESS      P1  0282
         BAL,R1   *KRDSC            GO,COMP REC ON KEYS    /SIG7-4137/*EP1  0283
         BGE      VGN02             GO PREPARE FOR NEXT COMPARISON      P1  0284
         LW,X4    *STT0,X2          EXCHANGE RECORD ENTRIES             P1  0285
         LW,X5    0,X4              LOSER ADD--REALLY WINNER            P1  0286
         LW,X6    0,X5                                                  P1  0287
         SCS,X6   16                                                    P1  0288
         STW,X6   0,X4                                                  P1  0289
         STW,X4   0,X5                                                  P1  0290
         STW,X5   *STT0,X2                                              P1  0291
VGN02    MTW,1    X2                                                    P1  0292
         MTW,14   TOURN             IS TOURNAMENT FULL                  P1  0293
         BNE      VGN01             NO:   GO PROCESS NEXT PAIR          P1  0294
*                                                                       P1  0295
         PAGE                                                           P1  0296
*                                                                       P1  0297
*  THE TOURNAMENT HAS BEEN FILLED AND EACH RECORD PAIR HAS PRODUCED     P1  0298
*       ONE WINNER AND ONE LOSER.  TOURNAMENT INFORMATION IS STORED     P1  0299
*       AS:                                                             P1  0300
*          BIT            0                 14/15/16                  31P1  0301
*         *STT0           FIRST ENTRY ORDINATE/ WINNER'S ADDRESS        P1  0302
*         *WINNER(WORD 0) FIRST ENTRY ORDINATE/ LOSER'S ADDRESS         P1  0303
*         *LOSER (WORD 0) WINNERS RECORD LENGTH  /LOSER'S RECORD LENGTH P1  0304
*                                                                       P1  0305
*  THE FOLLOWING CODE WILL TRANSFORM THE TOURNAMENT INFORMATION         P1  0306
*       TO:                                                             P1  0307
*          BIT            0                 14/15/16                  31P1  0308
*         *STT0           FIRST ENTRY ORDINATE/ LOSER'S RECORD ADDRESS  P1  0309
*         *LOSER (WORD 0) NEXT ENTRY ORDINATE    /LOSER'S RECORD LENGTH P1  0310
*         *WINNER(WORD 0)                        /WINNER'S RECORD LENGTHP1  0311
*                                                                       P1  0312
         PAGE                                                           P1  0313
*                                                                       P1  0314
         LI,X3    0                 STT0 ORDINATE--X-LEVEL RESULTS      P1  0315
VGN03    LCI      2                                                     P1  0316
         LM,X4    *STT0,X3          THE WINNER'S OF THE X-LEVEL COMPARESP1  0317
         BAL,R1   *KRDSC            GO,COMP REC ON KEYS    /SIG7-4137/*EP1  0318
         BGE      VGN04             EXCHANGE NOT NECESSARY              P1  0319
         LCI      2                 EXCHANGE CONTROLWORDS               P1  0320
         LM,X4    *STT0,X3                                              P1  0321
         XW,X4    X5                                                    P1  0322
         LCI      2                                                     P1  0323
         B        VGN05                                                 P1  0324
*                                                                       P1  0325
*  THIS REGION CREATES ONE X-LEVEL ENTRY SHOWING THE RESULTS OF THIS    P1  0326
*       COMPARISON AND CHANGES THE TWO X-LEVEL ENTRIES THAT WENT INTO   P1  0327
*       THIS COMPARE INTO Y-LEVEL ENTRIES                               P1  0328
*                                                                       P1  0329
VGN04    LCI      2                                                     P1  0330
         LM,X4    *STT0,X3                                              P1  0331
VGN05    STM,X4   BCT0+9                                                P1  0332
         LW,X6    0,X4              WINNER'S LOSER ADDRESS AND FED      P1  0333
         LW,RA    0,X6              WINNER'S RECORD LENGTH              P1  0334
         LW,X6    0,X5              LOSER'S LOSER ADDRESS AND FED       P1  0335
         LW,RB    0,X6              LOSER'S RECORD LENGTH               P1  0336
         SLD,RA   -16                                                   P1  0337
         STH,RA   RLTMP             SAVE LENGTHS                        P1  0338
         STH,RB   RLTMP,X1                                              P1  0339
         LCI      2                                                     P1  0340
         LM,X4    *STT0,X3                                              P1  0341
         LW,X6    0,X4              X-LOSER  FED AND ADDRESS I          P1  0342
         STW,X6   *STT0,X3                                              P1  0343
         LW,RA    0,X6                                                  P1  0344
         STH,RA   *X6,X1                                                P1  0345
         STH,X2   *X6               NEXT ENTRY ORDINATE AND RECORD LNGTHP1  0346
         AI,X3    1                 INCREMENT X-LEVEL INDEX             P1  0347
         LW,X6    0,X5              X-LOSER  FEO AND ADDRESS            P1  0348
         STW,X6   *STT0,X3                                              P1  0349
         LW,RA    0,X6              LOSER RECORD LENGTH                 P1  0350
         STH,RA   *X6,X1                                                P1  0351
         STH,X2   *X6               NEXT ENTRY ORDINATE                 P1  0352
         AI,X3    1                 INCREMENT X-LEVEL INDEX             P1  0353
         LW,X6    BCT0+9            FEO AND WINNER ADDRESS              P1  0354
         LW,X7    BCT0+10           Y-LEVEL LOSER-CREATE X-LEVEL ENTRY  P1  0355
         STW,X6   *STT0,X2          FEO AND WINNER ADDRESS              P1  0356
         STW,X7   0,X6              FEO AND LOSER ADDRESS               P1  0357
         LW,RA    RLTMP                                                 P1  0358
         STW,RA   0,X7              WINNER RECORD LENGTH/LOSER RCD LNGTHP1  0359
         CW,X3    X2                IS X-LEVEL INDEX = Y-LEVEL INDEX    P1  0360
         BE       VGN06             YES:  ALL DONE                      P1  0361
         AI,X2    1                 INCREMENT Y-LEVEL INDEX AND         P1  0362
         B        VGN03                 GO TO PROCESS THE NEXT PAIR     P1  0363
*                                                                       P1  0364
         PAGE                                                           P1  0365
*                                                                       P1  0366
*  THIS ROUTINE TRANSFORMS THE FINAL ENTRY INTO A Y-LEVEL ENTRY         P1  0367
*       TYPE AND SETS THE WINNER'S ENTRY INTO BCT0+9 AND BCT0+10        P1  0368
*       AS THE FIRST SELECTEE OF THE SORT                               P1  0369
*                                                                       P1  0370
VGN06    LW,X6    BCT0+10           FEO   LOSER'S ADDRESS               P1  0371
         STW,X6   *STT0,X2          FEO--LOSERS ADDRESS                 P1  0372
         LH,X7    RLTMP,X1                                              P1  0373
         STW,X7   0,X6              NEO--RECORD LENGTH                  P1  0374
         LH,X7    RLTMP             THE TOURNAMENT TABLE HAS BEEN       P1  0375
         STW,X7   BCT0+10               COMPLETED AND THE FIRST RECORD  P1  0376
         STW,X7   *BCT0+9                                               P1  0377
         B        *VGENR                HAS BEEN SELECTED--EXIT         P1  0378
*                                                                       P1  0379
         PAGE                                                           P1  0380
*                                                                       P1  0381
*                                                                       P1  0382
*  THIS REGION PROCESSES END OF FILE CONDITIONS OCCURRING DURING        P1  0383
*       THE INITIAL CORE LOAD PROCESS.                                  P1  0384
*                                                                       P1  0385
*  EOF DETECTED ON THE FIRST RECORD OF A RECORD PAIR                    P1  0386
*                                                                       P1  0387
VGN07    CI,X2    0                                                     P1  0388
         BE       VGN08                                                 P1  0389
         CI,X2    1                 ONLY ONE PAIR          /SIG7-1040/*CP1  0390
         BE       VGN12             YES                    /SIG7-1040/*CP1  0391
         SLS,X2   1                                                     P1  0392
         STH,X2   BCT0+1,X1         ADJUST NUMBER OF RECORDS TO ACTUAL  P1  0393
         SLS,X2   -1                RESTORE INDEX                       P1  0394
         B        VGN03-1                                               P1  0395
*       THE INPUT FILE WAS EMPTY THERE ARE NO RECORDS INTO THE SORT     P1  0396
VGN08    STH,X2   BCT0+1,X1                                             P1  0397
         STW,X2   BCT0+9                                                P1  0398
         STW,X2   BCT0+10                                               P1  0399
         B        *VGENR                                                P1  0400
*                                                                       P1  0401
*  EOF DETECTED ON THE SECOND RECORD OF A RECORD PAIR                   P1  0402
*                                                                       P1  0403
VGN09    CI,X2    0                 ONLY ONE RECORD        /SIG7-1040/*CP1  0404
         BE       VGN14             YES                    /SIG7-1040/*CP1  0405
         LW,X6    *STT0,X2          WINNER'S ADDRESS       /SIG7-1040/*CP1  0406
         LW,X7    0,X6                                                  P1  0407
         OR,X7    =X'60000000'      SET END OF FILE INDICATOR           P1  0408
         STW,X7   0,X6                                                  P1  0409
         AI,X2    1                 INCREMENT INDEX FOR Y-LEVEL COMPARESP1  0410
         B        VGN07             GO FINISH PROCESSING STT0           P1  0411
*                                                                       P1  0412
VGN10    LW,R14   R0                ACTUAL RECORD LENGTH                P1  0413
         AI,14    X'F'              ACCT FOR RCW'S AND EVEN/SIG7-2254/*DP1  0414
*                                   WORD IN ORDER          /SIG7-2254/*DP1  0415
         AND,R14  =X'FFFC'              EVEN MULTIPLE OF FOUR           P1  0416
         CW,8     FCT4
         BLE      VGN11             YES:  GO CREATE RCW'S               P1  0418
         LW,R0    FCT4              NO:  TRUNCATE THE RECORD            P1  0419
         AI,R0    -12                                      /SIG7-2254/*DP1  0420
         LW,R14   FCT4                                                  P1  0421
         AND,14   =X'3'             IS IT EVEN WORD MULT
         BNEZ     %+3                NO
         LW,14    FCT4
         B        VGN11
         LW,14    FCT4
         SLS,14   -2                TO WORDS
         AI,14    1                  UP TO NEXT WORD
         SLS,14   2                 BACK TO BYTES
VGN11    STW,R0   R13                                                   P1  0422
         STW,R14  R0                                                    P1  0423
         SLS,R14  -2                    R13 AND CONVERT TO WORD IN R14  P1  0424
         AW,R14   MSREC             TRAILER RCW ADDRESS PLUS ONE        P1  0425
         AI,R14   -1                                                    P1  0426
         STH,R13  *R14              SAVE ACTUAL RECORD LENGTH           P1  0427
         STH,R0   *R14,X1           SAVE SORT/MERGE RECORD LENGTH       P1  0428
         B        *R1               EXIT                                P1  0429
*                                                                       P1  0430
*        ONLY TWO RECORDS INPUT                            /SIG7-1040/*CP1  0431
VGN12    LW,X6    *STT0             FEO WINNER ADDRESS     /SIG7-1040/*CP1  0432
         STW,X6   BCT0+9                                   /SIG7-1040/*CP1  0433
         LW,R14   0,X6              FEO LOSER ADDRESS      /SIG7-1040/*CP1  0434
         STW,R14  *STT0             SET STT0 ENTRY         /SIG7-1040/*CP1  0435
         LW,X6    *R14              WIN/LOSER RCD LENGTH   /SIG7-1040/*CP1  0436
         LH,X7    X6                WINNER RCD LENGTH      /SIG7-1040/*CP1  0437
         STW,X7   BCT0+10           TO BCT0+10             /SIG7-1040/*CP1  0438
         STW,X7   *BCT0+9           AND TO WINNER RCW      /SIG7-1040/*CP1  0439
         AND,X6   =X'FFFF'          LOSER'S RCD LENGTH     /SIG7-1040/*CP1  0440
         STW,X6   *R14              TO LOSER RCW           /SIG7-1040/*CP1  0441
         B        *VGENR                                   /SIG7-1040/*CP1  0442
*        ONLY ONE RECORD INPUT                             /SIG7-1040/*CP1  0443
VGN14    LW,X6    *STT0             FEO WINNER ADDRESS     /SIG7-1040/*CP1  0444
         STH,X2   BCT0+1,X1         SET FLAG FOR 1 RCD IN  /SIG7-1040/*CP1  0445
         STW,X6   BCT0+9            TO BCT0+9              /SIG7-1040/*CP1  0446
         LH,X7    RLTMP             WINNER RECORD LENGTH   /SIG7-1040/*CP1  0447
         STW,X7   *X6                                      /SIG7-1040/*CP1  0448
         STW,X7   BCT0+10           TO BCT0+10             /SIG7-1040/*CP1  0449
         B        *VGENR                                   /SIG7-1040/*CP1  0450
*                                                          /SIG7-1040/*CP1  0451
         PAGE                                                           P1  0452
*                                                                       P1  0453
*  THIS REGION  GENERATES THE CODE FOR ZONED DECIMAL KEYS               P1  0454
*       REQUIRING NO TRANSLATION.                                       P1  0455
*                                                                       P1  0456
ZDECR    DATA     0                                                     P1  0457
*                                                                       P1  0458
ZDEC     STW,X5   ZDECR             SAVE RETURN ADDRESS                 P1  0459
         LI,X5    0                 INITIALIZE WORD COUNT               P1  0460
         LW,X6    KCOM             *LI,X6   0                           P1  0461
         AW,X6    KSTRTC            PLUS RELATIVE BYTE LOC OF KEY       P1  0462
         BAL,R1   STORSAM           GO STORE INTO TEMP AND COUNT IN X5  P1  0463
         LI,X6    1                                                     P1  0464
         AND,X6   KLNGC             IS EVEN NUMBER                      P1  0465
         BE       ZDEC3             YES                                 P1  0466
         LW,X6    KLNGC                                                 P1  0467
         AI,X6    1                                                     P1  0468
         AND,X6   =X'1E'            L=(BL+1)/2                          P1  0469
         SLS,X6   19                                                    P1  0470
         LW,X7    =X'FF0FFFFF'                                          P1  0471
         LS,X6    ZDCOM+2          *PACK,L                              P1  0472
         BAL,R1   STORU1D           STORE ASC-U1 ADDRS-STORE CESC-COUNT P1  0473
         LS,X6    ZDCOM            *DST,L   DECSAV                      P1  0474
         BAL,R1   STORSAM                                               P1  0475
         LS,X6    ZDCOM+2          *PACK,L                              P1  0476
         BAL,R1   STORU1A           STORE DESC-U1 ADDRS-STORE ASC-COUNT P1  0477
         LD,RA    DCOM             *BCS,8   DTRPE--BCS,8   DTRPN        P1  0478
         BAL,R1   TRAPNE                                                P1  0479
ZDEC1    LS,X6    ZDCOM+1          *DC,L   DECSAV                       P1  0480
         BAL,R1   STORSAM                                               P1  0481
         LD,RA    DCOM             *BCS,8                               P1  0482
         BAL,R1   TRAPEN                                                P1  0483
ZDEC2    BAL,R0   SEQEND            BCR,X3  %+2, BCS,X3  *R1            P1  0484
         B        *ZDECR                                                P1  0485
*                                                                       P1  0486
ZDEC3    LW,X6    ZDCE              LI,X7    LENGTH                     P1  0487
         AW,X6    KLNGC                                                 P1  0488
         BAL,R1   STORSAM                                               P1  0489
         LW,X6    ZDCE+1            BAL,R0   DEVSTP                     P1  0490
         BAL,R1   STORSAM                                               P1  0491
         LD,RA    ZDCEM                                                 P1  0492
         BAL,R1   TRAPNE                                                P1  0493
         B        ZDEC2                                                 P1  0494
         PAGE                                                           P1  0495
*                                                                       P1  0496
*  THIS REGION GENERATES THE CODE FOR PACKED DECIMAL KEYS               P1  0497
*       REQUIRING NO TRANSLATION.                                       P1  0498
*                                                                       P1  0499
PDECR    DATA     0                                                     P1  0500
*                                                                       P1  0501
PDEC     STW,X5   PDECR             SAVE RETURN ADDRESS                 P1  0502
         LI,X5    0                 INITIALIZE WORD COUNT               P1  0503
         LW,X6    KCOM             *LI,X6   0                           P1  0504
         AW,X6    KSTRTC                                                P1  0505
         BAL,R1   STORSAM                                               P1  0506
         LW,X6    KLNGC             BYTE LENGTH                         P1  0507
         SLS,X6   20                                                    P1  0508
         LW,X7    =X'FF0FFFFF'                                          P1  0509
         LS,X6    PDCOM            *DL,0                                P1  0510
         BAL,R1   STORU1A                                               P1  0511
         LD,RA    DCOM                                                  P1  0514
         BAL,R1   TRAPEN            TRAPE TO DESC                       P1  0515
PDEC1    LS,X6    PDCOM+1          *DC,0                                P1  0516
         BAL,R1   STORU1D                                               P1  0517
         LD,RA    DCOM                                                  P1  0520
         BAL,R1   TRAPNE            TRAPN TO DESC                       P1  0521
PDEC2    BAL,R0   SEQEND                                                P1  0522
         B        *PDECR                                                P1  0523
*                                                                       P1  0524
         PAGE                                                           P1  0525
*                                                                       P1  0526
*  THIS REGION GENERATES THE CODE FOR ALPHANUMERIC KEYS                 P1  0527
*       REQUIRING NO TRANSLATION.                                       P1  0528
*                                                                       P1  0529
ALPHR    DATA     0                                                     P1  0530
*                                                                       P1  0531
ALPH     STW,X5   ALPHR             SAVE RETURN ADDRESS                 P1  0532
ALP1     LI,X5    0                 INITIALIZE WORD COUNT               P1  0533
*                                                                       P1  0534
*  THIS REGION EXTRACTS THE STARTING POSITION AND LENGTH OF THE         P1  0535
*       KEY THAT FITS INTO ONE WORD AND CALLS THE APPROPRIATE           P1  0536
*       GENERATOR ROUTINE                                               P1  0537
*                                                                       P1  0538
         LI,X6    X'3'              COMPUTE THE RELATIVE POSITON        P1  0539
         AND,X6   KSTRTC                OF THE FIRST BYTE OF THE        P1  0540
         STW,X6   SINTMP                KEY WITHIN A COMPUTER WORD.     P1  0541
         AW,X6    KLNGC             PLUS LENGTH                         P1  0542
         CI,X6    X'4'                                                  P1  0543
         BLE      ALP2                                                  P1  0544
         LI,X6    X'4'              LENGTH MODULO 4                     P1  0545
ALP2     SW,X6    SINTMP            MINUS FIRST BYTE POSITION           P1  0546
         STW,X6   SINTMP+1              =LENGTH WITHIN COMPUTER WORD.   P1  0547
         LW,X7    KSTRTC                                                P1  0548
         SLS,X7   -2                CONVERT BYTE TO WORD ADDRESS        P1  0549
         STW,X7   SINTMP+2          WORD ADDRESS OF KEY                 P1  0550
         AWM,X6   KSTRTC            UPDATE BEGINNING BYTE ADDRESS       P1  0551
         LCW,RA   X6                SET LENGTH=LENGTH MINUS LENGTH BEINGP1  0552
         AWM,RA   KLNGC                 HANDLED BY THE CURRENT SEQUENCE.P1  0553
         CI,X6    4                 IS THIS A FULL WORD OF KEY          P1  0554
         BE       ALP3              YES:  BYPASS PARTIAL WORD PROCESSINGP1  0555
*                                                                       P1  0556
         BAL,R0   MASKGEN           NO:  PARTIAL WORD                   P1  0557
         B        ALP4              BYPASS FULL WORD                    P1  0558
*                                                                       P1  0559
ALP3     MTW,0    KMSKND            IS THIS INSTRUCTION NEEDED          P1  0560
         BNE      ALP4              NO:  BYPASS ITS GENERATION          P1  0561
         LW,X6    MSKCOM+2         *LI,X7   -1                          P1  0562
         STW,6    KMSKND                                   /SIG7-4137/*EP1  0563
         BAL,R1   STORSAM           SET INTO COMMAND SEQUENCE           P1  0564
ALP4     LW,X6    ACOM             *LW,X6   0,X4                        P1  0565
         AW,X6    SINTMP+2          RELATIVE WORD POSITION              P1  0566
         BAL,R1   STORU1AI                                              P1  0567
         LW,X6    ACOM+1           *CS,X6   0,X4                        P1  0568
         AW,X6    SINTMP+2          RELATIVE WORD POSITON               P1  0569
         BAL,R1   STORU1DI                                              P1  0570
         BAL,R0   SEQEND           *BCR,X3  %+2,BCS,X3  *R1             P1  0571
         LW,X6    KLNGC                                                 P1  0572
         CI,X6    0                 IS KEY FINISHED                     P1  0573
         BNE      ALP1              NO:  CONTINUE                       P1  0574
         B        *ALPHR            EXIT                                P1  0575
*                                                                       P1  0576
         PAGE                                                           P1  0577
*                                                                       P1  0578
*                                                                       P1  0579
*  THIS REGION GENERATES THE CODE FOR BINARY KEYS TO BE COMPARED        P1  0580
*       AS ALGEBRAIC QUANTITIES.                                        P1  0581
*                                                                       P1  0582
BINAR    DATA     0                                                     P1  0583
*                                                                       P1  0584
BINA     STW,X5   BINAR             SAVE RTURN ADDRESS                  P1  0585
         LI,X5    0                                                     P1  0586
         LW,X6    KSTRTC                                                P1  0587
         SLS,X6   -2                RELATIVE WORD POSITON               P1  0588
         STW,X6   SINTMP+2                                              P1  0589
         LI,X7    1                                                     P1  0590
         AND,X7   KSTRTC            DOES KEY START ON A HALF/FULL WORD  P1  0591
         BNE      BINA2             NO:  BYPASS SEQUENCE TEST/BOUNDARY  P1  0592
         LI,X7    1                 YES:  SEE IF IT IS AN EVEN NUMBER   P1  0593
         AND,X7   KLNGC                 OF BYTES.                       P1  0594
         BNE      BINA2             NOT EVEN NUMBER:  BYPASS SEQUENCE   P1  0595
         LW,X7    KLNGC             EVEN NUMBER                 /TESTS  P1  0596
         LI,X6    2                                                     P1  0597
         AND,X6   KSTRTC            IS KEY ON A WORD BOUNDARY           P1  0598
         BNE      BINA1             NO:  HALF WORD                      P1  0599
         CI,X7    8                 IS KEY A DOUBLE-WORD KEY            P1  0600
         BE       BINA4             YES:  DOUBLE-WORD                   P1  0601
         CI,X7    4                 IS KEY A FULL WORD KEY              P1  0602
         BE       BINA5             YES:  FULL-WORD                     P1  0603
BINA1    CI,X7    2                 IS KEY A HALF-WORD KEY              P1  0604
         BE       BINA6             YES:  HALF-WORD                     P1  0605
*                                                                       P1  0606
         PAGE                                                           P1  0607
*                                                                       P1  0608
*  THIS REGION GENERATES CODE FOR THOSE KEYS NOT MEETING THE            P1  0609
*       CRITERIA FOR A NATURAL HARDWARE SEQUENCE.                       P1  0610
*                                                                       P1  0611
BINA2    BAL,R0   TRNIST                                                P1  0612
         LD,RA    BMCOM+2                                               P1  0613
         BAL,R1   TRAPEN                                                P1  0614
         BAL,R0   AX5M                                                  P1  0615
         B        *BINAR                                                P1  0616
* CODE DELETED
*                                                                       P1  0618
*  THIS REGION GENERATES CODE FOR DOUBLE-WORD KEYS.                     P1  0619
*                                                                       P1  0620
BINA4    LW,X6    BMCOM            *LCI     2                           P1  0621
         BAL,R1   STORSAM                                               P1  0622
         LW,X6    SINTMP+2         *LM,RA    0,X5                       P1  0623
         OR,X6    BDCOM            *LM,RA   0,X5                        P1  0624
         BAL,R1   STORSAM                                               P1  0625
         LW,X6    BDCOM+1          *LM,RC   0,X4                        P1  0626
         OR,X6    SINTMP+2                                              P1  0627
         BAL,R1   STORSAM                                               P1  0628
         LD,RA    BDCOM+2                                               P1  0629
         BAL,R1   TRAPEN           *CD,RA   RC/CD,RC   RA               P1  0630
BINA3    BAL,8    SEQEND
         B        *BINAR                                                P1  0631
*                                                                       P1  0632
*  THIS REGION GENERATES CODE FOR FULL WORD KEYS.                       P1  0633
*                                                                       P1  0634
BINA5    LW,X6    BFCOM            *LW,RA   0,X5                        P1  0635
         OR,X6    SINTMP+2                  REL WORD POS                P1  0636
         BAL,R1   STORU1AI                                              P1  0637
         LW,X6    BFCOM+1          *CW,RA   0,X4                        P1  0638
         OR,X6    SINTMP+2                  REL WORD POS                P1  0639
         BAL,R1   STORU1DI                                              P1  0640
         B        BINA3                                                 P1  0641
*                                                                       P1  0642
*  THIS REGION GENERATES CODE FOR HALF-WORD KEYS.                       P1  0643
*                                                                       P1  0644
BINA6    LW,X6    KSTRTC                                                P1  0645
         SLS,X6   -1                                                    P1  0646
         STW,X6   SINTMP+2          HALF WORD REL LOC                   P1  0647
         OR,X6    KCOM              ON HALFWORD BOUNDARY   /SIG7-0741/*CP1  0648
         BAL,R1   STORSAM           YES:                   /SIG7-0741/*CP1  0649
         LW,X6    BHCOM            *LH,RA   *X4,X6                      P1  0650
         BAL,R1   STORU1A                                               P1  0651
         LW,X6    BHCOM+1                                               P1  0652
         BAL,R1   STORU1D                                               P1  0653
         B        BINA3                                                 P1  0654
*                                                                       P1  0655
         PAGE                                                           P1  0656
*                                                                       P1  0657
*  THIS ROUTINE LOADS CORE INITIALLY WITH RECORDS AND BUILDS THE        P1  0658
*       TOURNAMENT CONTROL TABLE (STT0).                                P1  0659
*                                                                       P1  0660
MSREC    DATA     0                                                     P1  0661
SREC     DATA     0                                                     P1  0662
TOURN    DATA     0                                                     P1  0663
RLTMP    DATA     0                                                     P1  0664
*                                                                       P1  0665
         PAGE                                                           P1  0666
*                                                                       P1  0667
*  THESE ARE THE SKELETON COMMAND CONSTANT FROM WHICH THE PRECEEDING    P1  0668
*       COMPARISON SEQUENCES ARE BUILT                                  P1  0669
*                                                                       P1  0670
*                                                                       P1  0671
KCOM     LI,X6    0                                                     P1  0672
         BE       0                                                     P1  0673
         BNE      *R1                                                   P1  0674
ZDCOM    DST,0    DECSAV            EXCLUSIVELY ZONED DECIMAL           P1  0675
         DC,0     DECSAV                                                P1  0676
         PACK,0   *X4,X6                                                P1  0677
         BOUND    8                                                     P1  0678
DCOM     RES      0
         BCS,8    DECTRP            TRAP ON BAD KEY
         BCS,8    DECTRP            TRAP ON BAD KEY
*                                                                       P1  0681
ZDCEM    BAL,R0   EVDED                                                 P1  0682
         BAL,R0   EVDEA                                                 P1  0683
*                                                                       P1  0684
ZDCE     LI,X7    0                                                     P1  0685
         BAL,R0   DEVSTP                                                P1  0686
*                                                                       P1  0687
*       NOTE:  THE COMMANDS:  BCS,8    DTRPE AND                        P1  0688
*                             BCS,8    DTRPN ARE                        P1  0689
*                             NOT INCLUDED IN THE COMMAND SEQUENCE      P1  0690
*                             UNLESS THE CONTINUE AFTER ILLEGAL         P1  0691
*                             DECIMAL DIGIT OPTION WAS SELECTED.        P1  0692
*                                                                       P1  0693
PDCOM    DL,0     *X4,X6            EXCLUSIVELY PACKED DECIMAL          P1  0694
         DC,0     *X4,X6                                                P1  0695
*                                                                       P1  0696
*                                                                       P1  0699
ACOM     LW,X6    0,X4                                                  P1  0700
         CS,X6    0,X4                                                  P1  0701
*                                                                       P1  0702
BHCOM    LH,RA    *X4,X6                                                P1  0703
         CH,RA    *X4,X6                                                P1  0704
*                                                                       P1  0705
BFCOM    LW,RA    0,X4                                                  P1  0706
         CW,RA    0,X4                                                  P1  0707
*                                                                       P1  0708
BDCOM    LM,RA    0,X5                                                  P1  0709
         LM,RC    0,X4                                                  P1  0710
         CD,RA    RC                                                    P1  0711
         CD,RC    RA                                                    P1  0712
*                                                                       P1  0713
BMCOM    LCI      2                                                     P1  0714
         LI,RA    0                                                     P1  0715
         BAL,R0   BNCMPA                                                P1  0716
         BAL,R0   BNCMPD                                                P1  0717
*                                                                       P1  0718
BDACPR   CD,RC    RA                                                    P1  0719
         CD,RA    RC                                                    P1  0720
*                                                                       P1  0721
BFACPR   CW,RC    RA                                                    P1  0722
         CW,RA    RC                                                    P1  0723
*                                                                       P1  0724
BHACPR   CH,RC    RA                                                    P1  0725
         CH,RA    RC                                                    P1  0726
*                                                                       P1  0727
*                                                                       P1  0728
GENMSK   DATA,4   X'FF000000',X'FF0000',X'FF00',X'FF'                   P1  0729
*                                                                       P1  0730
MSKCOM   LI,X7    0                                                     P1  0731
         LW,X7    0                                                     P1  0732
         LI,X7    -1                                                    P1  0733
*                                                                       P1  0734
*                                                                       P1  0737
*                                                                       P1  0738
         PAGE                                                           P1  0739
*                                                                       P1  0740
GKSTR    LW,X6    PRAMLOC                                               P1  0741
         SLS,X6   2                                                     P1  0742
         AW,X6    X5                SOURCE                              P1  0743
         LW,X7    =X'4000000'       COUNT                               P1  0744
         AI,X7    BA(SINTMP+4)      DESTINATION                         P1  0745
GKST1    LI,RC    0                                                     P1  0746
         STW,RC   SINTMP+4                                              P1  0747
         MBS,X6   0                                                     P1  0748
         LW,X6    SINTMP+4                                              P1  0749
         B        *R1                                                   P1  0750
*                                                                       P1  0751
GNSKY    LI,X5    24                                                    P1  0752
         LH,X6    *PRAMLOC,X5       NUMBER OF SORT KEYS                 P1  0753
         SLS,X6   16                LEFT JUSTUFIED IN X6                P1  0754
         B        *R1                                                   P1  0755
*                                                                       P1  0756
GKLNG    LW,X6    PRAMLOC                                               P1  0757
         SLS,X6   2                                                     P1  0758
         AW,X6    X5                SOURCE  ADDRESS                     P1  0759
         LW,X7    =X'3000000'       COUNT                               P1  0760
         AI,X7    BA(SINTMP+4)      DESTINATION                         P1  0761
         B        GKST1                                                 P1  0762
*                                                                       P1  0763
*                                                                       P1  0764
         PAGE                                                           P1  0765
*                                                                       P1  0766
*  THESE ROUTINES ARE SERVICE ROUTINES USED IN CODE GENERATION          P1  0767
*                                                                       P1  0768
STORSAM  STW,X6   *KASCL,X5         STORE INTO REQUESTED SEQUENCE       P1  0769
STOR1    STW,X6   *KDSCL,X5         STORE INTO OPPOSING SEQUENCE        P1  0770
         AI,X5    1                 COUNT WORD USED                     P1  0771
         B        *R1               RETURN                              P1  0772
*                                                                       P1  0773
STORU1D  STW,X6   *KASCL,X5                                             P1  0774
         OR,X6    =X'1'                                                 P1  0775
         B        STOR1                                                 P1  0776
*                                                                       P1  0777
STORU1A  STW,X6   *KDSCL,X5                                             P1  0778
         OR,X6    =X'1'                                                 P1  0779
STOR2    STW,X6   *KASCL,X5                                             P1  0780
STOR3    AI,X5    1                                                     P1  0781
         B        *R1                                                   P1  0782
*                                                                       P1  0783
TRAPNE   STW,RA   *KDSCL,X5         TRAPE                               P1  0784
         STW,RB   *KASCL,X5                                             P1  0785
         B        STOR3                                                 P1  0786
*                                                                       P1  0787
TRAPEN   XW,RA    RB                                                    P1  0788
         B        TRAPNE                                                P1  0789
*                                                                       P1  0790
STORU1DI STW,X6   *KASCL,X5                                             P1  0791
         OR,X6    =X'20000'                                             P1  0792
         B        STOR1                                                 P1  0793
*                                                                       P1  0794
STORU1AI STW,X6   *KDSCL,X5                                             P1  0795
         OR,X6    =X'20000'                                             P1  0796
         B        STOR2                                                 P1  0797
*                                                                       P1  0798
*                                                                       P1  0799
TRNIST   LI,X5    0                                                     P1  0800
         LW,X6    KCOM             *LI,X6    0                          P1  0801
         OR,X6    KLNGC                      BYTE LENGTH                P1  0802
         BAL,R1   STORSAM                                               P1  0803
         LW,X6    BMCOM+1          *LI,RA    0                          P1  0804
         OR,X6    KSTRTC                     BYTE DISPLACEMENT          P1  0805
         BAL,R1   STORSAM                                               P1  0806
         B        *R0                                                   P1  0807
*                                                                       P1  0808
*                                                                       P1  0809
SEQEND   LW,RA    KCOM+1                                                P1  0810
         LW,RB    KCOM+1                                                P1  0811
         LW,RC    KORDC                                                 P1  0812
         BE       SEQE1             BYPASS EXCHANGE                     P1  0813
         BAL,R1   EXSEQ             GO EXCHANGE ASCENDING AND DESCENDINGP1  0814
SEQE1    AW,RA    KDSCL                                                 P1  0815
         AW,RB    KASCL                                                 P1  0816
         AI,X5    2                                                     P1  0817
         AW,RA    X5                                                    P1  0818
         AW,RB    X5                                                    P1  0819
         AI,X5    -2                                                    P1  0820
         BAL,R1   TRAPNE                                                P1  0821
         LW,X6    KCOM+2                                                P1  0822
         BAL,R1   STORSAM                                               P1  0823
         AWM,X5   KDSCL                                                 P1  0824
         AWM,X5   KASCL                                                 P1  0825
         B        *R0                                                   P1  0826
*                                                                       P1  0827
AX5M     LW,RC    KORDC                                                 P1  0828
         BE       AX5M1                                                 P1  0829
         BAL,R1   EXSEQ                                                 P1  0830
AX5M1    AWM,X5   KASCL                                                 P1  0831
         AWM,X5   KDSCL                                                 P1  0832
         B        *R0                                                   P1  0833
*                                                                       P1  0834
*                                                                       P1  0837
EXSEQ    LW,X6    X5                                                    P1  0838
EXSE1    LW,RC    *KASCL,X6                                             P1  0839
         XW,RC    *KDSCL,X6                                             P1  0840
         STW,RC   *KASCL,X6                                             P1  0841
         MTW,15   X6                                                    P1  0842
         BGE      EXSE1                                                 P1  0843
         B        *R1                                                   P1  0844
         PAGE                                                           P1  0845
*                                                                       P1  0846
*  THIS ROUTINE GENERATES A PARTIAL WORD MASK AND THE APPROPRIATE       P1  0847
*       INSTRUCTION:  LW OR LI TO GO WITH IT.                           P1  0848
*                                                                       P1  0849
MASKGEN  LI,X3    0                 SET INDICATOR TO SHOW THAT A        P1  0850
         STW,X3   KMSKND                FULL WORD MASK WILL BE NEEDED   P1  0851
         LW,X3    SINTMP            FIRST BYTE POSITION                 P1  0852
         LW,X4    SINTMP+1          BYTE LENGTH                         P1  0853
         LW,X6    GENMSK,X3         AN-8-BIT MASK                       P1  0854
MASKG1   AI,X3    1                                                     P1  0855
         MTW,15   X4                                                    P1  0856
         BE       MASKG2            FINISHED                            P1  0857
         OR,X6    GENMSK,X3                                             P1  0858
         B        MASKG1                                                P1  0859
*                                                                       P1  0860
* THE MASK HAS BEEN GENERATED NOW IT MUST BE INSERTED INTO THE CODE     P1  0861
*       SEQUENCE                                                        P1  0862
*                                                                       P1  0863
MASKG2   LW,RA    SINTMP                                                P1  0864
         CI,RA    2                 CAN ALOAD IMMEDIATE COMMAND BE USED P1  0865
         BL       MASKG4            NO:  USE LOAD WORD                  P1  0866
         OR,X6    MSKCOM           *LI,X7                               P1  0867
MASKG3   BAL,R1   STORSAM           GO STORE INSTRUCTION IN COMMAND     P1  0868
         B        *R0                   SEQUENCE AND RETURN--EXIT       P1  0869
*                                                                       P1  0870
*  USE LW,X7  COMMAND.  PLACE MASK IN TABLE.                            P1  0871
*                                                                       P1  0872
MASKG4   STW,X6   *KMSKWD           STORE MASK INTO MASK TABLE          P1  0873
         LW,X6    KMSKWD            LOAD MASK ADDRESS                   P1  0874
         MTW,1    KMSKWD            UPDATE MASK TABLE ADDRESS FOR MORE  P1  0875
         OR,X6    MSKCOM+1         *LW,X7   0                           P1  0876
         B        MASKG3                                                P1  0877
*                                                                       P1  0878
         PAGE                                                           P1  0879
EOB      TEXTC    'KEYXX:  DATA TYPE'
EOC      TEXTC    'KEYXX:  TRANSLATION ERROR'
EOD      TEXTC    'KEYXX:  ABSVAL'
EOE      TEXTC    'KEYXX:  START'
EOF      TEXTC    'KEYXX:  LENGTH'
ERTBL    DATA,4   EOB,EOC,EOD,EOE,EOF
         PAGE                                                           P1  0884
*                                                                       P1  0885
ER2R     DO1      9                                                     P1  0886
         DATA     0                                                     P1  0887
*                                                                       P1  0888
ER2      STW,R2   ER2R              SAVE RETURN ADDRESS                 P1  0889
         LCI      7                                                     P1  0890
         STM,X6   ER2R+1                                                P1  0891
         LI,X6    X'11'             SPECIFICATION ERROR                 P1  0892
         STW,X6   CPER              CAUSE ABORT AFTER THIS PHASE        P1  0893
         XW,RF    X7                                                    P1  0894
         LW,R1    ERTBL-11,X7                                           P1  0895
         STW,R1   ER2R+8                                                P1  0896
         M:PRINT  (MESS,*ER2R+8)    PRINT MESSAGE                       P1  0897
         LCI      7                                                     P1  0898
         LM,X6    ER2R+1                                                P1  0899
ENDP1    RES      0
         B        *ER2R             RETURN                              P1  0900
         PAGE                                                           P1  0901
*                                                                       P1  0902
         END                                                            P1  0903

