TITLE  'ICATS SEND-A-MESSAGE-TO-SOMEBODY ROUTINE'              MES00010
*********************************************************************** MES00020
*                                                                     * MES00030
*  MODULE NAME =  MESSAGE                                             * MES00040
*                                                                     * MES00050
*  FUNCTION =  SEND A MESSAGE IN RESPONSE TO THIS ICATS REQUEST       * MES00060
*              TO WHOEVER GAVE IT TO ME, EITHER TO ANOTHER VIRTUAL    * MES00070
*              MACHINE IF THIS IS AN SMSG COMMAND, OR TO MYSELF       * MES00080
*              IF A CONSOLE COMMAND.  IF THIS HAPPENS TO BE A UTS     * MES00090
*              COMMAND, GIVE THE MESSAGE TO THE CONSOLE.              * MES00100
*                                                                     * MES00110
*  ENTRY POINTS =  MESSAGE                                            * MES00120
*                                                                     * MES00130
*  LINKAGE =  BALR R14,R15 FROM ANYWHERE IN ICATS PROGRAM.            * MES00140
*             THE ADDRESS OF THIS ROUTINE IS KEPT IN AN ADDRESS       * MES00150
*             CONSTANT IN THE ICATS COMMON DATA AREA (ICDATA).        * MES00160
*             FOR EXAMPLE,                                            * MES00170
*                 LA    R1,MESSAGE                                    * MES00180
*                 L     R15,AMESSAGE                                  * MES00190
*                 BALR  R14,R15                                       * MES00200
*                                                                     * MES00210
*  REGISTER CONTENTS UPON ENTRY =                                     * MES00220
*     R1  = POINTS TO THE CHARACTER MESSAGE LENGTH AND TEXT           * MES00230
*           WHICH IS IN THE FORMAT OF                                 * MES00240
*           MESSAGE  DC AL1(N)          # BYTES OF CHAR DATA          * MES00250
*                    DC CLN'THIS IS YOUR MESSAGE'                     * MES00260
*     R2  = POINTS TO THE ICATS COMMON DATA AREA AS ALWAYS.           * MES00270
*     R14 = RETURN ADDRESS BACK TO CALLER.                            * MES00280
*     R15 = ADDRESS OF THIS SUBROUTINE (USED FOR BASE REG).           * MES00290
*                                                                     * MES00300
*  ALSO, SMSGVMID = USER ID OF THE GUY WHO GAVE ME THIS SMSG,         * MES00310
*                   ONLY IF THIS IS A SMSG COMMAND.                   * MES00320
*                                                                     * MES00330
*  REGISTER CONTENTS UPON EXIT =                                      * MES00340
*     R15 = 0 = EVERYTHING WENT OK.                                   * MES00350
*                                                                     * MES00360
*  REGISTER USAGE:                                                    * MES00370
*     R0-R1 = USED TO PASS PARAMETERS TO SUBROUTINES.                 * MES00380
*     R2  =  ADDRESS OF ICATS COMMON DATA AREA (AS ALWAYS).           * MES00390
*     R3-R5 = FREE.                                                   * MES00400
*     R6  =  MESSAGE ADDRESS.                                         * MES00410
*     R7  =  MESSAGE LENGTH.                                          * MES00420
*     R8-R13 = FREE.                                                  * MES00430
*     R14 = RETURN ADDRESS FOR WHEN I CALL SUBROUTINES                * MES00440
*     R15 = SUBROUTINE ADDRESS                                        * MES00450
*                                                                     * MES00460
*  MODULE LOGIC =                                                     * MES00470
*      1)  IF THIS ISN'T AN SMSG COMMAND, DO A LINEDIT TO PUT THIS    * MES00480
*          MESSAGE TO THE CONSOLE.                                    * MES00490
*      2)  ELSE, DO A CP MESSAGE COMMAND TO THE VM USER ID IN         * MES00500
*          SMSGVMID.                                                  * MES00510
*                                                                     * MES00520
*  NORMAL EXIT =                                                      * MES00530
*      R15 = 0                                                        * MES00540
*                                                                     * MES00550
*  EXTERNAL REFERENCES = NONE                                         * MES00560
*                                                                     * MES00570
*  CONTROL BLOCKS =  ICDATA   (ICATS COMMON DATA AREA)                * MES00580
*                                                                     * MES00590
*  NON-STANDARD MACROS (FOUND IN ICATS MACLIB)                        * MES00600
*            ICDATA = ICATS COMMON DATA AREA DSECT.                   * MES00610
*                                                                     * MES00620
*  CHANGE ACTIVITY                                                    * MES00630
*    DATE        NAME       REASON FOR CHANGE                         * MES00640
*  04/18/83  RICK JASPER    BROKEN AWAY FROM ICATS MAINLINE INTO      * MES00650
*                           SEPARATE SUBROUTINE                       * MES00660
*  04/25/83  RICK JASPER    ADDED THE DELAYED MESSAGE ENTRY POINT     * MES00670
*  09/16/83  RICK JASPER    TOOK AWAY THE DELAYED MESSAGE CODE        * MES00680
*                           (IT WAS A STUPID WAY OF DOING THINGS)     * MES00690
*                                                                     * MES00700
*********************************************************************** MES00710
         EJECT                                                          MES00720
         PRINT GEN,NODATA                                               MES00730
