Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

assembly lang question

This topic is 2615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i think i might be misunderstanding this code[font=arial, verdana, tahoma, sans-serif][size=2]

MOV EDI,EDI // ignore
push EBP // save callers stack frame base[/font]
mov ebp, esp // re-adjust base stack frame pointer for this function
mov eax, dword ptr ss:[ebp+8] // go to address ebp+8 on the stack, and get the DWORD value stored there and put it in eax
xor edx, edx // assign edx to 0
lea ecx, dword ptr ds:[eax+4] // add 4 to the address in eax and assign the sum to ECX
mov dword ptr ds:[eax], edx // treat the value moved into eax as a ptr that holds an address which points to a dword and mov 0 into the location it's pointing to


is it safe to say that
mov eax, dword ptr ss:[ebp+8] <---- at ebp+8 there is a 4 byte address which is being moved into eax
mov dword ptr ds:[eax], edx <---- travel to the address stored in eax and store a 4 byte value of 00000000 there

Share this post


Link to post
Share on other sites
Advertisement
Yes, I also think that's what the code is doing. In case this is not clear to you, ebp+8 points to an argument that the caller has pushed onto the stack before making the call.

Where did you get this code? There are a couple of odd things in there (using "ds:" in the lea instruction doesn't seem to do anything, and that MOV EDI,EDI is a no-op too).

Share this post


Link to post
Share on other sites

Where did you get this code? There are a couple of odd things in there (using "ds:" in the lea instruction doesn't seem to do anything, and that MOV EDI,EDI is a no-op too).


It's pretty clearly a disassembly of a compiled program.


The "move edi,edi" is there for hot-patching and is added to all functions. Visual Studio and other debuggers can use it to patch on the fly (such as Edit-And-Continue mode), and it can be used to patch an executable after ship.


The rest of the disassembly is dereferencing a pointer passed to the function in preparation for using the data.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!