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

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



R1          : IN => # of parm, OUT : return value
R2-R13 : IN => function args [, OUT : extra return values]

As suggested by Michael, global registers can let kernel to pass some
information to applications so they can read. It is why he chose a fix range.
So I think we could keep them until there is reason not to do so. Just say
there are "for specific purposes not described here" .

----- Original Message -----
From: Cedric BAIL <cedric.bail@free.fr>
To: <f-cpu@seul.org>
Sent: Friday, June 07, 2002 11:42 AM
Subject: [f-cpu] Another proposition for a call convention


> An other call convention for call convention :
>
> R0 : zero
> R1 : number of parameter and return value
> R2-R13 : functions arguments (call-clobbered)
> R14 : pointer to pre allocated stack for all arguments and arguments
> after the 12th registers.
>
> 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
>
> and it's all. For normal function we have nothing to do !
> If we have more parameters than 12, we only need to do something like this :
>
> ex: printf("a %i %i %i ... %i %i %i", 1, 2, 3, ..., 12, 13, 14)
>
> we will do something like :
> loadconsx 14, R1
> loadcons STRINGADDR, R2
> loadconsx 1, R3
> loadconsx 2, R4
> loadconsx 3, R5
> ...
> loadconsx 12, R13
> move R63, R14
> subi 14 * 8, R63, R63 // allocated the needed space in stack
> subi 12 * 8, R14, R31 // use a temporary register to start transfering
>       // other parameters
> loadconsx 13, R30
> store -8, [R31], R30
> loadconsx 14, R30
> store -8, [R31], R30
> jump "printf", R60    // do the call and save return address.
>
> if you need less that 12 registers, like a printf("a") you only have to
> do :
> loadconsx 1, R1
> loadcons STRINGADDR, R2
>
> move R63, R14
> subi 8, R63, R63 // allocated the needed space in stack
>
> jump "printf", R60    // do the call and save return address.
>
> 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).
>
> So what is the problem of this solution ?
>
> A+
>   Cedric
> *************************************************************
> To unsubscribe, send an e-mail to majordomo@seul.org with
> unsubscribe f-cpu       in the body. http://f-cpu.seul.org/

*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/