TITLE  'ICATS TEST COMMAND ROUTINE'                            TES00010
*********************************************************************** TES00020
*                                                                     * TES00030
*  MODULE NAME =  TEST                                                * TES00040
*                                                                     * TES00050
*  FUNCTION =  QUERY, SET, OR RESET ONE OR ALL OF THE ICATS TEST      * TES00060
*              FLAGS.  THERE ARE 96 TEST FLAGS IN THE ICATS           * TES00070
*              COMMON DATA AREA, NAMED TEST1 - TEST98.  THIS          * TES00080
*              MODULE HANDLES THE TEST COMMAND WHO'S FORMAT IS;       * TES00090
*                   TEST  <NN|ALL>  <?|ON|OFF>  DEFAULTS TO ALL ?     * TES00100
*                                                                     * TES00110
*  ENTRY POINTS =  TEST                                               * TES00120
*                                                                     * TES00130
*  LINKAGE =  BALR R14,R15 FROM ICATS MAINLINE.                       * TES00140
*                                                                     * TES00150
*  REGISTER CONTENTS UPON ENTRY =                                     * TES00160
*      R2  = POINTS TO THE ICATS COMMON DATA AREA, AS ALWAYS.         * TES00170
*      R14 = RETURN ADDRESS BACK TO ICATS MAINLINE                    * TES00180
*      R15 = ENTRY POINT TO THIS MODULE                               * TES00190
*                                                                     * TES00200
*  REGISTER USAGE =                                                   * TES00210
*      R0-R1 = USED TO PASS PARAMETERS TO SUBROUTINES.                * TES00220
*      R2 =  USED TO ADDRESS THE ICATS COMMON DATA AREA.              * TES00230
*      R3 =  USED TO HOLD THE ADDRESS OF THE EDITED LINE TO OUTPUT.   * TES00240
*      R4-R10 = FREE                                                  * TES00250
*      R11 = MY BASE REGISTER                                         * TES00260
*      R14 = MY RETURN ADDRESS WHEN I CALL SOMEBODY                   * TES00270
*      R15 = SUBROUTINE ADDRESS                                       * TES00280
*                                                                     * TES00290
*                                                                     * TES00300
*  MODULE LOGIC:                                                      * TES00310
*      I)  SEE WHERE THIS COMMAND CAME FROM.  REJECT THIS             * TES00320
*          COMMAND IF IT DIDN'T COME FROM THE CONSOLE.                * TES00330
*     II)  ELSE GO AHEAD AND PROCESS THE COMMAND.                     * TES00340
*          A)  SEE WHAT WE'RE SUPPOSSED TO DO.                        * TES00350
*              1)  CHECK THE SECOND PARM.  IF NUMERIC OR ALL,         * TES00360
*                  THEN OK, ELSE DEFAULT TO ALL.                      * TES00370
*              2)  CHECK THE THIRD PARM (OR THE SECOND IF IT          * TES00380
*                  WASN'T NUMERIC OR ALL).  IF ?, ON, OR OFF,         * TES00390
*                  OK, ELSE DEFAULT TO ?.                             * TES00400
*          B)  DO IT.                                                 * TES00410
*                                                                     * TES00420
*                                                                     * TES00430
*  NORMAL EXIT =                                                      * TES00440
*      R15 = 0                                                        * TES00450
*                                                                     * TES00460
*  EXTERNAL REFERENCES = NONE                                         * TES00470
*                                                                     * TES00480
*  MACROS =  ICDATA = ICATS COMMON DATA AREA                          * TES00490
*            ETTE   = ENTER TRACE TABLE ENTRY SUBROUTINE              * TES00500
*                                                                     * TES00510
*  CHANGE ACTIVITY                                                    * TES00520
*    DATE        NAME       REASON FOR CHANGE                         * TES00530
*  04/29/83  RICK JASPER    INITIAL PROGRAM CREATION                  * TES00540
*                                                                     * TES00550
*********************************************************************** TES00560
*                                                                       TES00570
         PRINT GEN,NODATA                                               TES00580
