> In practice, though, you'll find it is right to left on x86 using the
> normal calling conventions. Since all parameters are passed on the
> stack and the stack pointer decreases, they have to be placed on the
> stack right to left so they end up the right-way round relative to the
> new function's stack frame, i.e.
>
>     more stack> <local vars> <frame ptr> <return addr> <arg1> <arg2>
> ...
>               esp          ebp
>
> Presumably this is so that the function can always access the first
> argument from the frame pointer without knowing how large the argument
> list really is, and the list can carry on indefinitely up the stack
> for varargs functions.

Well, like you mention, it's dependent on the calling convention, and since
calling convention does not show up at the caller side, you can't tell for
sure whether your function call gets compiled the way you say or no.  And if
you think of cases where function parameters are not even passed on the
stack (and are passed in registers, e.g __fastcall) then you wouldn't want
to rely on anything like that, even if you're explicitly coding for x86.

-------------
Ehsan Akhgari

Farda Technology (http://www.farda-tech.com/)

List Owner: [EMAIL PROTECTED]

[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]

Somewhere in the hurricane, hope is waiting.





Reply via email to