*---------------------------------------------------------------------* * * * Copyright (c) 1995, SAS Institute, Inc. * * Unpublished - All Rights Reserved * * * * S A S / C S A M P L E * * * * Name: C2ASMA * * * * Language: Assembler * * * * EntryPoint: SUMINT * * * * EntryType : C2ASMA expects to be called with a C framework * * in place and standard OS Linkage VL-type parameter * * list. The parameter list is expected to be of * * variable length, with at least one(1) argument, * * all arguments are expected to be pointers to int. * * The high-order bit of the last argument (a pointer) * * is expected to be set on. * * * * Files Note: 'prefix' is the installation defined high level * * qualifier for the SAS/C product. * * * * Function: Sum the list of integers passed in the parameter list * * and return the result in R15 to the caller. * * * * Purpose: C#AMSA demonstrates assembler communications by using * * CENTRY, CEXIT, CREGS, along with the CRAB and DSA. * * It also shows how to process a VL-type parameter list, * * such as the one produced by SAS/C __asm keyword, and * * how to return a value to a caller via CEXIT. * * * * C2ASMA is designed to be statically linked to a C * * program and expects to be provided with a normal * * C framework. * * * * Attributes: Re-entrant * * * * MVS - See prolog for prefix.SAMPLE.ASM(C2ASMC) * * * * CMS - See prolog for SAMPLASM MACLIB(C2ASMC) * * * * Misc Notes: * * - C2ASMA is not assembler dependent, use either * * Assembler H or High Level Assembler. * * * *---------------------------------------------------------------------* EJECT PRINT ON,GEN SUMINT@ CSECT CREGS USING SPACE SUMINT CENTRY INDEP=NO,DSA=0 *---------------------------------------------------------------------* * Make sure we actually got a plist address on the call. * *---------------------------------------------------------------------* SR R3,R3 Clear R3 for sum'ing LTR R1,R1 Is there a plist? BZ DONE Nope, just leave w/R3=0! SPACE *---------------------------------------------------------------------* * Sum integers passed via VL-Type parameter list. * *---------------------------------------------------------------------* SR R3,R3 Clear R3 for summing NEXTADD DS 0H L R4,0(R1) Load pointer A R3,0(R4) Add integer to sum TM 0(R1),X'80' End of VL-Plist? <---Note This Check BNZ DONE Yes, finish up and exit LA R1,4(R1) No, bump to next argument B NEXTADD Start again DONE DS 0H Yes, prepare to return SPACE *---------------------------------------------------------------------* * Exit with the sum of the integers provided to CEXIT in R3. * *---------------------------------------------------------------------* CEXIT RC=(R3),INDEP=NO,DSA=0 EJECT *---------------------------------------------------------------------* * Constants * *---------------------------------------------------------------------* LTORG Area for Literal Pool *---------------------------------------------------------------------* * Working Storage * *---------------------------------------------------------------------* COPY DSA Required for CENTRY/CEXIT *---------------------------------------------------------------------* * Dsects * *---------------------------------------------------------------------* COPY CRAB Required for CENTRY/CEXIT END SUMINT |