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) 1995, SAS Institute Inc.                 *
*                Unpublished - All Rights Reserved                    *
*                                                                     *
*                     S A S / C  S A M P L E                          *
*                                                                     *
*       Name: C#ASMA                                                  *
*                                                                     *
*   Language: Assembler                                               *
*                                                                     *
* EntryPoint: LOADMAA                                                 *
*                                                                     *
* Entry Type: Standard OS Linkage with a VL-type plist.  The          *
*             parameter list is expected to be variable length        *
*             with at least one argument.  All arguments are          *
*             expected to be pointers to int.  The high-order         *
*             bit of the last argument should be set on.              *
*                                                                     *
* Files Note: 'prefix' is the installation defined high level         *
*             qualifier for the SAS/C product.                        *
*                                                                     *
*   Function: Sum a list of integers passed as arguments and          *
*             return the sum to the caller in R15.                    *
*                                                                     *
*    Purpose: LOADMAA supports LOADMAC by providing an assembler      *
*             program that can be dynamically loaded via loadm.       *
*                                                                     *
* Attributes: Serially Reusable, NOT reentrant                        *
*                                                                     *
* MVS - See prolog for prefix.SAMPLE.ASM(LOADMAC)                     *
*                                                                     *
* CMS - See prolog for SAMPLASM MACLIB(LOADMAC)                       *
*                                                                     *
* Misc Notes:                                                         *
*            - LOADMAA is not assembler dependent, use either         *
*              Assembler H or High Level Assembler.                   *
*                                                                     *
*            - This assembler routine could have used CENTRY/CEXIT,   *
*              there is nothing about LOADMAA that prevents their     *
*              use.  See sample prefix.SAMPLE.C#ASM(C#ASMA) for an    *
*              example of using CENTRY/CEXIT.                         *
*                                                                     *
*            - LOADMAA is NOT reentrant due to the static savearea.   *
*                                                                     *
*---------------------------------------------------------------------*
         SPACE
LOADMAA  CSECT
*---------------------------------------------------------------------*
* Standard OS Entry Linkage                                           *
*---------------------------------------------------------------------*
         STM   14,12,12(13)       Save entry regs in callers area
         BALR  9,0                Load Base
         USING *,9                Tell Assembler
         LR    14,13              Save callee save area addr
         LA    13,SAVEAREA        Put mine in R13
         ST    14,4(13)           Save caller save area in mine
         ST    13,8(14)           Setup R14 for my calls
         SPACE
*---------------------------------------------------------------------*
* Make sure we actually got a plist address on the call.              *
*---------------------------------------------------------------------*
         SR    15,15              Clear 15 for sum'ing
         LTR   1,1                Is there a plist?
         BZ    DONE               Nope, just leave!
*---------------------------------------------------------------------*
* Sum integers passed via VL-Type parameter list.                     *
*---------------------------------------------------------------------*
NEXTADD  DS    0H
         L     4,0(1)             Load pointer
         A     15,0(4)            Add integer to sum
         TM    0(1),X'80'         End of VL-Plist? <---Note This Check
         BNZ   DONE               Yes, finish up and exit
         LA    1,4(1)             No, bump to next argument
         B     NEXTADD            Start again
DONE     DS    0H                 Yes, prepare to return
         SPACE
*---------------------------------------------------------------------*
*                                                                     *
* Standard OS Exit Linkage with the sum of the integers in R15.       *
*                                                                     *
*---------------------------------------------------------------------*
MAINXT   L     13,4(13)           Ptr to entry reg save area
         LM    0,12,20(13)        Reload registers  0-12
         L     14,12(13)          Restore return address to 14
         BR    14                 Return to caller
         SPACE
*---------------------------------------------------------------------*
* Constants                                                           *
*---------------------------------------------------------------------*
         LTORG                     Area for Literal Pool
*---------------------------------------------------------------------*
* Working Storage                                                     *
*---------------------------------------------------------------------*
         DS    0F                  Force Alignment
SAVEAREA DC    18F'0'              Standard Save area
         END   LOADMAA

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