 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Feb 14, 2014 8:57 am Post subject: help with mov command? |
|
|
| 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 |
|
 |
DDS Expert Cheater
Reputation: 3
Joined: 10 Feb 2011 Posts: 112 Location: Bill's Planet
|
Posted: Fri Feb 14, 2014 11:25 am Post subject: |
|
|
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.  _________________
elDarkDragonSlayer |
|
| Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Feb 14, 2014 12:23 pm Post subject: |
|
|
| ahhh ok got it, thanks a lot |
|
| Back to top |
|
 |
STN I post too much
Reputation: 43
Joined: 09 Nov 2005 Posts: 2676
|
Posted: Fri Feb 14, 2014 5:34 pm Post subject: Re: help with mov command? |
|
|
| 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/ _________________
|
|
| Back to top |
|
 |
|
|
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
|
|