| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Feb 20, 2016 8:13 pm Post subject: "cmp" command. Need help, thanks. |
|
|
I have a question about the "cmp" command.
From my understanding, "cmp" compares two registers or numbers and return "false" or "true", but it does not give a value to such registers. If so, what does the following code mean?
| Code: |
cmp ecx,01
mov eax,ecx
|
I understand that if "cmp ecx,01" is followed by "je XXXX", because it means if exc is equal to 01, then jump to somewhere. But from my understanding, the code above(in green color) basically means comparing ecx to 01, and moving ecx to eax regardless of the comparison between ecx and 01. So my question is: why bother comparing ecx and 01? Isn't redundant? BTW, the code is correct because I copied it from a game.
Thanks in advance.
Updated because of typo.
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Feb 20, 2016 8:36 pm Post subject: |
|
|
The CMP sets various EFLAGS.
The jump does not need to immediately follow.
Flags will remain set until overridden.
There are other instructions which set those flags too though.
So care must always be taken.
|
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Feb 20, 2016 8:37 pm Post subject: |
|
|
| Zanzer wrote: | The CMP sets various EFLAGS.
The jump does not need to immediately follow.
Flags will remain set until overridden.
There are other instructions which set those flags too though.
So care must always be taken. |
Oh, thanks a lot. Is there any tutorial about assembly commands? They are so confusing to me.
|
|
| Back to top |
|
 |
|