Differences Between the 16-bit Calling Conventions (OS/2)

  1. The order in which parameters are pushed on stack and their cleanup.

    When you use the _Far16 _Cdecl calling convention, the parameters are pushed on the stack in a right-to-left order. The caller cleans up the parameters on the stack. This is the opposite of the _Far16 _Pascal and _Far16_Fastcall conventions. When you use the _Far16 _Pascal convention, the parameters are pushed on the stack from left to right, and the callee (the function being called) cleans up the stack (usually by using a RET nn where nn is the number of bytes in the parameter list).

  2. The number of registers which can take parameters.

    The _Far16_Fastcall convention differs from _Far16 _Cdecl and _Far16_Pascal in that it uses three registers that can take parameters, similar to _Optlink. When you use _Far16 _Fastcall, registers are assigned to variable types as follows:

  3. Arguments are stored in the first available register allocated for their type. If all registers for that type are filled, the argument is pushed on the run-time stack from left to right.
  4. The method of returning structures, unions, and floating point types.

    For _Far16 _Cdecl and _Far16 _Pascal, all three types are returned with the address returned like a far pointer; that is, the value is in storage. The _Far16 _Pascal convention passes a hidden parameter, while _Far16 _Cdecl has a static area. This means that the _Far16 _Cdecl convention is nonreentrant, and should not be used in multithread programs.

    When you use the _Far16 _Fastcall convention, structures and unions are returned with the address returned like a near pointer. Like _Far16 _Pascal, _Far16 _Fastcall passes the address as a hidden parameter. Floating-point types are returned in ST(0).



Call Between 16-bit and 32-bit Code
16-bit Calling Conventions


Return Values from 16-Bit Calls