Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] LEA

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Jun 07, 2007 1:53 pm    Post subject: [Help] LEA Reply with quote

What is the LEA function used for? I understand that it puts the offset of one thing into an address, like below.

Code:

lea esi,[eax+a]



Now the value of esi is a. But couldn't you just use the mov function to do it? Or does the lea function do something else?
Back to top
View user's profile Send private message
Labyrnth
Moderator
Reputation: 9

Joined: 28 Nov 2006
Posts: 6285

PostPosted: Thu Jun 07, 2007 5:06 pm    Post subject: Re: [Help] LEA Reply with quote

samuri25404 wrote:
What is the LEA function used for? I understand that it puts the offset of one thing into an address, like below.

Code:

lea esi,[eax+a]



Now the value of esi is a. But couldn't you just use the mov function to do it? Or does the lea function do something else?


This loads esi with the address from [eax+a]

_________________

Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Thu Jun 07, 2007 5:23 pm    Post subject: Reply with quote

lea = load effective address

the address at the defined source is stored in your destination.

_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Jun 07, 2007 6:01 pm    Post subject: Reply with quote

sponge wrote:
lea = load effective address

the address at the defined source is stored in your destination.


(I knew it meant load effective address)

So basically the address pointed at by the pointer is stored in esi? How would the mov function handle the same thing, or would that be incorrect syntax? Mov would just add the "eax+a" and store that in esi, wouldn't it?
Back to top
View user's profile Send private message
Labyrnth
Moderator
Reputation: 9

Joined: 28 Nov 2006
Posts: 6285

PostPosted: Thu Jun 07, 2007 6:11 pm    Post subject: Reply with quote

The address calculated from [eax+a] is stored in esi
_________________

Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Jun 07, 2007 6:12 pm    Post subject: Reply with quote

Labyrnth wrote:
The address calculated from [eax+a] is stored in esi


Alright, thanks! =)
Back to top
View user's profile Send private message
Chi-Tur
How do I cheat?
Reputation: 0

Joined: 13 Jun 2007
Posts: 1

PostPosted: Wed Jun 13, 2007 5:13 pm    Post subject: ... Reply with quote

i guess that helped... ty
Shocked Shocked
Laughing Laughing
Arrow Arrow
Back to top
View user's profile Send private message
Programmer
Cheater
Reputation: 0

Joined: 02 Sep 2007
Posts: 48

PostPosted: Mon Sep 10, 2007 7:15 pm    Post subject: Reply with quote

This is a late post, but might help someone?

You can use it to get the address of a variable etc. e.g

Code:

Variable: db 00

lea edi, Variable


The EDI register now contains the memory address of your variable.

_________________
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Tue Sep 11, 2007 4:18 pm    Post subject: Reply with quote

Programmer wrote:
This is a late post, but might help someone?

You can use it to get the address of a variable etc. e.g

Code:

Variable: db 00

lea edi, Variable


The EDI register now contains the memory address of your variable.


Since the default is the lvalue anyway, wouldn't

mov edi, Variable

do the same thing (assuming you're not using masm which makes the default the rvalue).

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
Ksbunker
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2006
Posts: 88

PostPosted: Tue Sep 11, 2007 8:16 pm    Post subject: re: Reply with quote

Take from Art of Assembly (http://webster.cs.ucr.edu/AoA/DOS/ch06/CH06-1.html#HEADING1-136)

Code:
LEA destination, source


specifically

Code:
lea register, memory


Of Particular significance;

Quote:
1. lea ax, [bx]
2. lea bx, 3[bx]
3. lea ax, 3[bx]
4. lea bx, 4[bp+si]
5. lea ax, -123[di]


The lea ax, [bx] instruction copies the address of the expression [bx] into the ax register. Since the effective address is the value in the bx register, this instruction copies bx's value into the ax register. Again, this instruction isn't very interesting because mov can do the same thing, even faster.

The lea bx,3[bx] instruction copies the effective address of 3[bx] into the bx register. Since this effective address is equal to the current value of bx plus three, this lea instruction effectively adds three to the bx register. There is an add instruction that will let you add three to the bx register, so again, the lea instruction is superfluous for this purpose.

The third lea instruction above shows where lea really begins to shine. lea ax, 3[bx] copies the address of the memory location 3[bx] into the ax register; i.e., it adds three with the value in the bx register and moves the sum into ax. This is an excellent example of how you can use the lea instruction to do a mov operation and an addition with a single instruction.

The final two instructions above, lea bx,4[bp+si] and lea ax,-123[di] provide additional examples of lea instructions that are more efficient than their mov/add counterparts.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites