9.1.4 Return value

(1)

Registers used for passing of return values

The registers used for passing of return values are AX, BC, and DE.

(2)

The return values and pointers to return values are allocated either to registers or in the stack

The return values and pointers to return values are allocated either to registers or in the stack as described below.

-

For a return value with a size of five bytes or more, the pointer to the return value is set to the first parameter as a near pointer.
This means that the passing conventions for the first parameter are applied to the return value. In accordance with this, the passing conventions for (n + 1)-th parameter are applied to n-th parameter (n = 1, ..., N) which is specified in the program
For the details of description, see "9.1.3 Passing arguments".

-

A return value whose size is 4 bytes or less is allocated to registers.

-

For the method of allocating a far pointer to registers, see section "9.1.3 Passing arguments".

-

A 4-byte structure or union whose only member is a far pointer is considered to be other than a far pointer.

-

The conventions for allocating a return value of 4 bytes or less to registers are given in the following table.

Return Value Size

Register to which Argument is Allocated

1-byte

A

2-byte

AX

3-byte

C-AX

4-byte

far pointer: A-DE

Other than far pointer: BC-AX

 

"-" in this table is a symbol to associate 8-bit or 16-bit registers to other 16-bit registers.

Each return value is allocated to registers so that the descending order of addresses (from upper address to lower address) for the bytes composing the return value matches the register specification order (from left to right) shown in the above table.

Caution

Structures or unions of 4 bytes or less are targets to be allocated to registers.