0

I think these two code snippets should have the same effect. The current code is

add esp, 36
pop esi
sub esp, 40

which works. I want to replace it with

mov esi, [esp + 36]

but replacing my current code with this code has a different effect. Are these two snippets equivalent?

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by wildgoose
0

No the first one is popping whatever is on the stack at that location, the second one is considering whatever is at that position in the stack to be a memory address and you're saying whatever is at that address copy it into esi.
Consider stepping through the code through a debugger.

0

They look as though they should do the same thing. The only thing I can think of is if you have got an "assume ss" somewhere. Other than that, you could try posting a larger code fragment so that we can see it in context.

0

Are you preserving ebx, esi, edi ? These three registers are to be protected in function calls.

Your two code snippets do load the same value from memory though!

In Win32 The Stack Selector SS:, Data Selector DS: and Extra Selector ES: are typically set the same from the application point of view. In the older 16-bit Operating systems, the 'Segment Registers' as they were called then were almost always different !

This topic has been dead for over six months. 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.