TITLE  'ICATS FAKE A READ-FROM-A-UTS ROUTINE'                  FAK00010
*********************************************************************** FAK00020
*                                                                     * FAK00030
*  MODULE NAME =  FAKE UTS READ                                       * FAK00040
*                                                                     * FAK00050
*  FUNCTION =  SIMULATE A READ FROM A UTS MACHINE BY READING          * FAK00060
*              DATA FROM THE CMS FILE ICATS INDATA A, AND             * FAK00070
*              PUTTING IT WHERE THE CALLER WANTS.                     * FAK00080
*              IF THE END OF THE CMS FILE IS HIT BEFORE WE HAVE       * FAK00090
*              READ ENOUGH BYTES, RESTART FROM THE BEGINNING.         * FAK00100
*                                                                     * FAK00110
*  NOTE =  YOU CAN SIMULATE EITHER FIXED- OR VARIABLE-LENGTH          * FAK00120
*              UTS DATA BY CHANGING THE DATA IN THE CMS FILE          * FAK00130
*              ICATS INDATA A.  USE THE VIN OR FIN EXECS TO           * FAK00140
*              CHANGE THAT FILE.                                      * FAK00150
*                                                                     * FAK00160
*  ENTRY POINTS =  FAKEREAD                                           * FAK00170
*                                                                     * FAK00180
*  LINKAGE =  SOME ROUTINE DECIDES TO READ SOME DATA FROM THE UTS     * FAK00190
*             (FOR EXAMPLE, THE WRITE ROUTINE TO GET THE DATA TO      * FAK00200
*             WRITE TO THE CMS FILE), BUT THIS REQUEST DIDN'T COME    * FAK00210
*             FROM A REAL UTS.  RATHER IT CAME FROM A FAKE            * FAK00220
*             INTERRUPT VIA THE FAKIT COMMAND.                        * FAK00230
*             THE CALLER DID THIS                                     * FAK00240
*                 LA    R0,XXX             HOW MANY BYTES HE WANTS    * FAK00250
*                 LA    R1,BUFFER          WHERE HE WANTS IT          * FAK00260
*                 L     R15,AREADUTS                                  * FAK00270
*                 BALR  R14,R15                                       * FAK00280
*             TO GET TO THE UTS I/O ROUTINE AND THE UTS I/O           * FAK00290
*             ROUTINE DETERMINED THIS WAS A FAKE INTERRUPT, SO        * FAK00300
*             IT DID THIS                                             * FAK00310
*                 L     R15,FAKEREAD                                  * FAK00320
*                 BALR  R14,R15                                       * FAK00330
*             TO GET TO ME.                                           * FAK00340
*                                                                     * FAK00350
*  REGISTER CONTENTS UPON ENTRY =                                     * FAK00360
*     R0  = HOW MANY BYTES THE CALLER WANTS FROM THE UTS.             * FAK00370
*     R1  = THE BUFFER ADDRESS.                                       * FAK00380
*     R2  = POINTS TO THE ICATS COMMON DATA AREA AS ALWAYS.           * FAK00390
*     R14 = RETURN ADDRESS BACK TO THE UTS I/O ROUTINE.               * FAK00400
*     R15 = ADDRESS OF THIS SUBROUTINE (USED FOR BASE REG).           * FAK00410
*                                                                     * FAK00420
*  REGISTER CONTENTS UPON EXIT =                                      * FAK00430
*         R15 = 0 = EVERYTHING WENT OK.                               * FAK00440
*      OR R15 = 4 = THE FILE ICATS INDATA A DOES NOT EXIST.           * FAK00450
*      OR R15 = 8 = INCORRECT BUFFER LENGTH (NOT POSITIVE).           * FAK00460
*                                                                     * FAK00470
*     REGISTER USAGE:                                                 * FAK00480
*     R0  = FREE                                                      * FAK00490
*     R1  = FREE                                                      * FAK00500
*     R2  = ICATS COMMON DATA AREA BASE REGISTER (ICDATA)             * FAK00510
*  R3-R6  = FREE                                                      * FAK00520
*     R7  = BUFFER ADDRESS LENGTH.  AMOUNT OF DATA LEFT TO READ.      * FAK00530
*     R8  = BUFFER ADDRESS POINTER.  WHERE TO PUT THE NEXT RECORD.    * FAK00540
*     R9  = FREE                                                      * FAK00550
*     R10 = USED TEMPORARILY TO HOLD THE RETURN CODE                  * FAK00560
*     R11 = BASE REGISTER FOR THIS ROUTINE                            * FAK00570
* R12-R13 = FREE                                                      * FAK00580
*     R14 = TEMPORARY WORK REGISTER AND RETURN ADDRESS FOR WHEN       * FAK00590
*           CALL SUBROUTINES                                          * FAK00600
*     R15 = SUBROUTINE ADDRESS                                        * FAK00610
*                                                                     * FAK00620
*  NORMAL EXIT =                                                      * FAK00630
*      R15 = 0                                                        * FAK00640
*                                                                     * FAK00650
*  EXTERNAL REFERENCES = NONE                                         * FAK00660
*                                                                     * FAK00670
*  CONTROL BLOCKS =  ICDATA   (ICATS COMMON DATA AREA)                * FAK00680
*                                                                     * FAK00690
*  NON-STANDARD MACROS (FOUND IN ICATS MACLIB)                        * FAK00700
*            ICDATA = ICATS COMMON DATA AREA DSECT.                   * FAK00710
*                                                                     * FAK00720
*  CHANGE ACTIVITY                                                    * FAK00730
*    DATE        NAME       REASON FOR CHANGE                         * FAK00740
*  04/21/83  RICK JASPER    BROKEN AWAY FROM ICATS MAINLINE INTO      * FAK00750
*                           SEPARATE SUBROUTINE                       * FAK00760
*                                                                     * FAK00770
*********************************************************************** FAK00780
         EJECT                                                          FAK00790
         PRINT GEN,NODATA                                               FAK00800
