www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback


/*--------------------------------------------------------------------+
|                                                                     |
|                 Copyright (c) 1996, SAS Institute Inc.              |
|                   Unpublished - All Rights Reserved                 |
|                                                                     |
|                     S A S / C  S A M P L E                          |
|                                                                     |
|       Name: ALOADMC                                                 |
|                                                                     |
|   Language: C                                                       |
|                                                                     |
| EntryPoint: CRBC                                                    |
|                                                                     |
| Entry Type: C Linkage                                               |
|                                                                     |
| Files Note: 'prefix' is the installation defined high level         |
|             qualifier for the SAS/C product.                        |
|                                                                     |
|   Function: C function to display the CRAB address.                 |
|                                                                     |
|    Purpose: MVS see prefix.SAMPLE.ASM(ALOADMM) prolog               |
|             CMS see SAMPLASM MACLIB(ALOADMM) prolog                 |
|                                                                     |
| MVS -                                                               |
|       Compile/Link/Go: see preefix.SAMPLE.ASM(ALOADMM) prolog       |
| CMS -                                                               |
|       Compile/Link/Go: see SAMPLASM MACLIBM(ALOADMM) prolog         |
|                                                                     |
| Misc Notes:                                                         |
|                                                                     |
|            - The primary modules in sample ALOADM use this function |
|              to display the CRAB address.  When the CRAB addresses  |
|              displayed are all the same, it means that a single     |
|              C execution framework is being maintained.             |
|                                                                     |
+--------------------------------------------------------------------*/
#include <stdio.h>
#include <options.h>

#include <svc.h>
#include <regs.h>

#include <svc.h>
#include <code.h>
#include <regs.h>
#include <dec370.h>
#include <str370.h>

#define LEN_PACKED 4
#define LEN_UNPACKED 8

int crbc(void)
{
  char gmt_time[4];
  char date_packed [LEN_PACKED];
  char date_unpacked [LEN_UNPACKED];
  int  retcode;

  long r12area;
  /**************************************************************/
  /*                                                            */
  /* NOTE: The purpose of the following code is to illustrate   */
  /*       the use of inline machine code.  It is not the best  */
  /*       way to obtain or manipulate time information.        */
  /*                                                            */
  /**************************************************************/

                          /*------------------------------------*/
  _ldregs(0);             /* Frame: Start inline machine code   */
                          /*        sequence                    */
  _stregs(R12,            /* Frame: End inline mach code        */
                          /*        sequence.                   */
          &r12area);      /*        Save CRAB address in R12    */
                          /*------------------------------------*/

                          /*------------------------------------*/
  _ldregs(R1,0X82);       /* Frame: Start inline machine code   */
                          /*        sequence.  Setup for SVC 11 */
                          /*        (TIME) call by setting R1   */
                          /*        for ZONE = GMT (x80) and    */
                          /*        DEC type time (x02).        */
                          /*------------------------------------*/

                          /*------------------------------------*/
  _ossvc(11);             /* Issue the SVC call                 */
                          /*------------------------------------*/

                          /*------------------------------------*/
  _stregs(R0+R1+R15,      /* Frame: End inline mach code        */
                          /*        machine code sequence.      */
                          /*        Save registers:             */
          &gmt_time,      /*        R0 -> time in HHMMSSth      */
          &date_packed,   /*        R1 -> date in 0CYYYDDF      */
          &retcode);      /*        R15-> return code           */
                          /*------------------------------------*/

                          /*------------------------------------*/
  _ldregs(R2+R3,          /* Frame: Start inline mach code      */
                          /*        sequence.                   */
        &date_unpacked,   /* R2->Address of unpacked area       */
        &date_packed);    /* R3->Address of packed data from    */
                          /*     SVC 11 (TIME) above.           */
                          /*------------------------------------*/

                          /*------------------------------------*/
  UNPK(0+b(2),            /* R2: address of output              */
     LEN_UNPACKED,        /* Length of output area              */
     0+b(3),              /* R3: address of packed data         */
     LEN_PACKED);         /* Length of packed data              */
                          /*------------------------------------*/

                          /*------------------------------------*/
  MVC(0+b(2),2,3+b(2));   /* Move Year to first 2 bytes         */
  MVC(3+b(2),3,5+b(2));   /* Move day-of-year to left two bytes */
                          /*------------------------------------*/

  /* Note: _stregs is not used because it is not necessary in   */
  /*       in this case.  The first instance of regular C code  */
  /*       will also terminate an inline machine code sequence. */

  date_unpacked[2] = '/' ;/* Setup YYDDD and                    */
  date_unpacked[6] = 0x00;/* .. null terminate the string.      */

  printf("CRBC: CRAB address = R12 (hex) = %x"
         "  GMT is %02x:%02x:%02x.%02x   Date: %s\n",
         r12area,
         gmt_time[0],
         gmt_time[1],
         gmt_time[2],
         gmt_time[3],
         date_unpacked);

  return(0);
}

Copyright (c) 2000 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement