develooper Front page | perl.perl6.internals | Postings from October 2001

Parameter passing conventions

Thread Next
From:
Dan Sugalski
Date:
October 26, 2001 13:38
Subject:
Parameter passing conventions
Message ID:
5.1.0.14.2.20011026150053.020e12d0@pop.sidhe.org
Okay, here are the conventions.

*) The callee is responsible for saving and restoring non-scratch registers
*) The first five registers (I0-I4, S0-S4, P0-P4, N0-N4) are scratch and do 
not have to be preserved by the callee
*) In *ALL* cases where the stack is used, things are put on the stack in 
*reverse* order. The topmost stack element *must* be the integer count of 
the number of elements on the stack
*) The callee is responsible for making sure the stack is cleaned off.

Inbound args
============
If the called subroutine has a fixed number of arguments, they will be 
placed in the first five registers of the appropriate register types. First 
integer goes in I0, second in I1, and so on.

If there are too many arguments of a particular type the overflow go on the 
stack. If there are a variable number of arguments, all the *non* fixed 
args go on the stack.

Argument ordering is irrelevant for args in registers. Args on the stack 
must be put there in the reverse order they appear.

Outbound args
=============
If the called subroutine returns a fixed number of things, they're returned 
in the first five registers of each type. Overflow goes on the stack in 
reverse order, with a count on top.

If the called subroutine returns a variable number of things, the fixed 
things (if any) go in registers. The rest go on the stack.

*PLEASE NOTE*

Most HLL subs (i.e. generic perl/python/ruby subs) take a single parameter, 
a list PMC, and return a single element usually a list PMC.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About