By default, the calling mechanism the compiler uses is register, that is, the compiler will try to pass as much parameters as posible by storing them in a free register. Not all registers are used, because some registers have a special meaning, but this depends on the CPU.
Function results are returned in the accumulator ( rst register), if they t in the register. Methods calls (from either objects or clases) have an additional invisible parameter which is self. This parameter is the leftmost parameter within a method call (it is therefore the last parameter passed to the method).
When the procedure or function exits, it clears the stack.
Other calling methods are available for linking with external object les and libraries, these are summarized in table (6.3). The rst column lists the modi er you specify for a procedure declaration. The second one lists the order the paramaters are pushed on the stack. The third column speci es who is responsible for cleaning the stack: the caller or the called function. The alignment column indicates the alignment of the parameters sent to the stack area. Finally, the fth column indicates if any registers are saved in the entry code of the subroutine.
|
More about this can be found in chapter 7, page 384 on linking. Information on GCC registers saved, GCC stack alignment and general stack alignment on an operating system basis can be found in Appendix H. As of version 2.0 (actually, in 1.9.x somewhere) , the register modi er is the default calling convention, prior to that, it was the oldfpccall convention.
The default calling convention, i.e., the calling convention used when none is speci ed explicitly, can be set using the f$calling g directive, section 1.1.7, page 44. The default calling convention for the current platform can be speci ed with
{$CALLING DEFAULT}
|
Remark: The popstack modi er is no longer supported as of version 2.0, but has been renamed to oldfpccall. The saveregisters modi er can no longer be used.