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

Re: [f-cpu] Another proposition for a call convention

On Fri, Jun 07, 2002 at 11:42:11AM +0200, Cedric BAIL wrote:
> An other call convention for call convention :
> R0 : zero
> R1 : number of parameter and return value

The number of parameters is not needed in most languages.

> R2-R13 : functions arguments (call-clobbered)
> R14 : pointer to pre allocated stack for all arguments and arguments
> after the 12th registers.

Pre-allocating is a nice idea, but unfortunately it leads to trouble
if the caller hasn't allocated enough memory.

BTW: we can refine both my and your version by defining that r14 and
r15 are also used for arguments, and that r63 (that is, top of stack)
points to the allocated memory. Since a call doesn't mess with the
stack (like Intel's calls do), this should be safe.

> R15-R31 : temporary registers (call-clobbered)
> R32-R59 : local registers (callee-saver)
> R60 : return adress
> R61 : global pointer
> R62 : Frame pointer
> R63 : stack pointer
> (We can add a R59 = static link, for language like caml, but I think that
> specifing that their are callee-saved, will be good enough for a call
> convention between every language and the system)
> For va_start we only do this :
> 	storem R2, [R14], R13 // only store the register from R2 to R13

You need to evaluate r1 and store only those registers that are actually
used (unless the caller *always* allocates 12 empty slots, no matter
how many arguments there are).

> and it's all. For normal function we have nothing to do !

In the original version, we need not store anything either for
`normal' functions.

> I know we first need to store the address label in a register and then use it,
> but that more easy to understand in that way (and in general, we can write
> the same code without the need of temporary registers).
> I think that we have an error in the manual, the second register in a jump
> give normally PC and not PC+4, I don't see the usage of this feature (but
> for a call PC+4 is really a good idea).


	jmp r2 [, r1] =>

		r1 := PC + 4;	-- optional
		PC := r2;

	jmp<cc> r3, r2 [, r1] =>

		if condition_true(<cc>, r3) then
			r1 := PC + 4;	-- optional
			PC := r2;
		end if;

`PC + 4' is supposed to point to the instruction right after the jmp.

 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/