Application programming on z/OS
|
Previous topic |
Next topic |
Contents |
Glossary |
Contact z/OS |
PDF
More information about the z/OS Language Environment Application programming on z/OS |
|
|
Examples show how program languages use callable services. Invocation of callable services from PL/I Figure 1 shows a PL/I program invoking the math callable services CEESIMOD and CEESSLOG for Modular arithmetic and log base e. Figure 1. Sample
invocation of a math callable service from a PL/I program
PLIMATH: PROC OPTIONS(MAIN);
DCL CEESSLOG ENTRY OPTIONS(ASM) EXTERNAL;
DCL CEESIMOD ENTRY OPTIONS(ASM) EXTERNAL;
DCL ARG1 RESULT REAL FLOAT DEC (6);
DCL ARGM1 ARGM2 RES2 FLOAT BINARY(21)
DCL FC CHARACTER (12);
/* Call log base e routine, which has */
/* only one input parameter */
CALL CEESSLOG (ARG1, FC, RESULT)
IF ( FC = '000000000000000000000000'X )
THEN DO;
PUT SKIP LIST
('Error occurred in call to CEESSLOG.' );
ELSE;
/* Call modular arithmetic routine, */
/* which has two input parameters */
CALL CEESIMOD (ARGM1, ARGM2, FC, RES2);
IF ( FC = '000000000000000000000000'X )
THEN DO;
PUT SKIP LIST
('Error occurred in call to CEESIMOD.' );
ELSE;
END;
Invocation of callable services from C Figure 2 shows a C program invoking the math callable services CEESDGL1 and CEESIMOD for Log base 10 and modular arithmetic. Figure 2. Sample invocation of a math callable service from a
C program
#include <leawi.h>
#include <string.h>
#include <stdio.h>
int main (void) {
_FLOAT8 f1,result;
_INT4 int1, int2, intr;
_FEEDBACK fc;
#define SUCCESS "\0\0\0\0"
f1 = 1000.0;
CEESDLG1(&f1,&fc,&result);
if (memcmp(&fc,SUCCESS,4) != 0) {
printf("CEESDLG1 failed with message number %d\n",
fc.tok_msgno);
exit(2999);
}
printf("%f log base 10 is %f\n",f1,result);
int1 = 39;
int2 = 7;
CEESIMOD(&int1,&int2,&fc,&intr);
if (memcmp(&fc,SUCCESS,4) != 0) {
printf("CEESIMOD failed with message number %d\n",
fc.tok_msgno);
exit(2999);
}
printf("%d modulo %d is %d\n",int1,int2,intr);
}
Invocation of callable services from Assembler Figure 3 shows the invocation of a callable service from an Assembler language program. Figure 3. Sample invocation of a callable service from an Assembler
program
LA R1,PLIST
L R15,=V(CEESERV)
BALR R14,R15
CLC FC(12),CEE000 Check if feedback code is zero
BNE ER1 If not, branch to error routine
.
.
.
PLIST DS 0D
DC A(PARM1)
.
.
.
Parms 2 through n
DC A(FC+X'80000000') Feedback code as last parm
PARM1 DC F'5' Parm 1
.
.
.
Parms 2 through n
FC DS 12C Feedback code as last parm
CEE000 DC 12X'00' Good feedback code
|
Copyright IBM Corporation 1990, 2010 |