TEST     CSECT                                                          TES00590
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      TES00600
         USING *,R15              USE R15 FOR NEXT INSTRUCTION ONLY     TES00610
         STM   R0,R14,TESTREGS    SAVE ALL THE REGISTERS                TES00620
         DROP  R15                                                      TES00630
         USING TEST,R11           SWITCH BASE REGISTER TO R11           TES00640
         LR    R11,R15                                                  TES00650
         TM    FLAGB,CONSCMD      IS THIS A CONSOLE COMMAND ??          TES00660
         BO    TESTCONA           DON'T REJECT IT SO.                   TES00670
         L     R15,AREJECT        GO TO REJECT-THIS-COMMAND ROUTINE     TES00680
         BALR  R14,R15                                                  TES00690
         B     TESTBYE                                                  TES00700
TESTCONA EQU   *               SET COMMAND DEFAULTS TO                  TES00710
         MVI   TESTFLAG,TESTALL+TESTQ      TEST ALL ?                   TES00720
         CLC   PARM2,=CL8' '        DID HE SPECIFY ANYTHING ??          TES00730
         BE    DOIT                 ALL SET THEN.                       TES00740
         CLC   PARM2,=CL8'ALL'      DID HE SPECIFY ALL ??               TES00750
         BE    CHECK3RD             SECOND PARM ALL SET IF SO.          TES00760
         LA    R1,PARM2             ELSE CHECK FOR NUMBER               TES00770
         L     R15,ACONDEC                                              TES00780
         BALR  R14,R15                                                  TES00790
         LTR   R15,R15         WAS IT A NUMBER ??                       TES00800
         BNE   TESTCONB        NOPE, LET DEFAULT OF ALL STAND.          TES00810
         C     R0,=F'1'        CHECK UPPER AND LOWER FLAG LIMITS        TES00820
         BL    GIVEHELP                                                 TES00830
         C     R0,=F'96'                                                TES00840
         BH    GIVEHELP                                                 TES00850
         NI    TESTFLAG,ALL-TESTALL       HE DIDN'T WANT ALL            TES00860
         STH   R0,FLAGNUM                                               TES00870
         B     CHECK3RD                                                 TES00880
*    SECOND PARM WASN'T NUMERIC OR 'ALL'.  DEFAULT TO 'ALL' AND         TES00890
TESTCONB MVC   PARM3,PARM2     USE 2ND PARM AS THE 3RD PARM.            TES00900
*                                                                       TES00910
*    CHECK THE THIRD PARM FOR ?, OFF, OR ON.                            TES00920
*                                                                       TES00930
CHECK3RD CLC   PARM3,=CL8' '        DID HE SPECIFY ANYTHING ??          TES00940
         BE    DOIT                 ALL SET THEN.                       TES00950
         CLC   PARM3,=CL8'?'        DID HE SPECIFY QUERY ??             TES00960
         BE    DOIT                 ALL SET THEN.                       TES00970
         NI    TESTFLAG,ALL-TESTQ      IT WASN'T QUERY.                 TES00980
         OI    TESTFLAG,TESTON         ASSUME IT'S ON.                  TES00990
         CLC   PARM3,=CL8'ON'          IS 'ON' CORRECT ??               TES01000
         BE    DOIT                    ALL SET THEN.                    TES01010
         NI    TESTFLAG,ALL-TESTON     MUST BE OFF THEN.  ELSE AN ERROR TES01020
         OI    TESTFLAG,TESTOFF                                         TES01030
         CLC   PARM3,=CL8'OFF'      DID HE SPECIFY ALL ??               TES01040
         BE    DOIT                 ALL SET THEN.                       TES01050
*    HE ENTERED SOMETHING I COULDN'T UNDERSTAND.  GIVE HIM A MESSAGE    TES01060
*    GIVING HIM THE CORRECT FORM OF TEST <NN|ALL> <?|OFF|ON>            TES01070
GIVEHELP LA    R1,HELPMSG                                               TES01080
         B     TESTMSG                ALL DONE HERE                     TES01090
