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

Re: [MiNT] Stack restore done by OS



Am 10.10.2010, 17:14 Uhr, schrieb Vincent Rivière <vincent.riviere@freesbee.fr>:

I guess it would have a wrong stackpointer afterwards.

Yes.
Just as when you manually fix the stack.

It would even be a bit better with stdcall.
If you assume you are calling a function which is not buggy:
- with stdcall, you may make a mistake when pushing the arguments
- with cdecl, you may make another mistake when cleaning the stack !

True, but it is more unlikely to make the same mistake twice (e.g. push 3, pop 4, should be 2 or so), than just not knowing about what the function pops.

In cdecl you may have wrong arguments in the called function, but afterwards it's all correct again.

Actually, the real rule is: the stack must be adjusted before any rts. So the stack must be adjusted either after each jsr/trap, or just once before rts (or a mix of both). GCC sometimes do that to minimize stack adjustments.

Yes, I came to that idea later - the compiler (or assembler-writer) should know where the locals are.

--
Helmut Karlowski