//******** Multiple PL/I Calls from Assembler        14.12.94+14.12.94
//*        PL/I Programming Guide, p. 396-398
//*
//APPVVASM JOB CLASS=A,MSGCLASS=T,NOTIFY=VLAD
//ASM     EXEC ASMHC
//ASM.SYSLIN   DD UNIT=SYSTS,DSN=&&LOADSET,SPACE=(80,(100,60)),
//             DCB=BLKSIZE=80,DISP=(,PASS)
//* ------------------------------------------------------------------
ASMPROC  CSECT
         ENTRY ASMROUT
         STM   14,12,12(13)     - Store Supervisor registers
         BALR  10,0             - Establish addessability
         USING *,10
         LA    4,SAVEAREA       - Load current Save Area address
         ST    13,4(4)          - Store chain back address
         ST    4,8(13)          - Store chain forward address
         LR    13,4             - Store current Save Area address
* --------------------------------------------------------------------
         SR    1,1              - No parameters, no value returned
         L     15,=V(PLICALLA)  - Call MAIN PL/I procedure
         BALR  14,15              to set PL/I environment
* --------------------------------------------------------------------
         L     13,4(13)         - On returning from PL/I procedure ...
         L     14,12(13)
         LM    1,12,24(13)
         BR    14               - Return to Supervisor
* --------------------------------------------------------------------
         DC    C'ASMROUT'       - Name in PL/I format
         DC    AL1(7)
ASMROUT  DS    0H
         STM   14,12,12(13)     - Store MAIN PL/I procedure registers
         BALR  10,0             - Establish addessability
         USING *,10
* --------------------------------------------------------------------
         LA    0,104            - Get storage for new DSA
         L     1,76(13)
         ALR   0,1
         CL    0,12(12)         - Is there enough space left?
         BNH   ENOUGH           - Yes, enough
         L     15,116(12)       - Load address of overflow routine
         BALR  14,15              and branch to it
*
ENOUGH   EQU   *
         ST    0,76(1)          - Store addr of start of avail storage
         ST    13,4(1)          - Set back chain
         ST    1,8(13)          - Set forward chain
         MVC   72(4,1),72(13)   - Copy address of workspace
         LR    13,1             - Point register 13 at new DSA
         MVI   0(13),X'80'      - Set flags in DCA
         MVI   1(13),X'00'        to preserve PL/I
         MVI   86(13),X'91'       error-handling
         MVI   87(13),X'C0'       in Assembler routine
*
         SR    1,1              - No parameters, no value returned
         L     15,=V(HEAD)      - Call PL/I routine
         BALR  14,15              to print page header
*
LOOP     EQU   *
         LA    1,PARMLST1       - Load parameter address
         L     15,=V(PLIN)      - Call PL/I routine
         BALR  14,15              to read and add
*
         L     3,RESULT
         LTR   3,3              - Test result and
         BM    OUTLOOP            brunch out if negative
*
         LA    1,PARMLST2       - Load parameter address
         L     15,=V(PLOUT)     - Call PL/I routine
         BALR  14,15              to print result
         B     LOOP             - Branch to loop head
*
OUTLOOP  EQU   *
         SR    1,1              - No parameters, no value returned
         L     15,=V(FOOT)      - Call PL/I routine
         BALR  14,15              to print page header
* --------------------------------------------------------------------
         L     13,4(13)
         LM    14,12,12(13)
         BR    14               - Return to MAIN PL/I procedure
* --------------------------------------------------------------------
PARMLST1 DC    A(DATA)
PARMLST2 DC    A(X'80000000'+RESULT)
DATA     DC    F'123'
RESULT   DC    F'0'
SAVEAREA DC    18F'0'
         END   ASMPROC
//* ------------------------------------------------------------------
//PLI    EXEC  PLIXCLG,REGION.LKED=500K
//PLI.SYSLIN   DD DSN=&&LOADSET,DCB=BLKSIZE=80,DISP=(MOD,PASS)
//* ------------------------------------------------------------------
* PROCESS;
  MAIN: PROC OPTIONS(MAIN);
             DCL  ASMROUT ENTRY;
             CALL ASMROUT;
        END;
* PROCESS;
  PLIN: PROC(I) RETURNS(BIN FIXED(31));
            DCL (I,J) BIN FIXED(31);
            GET LIST(J);
            RETURN(I+J);
  HEAD: ENTRY;
            PUT LIST('Start of output');
            PUT SKIP;
        END;
* PROCESS;
  PLOUT: PROC(K);
             DCL K BIN FIXED(31);
             PUT SKIP LIST(K);
             RETURN;
  FOOT:  ENTRY;
             PUT SKIP(2) LIST('End of output');
         END;
//* ------------------------------------------------------------------
//GO.SYSIN DD *
  50 77 123 234 345 456 -23 -100 -123 -234
//
