I have been a C/C++ programmer for 4 years now, and now that I'm actually reading a tut on it, I have to say, I am impressed! The whole concept of the DS really is cool; and it's flexability is the best I have seen.

While I was reading one of the lessons I noticed how they mentioned that the ESP changed according the data pushed.
So, would the following code be considered valid?

mov ebx, esp
push dword [first_var]
push dword [middle_var]
push dword [last_var]
call [my_function]
mov esp, ebx
10 Years
Discussion Span
Last Post by Duoas

In my opinion its bad practice to do that. Though as already said its valid if EBX remains unchanged after the function returns.


Yes, it is bad practice. But the caller's question was, as I understood it, more to the way the stack actually works than to the propriety of doing it.

I could be wrong.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.