*    AT THIS POINT, TESTALL IS SET OR FLAGNUM IS VALID.                 TES01100
*    ALSO ONE FLAG, TESTQ, TESTOFF, OR TESTON, IS SET.                  TES01110
*    LET'S DO WHAT HE WANTED US TO DO.                                  TES01120
DOIT     DS    0H                                                       TES01130
         TM    TESTFLAG,TESTQ    ARE WE TO TURN ANY FLAGS OFF OR ON ??  TES01140
         BO    DOQUERY           NOPE, IT'S JUST A QUERY.               TES01150
*    ELSE WE HAVE SOME TURNING ON OR OFF TO DO.  WHICH IS IT ??         TES01160
         TM    TESTFLAG,TESTON       ARE WE TO TURN SOME (OR ONE) ON ?? TES01170
         BNO   DOOFF                 NO, MUST BE OFF THEN.              TES01180
         TM    TESTFLAG,TESTALL      TURN ALL ON ??                     TES01190
         BNO   TURN1ON               NO, JUST TURN ONE ON               TES01200
         MVC   TEST0108(12),=12X'FF'   TURN ON ALL THE TEST FLAGS.      TES01210
         B     DOQUERY                 LET HIM KNOW THAT THEY'RE ALL ON TES01220
TURN1ON  EQU   *         WE'VE GOT ONLY 1 TEST FLAG TO TURN ON          TES01230
         LH    R6,FLAGNUM           WHICH FLAG IS IT ??                 TES01240
         BCTR  R6,R0                                                    TES01250
         SRL   R6,3                                                     TES01260
         LA    R7,TEST0108(R6)      R7 = ADDRESS OF CORRECT FLAG        TES01270
         LH    R6,FLAGNUM           NOW WHICH BIT DO WE TURN ON ??      TES01280
         BCTR  R6,R0                                                    TES01290
         N     R6,=X'00000007'      USE LAST THREE BITS ONLY            TES01300
         SR    R8,R8                                                    TES01310
         IC    R8,ONTABLE(R6)       R8 = CORRECT BIT TO TURN ON         TES01320
         EX    R8,OIINSTR           TURN ON THAT BIT                    TES01330
         B     DOQUERY              LET HIM KNOW WHICH FLAGS ARE ON     TES01340
*    WE'VE GOT TO TURN OFF ONE OR ALL THE FLAGS.                        TES01350
DOOFF    TM    TESTFLAG,TESTALL      TURN ALL OFF ??                    TES01360
         BNO   TURN1OFF              NO, JUST ONE                       TES01370
         MVC   TEST0108(12),=12X'00'   TURN OFF ALL THE TEST FLAGS.     TES01380
         B     DOQUERY                 LET HIM KNOW THEY'RE ALL OFF     TES01390
TURN1OFF EQU   *         WE'VE GOT ONLY 1 TEST FLAG TO TURN OFF         TES01400
         LH    R6,FLAGNUM           WHICH FLAG IS IT ??                 TES01410
         BCTR  R6,R0                                                    TES01420
         SRL   R6,3                                                     TES01430
         LA    R7,TEST0108(R6)      R7 = ADDRESS OF CORRECT FLAG        TES01440
         LH    R6,FLAGNUM           NOW WHICH BIT DO WE TURN OFF ??     TES01450
         BCTR  R6,R0                                                    TES01460
         N     R6,=X'00000007'      USE LAST THREE BITS ONLY            TES01470
         SR    R8,R8                                                    TES01480
         IC    R8,OFFTABLE(R6)      R8 = CORRECT BIT TO TURN OFF        TES01490
         EX    R8,NIINSTR           TURN OFF THAT BIT                   TES01500
