943,715 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 658
  • Assembly RSS
Jun 9th, 2009
0

Two code snippets that should have the same effect but don't

Expand Post »
I think these two code snippets should have the same effect. The current code is
Assembly Syntax (Toggle Plain Text)
  1. add esp, 36
  2. pop esi
  3. sub esp, 40
which works. I want to replace it with
Assembly Syntax (Toggle Plain Text)
  1. mov esi, [esp + 36]
but replacing my current code with this code has a different effect. Are these two snippets equivalent?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Recursive is offline Offline
1 posts
since Jun 2009
Jun 10th, 2009
0

Re: Two code snippets that should have the same effect but don't

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.
Last edited by sysop_fb; Jun 10th, 2009 at 9:06 am.
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
Jun 25th, 2009
0

Re: Two code snippets that should have the same effect but don't

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.
Reputation Points: 14
Solved Threads: 4
Junior Poster
mathematician is offline Offline
149 posts
since Nov 2006
Jun 26th, 2009
0

Re: Two code snippets that should have the same effect but don't

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 !
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: new to assembly
Next Thread in Assembly Forum Timeline: MIPS: Print array in columns (SPIM)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC