| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Mar 01, 2016 8:31 pm Post subject: Two questions about this short piece of code. Thanks. |
|
|
| Code: |
cmp edi,01
cmovl edi,eax
mov eax,00000064
cmp edi,64
cmovg edi,eax
call .......
|
Here are my questions:
1. why compare "edi" to "01" and "64", it seems redundant to me....
2. if I change "mov eax, 00000064" to "mov eax,64", would the result be the same?
Thanks a lot.
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Tue Mar 01, 2016 9:47 pm Post subject: |
|
|
I am only assuming the instruction before all of this sets EAX to 1?
It first compares EDI to 1.
If EDI is less than 1, then it will move the value of EAX (possibly 1?) into EDI.
It then compares EDI against 100.
If EDI is greater than 100, it will move the value of EAX (100) into EDI.
This chunk of code appears to be verifying that the end result is EDI containing a number between 1 and 100.
Both of those move statements would be the same, yes.
|
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Mar 01, 2016 11:43 pm Post subject: |
|
|
| Zanzer wrote: | I am only assuming the instruction before all of this sets EAX to 1?
It first compares EDI to 1.
If EDI is less than 1, then it will move the value of EAX (possibly 1?) into EDI.
It then compares EDI against 100.
If EDI is greater than 100, it will move the value of EAX (100) into EDI.
This chunk of code appears to be verifying that the end result is EDI containing a number between 1 and 100.
Both of those move statements would be the same, yes. |
You are right! The two lines of code above are:
| Code: |
mov eax,00000001
movzx edi,byte ptr [ecx+1A]
|
Does
works with:
?
Or, can I just use ?
I mean do I need to use cmp with cmovl, or can I just use cmovl? Doesn't cmovl mean "compare and move if less"?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25830 Location: The netherlands
|
Posted: Wed Mar 02, 2016 2:44 am Post subject: |
|
|
cmovl is "conditional move if less"
the previous cmp does the compare, the cmov<> instruction will get executed if it's condition has been met.
(so yes, the cmp is needed)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Wed Mar 02, 2016 11:01 am Post subject: |
|
|
| Dark Byte wrote: | cmovl is "conditional move if less"
the previous cmp does the compare, the cmov<> instruction will get executed if it's condition has been met.
(so yes, the cmp is needed) |
Oh, got it. Thank you.
|
|
| Back to top |
|
 |
|