//ALOADMJ JOB .............................................. <== Verify
//**                                                                  *
//**           Copyright (c) 1995 - SAS Institute, Inc.               *
//**             Unpublished - All Rights Reserved                    *
//**                                                                  *
//**  Name   : ALOADMJ  ( C main to assembler dynamically loading     *
//**                      a C function)                               *
//**                                                                  *
//**  Purpose: Demonstrate how to maintain a single C execution       *
//**           framework in a C and assembler environment.            *
//**                                                                  *
//**  Function: Compile, assemble, and lked'it source files listed    *
//**            below.                                                *
//**                                                                  *
//**  Source  : see prefix.SAMPLE.ASM members -                       *
//**            ALOADMM - C main for Part#1, statically linked with   *
//**                      an assembler routine                        *
//**            ALOADMC - C function to display CRAB address          *
//**            ALOADMA - Assembler routine used by Part#1 and Part#2 *
//**            ALOADMD - Dynamically loaded C function               *
//**                                                                  *
//**  Details : ALOADM is a two part example, this JCL supports       *
//**            Part 1.  See prefix.SAMPLE.ASM(ALOADMM) for details.  *
//**                                                                  *
//**  NOTE: Ensure the statments indicated by '<==Verify' have been   *
//**        customized for your local environment.  'prefix' is the   *
//**        installation defined high level qualifier for the SAS/C
//**        product.
//**
//*
//*********************************************************************
//*                                                                   *
//*  Compile the C main program.                                      *
//*                                                                   *
//*********************************************************************
//*
//ALOADMM EXEC LC370C
//C.SYSLIN  DD DSN=your.object.library(ALOADMM),             <== Verify
//             DISP=SHR
//C.SYSIN   DD DSN=prefix.SAMPLE.ASM(ALOADMM),               <== Verify
//             DISP=SHR
//*
//*********************************************************************
//*                                                                   *
//*  Using HLASM, assemble the assembler program.                     *
//*  Note: MAC1 is the SAS/C assembler macro library.                 *
//*                                                                   *
//*  Options NODECK and OBJECT are specified so that the assembler    *
//*  will know where to place the output object deck.                 *
//*                                                                   *
//*  Option SYSPARM(NOINDEP) is required so that the conditional      *
//*  assembler instructions in the source will know how to specify    *
//*  the CENTRY and CEXIT macros.                                     *
//*                                                                   *
//*********************************************************************
//ALOADMA     EXEC hlasmc,COND=(0,NE),                       <== Verify
//            PARM.ASM='NODECK,OBJECT,SYSPARM(NOINDEP)',
//            MAC1='prefix.MACLIBA'                          <== Verify
//ASM.SYSIN   DD  DSN=prefix.SAMPLE.ASM(ALOADMA),            <== Verify
//            DISP=SHR
//ASM.SYSLIN  DD DSN=your.object.library(ALOADMA),           <== Verify
//            DISP=SHR
//*
//*********************************************************************
//*                                                                   *
//*  Compile the C function which displays the CRAB address           *
//*                                                                   *
//*********************************************************************
//*
//ALOADMC      EXEC LC370C,COND=(0,NE)
//C.SYSLIN     DD DSN=your.object.library(ALOADMC),          <== Verify
//             DISP=SHR
//C.SYSIN      DD DSN=prefix.SAMPLE.ASM(ALOADMC), <== Verify
//             DISP=SHR
//*
//*********************************************************************
//*                                                                   *
//*  CLINK the C main, assembler, and c function into a single        *
//*  module.                                                          *
//*                                                                   *
//*  Note: CLINK is not required for this sample, but is being used   *
//*        for illustration only.                                     *
//*                                                                   *
//*********************************************************************
//*
//CLINK1       EXEC LC370LR,COND=(0,NE)
//LKED.SYSLMOD DD DSN=your.load.library,                     <== Verify
//             DISP=SHR
//LKED.SYSIN   DD *
  INCLUDE OBJINPT(ALOADMM)       C main function
  INCLUDE OBJINPT(ALOADMA)       Assembler loading routine
  INCLUDE OBJINPT(ALOADMC)       C function to display CRAB Address
  ENTRY MAIN                     Ensure Correct Entry Point
  NAME  ALOADMJ(R)               The Dynamic Loader Module
/*
//LKED.OBJINPT DD DISP=SHR,DSN=your.object.library           <== Verify
//*
//*********************************************************************
//*
//*  Compile the C function that will be dynamically loaded.          *
//*                                                                   *
//*  Note: Reentrant code is not required for this sample, but is     *
//*        being used here because so many functions which are        *
//*        dynmaically loaded are required to be reentrant.           *
//*                                                                   *
//*********************************************************************
//*
//CDYNLOAD     EXEC LC370C,COND=(0,NE),
//             PARM.C='RENT'
//C.SYSLIN     DD DSN=your.object.library(ALOADMD),          <== Verify
//             DISP=SHR
//C.SYSIN      DD DSN=prefix.SAMPLE.ASM(ALOADMD),
//             DISP=SHR
//*
//*********************************************************************
//*
//* CLINK the dynamically loaded module with the C function to        *
//* display the CRAB address.                                         *
//*                                                                   *
//*  Note: CLINK must be used to pre-link this dynamically loaded     *
//*        module because it was compiled with the 'RENT' option.     *
//*                                                                   *
//*  Note: Dynmaically loaded C programs are required to have one     *
//*        of two entry points:                                       *
//*        Reentrant Code:      #DYNAMN     <--ALOADMD Entry Point    *
//*        Non-Reentrant Code:  #DYNAMNR                              *
//*                                                                   *
//*********************************************************************
//*
//CLINK2       EXEC LC370LR,COND=(0,NE)
//LKED.SYSLMOD DD DSN=your.load.library,                     <== Verify
//             DISP=SHR
//LKED.SYSIN   DD *
  INCLUDE OBJINPT(ALOADMD)     C dynamically loadable function
  INCLUDE OBJINPT(ALOADMC)     C function to display CRAB address
  ENTRY #DYNAMN                <--Notice Entry: Reentrant Code
  NAME  CDYNLD(R)              Create dynamically loadable module
/*
//LKED.OBJINPT DD DSN=your.object.library,                   <== Verify
//             DISP=SHR
//*
//*********************************************************************
//*
//* Execute the sample program.                                       *
//*
//*********************************************************************
//GO           EXEC PGM=ALOADMJ,COND=(0,NE)
//STEPLIB      DD DSN=your.load.library,                     <== Verify
//             DISP=SHR
//             DD DSN=prefix.LOAD,                           <== Verify
//             DISP=SHR
//SYSPRINT     DD SYSOUT=*                                   <-- stdout
//SYSTERM      DD SYSOUT=*                                   <-- stderr
//