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 with mov command?

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

Joined: 05 Apr 2013
Posts: 644

PostPosted: Fri Feb 14, 2014 8:57 am    Post subject: help with mov command? Reply with quote

How do you move the value of one register to another? Say in a game the current ammo of a gun was located in edi+00000004 and the max value of ammo for that gun (value it reloads to) was located in edi+00000008, I tried using mov [edi+04],[edi+08] but that doesn't work... also, is there a difference between mov [a],b and mov a,[b]? i also tried using a registersmbol and mov [registername]edi+08 nd then mov [edi+04],registername and instead got some wierd value for the ammo.
Back to top
View user's profile Send private message
DDS
Expert Cheater
Reputation: 3

Joined: 10 Feb 2011
Posts: 112
Location: Bill's Planet

PostPosted: Fri Feb 14, 2014 11:25 am    Post subject: Reply with quote

You can use another register for that.
Code:


push eax //Save the value of register eax

mov eax,[edi+00000008] // Move the value of max ammo into the reg eax

mov [edi+00000004],eax // now eax has the max ammo value, move it to the current ammo address

pop eax // Restore the Original eax value



And the difference between mov [a],b and mov a,[b] is.
Code:


mov [a],b // Moves the value of the variable b into the address of variable a

mov a,[b] // Moves the value from the address of variable b into the variable a



And finally, You got a weird value when you did this.

Code:


mov [edi+04],registername



Because you were moving the address of [registername] into the address of [edi+04] instead of moving the value of the [registername] Address into the address of [edi+04].

I know that this is a little confusing for you right now if you are a newbie
but dont worry everything will make sense if you keep triying. Wink

_________________
elDarkDragonSlayer
Back to top
View user's profile Send private message Visit poster's website
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Fri Feb 14, 2014 12:23 pm    Post subject: Reply with quote

ahhh ok got it, thanks a lot
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Fri Feb 14, 2014 5:34 pm    Post subject: Re: help with mov command? Reply with quote

vng21092 wrote:
How do you move the value of one register to another? Say in a game the current ammo of a gun was located in edi+00000004 and the max value of ammo for that gun (value it reloads to) was located in edi+00000008, I tried using mov [edi+04],[edi+08] but that doesn't work... also, is there a difference between mov [a],b and mov a,[b]? i also tried using a registersmbol and mov [registername]edi+08 nd then mov [edi+04],registername and instead got some wierd value for the ammo.


You can't mov(copy) values between two memory addresses in a single instruction. I have seen people get confused with this and its probably because CE automatically takes care of data type calculation for you based on register. e.g mov [address], 4 is actually mov dword ptr [address], 4...you don't see the dword ptr because CE takes care of that.

So the easiest way to understand and remember this is whenever you see [] there should be a dword(datatype) ptr [address] and there can NEVER be TWO dword ptr in a single instruction. So when you tried to mov [edi+04],[edi+08]...what you are actually writing is mov dword ptr [edi+04], dword ptr [edi+08] which is not correct. Got it ?

The solution is moving the value of max ammo in a register and then saving it in the current ammo address like this

push eax
mov eax, dword ptr [edi+08]
mov dword ptr [edi+04], eax
pop eax

or if you are feeling lazy like i always do, this is another solution
push [edi+08]
pop [edi+04]

"also, is there a difference between mov [a],b and mov a,[b]?"

yes like i said above CE handles the datatype which is pretty confusing for newbies to asm. mov [a], b is mov datasize ptr [a], b. Whenever you see [] that means the value inside [] is being accessed and not the register or address (the only exception is with lea instruction but nvm that for now) so
mov [a],b = mov whats at b into what a points at.
mov a, [b] = vice versa

Read this tutorial by Dabhand on basic assembly especially the part about MOV instruction and you will never get confused again.
http://deviatedhacking.com/index.php/topic/1974-basic-assembly-tutorial-opcodes-and-instructions-explanations/

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
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