These call conventions are relevant to .NET managed code when using Platform Invoke only to call unmanaged code.
COBOL programs can call and be called by programs written in other languages. However, some languages handle calls differently from COBOL. For example, some language pass parameters in the opposite order from that expected by COBOL programs. To enable COBOL and non-COBOL programs to call each other, you can adjust the calling mechanisms that the COBOL program uses or that it expects to be used.
To specify the calling mechanisms you require, you first construct the call convention number that produces the required mechanisms. The call convention number is a 16-bit number defined as follows:
0 | Process parameters from right-to-left |
1 | Process parameters from left-to-right |
0 | Parameters removed from stack by calling program |
1 | Parameters removed from stack by called program |
0 | RETURN-CODE is updated on exit |
1 | RETURN-CODE is not updated on exit |
0 | Normal linking behavior |
1 | Call is resolved at link time |
0 | The call does not conform to the Windows stdcall calling convention |
1 | The call conforms to the Windows stdcall calling convention |
0 | The parameter-count of individual entry-points is checked |
1 | The parameter-count of individual entry-points is not checked |
0 | The case of the program or call name is disregarded |
1 | The case of the program or call name is significant |
0 | Normal calling behavior |
1 | The first parameter is always the RETURNING item for the CALL |
When you have constructed the call convention number, you convert it to a decimal number, and then assign this decimal number to a name, by defining it the Special Names paragraph. You then use the call convention name in the CALL statement.
For example, if you define the following call conventions:
SPECIAL-NAMES. CALL-CONVENTION 0 IS Microsoft-c CALL-CONVENTION 3 IS Pascal.
you can then use one convention when calling a C program as follows:
CALL Microsoft-c "routine-name" USING parameter-1,parameter-2
and use the other convention when receiving a call from a Pascal program, such as:
PROCEDURE DIVISION Pascal USING parameter-1,parameter-2
If you do not specify a call convention, the standard COBOL convention (call-convention 0) is assumed, unless the DEFAULTCALLS Compiler directive is used.