Application programming on z/OS
Previous topic | Next topic | Contents | Glossary | Contact z/OS | PDF


How programs are compiled on z/OS

Application programming on z/OS

The function of a compiler is to translate source code into an object deck, which must then be processed by a binder (or a linkage editor) before it is executed.

During the compilation of a source module, the compiler assigns relative addresses to all instructions, data elements, and labels, starting from zero. The addresses are in the form of a base address plus a displacement. This allows programs to be relocated, that is, they do not have to be loaded into the same location in storage each time that they are executed. Any references to external programs or subroutines are left as unresolved. These references will either be resolved when the object deck is linked, or dynamically resolved when the program is executed.

To compile programs on z/OS®, you can use a batch job, or you can compile under TSO/E through commands, CLISTs, or ISPF panels. For C programs, you can compile in a z/OS UNIX® shell with the c89 command. For COBOL programs, you can compile in a z/OS UNIX shell with the cob2 command.

For compiling through a batch job, z/OS includes a set of cataloged procedures that can help you avoid some of the JCL coding you would otherwise need to do. If none of the cataloged procedures meet your needs, you will need to write all of the JCL for the compilation.

As part of the compilation step, you need to define the data sets needed for the compilation and specify any compiler options necessary for your program and the desired output.

The data set (library) that contains your source code is specified on the SYSIN DD statement, as shown in Figure 1.

Figure 1. SYSIN DD statement for the source code
//SYSIN DD DSNAME=dsname,
// DISP=SHR
You can place your source code directly in the input stream. If you do so, use this SYSIN DD statement:
//SYSIN DD *

When you use the DD * convention, the source code must follow the statement. If another job step follows the compilation, the EXEC statement for that step follows the /* statement or the last source statement.





Copyright IBM Corporation 1990, 2010