*        PART 1 OF SORTP1
* CATALOG NO 704985-1  SIGMA 5/7 SORT             OVERLAY 1
*  VERSION C00
         SYSTEM   SIG7FDP
         SYSTEM   BPM
         CSECT    0
*
         PAGE
*
         DEF      SCR1,SIN33,SIN3R
         DEF      BDACPR,BFACPR,BHACPR,BMCOM
         DEF      ER2,KASCL,KCOM,KSTRTC,KTRANI,SEQEND
         DEF      STORSAM,STOR1,TRAPEN,TRNIST
         REF      CNVRT,KRASC,MASKS,DECSAV,DECTRP
         REF      BNCMPA,BNCMPD
         REF      DEVSTP,EVDEA,EVDED
         REF      BNEBC,EBCBN
         REF      SINTMP,RLKCM
         REF      KLNGC
         REF      ENDSNAP
         REF      SRTMIN
         REF      CPER,CRSF
*
         REF      PRAMLOC,COMPSTOP
         SREF     ZDCT,PDCT,ALFT,BNAV,SIN315X,SIN35X
         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
INITBL   DATA,4   0,MASKS,50,0,0
*
KORDC    DATA     0
KSTRTC   DATA     0                 STARTING BYTE OF KEY
KNUM     DATA     0
TCMP     DATA,1   C'Z',C'P',C'A',C'B'
TRANVEC  DATA,4   ZDEC,PDEC,ALPH,BINA,ZDCT,PDCT,ALFT,BNAV
KLNTBL   DATA,1   31,16,255,8,31,16,255,8
*
         PAGE
