Tuukka Toivonen wrote:

> > > What registers I should save and what registers are not needed
> > > to save? I have saved everything with 'pushad' but that's
> > > inefficient.
> > 
> > On x86, you don't need to save any registers; a function call is
> > assumed to corrupt all registers.
> 
> I definitely think that is not correct; if I ignore the fact that
> special registers like ESP have to be saved that leaves me EBP;
> I didn't save EBP and the program crashed; I saved EBP and it worked.
> 
> Maybe you consider EBP special (frame pointer)?

Yep. ebp has to be saved.

> -fomit-frame-pointer doesn't change the set of registers which have
> to be saved, does it?

I think that EBP has to be saved even with -fomit-frame-pointer, at
least for functions with external linkage. Otherwise you wouldn't be
able to call functions which were compiled with -fomit-frame-pointer
from functions which were compiled without it.

> What about FPU registers? Can I assume they're empty when entering
> function?

I don't know. Try compiling some code which uses the FPU with `gcc -S', 
and see if gcc saves the FPU state.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to