Aldo Calpini writes:
>
>hi there,
>the Examples page on www.parrotcode.org states this about subroutines:
>
>    The first five registers (I0-I4, S0-S4, P0-P4, N0-N4) are scratch
>    and do not have to be preserved by the callee.
>
>this seems to be false for *recursive* subroutines. this is my PASM
>code fibo.pasm (it calculates the fibonacci number of 32):

I think you may be misinterpreting the calling convention, although
sometimes I miss discussion myself, but...

The convention says they are not required to be saved, which means,
a caller better not put anything in there and expect them to be
saved.

Currently, parrotcode.org is very out of date in many areas, including
even the version of the release.

The current Parrot calling convention (a topic of some debate) is
caller save, so the above statement is moot as it was for the old
convention. However if the convention were still callee save, the
scratch regs are just part of the "protocol", they aren't magically
saved and restored for the caller if the callee scribbles on them.

For optimization, you may use r0-r4 regs to specify how many return
values, and then place those return values in r5-r31, instead of
pushing and popping them, which is what I expect languages supporting
a single return value will prefer; its definitely what my compiler
will do.

<opinion>
How a prototype specifies its calling convention is still
undocumented, I expect we may have something along the lines of
a PERLCALL and a FASTCALL, where the FASTCALL uses the regs
and the PERLCALL uses a combination as per the convention.
</opinion>

Hope this helps,

-Melvin Smith

IBM :: Atlanta Innovation Center
[EMAIL PROTECTED] :: 770-835-6984


Reply via email to