Microsoft KB Archive/52175

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:25, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q52175 to Microsoft KB Archive/52175 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Passing a Structure from Assembly Language to COBOL

PSS ID Number: Q52175 Article last modified on 11-30-1990

3.00 3.00a MS-DOS

Summary: The two programs shown below demonstrate how a Microsoft assembly language program can pass a structure to a called COBOL routine. This information about interlanguage calling applies to Microsoft COBOL versions 3.00 and 3.00a for MS-DOS.

More Information: For more examples of passing other types of parameters between COBOL and assembly language, query on the following word: COB2MASM For a complete discussion about mixed-language programming with COBOL, search in the Software/Data Library for the following word: COBMIXED

Code Example

The following COBOL program is COB.CBL, which is invoked by an assembly language program. The COBOL routine displays the values of a passed structure. $SET LITLINK IDENTIFICATION DIVISION. PROGRAM-ID. "_COBPROG“. DATA DIVISION. LINKAGE SECTION. 01 REC-1. 05 INTNUM PIC 9(4) COMP-5. 05 LONGNUM PIC 9(8) COMP-5. 05 THESTRING PIC X(8). PROCEDURE DIVISION using REC-1. DISPLAY”Passed INTNUM : " INTNUM. DISPLAY “Passed LONGNUM :” LONGNUM. DISPLAY “Passed THESTRING :” THESTRING. EXIT PROGRAM. The following program is ASM.ASM, which creates a structure that is passed to a called COBOL routine: .MODEL LARGE, C ; COBOL uses C calling convention usrType STRUC ; structure matches one in COBOL iAsm DW 10 lAsm DD 43210 sAsm DB ‘Assembly’ usrType ENDS .STACK 200h .DATA AsmRec usrType <> .CODE EXTRN CobProg:PROC MasmProg: mov ax, @DATA ; initialize data segment mov ds, ax mov cx, 1 ; load count mov ax, SEG AsmRec ; put address of structure on stack push ax mov ax, OFFSET AsmRec push ax mov bp, sp ; set up bp for COBOL stack CALL CobProg add sp, 4 ; clean up stack after call mov ax, 4C00h ; terminate process with return code INT 21h ; call MS-DOS to terminate END MasmProg To demonstrate these programs from an .EXE program, compile and link for MS-DOS as follows: COBOL COB.CBL; MASM ASM.ASM; LINK ASM COB; COB.EXE produces the following output: Passed INTNUM : 00010 Passed LONGNUM : 000043210 Passed THESTRING : Assembly

Copyright Microsoft Corporation 1990.