*
SCR1R    DATA     0
SCR1     STW,X5   SCR1R             SAVE RETURN ADDRESS
         LI,5     ENDP1
         STW,5    ENDSNAP            IN CASECOF DUMP
         LW,5     KRASC                                    /SIG7-4137/*E4985
         STW,5    INITBL                                   /SIG7-4137/*E4985
         BAL,X5   SIN3              GENERATE KEY COMPARISON ROUTINE
         BCR,0    *SCR1R            RETURN TO SEGMENT 0
*
         PAGE
*
*
*
*  THIS ROUTINE GENERATES TWO KEY COMPARISON ROUTINES.  ONE FOR
*       COMPARISONS IN THE SENSE (ASCENDING/DESCENDING) REQUESTED
*       IN THE SORT KEY SPECIFICATIONS AND THE OTHER IN THE EXACT
*       OPPOSITE SENSE.
*
*  AT ENTRY TO THIS ROUTINE
*        REGISTER:  5=THE RETURN ADDRESS
*
*  ON EXIT THE COMPARE SEQUENCE HAS BEEN GENERATED
*
         PAGE
*
*
SIN3R    DATA     0
*
KASCL    DATA     0                 ADDR OF BEG OF AC SEQ
KMSKWD   DATA     0                 ADDR OF BEG MASK TABLE
CURKEY   DATA     0                 MASK NEEDED SWITCH 0 NEEDED
KTRANI   DATA     0                 TRANS PARM 0 NO CARDS
KMSKND   DATA     0                 MASK NEEDED SW 0 NEEDED
CKNUM    DATA     0,0
*
SIN3     STW,X5   SIN3R             SAVE RETURN ADDRESS
         LCI      5
         LM,X2    INITBL            INITIALIZE SIN3 CONSTANTS
         STM,X2   KASCL
         BAL,R1   GNSKY             GO GET NUMBER OF SORT KEYS
         SCS,X6   16                RIGHT JUSTIFIED
         STW,X6   CNVRT
         BAL,R1   EBCBN             GO CONVERT TO BINARY
         LW,X6    CNVRT+1
         STW,X6   KNUM              NUMBER OF SORT KEYS
         STW,X1   CKNUM             SET FOR FIRST KEY
*
         PAGE
*
*  INITIALZATION FOR SIN3 IS COMPLETE.  BEGIN LOOPING ON KEY PARAMETERS.
*
SIN31    LW,X7    CURKEY
         LI,2     0                                        /SIG7-4137/*E4985
         STW,2    KMSKND                                   /SIG7-4137/*E4985
         LW,R2    CKNUM
         STW,R2   CNVRT+1
         BAL,X5   BINEBC            CONVERT KEY NUMBER TO EBCDIC
         LW,X5    CNVRT+1
         STH,X5   EOB+1
         STH,X5   EOC+1
         STH,X5   EOD+1
         STH,X5   EOE+1
         STH,X5   EOF+1
         LB,R2    *PRAMLOC,X7       KEY TYPE
         LI,X2    3                 BYTE INDEX
SIN312   LB,R1    TCMP,X2
         CW,R1    R2
         BCR,X3   SIN315            YES:
         BDR,X2   SIN312            NO:
         LB,R1    TCMP              IS DATA TYPE Z
         CW,R1    R2
         BCR,X3   SIN315            YES:
         LI,RF    X'B'              DATA TYPE MESSAGE
         BAL,R2   ER2
SIN315   RES      0
         LW,X6    CRSF             IS IT CO-RESIDENT
         BEZ      SIN315X          NO.
SIN33    STW,X2   KTYPC
         LW,X5    CURKEY
         AI,X5    1
         BAL,R1   GKSTR             GET STARTING BYTE LOCATION
         STW,X6   CNVRT
         BAL,R1   EBCBN             CONVERT TO BINARY
         LW,X6    CNVRT+1
         CW,X6    RLKCM
         BCR,X2   %+3
         LI,RF    X'E'              START MESSAGE
         BAL,R2   ER2
         AI,6     7                 ADJ FOR 2 ADDED WORDS  /SIG7-2254/*D4985
         STW,X6   KSTRTC
         LW,X5    CURKEY
         AI,X5    5
         BAL,R1   GKLNG             GET KEY LENGTH
         SCS,X6   24                RIGHT JUSTIFIED
         STW,X6   CNVRT
         BAL,R1   EBCBN             CONVERT TO BINARY
         LW,X6    CNVRT+1
         STW,X6   KLNGC
         AW,X6    KSTRTC
         AI,6     -8                                       /SIG7-2254/*D4985
         MTW,0    SRTMIN            1 ST TIME THRU WILL BE ZERO
         BNEZ     SIN33A
         STW,6    SRTMIN            1 ST KEY HIGH LOC
         B        SIN33B
SIN33A   CW,6     SRTMIN             CURR KEY VERSUS PREV
         BLE      SIN33B
         STW,6    SRTMIN            HIGHER KEY SO SAVE
SIN33B   CW,6     RLKCM
         BCR,X2   %+3
         LI,RF    X'F'              LENGTH MESSAGE
         BAL,R2   ER2
         LW,X5    KTYPC             KEY LENGTH
         LW,X6    KLNGC              KEY LENGTH
         CB,X6    KLNTBL,X5         COMPARE AGAINST MAXIMUM VALUE
         BCR,X2   %+3               LESS THAN OR EQUAL TO MAXIMUM VALUE
         LI,RF    X'F'              GREATER THAN MAXIMUM--ILLEGAL
         BAL,R2   ER2                   CONDITION--PRINT MESSAGE
         LW,X5    CURKEY            BASE BYTE LOC FOR KEY PARAMETERS
         AI,X5    8                     FOR THIS KEY+8 = ORDER BYTE LOC
         LB,X6    *PRAMLOC,X5       ORDER (A OR D)
         LI,X7    1                 SET FOR DESCENDING
         CI,X6    C'D'              IS KEY AN ASCENDING KEY
         BCR,X3   SIN34             NO:  DESCENDING
         LI,X7    0                 YES:  ASCENDING   SET X7
SIN34    STW,X7   KORDC             SET KORDC =0 IF ASCEND, =1 IF DESC
         LW,X6    KTYPC
         LW,X5    TRANVEC,X6
         BAL,X5   *X5
*                                       ROUTINE
         LI,X5    10
         AWM,X5   CURKEY            INCREMENT PARAMETER BASE
         MTW,1    CKNUM             COUNT KEY
         MTW,RF   KNUM              IS THIS THE LAST KEY
         BCS,X3   SIN31             NO:  GO TO NEXT KEY
*
*  THIS REGION FINISHES THE COMPARE SEQUENCE AFTER ALL KEY PARAMETERS
*       HAVE BEEN PROCESSED.
*
         LI,5     0                                        /SIG7-2254/*D4985
         STW,5    KORDC                                    /SIG7-2254/*D4985
         LW,6     BFCOM                                    /SIG7-2254/*D4985
         LW,9     KASCL             WORD/POS BEGIN OF UNIQUE/KEY/SEQN
         AI,6     1
         STW,9    COMPSTOP
         BAL,9    STORUD
         LW,6     BFCOM+1                                  /SIG7-2254/*D4985
         AI,6     1                                        /SIG7-2254/*D4985
         BAL,9    STORUC
         BAL,R0   SEQEND                                   /SIG7-2254/*D4985
         LW,6     STOR1+1          B *9 TERMINATE CMP SEQ
         STW,6    *KASCL
         LW,X5    CRSF             IS IT CO-RESIDENTT
         BEZ      SIN35X           NO.
         B        *SIN3R           EXIT
         PAGE
*
*  THIS REGION  GENERATES THE CODE FOR ZONED DECIMAL KEYS
*       REQUIRING NO TRANSLATION.
*
ZDECR    DATA     0
*
ZDEC     STW,X5   ZDECR             SAVE RETURN ADDRESS
         LI,X5    0                 INITIALIZE WORD COUNT
         LW,X6    KCOM             *LI,X6   0
         AW,X6    KSTRTC            PLUS RELATIVE BYTE LOC OF KEY
         BAL,R1   STORSAM           GO STORE INTO TEMP AND COUNT IN X5
         LI,X6    1
         AND,X6   KLNGC             IS EVEN NUMBER
         BCR,X3   ZDEC3             YES
         LW,X6    KLNGC
         AI,X6    1
         AND,X6   =X'1E'            L=(BL+1)/2
         SLS,X6   19
         STW,6    SAVE6             SAVE FOR FUTURE LS
         LW,X7    =X'FF0FFFFF'
         LS,X6    ZDCOM+2          *PACK,L
         BAL,9    STORUA
         LW,6     DCOM
         BAL,9    STORSAM
         LW,6     SAVE6             RESTORE FOR LS
         LS,X6    ZDCOM            *DST,L   DECSAV
         BAL,R1   STORSAM
         LS,X6    ZDCOM+2          *PACK,L
         BAL,9    STORUB
         LW,6     DCOM
         BAL,9    STORSAM
         LW,6     SAVE6             RESTORE FOR LS
         LS,6     ZDCOM+1           * DC,L DECSAV
         BAL,R1   STORSAM
ZDEC2    BAL,R0   SEQEND            BCR,X3  %+2, BCS,X3  *R1
         BCR,0    *ZDECR
*
ZDEC3    LW,X6    ZDCE              LI,X7    LENGTH
         AW,X6    KLNGC
         BAL,R1   STORSAM
         LW,X6    ZDCE+1            BAL,R0   DEVSTP
         BAL,R1   STORSAM
         LD,RA    ZDCEM
         BAL,9    TRAPEN+1
         BCR,0    ZDEC2
         PAGE
*
*  THIS REGION GENERATES THE CODE FOR PACKED DECIMAL KEYS
*       REQUIRING NO TRANSLATION.
*
PDECR    DATA     0
*
PDEC     STW,X5   PDECR             SAVE RETURN ADDRESS
         LI,X5    0                 INITIALIZE WORD COUNT
         LW,X6    KCOM             *LI,X6   0
         AW,X6    KSTRTC
         BAL,R1   STORSAM
         LW,X6    KLNGC             BYTE LENGTH
         SLS,X6   20
         STW,6    SAVE6             SAVE FOR FUTURE LS
         LW,X7    =X'FF0FFFFF'
         LS,X6    PDCOM            *DL,0
         BAL,9    STORUB
         LW,6     DCOM
         BAL,9    STORSAM
         LW,6     SAVE6             RESTORE FOR LS
         LS,6     PDCOM+1           * DC,0
         BAL,9    STORUA
         LW,6     DCOM
         BAL,9    STORSAM
         BAL,8    SEQEND
         BCR,0    *PDECR
*
         PAGE
         PAGE
*
*  THIS REGION GENERATES THE CODE FOR ALPHANUMERIC KEYS
*       REQUIRING NO TRANSLATION.
*
ALPHR    DATA     0
*
ALPH     STW,X5   ALPHR             SAVE RETURN ADDRESS
ALP1     LI,X5    0                 INITIALIZE WORD COUNT
*
*  THIS REGION EXTRACTS THE STARTING POSITION AND LENGTH OF THE
*       KEY THAT FITS INTO ONE WORD AND CALLS THE APPROPRIATE
*       GENERATOR ROUTINE
*
         LI,X6    X'3'              COMPUTE THE RELATIVE POSITON
         AND,X6   KSTRTC                OF THE FIRST BYTE OF THE
         STW,X6   SINTMP                KEY WITHIN A COMPUTER WORD.
         AW,X6    KLNGC             PLUS LENGTH
         CI,X6    X'4'
         BCR,X2   ALP2
         LI,X6    X'4'              LENGTH MODULO 4
ALP2     SW,X6    SINTMP            MINUS FIRST BYTE POSITION
         STW,X6   SINTMP+1              =LENGTH WITHIN COMPUTER WORD.
         LW,X7    KSTRTC
         SLS,X7   -2                CONVERT BYTE TO WORD ADDRESS
         STW,X7   SINTMP+2          WORD ADDRESS OF KEY
         AWM,X6   KSTRTC            UPDATE BEGINNING BYTE ADDRESS
         LCW,RA   X6                SET LENGTH=LENGTH MINUS LENGTH BEING
         AWM,RA   KLNGC                 HANDLED BY THE CURRENT SEQUENCE.
         CI,X6    4                 IS THIS A FULL WORD OF KEY
         BCR,X3   ALP3              YES:  BYPASS PARTIAL WORD PROCESSING
*
         BAL,R0   MASKGEN           NO:  PARTIAL WORD
         BCR,0    ALP4              BYPASS FULL WORD
*
ALP3     MTW,0    KMSKND            IS THIS INSTRUCTION NEEDED
         BCS,X3   ALP4              NO:  BYPASS ITS GENERATION
         LW,X6    MSKCOM+2         *LI,X7   -1
         STW,6    KMSKND                                   /SIG7-4137/*E4985
         BAL,R1   STORSAM           SET INTO COMMAND SEQUENCE
ALP4     LW,X6    ACOM             *LW,X6   0,X4
         AW,X6    SINTMP+2          RELATIVE WORD POSITION
         BAL,9    STORUD
         LW,X6    ACOM+1           *CS,X6   0,X4
         AW,X6    SINTMP+2          RELATIVE WORD POSITON
         BAL,9    STORUC
         BAL,R0   SEQEND           *BCR,X3  %+2,BCS,X3  *R1
         LW,X6    KLNGC
         CI,X6    0                 IS KEY FINISHED
         BCS,X3   ALP1              NO:  CONTINUE
         BCR,0    *ALPHR            EXIT
*
         PAGE
*
*
*  THIS REGION GENERATES THE CODE FOR BINARY KEYS TO BE COMPARED
*       AS ALGEBRAIC QUANTITIES.
*
BINAR    DATA     0
*
BINA     STW,X5   BINAR             SAVE RTURN ADDRESS
         LI,X5    0
         LW,X6    KSTRTC
         SLS,X6   -2                RELATIVE WORD POSITON
         STW,X6   SINTMP+2
         LI,X7    1
         AND,X7   KSTRTC            DOES KEY START ON A HALF/FULL WORD
         BCS,X3   BINA2             NO:  BYPASS SEQUENCE TEST/BOUNDARY
         LI,X7    1                 YES:  SEE IF IT IS AN EVEN NUMBER
         AND,X7   KLNGC                 OF BYTES.
         BCS,X3   BINA2             NOT EVEN NUMBER:  BYPASS SEQUENCE
         LW,X7    KLNGC             EVEN NUMBER                 /TESTS
         LI,X6    2
         AND,X6   KSTRTC            IS KEY ON A WORD BOUNDARY
         BCS,X3   BINA1             NO:  HALF WORD
         CI,X7    8                 IS KEY A DOUBLE-WORD KEY
         BCR,X3   BINA4             YES:  DOUBLE-WORD
         CI,X7    4                 IS KEY A FULL WORD KEY
         BCR,X3   BINA5             YES:  FULL-WORD
BINA1    CI,X7    2                 IS KEY A HALF-WORD KEY
         BCR,X3   BINA6             YES:  HALF-WORD
*
         PAGE
*
*  THIS REGION GENERATES CODE FOR THOSE KEYS NOT MEETING THE
*       CRITERIA FOR A NATURAL HARDWARE SEQUENCE.
*
BINA2    BAL,R0   TRNIST
         LD,RA    BMCOM+2
         BAL,R1   TRAPEN
         AWM,5    KASCL
         BCR,0    *BINAR
*
*  THIS REGION GENERATES CODE FOR DOUBLE-WORD KEYS.
*
BINA4    LW,X6    BMCOM            *LCI     2
         BAL,R1   STORSAM
         LW,X6    SINTMP+2         *LM,RA    0,X5
         OR,X6    BDCOM            *LM,RA   0,X5
         BAL,R1   STORSAM
         LW,X6    BDCOM+1          *LM,RC   0,X4
         OR,X6    SINTMP+2
         BAL,R1   STORSAM
         LD,RA    BDCOM+2
         BAL,R1   TRAPEN           *CD,RA   RC/CD,RC   RA
BINA3    BAL,8    SEQEND
         BCR,0    *BINAR
*
*  THIS REGION GENERATES CODE FOR FULL WORD KEYS.
*
BINA5    LW,X6    BFCOM            *LW,RA   0,X5
         OR,X6    SINTMP+2                  REL WORD POS
         BAL,9    STORUD
         LW,X6    BFCOM+1          *CW,RA   0,X4
         OR,X6    SINTMP+2                  REL WORD POS
         BAL,9    STORUC
         BCR,0    BINA3
*
*  THIS REGION GENERATES CODE FOR HALF-WORD KEYS.
*
BINA6    LW,X6    KSTRTC
         SLS,X6   -1
         STW,X6   SINTMP+2          HALF WORD REL LOC
         OR,X6    KCOM              ON HALFWORD BOUNDARY   /SIG7-0741/*C4986
         BAL,R1   STORSAM           YES:                   /SIG7-0741/*C4986
         LW,X6    BHCOM            *LH,RA   *X4,X6
         BAL,9    STORUB
         LW,X6    BHCOM+1
         BAL,9    STORUA
         BCR,0    BINA3
*
         PAGE
*
*  THESE ARE THE SKELETON COMMAND CONSTANT FROM WHICH THE PRECEEDING
*       COMPARISON SEQUENCES ARE BUILT
*
*
KCOM     LI,X6    0
         BCR,X3   0
         BCS,X3   *R1
ZDCOM    DST,0    DECSAV            EXCLUSIVELY ZONED DECIMAL
         DC,0     DECSAV
         PACK,0   *X4,X6
DCOM     BCS,8    DECTRP            ABORT
         BOUND    8
*
ZDCEM    BAL,R0   EVDED
         BAL,R0   EVDEA
*
ZDCE     LI,X7    0
         BAL,R0   DEVSTP
*
PDCOM    DL,0     *X4,X6            EXCLUSIVELY PACKED DECIMAL
         DC,0     *X4,X6
*
*
*
ACOM     LW,X6    0,X4
         CS,X6    0,X4
*
*
BHCOM    LH,RA    *X4,X6
         CH,RA    *X4,X6
*
BFCOM    LW,RA    0,X4
         CW,RA    0,X4
*
BDCOM    LM,RA    0,X5
         LM,RC    0,X4
         CD,RA    RC
         CD,RC    RA
*
BMCOM    LCI      2
         LI,RA    0
         BAL,R0   BNCMPA
         BAL,R0   BNCMPD
*
*
*
BDACPR   CD,RC    RA
         CD,RA    RC
*
BFACPR   CW,RC    RA
         CW,RA    RC
*
BHACPR   CH,RC    RA
         CH,RA    RC
*
*
GENMSK   DATA,4   X'FF000000',X'FF0000',X'FF00',X'FF'
*
MSKCOM   LI,X7    0
         LW,X7    0
         LI,X7    -1
*
*
*
         PAGE
*
GKSTR    LW,X6    PRAMLOC
         SLS,X6   2
         AW,X6    X5                SOURCE
         LW,X7    =X'4000000'       COUNT
         AI,X7    BA(SINTMP+4)      DESTINATION
GKST1    LI,RC    0
         STW,RC   SINTMP+4
         MBS,X6   0
         LW,X6    SINTMP+4
         BCR,0    *R1
*
GNSKY    LI,X5    24
         LH,X6    *PRAMLOC,X5       NUMBER OF SORT KEYS
         SLS,X6   16                LEFT JUSTUFIED IN X6
         BCR,0    *R1
*
GKLNG    LW,X6    PRAMLOC
         SLS,X6   2
         AW,X6    X5                SOURCE  ADDRESS
         LW,X7    =X'3000000'       COUNT
         AI,X7    BA(SINTMP+4)      DESTINATION
         BCR,0    GKST1
*
*
         PAGE
*
*  THESE ROUTINES ARE SERVICE ROUTINES USED IN CODE GENERATION
*
STORSAM  STW,X6   *KASCL,X5         STORE INTO REQUESTED SEQUENCE
STOR1    AI,5     1                 COUNT WORD USED
         BCR,0    *R1               RETURN
*
*
TRAPEN   XW,10    11                GET ASC COMP IN 11
         MTW,0    KORDC             0 = ASC, NOT 0 = DESC
         BEZ      %+2
         XW,11    10                PUT DESC COMP IN 11
         STW,RB   *KASCL,X5
         B        STOR1
*
*
*
TRNIST   LI,X5    0
         LW,X6    KCOM             *LI,X6    0
         OR,X6    KLNGC                      BYTE LENGTH
         BAL,R1   STORSAM
         LW,X6    BMCOM+1          *LI,RA    0
         OR,X6    KSTRTC                     BYTE DISPLACEMENT
         BAL,R1   STORSAM
         BCR,0    *R0
*
*
SEQEND   LW,11    KCOM+1            BCR,3    0
         AW,RB    KASCL
         AI,X5    2
         AW,RB    X5
         AI,X5    -2
         STW,11   *KASCL,5          STORE INST
         AI,5     1                 COUNT WORD USED
         LW,X6    KCOM+2
         BAL,R1   STORSAM
         AWM,X5   KASCL
         BCR,0    *R0
*
* ADDS 1 TO BIT 31 UP THE REGISTER IF DESC KEY (4 TO 5)
STORUA   MTW,0    KORDC             0 IF ASC, NOT 0 IF DESC
         BEZ      %+2
         OR,6     =X'1'             ADD 1 TO REG 4 TO 5
         STW,6    *KASCL,5           STORE WORD
         B        STOR1
* ADDS 1 TO BIT 31 UP THE REGISTER IF ASC KEY (4 TO 5)
STORUB   MTW,0    KORDC
         BNEZ     %+2
         OR,6     =X'1'
         STW,6    *KASCL,5
         B        STOR1
* ADDS 1 TO BIT 14 UP THE INDEX REGISTER IF DESC KEY (4 TO 5)
STORUC   MTW,0    KORDC              0 IF ASC, NOT 0 IF DESC
         BEZ      %+2
         OR,6     =X'20000'         UP INDEX REG FROM 4 TO 5
         STW,6    *KASCL,5          STORE COMP INST
         B        STOR1
* ADDS 1 TO BIT 14 UP THE INDEX REGISTER IF ASC KEY (4 TO 5)
STORUD   MTW,0    KORDC
         BNEZ     %+2
         OR,6     =X'20000'
         STW,6    *KASCL,5
         B        STOR1
         PAGE
*
*  THIS ROUTINE GENERATES A PARTIAL WORD MASK AND THE APPROPRIATE
*       INSTRUCTION:  LW OR LI TO GO WITH IT.
*
MASKGEN  LI,X3    0                 SET INDICATOR TO SHOW THAT A
         STW,X3   KMSKND                FULL WORD MASK WILL BE NEEDED
         LW,X3    SINTMP            FIRST BYTE POSITION
         LW,X4    SINTMP+1          BYTE LENGTH
         LW,X6    GENMSK,X3         AN-8-BIT MASK
MASKG1   AI,X3    1
         MTW,15   X4
         BCR,X3   MASKG2            FINISHED
         OR,X6    GENMSK,X3
         BCR,0    MASKG1
*
* THE MASK HAS BEEN GENERATED NOW IT MUST BE INSERTED INTO THE CODE
*       SEQUENCE
*
MASKG2   LW,RA    SINTMP
         CI,RA    2                 CAN ALOAD IMMEDIATE COMMAND BE USED
         BCS,X1   MASKG4            NO:  USE LOAD WORD
         OR,X6    MSKCOM           *LI,X7
MASKG3   BAL,R1   STORSAM           GO STORE INSTRUCTION IN COMMAND
         BCR,0    *R0                   SEQUENCE AND RETURN--EXIT
*
*  USE LW,X7  COMMAND.  PLACE MASK IN TABLE.
*
MASKG4   STW,X6   *KMSKWD           STORE MASK INTO MASK TABLE
         LW,X6    KMSKWD            LOAD MASK ADDRESS
         MTW,1    KMSKWD            UPDATE MASK TABLE ADDRESS FOR MORE
         OR,X6    MSKCOM+1         *LW,X7   0
         BCR,0    MASKG3
*
SAVE6    DATA     0
         PAGE
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
*
ER2R     DO1      9
         DATA     0
*
ER2      STW,R2   ER2R              SAVE RETURN ADDRESS
         LCI      7
         STM,X6   ER2R+1
         LI,X6    X'11'             SPECIFICATION ERROR
         STW,X6   CPER              CAUSE ABORT AFTER THIS PHASE
         XW,RF    X7
         LW,R1    ERTBL-11,X7
         STW,R1   ER2R+8
         M:PRINT  (MESS,*ER2R+8)    PRINT MESSAGE
         LCI      7
         LM,X6    ER2R+1
ENDP1    RES      0
         BCR,0    *ER2R             RETURN
         PAGE
*
         END

