Richard Tobin wrote:
> In article <fqgubh$d4q$>, jacob navia <> wrote:
>
>>> Do any OS ABIs require the caller to take any care of the frame
>>> pointer?
>
>> Yes, the frame pointer should be preserved at all times.
>
> But why?
>
>>> I just looked up the x86 call conventions. As far as I can see, the
>>> calle saves and restores the frame pointer and does not use its old
>>> value. So on these systems you do can use it for anyh purpose you
>>> like.
>
>> Yes, as I said in my message. Please read it again.
>
> You seem to be contradicting yourself. You say it must be preserved
> at all times, and then you agree you can use it for any purpose.
> Please explain.
>
A procedure can use any reserved register but the stack pointer
to any purpose anywhere, it needs only to save its value in
the stack, then restore it later. The value is preserved.
Obviously, if you do not preserve the stack pointer, many programs like
the debugger and others will no longer work, but in principle
your program will run without any problem.
>>> No, this is certainly not true. I have used several languages that
>>> just did system call instructions directly. The normal procedure
>>> calling convention was irrelevant.
>
>> Sure, but even using those "direct" calls, the frame
>> pointer must be preserved.
>
> Why? What happens if you don't?
If you do not preserve the stack pointer, you BREAK the
frame pointer chain, what means that you will destroy the possibility of
returning to the calling functions.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32