public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [OT] caller-save/callee-save register styles
@ 2003-09-07 18:24 Nagendra Singh Tomar
  2003-09-08 14:21 ` Jeff Garzik
  0 siblings, 1 reply; 3+ messages in thread
From: Nagendra Singh Tomar @ 2003-09-07 18:24 UTC (permalink / raw)
  To: linux-kernel

I would like to know various people's experiences about the caller-save 
and callee-save style of preserving register values across procedure 
calls. I feel that the ABI specification should specify that but I was 
unable to figure that out in the ELF-ABI specification.
What I have personally seen is only callee-save style in which the 
modified registers are PUSHed on the stack on entering the function and 
POPed on leaving the function. That means the caller can assume that all 
the regsiter values will be same just before and after the 'call' 
instruction.
Can we assume one of these styles when writing assembly code that has to 
be linked with C code generated by the compiler or do we have to first 
ensure the style that the compiler follows and then use that.
Comments on how other ABIs do it are highly welcome, though I am 
particularly interested about the ELF-ABI and  x86 arch.

Thanx,
tomar


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [OT] caller-save/callee-save register styles
@ 2003-09-08  9:33 Mikael Pettersson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Pettersson @ 2003-09-08  9:33 UTC (permalink / raw)
  To: linux-kernel, nagendra_tomar

On Sun, 7 Sep 2003 23:54:59 +0530 (IST), Nagendra Singh Tomar wrote:
>I would like to know various people's experiences about the caller-save 
>and callee-save style of preserving register values across procedure 
>calls. I feel that the ABI specification should specify that but I was 
>unable to figure that out in the ELF-ABI specification.
>What I have personally seen is only callee-save style in which the 
>modified registers are PUSHed on the stack on entering the function and 
>POPed on leaving the function. That means the caller can assume that all 
>the regsiter values will be same just before and after the 'call' 
>instruction.

"All" is a bad assumption. Most ABIs have both caller-save and
callee-save registers, so you need to save those caller-save
registers that are to be live over the call.

>Can we assume one of these styles when writing assembly code that has to 
>be linked with C code generated by the compiler or do we have to first 
>ensure the style that the compiler follows and then use that.
>Comments on how other ABIs do it are highly welcome, though I am 
>particularly interested about the ELF-ABI and  x86 arch.

Neither the ELF spec nor the generic SVR4 ABI documents these things.
You need the Processor-Specific Supplement, a.k.a. psABI.

There is no central repository for these, but last time I checked,
the ia32 psABI was downloadable from SCO or Caldera.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-08 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-07 18:24 [OT] caller-save/callee-save register styles Nagendra Singh Tomar
2003-09-08 14:21 ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2003-09-08  9:33 Mikael Pettersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox