Return Values from 16-Bit Calls (OS/2)
Return Value Registers
| Type |
cdecl |
pascal |
fastcall |
| char |
AL |
AL |
AL |
| unsigned char |
AL |
AL |
AL |
| char far* |
AX/DX1 |
AX/DX1 |
AX/DX1 |
| short |
AX |
AX |
AX |
| long |
DX/AX 2 |
DX/AX 2 |
DX/AX 2 |
| float |
AX/DX 3 |
AX/DX 4 |
ST(0) |
| double |
AX/DX 3 |
AX/DX 4 |
ST(0) |
| long double |
AX/DX 3 |
AX/DX 4 |
ST(0) |
| struct_>4_bytes |
AX/DX 5 |
AX/DX 6 |
AX/DX 6 |
| struct_<=4_bytes |
AX/DX 7 |
AX/DX 7 |
AX/DX 7 |
Notes:
- Far pointers are always returned such that the offset is
in AX and the selector is in DX.
- For long cdecl, long pascal, long fastcall:
The high word is in DX and the low word is in AX.
- For float, double, long double cdecl:
The compiler does not provide a hidden parameter, but
rather places the return value in an external static
variable, __fac, which is defined as a qword. On return,
DX contains the selector and AX contains the offset of
__fac. For functions with type long double cdecl, the
returned value is placed in ST(0).
- For float, double, long double with pascal:
The compiler reserves space in automatic storage for the
return value and pushes a pointer to this area (offset
only, SS is always assumed). The callee stores the return
value in this area and returns the offset of this area in
AX and returns SS in DX.
- For structures greater than 4 bytes, cdecl:
The compiler reserves sizeof(struct_20_byes) in
uninitialized static (BBS) for the callee. No hidden
parameter is passed; the callee moves the return
structure into this static reserved area and returns the
offset of the structure in AX and the selector in DX.
- For structures greater than 4 bytes, pascal, fastcall:
The compiler reserves space for the return value in the
caller's automatic storage and pushes the address of this
area as a near pointer. SS will be assumed as the
selector. This parameter is pushed last as a hidden
parameter. The offset of the resereved space is returned
in AX, and the selector (SS) is returned in DX.
- For structures less than or equal to 4 bytes:
The compiler returns the contents of the structure in AX
and DX, with the lower 2 bytes in AX and the higher 2
bytes in DX.
- If the structure is packed and its size is 1
byte, AL is used.
- If the structure is 2 bytes, AX is used.
- If the structure is packed and its size is 3
bytes, space is reserved in the data segment, the
offset is returned in AX, and the selector is
returned in DX.

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