Ordering Parameters to Pass to Non-COBOL Programs

The order in which the parameters are passed, since the calling program might not pass parameters in the order that the called program expects them.

You pass parameters to a non-COBOL program in much the same way as to a COBOL program, by specifying them in the USING phrase of the CALL statement. For example:

CALL call-convention "program-name" USING parameter-1, parameter-2

Just as when calling COBOL programs, the order of the parameters is important. However, some languages, such as Pascal, expect parameters in the opposite order from that expected by COBOL programs. You can use the call convention to define the order in which to pass the parameters.

COBOL programs pass parameters by pushing them onto the stack before calling the subprogram. The parameters can be pushed onto the stack either from right-to-left (reverse order) or from left-to-right (order specified). The first of these methods is the convention used by COBOL and by C. The second method is used by languages such as Pascal.

For example, on entry to a subprogram called with the statement:

CALL "sub-prog" USING  parameter-1

the stack looks like one of the following illustrations. In both cases, parameters are pushed onto the stack from high memory to low memory. Stack Pointer is the register that points to the next vacant slot in the stack.

Figure 1. *