Jump to content
  • Advertisement
Sign in to follow this  
roby65

[ASM] Lea

This topic is 3711 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

Hi guys, i'm learning a little of reverse engineering these days, but i can't understand a thing.....what's "lea"? it's like a mov but i can't understand the difference....

Share this post


Link to post
Share on other sites
Advertisement
LEA, unlike MOV, doesn't actually access memory. Instead, it allows you to use any of the normal addressing modes, and store the result of the addressing itself (the calculated Effective Address) into a register for direct use.

Share this post


Link to post
Share on other sites
You'll probably have better results if you try to learn to program in assembler, rather than reverse engineering.

Share this post


Link to post
Share on other sites
If you want to load the value at the address [ebx + 8*edx], you write:
mov eax, [ebx + 8*edx]

What this instruction does is it calculates the address by multiplying edx by eight and then add that to ebx, and then look at that address and receives the value and stores it into eax. If you just want to calculate the address and store the address, you write:
lea eax, [ebx + 8*edx]

If you will, this is just a common shortcut for writing:
mov eax, edx
shl eax, 3
add eax, ebx
mov eax, [eax]

Share this post


Link to post
Share on other sites
It's like & in C/C++ when you use it in certain MSVC inline assembly statements that reference C/C++ variables.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
You'll probably have better results if you try to learn to program in assembler, rather than reverse engineering.

Yeah it's like trying to read a Spanish book if you don't know the language by looking up each work in a dictionary first. Theoretically it might work but just image how much faster you can read the book and understand it if you actually learned Spanish first!
I wouldn't waste any more time before learning Assembly first like Sneftel said.

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!