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: ASM@CA                                                  *
*                                                                     *
*   Language: Assembler                                               *
*                                                                     *
* EntryPoint: ASMAIN                                                  *
*                                                                     *
* Entry Type: OS Linkage                                              *
*                                                                     *
* Files Note: 'prefix' is the installation defined high level         *
*             qualifier for the SAS/C product.                        *
*                                                                     *
*   Function: An assembler program which calls a statically linked    *
*             INDEP C function to print a list of variables which     *
*             were passed as parameters using standard C function     *
*             linkage.                                                *
*                                                                     *
*    Purpose: Demonstrate how to call a statically linked INDEP       *
*             C function from assembler:                              *
*              - passing a parameter list using standard C linkage    *
*              - without the aid of CENTRY/CEXIT                      *
*              - terminating the SAS/C framework created for the      *
*                C function when the assembler terminates             *
*                                                                     *
* MVS -                                                               *
*    Compile/Link/Go: submit prefix.SAMPLE.AUX(ASM@CJ)                *
*                                                                     *
* CMS -                                                               *
*                                                                     *
*     Source:  SAMPLASM MACLIB(ASM@CA and ASM@CC)                     *
*                                                                     *
*   Assemble: hlasm asm@ca                                            *
*                                                                     *
*    Compile: global maclib lc370                                     *
*             lc370 asm@cc (indep sname asmcc                         *
*                                                                     *
*       Load: global txtlib lc370std lc370bas                         *
*             load asm@ca asm@cc ( nomap reset asmmain                *
*                                                                     *
*     Genmod: genmod asm@c (from asmmain                              *
*                                                                     *
*    Execute: asm@c                                                   *
*                                                                     *
*      Notes:                                                         *
*             - On CMS:                                               *
*              .Rename ASM@CA to fileid: ASM@CA ASSEMBLE              *
*              .Rename ASM@CC to fileid: ASM@CC C                     *
*                                                                     *
* Misc Notes:                                                         *
*            - ASM@CA is not assembler dependent, use either          *
*              Assembler H or High Level Assembler.                   *
*                                                                     *
*---------------------------------------------------------------------*
         SPACE
ASMMAIN  CSECT
*-------------------------------> Start: 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 callee save area in mine
         ST    13,8(14)           Tell callee my save area adr
*-------------------------------> End  : Standard Entry Linkage
         SPACE
*---------------------------------------------------------------------*
* Assembler segment that calls C Function                             *
*---------------------------------------------------------------------*
         MVC    STR,=A(STRING)    Move Ptr to String to parmlist
         MVC    INT,I             Move Int to parmlist
         MVC    DOUBLE,D          Move Double to parmlist
         LA     1,PARMLIST        Load the addr of parmlist in R1
         L      15,=V(CFUNC)      Load the vcon of CFUNC in R15
         BALR   14,15             Call the C function
         SPACE
*---------------------------------------------------------------------*
* Shutdown the C environment                                          *
* Note: L$UEXIT does not require a parmlist.                          *
*---------------------------------------------------------------------*
         L      15,=V(L$UEXIT)    Load the vcon of L$UEXIT in 15
         BALR   14,15             Call L$UEXIT
         SPACE
*---------------------------------------------------------------------*
* Exit                                                                *
*---------------------------------------------------------------------*
*-------------------------------> Start: Standard OS Exit  Linkage
MAINXT   L     13,4(13)           Ptr to entry reg save area
         LM    14,12,12(13)       Reload regs at entry
         SR    15,15              Zero R15
         BR    14                 Return to caller
*-------------------------------> End  : Standard OS Exit  Linkage
         SPACE
*---------------------------------------------------------------------*
* Constants                                                           *
*---------------------------------------------------------------------*
         LTORG
STRING   DC    CL11'Hello World',X'00'
         DS    0D
D        DC    D'67.4242'
I        DC    F'42'
*---------------------------------------------------------------------*
* Working Storage/Variables                                           *
*---------------------------------------------------------------------*
PARMLIST DS    0D     The Parmlist to the called Routine
INT      DS    F
         DS    0D      Force alignment
DOUBLE   DS    D       Note: The SAS/C Compiler always aligns doubles
*                            on a doubleword boundry and expects
*                            doubles passed as parameters to be
*                            aligned on a doubleword boundry.
*
STR      DS    A
         DS    0F                 Ensure alignment
SAVEAREA DC    18F'0'             Standard Save area
         END

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