MESSAGE  CSECT                                                          MES00740
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      MES00750
         USING MESSAGE,R15      USE R15 FOR NEXT INSTRUCTION ONLY       MES00760
         STM   R0,R14,MESSREGS  SAVE CALLERS REGISTERS                  MES00770
         DROP  R15                                                      MES00780
         USING MESSAGE,R11       USE R11 FOR THIS ROUTINE'S BASE REG    MES00790
         LR    R11,R15           SWITCH BASE REGISTER TO R11            MES00800
*                                                                       MES00810
         LR    R6,R1             SWITCH MESSAGE ADDRESS TO R6           MES00820
         SR    R7,R7             PICK UP MESSAGE LENGTH IN R7           MES00830
         IC    R7,0(R6)                                                 MES00840
         LTR   R7,R7             CHECK FOR NULL MESSAGE                 MES00850
         BZ    MESSBYE           IGNORE IF SO                           MES00860
         TM    FLAGB,SMSGCMD         IS THIS AN SMSG COMMAND ??         MES00870
         BO    MESSCONA              YES, GO DO THE CP MSG COMMAND      MES00880
         LINEDIT TEXTA=(R6),RENT=NO,DOT=NO                              MES00890
         B     MESSBYE           GOODBYE.                               MES00900
MESSCONA DS    0H                                                       MES00910
         MVC   MSGUID,SMSGVMID   MOVE IN SMSG'ER USER ID                MES00920
         LA    R6,1(R6)          BUMP PAST MESSAGE LENGTH               MES00930
*    THIS IS AN SMSG COMMAND.                                           MES00940
*    R6 = ADDRESS OF MESSAGE TEXT                                       MES00950
*    R7 = LENGTH OF MESSAGE TEXT (WHICH IS POSITIVE)                    MES00960
         MVI   MSGTEXT,C' '         BLANK OUT OLD MESSAGE               MES00970
         MVC   MSGTEXT+1(79),MSGTEXT                                    MES00980
         C     R7,=F'80'            IF MESSAGE LENGTH > 80,             MES00990
         BNH   MESSCOND             THEN GIVE JUST THE                  MES01000
         LA    R7,80                FIRST 80 CHARACTERS.                MES01010
MESSCOND DS    0H                                                       MES01020
         BCTR  R7,R0                DECREMENT LENGTH FOR MVC INSTR.     MES01030
         EX    R7,MESSMVC           MOVE MESSAGE INTO COMMAND           MES01040
*          PUT IN THE DELIMITING 8X'FF'                                 MES01050
         LR    R10,R7               PREPARE INDEX REGISTER              MES01060
         N     R10,=X'FFFFFFF8'                                         MES01070
         L     R8,=X'FFFFFFFF'                                          MES01080
         ST    R8,MSGTEXT+8(R10)    PUT IN THE FIRST 4 X'FF'            MES01090
         ST    R8,MSGTEXT+12(R10)   NOW THE NEXT 4                      MES01100
         LA    R1,MSGCMD            DO A 'CP MESSAGE ...' COMMAND       MES01110
         SVC   202                                                      MES01120
         DC    AL4(*+4)                                                 MES01130
MESSBYE  LA    R15,0          RETURN CODE = 0 = EVERYTHING'S GREAT      MES01140
         LM    R0,R14,MESSREGS                                          MES01150
         BR    R14            BYE                                       MES01160
*                                                                       MES01170
MESSREGS DS    15F                                                      MES01180
MSGCMD   DS    0D           MUST BE DOUBLEWORD ALIGNED                  MES01190
         DC    CL8'CP'                                                  MES01200
         DC    CL8'MESSAGE'                                             MES01210
MSGUID   DC    CL8' '                                                   MES01220
MSGTEXT  DS    CL128                                                    MES01230
MESSMVC  MVC   MSGTEXT(0),0(R6)                                         MES01240
         LTORG                                                          MES01250
         ICDATA                                                         MES01260
         END                                                            MES01270