[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Stack restore done by OS
On 10/10/2010 16:51, Helmut Karlowski wrote:
What would happen if the caller pushed the wrong amount onto the stack?
I guess it would have a wrong stackpointer afterwards.
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 !
NB: On Atari, if your stack is big enough, you don't have to clean it
up after each system call. You can make a big cleanup at the end... or
But the stack is used for local variables, or am I getting something wrong?
My silly remark was about a small, classic assembler program with only
some OS calls, no subroutines and no local variables.
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