FAKEREAD CSECT                                                          FAK00810
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      FAK00820
         USING FAKEREAD,R15     USE R15 FOR NEXT INSTRUCTION ONLY       FAK00830
         STM   R1,R14,UTSIOREG  SAVE CALLERS REGISTERS                  FAK00840
         DROP  R15                                                      FAK00850
         USING FAKEREAD,R11      USE R11 FOR THIS ROUTINE'S BASE REG    FAK00860
         LR    R11,R15           SWITCH BASE REGISTER TO R11            FAK00870
         LTR   R0,R0             INSURE POSITIVE LENGTH                 FAK00880
         BNP   READBAD0          GIVE AN ERROR IF <= 0                  FAK00890
         LR    R7,R0             SAVE BUFFER LENGTH                     FAK00900
         LR    R8,R1             SAVE BUFFER ADDRESS                    FAK00910
         FSOPEN 'ICATS INDATA A'                                        FAK00920
         LTR   R15,R15           CHECK FOR FILE-DOES-NOT-EXIST          FAK00930
         BNZ   READNONE          NOPE, FILE'S NOT THERE                 FAK00940
READREAD DS    0H                                                       FAK00950
         FSREAD 'ICATS INDATA A',BUFFER=(R8),BSIZE=(R7)                 FAK00960
         C     R15,=F'12'    SEE IF END-OF-FILE YET                     FAK00970
         BNE   READCONA      NOPE, WE DID READ SOMETHING                FAK00980
*                            ELSE RESET READ POINTER TO START OF FILE   FAK00990
         FSPOINT 'ICATS INDATA A',RDPNT=1                               FAK01000
         B     READREAD          START RE-READING THE FILE              FAK01010
READCONA DS    0H          NOTE:  R0 = # BYTES DATA JUST READ           FAK01020
         AR    R8,R0             POINT TO NEXT DATA AREA                FAK01030
         SR    R7,R0             THERE'S LESS LEFT TO READ NOW          FAK01040
         BP    READREAD          CONTINUE READING IF NOT DONE YET       FAK01050
         LA    R10,0          RETURN CODE = 0 = EVERYTHING'S GREAT      FAK01060
READBYE  FSCLOSE 'ICATS INDATA A'                                       FAK01070
         LR    R15,R10           TRANSFER RETURN CODE                   FAK01080
         LM    R1,R14,UTSIOREG                                          FAK01090
         BR    R14            BYE                                       FAK01100
*                                                                       FAK01110
READNONE LA    R10,4          RC = 4 = ICATS INDATA A DOES NOT EXIST    FAK01120
         B     READBYE                                                  FAK01130
*                                                                       FAK01140
READBAD0 LA    R10,8          RC = 8 = INCORRECT BUFFER LENGTH          FAK01150
         B     READBYE                                                  FAK01160
*                                                                       FAK01170
READMVC  MVC   0(0,R8),RCBINBUF                                         FAK01180
UTSIOREG DS    15F                                                      FAK01190
RCBINBUF DS    CL80                                                     FAK01200
         LTORG                                                          FAK01210
         ICDATA                                                         FAK01220
         END                                                            FAK01230