Microsoft KB Archive/32481

Explanation of Mixed-Language Programming in COBOL 3.00

PSS ID Number: Q32481 Article last modified on 11-16-1992

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: The method for interlanguage calling depends upon which language (COBOL or the other language) is the main program.

More Information: Microsoft COBOL Versions 3.00 and 3.00a can do interlanguage calling with FORTRAN Versions 4.00, 4.01, and 4.10. COBOL was not tested with Microsoft FORTRAN Version 5.00, and the MINITF.OBJ initialization routines probably won’t work with FORTRAN 5.00. This means that to do interlanguage calling from COBOL 3.00 or 3.00a to FORTRAN 5.00, FORTRAN would have to be the main program, but Microsoft has not tested this combination of versions. COBOL 3.00 and 3.00a can call only Pascal Version 4.00 (the current version as of September 1989). If COBOL is the main program, the following information applies: 1. Using COBOL as the main program is recommended only if you are CALLing assembly language. 2. The large-memory model must be used for mixed-language programming. Since Microsoft QuickC Version 1.x uses the medium-memory model, QuickC routines cannot be called from COBOL. 3. Most languages, especially Microsoft C and FORTRAN, assume the following: SS = DS = DGROUP Microsoft COBOL and Lattice C do not meet this assumption. 4. Microsoft C and FORTRAN also perform stack checking, which requires that the other language’s run-time system be initialized. Therefore, Microsoft COBOL Version 3.00 provides the following run-time initialization modules for other languages: Language Module ——– —— Microsoft C Versions 4.00 through 5.10 MINITC.OBJ Microsoft FORTRAN Versions 4.00, 4.01, 4.10 MINITF.OBJ Lattice C LINITC.OBJ Only linking them creates the required entry point, as follows: LINK FRED+MINITC+CSUBBS…; Corrupt data in the COBOL program is an indication that the appropriate INIT object file was not specified during the LINK process. Note: All C or FORTRAN programs must be compiled with stack checking off and SS=DS=DGROUP disabled by compile-time directives. This includes all run-time routines they may call (floating-point math, etc.). If COBOL is not the main program, the following information applies: 1. When the driver (main program) is in another language, COBOL is forced to be self contained. This eliminates the need for MINIT routines. 2. The COBOL CALLing conventions are as follows: a. CALL “FRED” USING PARM1, PARM2. b. PARM1 would be POPped from the stack first, as follows: +——-+ | PARM1 | +——-+ | PARM2 | +——-+ c. The CX register contains the number of arguments. d. COBOL always cleans the stack after a CALL (that is, COBOL reloads all of the segment registers).

Copyright Microsoft Corporation 1992.