[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] Call convention resume



On Mon, Jun 24, 2002 at 02:21:30AM +0200, Christophe wrote:
[...]
> > > R1 : number of parameter (for debug and security) and return value
> >
> > I still do not agree with that point. It's a waste.
> 
> Not only it is a waste but it is unefficient. Why ? how many arguments for such
> function : int f (struct a _a) ? 1 or the number of words necessary for struct
> a ? it doesn't make a sense to have one. If you really want a debug info, pass
> a parameter signature instead, something like C++ functions signature but just
> for parameters. So if you call a function with three integer arguments then
> passing the string "iii" (for example) would be more precise and usable for
> debug than just passing number of arguments. Personnally i would drop it.

If you want an argument check, do what C++ does: add the signature to the
function's name, and check the arguments at compile/link time.  The only
place where a run-time check may be reasonable is in a varargs function.

[...global registers...]
> > Better make r61 (or r63) the return address. Statically linked programs
> > don't use the PLT and GOT pointers, and we don't want to have a hole in
> > the middle.
> >
> > The stack pointer is always the end of the allocated area on the stack.
> > If a program uses memory from the stack, it MUST move the stack pointer.
> > That way, the operating system can tell how big the user mode stack is.
> >
> 
> I totally aggree with Michael; something like :
> 
> R63/62 : return pointer (RP) , mandatory
> R62/63 : stack pointer (SP) , mandatory
> R61       : frame pointer (FP) , optional
> R60       : GOT                        , optional
> R59       : PLT                         , optional
> 
> R14 should point on the first argument pushed in stack, so we can access it as
> an argument pointer (AP)
> 
> R14,R61 and R62 all point on the same stack indeed.
> 
> Personnally I would have used R60 for AP instead of R14, unless there is a real
> reason to choose r14.

In principle, we don't need any pointer for it if we specify that
additional arguments (beyond R1...R15) are found at the top of the stack -
that is, in the place where the stack pointer points to.  R62 also becomes
the argument pointer in that case. This also makes things more clean for
varargs functions: just push R15...R1, and you get a contiguous array
of arguments on the stack, with R62 pointing to it.

-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/