 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Stacktrace Expert Cheater
Reputation: 1
Joined: 04 Jul 2015 Posts: 105
|
Posted: Tue May 10, 2016 10:31 pm Post subject: Question about CMP/Compare |
|
|
Hi, I'm pretty new to Assembly and I understand some of it. (Enough to make cheats.) But, for quite a while I've been pretty confused at how the compare works. I have an example of a code I'd like you to explain in a understandable way.
"cmp dword ptr [esi+3C],00
je GameProcess+AC25B4""
So my theory is, it's like English right? But from what I know in English w/e, I'd assume that code does
it compares if the value of ESI+3C is 0, and if it's '0' it will jump to "GameProcess+AC25B4" if it's for example '1' it will ignore the jump. Now, is that right? Haha, sorry if I'm stupid but I'm trying my best. I do have a learning disability so it's quite the challenge to figure it out.
If you're gonna help I'll appreciate it a lot But please explain how I'm wrong (if i'm wrong) in a way even that those with learning disabilities will understand. So a short, easy way. Thanks!
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue May 10, 2016 11:02 pm Post subject: |
|
|
You are correct.
|
|
Back to top |
|
 |
Stacktrace Expert Cheater
Reputation: 1
Joined: 04 Jul 2015 Posts: 105
|
Posted: Wed May 11, 2016 3:43 am Post subject: |
|
|
++METHOS wrote: | You are correct. |
Ah, that's awesome! Thanks man
Edit: Hmm, I forgot about one.
"cmp eax,edi"
it doesn't get anything to compare from that one instruction, so how does that one work? I'm sure it's extremely obvious and I'm just being silly, but rather than believing my own conclusions, I'd rather know the answer. Thanks again
|
|
Back to top |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Wed May 11, 2016 3:49 am Post subject: |
|
|
Could you post a bit more code (or a screenshot maybe)?
Because
simply compares eax with edi (as you may have guessed ).
|
|
Back to top |
|
 |
Stacktrace Expert Cheater
Reputation: 1
Joined: 04 Jul 2015 Posts: 105
|
|
Back to top |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Wed May 11, 2016 3:57 am Post subject: |
|
|
It's pretty much the same as in your first post.
The program compares both the registers (resp. their values) eax and edx and jumps to the function's end, if they have the same value.
If not, it executes all the code in between.
|
|
Back to top |
|
 |
STN I post too much
Reputation: 43
Joined: 09 Nov 2005 Posts: 2676
|
Posted: Wed May 11, 2016 4:02 am Post subject: |
|
|
Yep.
If you want to learn conditional jumps properly, learn about flags. They govern which direction the jump will be taken. E.g je GameProcess+AC25B4"" is actually jz - jump if zero(flag) set.
CMP can also work like this
sub ecx, 0
jz 92ace
^That is perfectly fine instruction as and does the same thing
cmp ecx, 0
jz 92ace
The magic is FLAGS. They get set as different instructions are executed. Open Ollydbg and notice them, that is an awesome way to learn to see it in action and how i learned myself
These two resources look good to learn from
https://en.wikipedia.org/wiki/FLAGS_register
http://www.cavestory.org/guides/csasm/guide/asm_flags.html
_________________
|
|
Back to top |
|
 |
Stacktrace Expert Cheater
Reputation: 1
Joined: 04 Jul 2015 Posts: 105
|
Posted: Wed May 11, 2016 4:02 am Post subject: |
|
|
hhhuut wrote: | It's pretty much the same as in your first post.
The program compares both the registers (resp. their values) eax and edx and jumps to the function's end, if they have the same value.
If not, it executes all the code in between. |
Ah, thanks for your help! If I understood you correctly, that makes a lot of sense now.
So basically, if the compare doesn't have a ",00" at the end, but rather two registers without any value checking listed, it will compare if the value/addr for the two registers are the same? So,
cmp ecx,esi
je GameProcess+1
it checks if the value for ecx,esi is the same, and if it is the same, it'll jump to GameProcess+1 and if forexample ecx is 3, esi is 9 it'll ignore the jump and continue on within the function? Hopefully I'm not asking too many questions here, just want to make extra-sure I know what I'm doing Greatly appreciate it!
(Ah, I did some reverse engineering to see if I understood you. I indeed did! This all makes a lot more sense now, and thanks to STN I also now have more understanding within jumps, awesome!)
-------------------------------------------------------------
I can't double post, so here's my reply to STN
Thanks for the help! I'm glad I stumbled upon this forum, such a helpful community I'll take a look at the sources you shared!
|
|
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
|
|