Originale-mail to me for new edition

 

Function results

 

The following conventions are used for returning function result values.

·    Ordinal results are returned, when possible, in a CPU register. Bytes are returned in AL, words are returned in AX, and double-words are returned in EAX.

·    Real results are returned in the floating-point coprocessor’s top-of-stack register (ST(0)). For function results of type Currency, the value in ST(0) is scaled by 10000. For example, the Currency value 1.234 is returned in ST(0) as 12340.

·    For a string, dynamic array, method pointer, variant, or Int64 result, the effects are the same as if the function result were declared as an additional var parameter following the declared parameters. In other words, the caller passes an additional 32-bit pointer that points to a variable in which to return the function result.

·    Pointer, class, class-reference, and procedure-pointer results are returned in EAX.

·    For static-array, record, and set results, if the value occupies one byte it is returned in AL; if the value occupies two bytes it is returned in AX; and if the value occupies four bytes it is returned in EAX. Otherwise, the result is returned in an additional var parameter that is passed to the function after the declared parameters.

 

Topic groups

 

See also

Parameters and function results: Overview

Procedures and functions: Overview

 

 

译文

 

函数结果

 

下列约定用于返回函数结果的值:

·    序数型结果返回时,如果可能,都在CPU寄存器中。字节在AL中返回,字在AX中返回,双字在EAX中返回。

·    实数结果返回在数字协处理器的栈顶寄存器(ST(0))。对于Currency类型的函数结果,返回值被乘以10000倍。例如,Currency1.234作为12340返回到ST(0)中。

·    对于串、动态数组、方法指针、变体或Int64等类型的函数结果,效果相当于函数结果作为一个额外的var参数被声明在函数声明的参数之后。换句话说,调用者传递一个指向一个变量的额外的32位指针,函数结果就返回到该指针中。

·    指针、类、类引用以及过程指针等函数结果在EAX中返回。

·    对于静态数组、记录以及集合类型的记过,如果返回值占用一个字节,那么它在AL中返回;如果占用两个字节,那么在AX中返回,如果占用四个字节,那么在EAX中返回。除此之外,函数结果在一个额外的var参数中返回,该var参数在函数声明的参数之后被传递给函数。

 

主题组

 

相关主题

参数和函数结果:概述

过程和函数:概述