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 


What is the difference between "Mov" and "Lea

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Fri Jan 29, 2016 5:53 am    Post subject: What is the difference between "Mov" and "Lea Reply with quote

Hi.
This is my big question :
What is the difference between "Mov" and "Lea"?
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Fri Jan 29, 2016 6:33 am    Post subject: Reply with quote

A small example:

ebx = 0x12345678
value at that address = 0x500

Code:
mov eax,ebx

Now eax = 0x12345678

Code:
mov eax,[ebx]

Now eax = 0x500

Code:
lea eax,ebx

Invalid instruction!

Code:
lea eax,[ebx]

Now eax = 0x12345678

So basically, as the names already suggest, "mov" copies the value of the source operand (right operand) to the target operand (left operand). If the source is a register (like the first code snippet) then the target operand equals the source operand.
If the source operand is a memory location (either static or referenced via registers) then "mov" will copy the memory value stored at that specific location (like code snippet 2).

"lea" stands for "load effective address" and only loads the address of a memory location into the target operand (which I think is mandatory to be a register).

So as you see, code snippet 1 and code snippet 4 have the exact same effect, but it is not possible to get the value "0x500" stored at [ebx] into eax when using "lea" ...

Hope that cleared things up.
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Fri Jan 29, 2016 6:41 am    Post subject: Reply with quote

Mov eax, [edx+1234] means "read what is at address edx+1234 and put it in eax".
lea eax, [edx+1234], means "eax=edx+1234", it would be the equivalent of "mov eax, edx+1234" if were a valid asm instruction.

Lea is often used to perform multiple basic math operations in one instruction (like lea eax,[ebx+edx*4+123] instead of one mov, one imul and two add)

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
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 Gamehacking 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