![]() Chapter Contents |
![]() Previous |
![]() Next |
Communication with Assembler Programs |
Before a C program can be executed, the C execution
framework must be created. Normally, the framework is created by the library
routine L$CMAIN, which is defined by the linkage editor to be the first routine
executed in a C load module. L$CMAIN expects to be called by the operating
system and therefore expects a standard OS/390 or CMS format parameter list,
consisting of a character string plus various system-dependent format information.
L$CMAIN processes this information, transforms it into the C standard
argc
and
argv
format, and calls the C
main
function with the constructed
argc
and
argv
.
L$CMAIN can be called directly from assembler to pass control to a
main
C routine via the normal C entry point, MAIN. However, invoking a C program
via MAIN is rarely convenient because the type of parameter list required
is both inflexible (allowing only character data to be passed) and operating
system dependent.
Note:
The behavior of $MAINC and $MAINO in CICS is different than the behavior of
these entry points under OS/390 or CMS. See Calling a C Program from Assembler via $MAINO in CICS.
Entry point $MAINC expects to receive a list
of addresses
in the standard OS VL-type parameter list format. $MAINC transforms the input
parameters into the standard C
argc
value (number of arguments
plus 1) and the
argv
vector. Each element of
argv
after
argv[0]
contains the corresponding address from the
input parameter list. (For example,
argv[1]
contains the first
address from the list.)
Entry point $MAINO expects a list of addresses in the
standard OS VL-type parameter list format. The first argument to $MAINO is
a pointer to a string containing run-time options, preceded by a halfword
containing the number of characters in the string. The first word in the
argument list should address the prefix, not the string itself. This information
is processed by the run-time library and is not passed to the C
main
program. Each element of argv after
argv[0]
contains the corresponding
address from the input parameter list. (For example,
argv[1]
contains the second address from the list, which represents the first
argument.)
Calling a C main Function from Assembler via $MAINO shows an assembler program that calls a C function through $MAINO. The C program using the argument as passed by assembler through $MAINO is in C main Function Called from an Assembler Driver via $MAINO.
Calling a C Program from Assembler via $MAINO in CICS shows sample code that calls a C program from assembler using the entry point $MAINO from CICS. CICS command-level programs are called with a parameter list of at least two entries: the address of the EXEC interface block (EIB) and the COMMAREA address. If there is no COMMAREA, a value of x'ff000000' is passed in its place.
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.