*                                                                       TES01510
DOQUERY  EQU   *                                                        TES01520
         LA    R1,OFFMSG                                                TES01530
         CLC   TEST0108(12),=12X'00'   TEST FOR ALL BITS OFF.           TES01540
         BE    TESTMSG                                                  TES01550
         LA    R1,ONMSG                                                 TES01560
         CLC   TEST0108(12),=12X'FF'   TEST FOR ALL BITS ON.            TES01570
         BE    TESTMSG                                                  TES01580
*    SOME BITS ARE ON AND SOME ARE OFF.  GIVE A HEADING MESSAGE         TES01590
*    THAT THE FOLLOWING BITS ARE ON, THE REST ARE OFF.  THEN GIVE       TES01600
*    ANOTHER LINE LISTING ALL THE ONES THAT ARE ON.                     TES01610
         LA    R1,HEADMSG                                               TES01620
         L     R15,AMESSAGE                                             TES01630
         BALR  R14,R15                                                  TES01640
*    IN THE FOLLOWING LOOP, CNTR = TEST FLAG COUNTER (1-96)             TES01650
*        R3 = USED TO SEE IF WE'VE CHECKED ALL THE FLAGS YET.           TES01660
*        R4 = USED TO CHECK IF THIS LINE NEEDS TO BE PRINTED.           TES01670
*        R5 = USED TO CHECK IF THIS LINE NEEDS TO BE PRINTED.           TES01680
*        R6 = ADDRESS OF THIS TEST FLAG (TEST0108 - TEST8996)           TES01690
*             CONTROLS OUTER LOOP. CHECK ALL 12 FLAG BYTES.             TES01700
*        R7 = ADDRESS OF NEXT FREE POSITION IN OUTPUT LINE              TES01710
*             (CURRTEXT - CURRTEXT+78).  THEN THE LINE GETS PRINTED.    TES01720
*        R8 = WHICH BIT TO TEST (X'80' - X'01')                         TES01730
*             CONTROLS INNER LOOP.  CHECK EACH BIT IN THIS FLAG.        TES01740
         MVC   CNTR,=PL2'0'                                             TES01750
         LA    R3,TEST8996                                              TES01760
         LA    R4,CURRTEXT                                              TES01770
         LA    R5,CURRTEXT+79                                           TES01780
         LA    R6,TEST0108         START WITH FIRST TEST FLAG           TES01790
         LA    R7,CURRTEXT                                              TES01800
         MVI   CURRTEXT-1,80       PUT IN LENGTH OF OUTPUT LINE         TES01810
         MVC   CURRTEXT(80),=CL80' '   START WITH A FRESH BLANK LINE    TES01820
LOOPFLAG EQU   *                OUTER FLAG LOOP                         TES01830
         LA    R8,X'80'            START WITH HIGH ORDER BIT OF FLAG    TES01840
LOOPBIT  EQU   *                                                        TES01850
         AP    CNTR,=P'1'          BUMP TEST FLAG COUNTER               TES01860
         EX    R8,TMINSTR          IS THIS BIT ON ??                    TES01870
         BNO   NEXTBIT             NO, DON'T PUT IN OUTPUT LINE         TES01880
         OI    CNTR+1,X'0F'        SET SIGN FOR UNPACK                  TES01890
         UNPK  WORKA,CNTR          GET TEST FLAG NUMBER IN EBCDIC       TES01900
         MVC   0(3,R7),WORKA+2     MOVE IN 2 DIGITS                     TES01910
         CP    CNTR,=P'10'         IF LESS THAN TEST10, BLANK OUT       TES01920
         BNL   SKIP1               LEADING ZERO                         TES01930
         MVI   0(R7),C' '                                               TES01940
SKIP1    LA    R7,3(R7)            BUMP TO NEXT FREE POSITION IN OUTPUT TES01950
         CR    R7,R5                     TIME TO PRINT THIS LINE YET ?? TES01960
         BL    NEXTBIT                   NOPE, CONTINUE CHECKING        TES01970
         LA    R1,CURRTEXT-1                                            TES01980
         L     R15,AMESSAGE                                             TES01990
         BALR  R14,R15                   GO PRINT THE LINE WHEN FULL    TES02000
         LA    R7,CURRTEXT               RESET LINE POINTER             TES02010
         MVC   CURRTEXT(80),=CL80' '     BLANK OUT LINE AGAIN           TES02020
