zCOBOL
Portable Mainframe COBOL |
|
|
The zc390 translator is a java regular expression based parser which reads COBOL source program and generates HLASM compatible mainframe assembler source program in one pass. Each recognized COBOL verb starts a new assembler macro call statement with all the parameters up to the next verb, period, or paragraph label passed as positional parameters. Periods generate a separate macro call to PERIOD to generate end to all the structures in the previous sentence. Paragraph and section labels generate call to LABEL with the name and type of label to generate. All hyphens in names are translated to underscores for HLASM compatibility.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
All the macros for the COBOL language verbs and section headings are stored in the macro library z390\zcobol. These macros parse the parameters, validate them for any syntax errors, and issue calls to generation macros in separate directory as described below. For example, the zcobol\IF.MAC macro generates multiple calls to the generation macros GEN_COMP, GEN_BC GEN_B, and GEN_LABEL. There are no language specific code generation macros in the zcobol directory so it is shared across multiple target language environments. All the macros are written in structured form using the z390 ZSTRMAC SPE structured programming extensions such as AIF, AELSEIF, AELSE, AEND, AWHILE, etc. As a result there are no explicit AGO or AIF labels in these macros.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The COBOL compute statement now supported in v1.5.00d is a good example to study to understand how the zcobol compiler works. The steps followed to compile the following MOVE and COMPUTE statements are as follows: 77 FLT-SRT
USAGE FLOAT-SHORT OCCURS 2.
The generated zcobol HLASM assembler code for these 2 COBOL statements is as follows: 0000DC (1/99)652 * MOVE
1.1 TO FLT-SRT(2) See the results for this calculation in the regression test zcobol\test\TESTSIX1.CBL. Note that using DFP the result is exactly 3.3 which is not the case when using HFP COMP-1 floating point due to conversion to base 2 versus base 10. The zcobol\ZC_CALC.MAC macro is written in ZSTRMAC structured conditional macro assembler consisting of about 850 lines of code with no AGO statements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zCOBOL Target Source Language Generation Macros All the target source language generation macros called by the COBOL verb macros in z390\zcobol are stored in the following directories by target language:
Current only the z390 HLASM compatible source generation macros are being fully developed along with the required runtime support functions stored in the zcobol\z390\ZC390LIB.390 dynamically loaded runtime module. However the zcobol demos include a hello world COBOL program which can be compiled and executed in each of the target environments form the same zcobol\demo\HELLO.CBL source program. The following commands generate the corresponding source language equivalent and executable:
If you are interested in joining in the open source zcobol development effort in any of the 4 target language environments or want to add another target language environment, join the zcobol development email discussion group and make your interests known. Melvyn Maltz is currently developing additional EXEC CICS support for zcobol programs.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The z390\zcobol\z390 code generation macro directory also contains all the source code and the ZC390CVT.CPY copybook required to build the z390\linklib\ZC390LIB.390 runtime load module which is dynamically loaded by all generated z390 zCOBOL programs. This module contains the following components:
The ZC390CVT.CPY copybook is used in every zcobol generated program to define the DSECT addressed by register 9. The same copybook is also used in ZC390LIB.MLC to generated the CVT at the beginning of the ZC390LIB.390 runtime load module with addresses of all the entries followed by work areas used by the code generation macros. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The zcobol code generation macros in zcobol\z390 generate base free code for the procedure division using relative instructions for both branch addressing and for literal addressing as required. The only address constants generated in zcobol programs are for statically linked CALL's to other zcobol or assembler programs. The only limit on the combined size of working storage and the procedure division is 16 MB. In order to use relative addressing for literals, all odd length literals are padded to even lengths. The LARL instruction is used to set address of data field or literal field as required for use in following RX type instructions. To address working storage and linkage section data fields, conventional base registers are dynamically allocated as required for use in RX type instructions. Since R13 always points to the beginning of working-storage, no dynamic base registers are required for access to data items in the first 4k of working storage.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
When the option CICS is specified on the command line for ZC390C, ZC390CL, or ZC390CLG, then the zcobol\ZCOBOL.MAC global option &ZC_CICS is set on and the following changes in code generation are made:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
IBM, CICS, HLASM, MVS, OS/390, VSAM, z9, z10, and z/OS
are registered trademarks
of International Business Machines Corporation
This page last updated
Wednesday May 27, 2009.
Webmaster
Copyright 2009 Automated Software Tools Corporation