Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - typically, structures are not returned in registers. instead, the caller http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Typically, structures are not returned in registers.  Instead, the caller
allocates space on the stack for the return value and sets register SI to
point to it.  The called routine then places the return value at the
location pointed to by register SI.

The following form of the auxiliary pragma can be used to specify the
register that is to be used to point to the return value.

+--------------------------------------------------------------------------+
|      #pragma aux sym value struct (caller|routine) reg_set [;]           |
|                                                                          |
+--------------------------------------------------------------------------+

where
    description

sym
    is a function name.

reg_set
    is a register set.

"caller" specifies that the caller will allocate memory for the return
value.  The address of the memory allocated for the return value is placed
in the register specified in the register set by the caller before the
function is called.  If an empty register set is specified, the address of
the memory allocated for the return value will be pushed on the stack
immediately before the call and will be returned in register AX by the
called routine.  It is assumed that the memory for the return value is
allocated from the stack segment (the stack segment is contained in segment
register SS).

"routine" specifies that the called routine will allocate memory for the
return value.  Upon returning to the caller, the register specified in the
register set will contain the address of the return value.  An empty
register set is not allowed.

Only the following registers are allowed in the register set:  AX, DX, BX,
CX, SI or DI.  Note that in a big data model, the address in the return
register is assumed to be in the segment specified by the value in the SS
segment register.

If the size of the structure being returned is 1, 2 or 4 bytes, it will be
returned in registers.  The return register will be selected from the
register set in the following way.

 1. A 1-byte structure will be returned in one of the following registers:
     AL, AH, DL, DH, BL, BH, CL or CH.  If no register set is specified,
    register AL will be used.

 2. A 2-byte structure will be returned in one of the following registers:
     AX, DX, BX, CX, SI or DI.  If no register set is specified, register AX
    will be used.

 3. A 4-byte structure will be returned in one of the following register
    pairs:  DX:AX, CX:BX, CX:AX, CX:SI, DX:BX, DI:AX, CX:DI, DX:SI, DI:BX,
    SI:AX, CX:DX, DX:DI, DI:SI, SI:BX or BX:AX.  If no register set is
    specified, register pair DX:AX will be used.

The following form of the auxiliary pragma can be used to specify that
structures whose size is 1, 2 or 4 bytes are not to be returned in
registers.  Instead, the caller will allocate space on the stack for the
structure return value and point register SI to it.

+--------------------------------------------------------------------------+
|      #pragma aux sym value struct struct [;]                             |
|                                                                          |
+--------------------------------------------------------------------------+

where
    description

sym
    is a function name.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson