Calling the z/OS XL C/C++ compiler from assembler

To invoke the compiler dynamically under z/OS®, you can use macro instructions such as ATTACH, LINK, or CALL in an assembly language program. For complete information on these macro instructions, refer to the list of documents in z/OS V2R2 Information Roadmap.

The syntax of each macro instruction is as follows:
Read syntax diagramSkip visual syntax diagram
>>-+-------+--ATTACH--EP=CCNDRVR--,--PARAM=--(------------------>
   '-label-'                                     

>--option_list--+----------------+------------------------------>
                '-,--ddname_list-'   

>--)--,--VL=1--,--DCB=dcb_addr--,--TASKLIB=dcb_addr------------><

Read syntax diagramSkip visual syntax diagram
>>-+-------+--LINK--EP=CCNDRVR--,--PARAM=--(-------------------->
   '-label-'                                   

>--option_list--+----------------+--)--,--VL=1-----------------><
                '-,--ddname_list-'               

Read syntax diagramSkip visual syntax diagram
>>-+-------+--CALL--EP=CCNDRVR--,--(---------------------------->
   '-label-'                           

>--option_list--+----------------+--)--,--VL-------------------><
                '-,--ddname_list-'             

where:
EP
Specifies the symbolic name of the z/OS XL C/C++ compiler CCNDRVR. The control program determines the entry point at which execution is to begin.
PARAM
Specifies a list that contains the addresses of the parameters to be passed to the z/OS XL C/C++ compiler
option_list
Specifies the address of a list that contains the options that you want to use for the compilation.

The option_list must begin on a halfword boundary. The first 2 bytes must contain a count of the number of bytes in the remainder of the list. You specify the options in the same manner as you would on a JCL job, with spaces between options. If you do not want to specify any options, the count must be zero.

For C++ compiler invocation, you must include the characters CXX, and a blank before the list of compiler options. The number of bytes therefore should be 4 bytes longer.

ddname_list
Specifies the address of a list that contains alternative ddnames for the data sets that are used during the compiler processing. If you use standard ddnames, you can omit this parameter.

The ddname_list must begin on a halfword boundary. The first two bytes must contain a count of the number of bytes in the remainder of the list. You must left-justify each name in the list, and pad it with blanks to a length of 8 bytes.

The sequence of ddnames in the list is:
  • SYSIN
  • SYSLIN
  • SYSMSGS - this ddname is no longer used, but is kept in the list for compatibility with old assembler macros.
  • SYSLIB
  • USERLIB
  • SYSPRINT
  • SYSCPRT
  • SYSPUNCH
  • SYSUT1
  • SYSUT4
  • SYSUT5
  • SYSUT6
  • SYSUT7
  • SYSUT8
  • SYSUT9
  • SYSUT10
  • SYSUT14
  • SYSUT15
  • SYSEVENT
  • TEMPINC
  • IPACNTL
  • SYSUT16
  • SYSUT17
  • SYSUTIP
  • SYSCDBG
  • ASMLIB
You can omit an alternative ddname from this list by entering binary zeros in its 8-byte entry, or if it is at the end of this list, by shortening the list. If you omit a ddname, the compiler will use the appropriate default ddname from this list.
VL or VL=1
Specifies that the sign bit is to be set to 1 in the last fullword of the address parameter.
DCB
Specifies the address of the control block for the partitioned data set that contains the compiler.
TASKLIB
Specifies the address of the DCB for the library that is to be used as the attached tasks library.

The return code from the compiler is returned in register 15.

If you code the macro instructions incorrectly, the compiler is not invoked, and the return code is 32. This error could be caused if the count of bytes in the alternative ddnames list is not a multiple of 8, or is not between 0 to 184.

If you specify an alternative ddname for SYSPRINT, the stdout stream is redirected to refer to the alternate ddname.

The following examples show the use of three assembler macros that rename ddnames completely or partially. Following each macro is the JCL that is used to invoke it.