To improve performance of a C, C++, COBOL, or PL/I routine
called repeatedly from assembler, use a Language Environment-conforming
assembler routine, because the Language Environment environment
is maintained across calls. If the assembler routine is not Language Environment-conforming,
the Language Environment environment
is initialized and terminated at every call. To improve the performance
for an assembler routine that is not Language Environment-conforming,
use preinitialization services. (See z/OS Language Environment Programming Guide
for
information about using preinitialization services.)
The call can be either a static call (the HLL routine is linked
with the assembler routine) or a dynamic load (using the CEELOAD or
the CEEFETCH macro). The assembler routine is a main routine and the
called HLL program is a subroutine.
For example, see Figure 1, which demonstrates
a Language Environment-conforming
assembler routine statically calling a COBOL program.
Figure 1. Language Environment-conforming
assembler routine calling COBOL routine *COMPILATION UNIT: LEASMCB
* =====================================================================
* Bring up the LE/370 environment
* =====================================================================
CEE2COB CEEENTRY PPA=MAINPPA,AUTO=WORKSIZE
USING WORKAREA,13
*
* Call the COBOL program
*
CALL ASMCOB,(X,Y) Invoke COBOL subroutine
*
* Call the CEEMOUT service
*
CALL CEEMOUT,(MESSAGE,DESTCODE,FC) Dispatch message
CLC FC(8),CEE000 Was MOUT successful?
BE GOOD Yes.. skip error logic
LH 2,MSGNO No.. Get message number
ABEND (2),DUMP LIGHTS OUT!
*
* Terminate the LE/370 environment
*
GOOD CEETERM RC=0 Terminate with return code zero
*
* ---------------------------------------------------------------
*
* Data Constants and Static Variables
*
Y DC PL3'+200' 2nd parm to COBOL program (input)
MESSAGE DS 0H
MSGLEN DC Y(MSGEND-MSGTEXT)
MSGTEXT DC C'AFTER CALL TO COBOL: X='
X DS ZL6 1st parm for COBOL program (output)
MSGEND EQU *
DESTCODE DC F'2' Directs message to MSGFILE
CEE000 DC 3F'0' Success condition token
FC DS 0F 12-byte feedback/condition code
SEV DS H severity
MSGNO DS H message number
CSC DS X flags - case/sev/control
CASE EQU X'C0' 11..... case (1 or 2)
SEVER EQU X'38' ..111.. severity (0 thru 4)
CNTRL EQU X'03' .....11 control (1=IBM FACID, 0=USER)
FACID DS CL3 facility ID
ISI DS F index into ISI block
*
MAINPPA CEEPPA Constants describing the code block
* ====================================================================
* Workarea
* ====================================================================
WORKAREA DSECT
CEEDSA , Mapping of the Dynamic Save Area
CEECAA , Mapping of the Common Anchor Area
CEEEDB , Mapping of the Enclave Data Block
*
END CEE2COB
Figure 2. COBOL routine
called from Language Environment-conforming
assembler *Module/File Name: IGZTASM
IDENTIFICATION DIVISION.
PROGRAM-ID. ASMCOB.
*
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*
LINKAGE SECTION.
01 X PIC +9(5).
01 Y PIC S9(5) COMP-3.
*
PROCEDURE DIVISION USING X Y.
COMPUTE X = Y + 1.
*
GOBACK.