NEXTBIT  EQU   *        DO WE HAVE ANOTHER BIT TO CHECK IN THIS FLAG ?? TES02030
         SRA   R8,1                GET NEXT BIT TO CHECK                TES02040
         BNZ   LOOPBIT             GO CHECK NEXT BIT IF NOT ZERO YET    TES02050
         LA    R6,1(R6)     DONE WITH THAT FLAG, LET'S CHECK NEXT ONE   TES02060
         CR    R6,R3               LAST FLAG YET ??                     TES02070
         BNH   LOOPFLAG            NOPE, KEEP CHECKING                  TES02080
         LA    R1,CURRTEXT-1                                            TES02090
         CR    R7,R4               PARTIAL LINE LEFT UNPRINTED ??       TES02100
         BE    TESTBYE                                                  TES02110
*    GIVE HIM THE MESSAGE WHOSE ADDRESS IS IN R1 AND LEAVE.             TES02120
TESTMSG  L     R15,AMESSAGE                                             TES02130
         BALR  R14,R15                                                  TES02140
TESTBYE  DS    0H                                                       TES02150
         LM    R0,R14,TESTREGS                                          TES02160
         SR    R15,R15                RETURN CODE = 0                   TES02170
         BR    R14                                                      TES02180
TESTREGS DS    15F                                                      TES02190
WORKA    DS    F                                                        TES02200
FLAGNUM  DS    H                                                        TES02210
CNTR     DS    PL2                                                      TES02220
ONTABLE  DC    X'8040201008040201'                                      TES02230
OFFTABLE DC    X'7FBFDFEFF7FBFDFE'                                      TES02240
OIINSTR  OI    0(R7),X'00'                                              TES02250
NIINSTR  NI    0(R7),X'00'                                              TES02260
TMINSTR  TM    0(R6),X'00'                                              TES02270
*                                                                       TES02280
TESTFLAG DC    X'00'        TEST COMMAND ROUTINE FLAG                   TES02290
TESTALL     EQU    X'80'         DO THIS TO ALL THE TEST FLAGS          TES02300
TESTQ       EQU    X'40'         QUERY TEST FLAG(S)                     TES02310
TESTON      EQU    X'20'         TURN ON THE TEST FLAG(S)               TES02320
TESTOFF     EQU    X'10'         TURN OFF THE TEST FLAG(S)              TES02330
*                                                                       TES02340
HELPMSG  DC    AL1(HELPMSGE)                                            TES02350
         DC    C'THE CORRECT FORM IS TEST <ALL|nn> <?|OFF|ON>'          TES02360
         DC    C'  (NN IS 1 - 96).'                                     TES02370
HELPMSGE EQU   *-HELPMSG-1                                              TES02380
*                                                                       TES02390
ONMSG    DC    AL1(ONMSGE)                                              TES02400
         DC    C'ALL THE TEST FLAGS ARE ON'                             TES02410
ONMSGE   EQU   *-ONMSG-1                                                TES02420
*                                                                       TES02430
OFFMSG   DC    AL1(OFFMSGE)                                             TES02440
         DC    C'ALL THE TEST FLAGS ARE OFF'                            TES02450
OFFMSGE  EQU   *-OFFMSG-1                                               TES02460
*                                                                       TES02470
HEADMSG  DC    AL1(HEADMSGE)                                            TES02480
         DC    C'THE FOLLOWING FLAGS ARE ON, THE REST ARE OFF'          TES02490
HEADMSGE EQU   *-HEADMSG-1                                              TES02500
         LTORG                                                          TES02510
         ICDATA                                                         TES02520
         END                                                            TES02530