 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ciglipaf How do I cheat?
Reputation: 0
Joined: 26 Jul 2015 Posts: 6
|
Posted: Thu Aug 06, 2015 5:17 pm Post subject: how fcom works? why i fail? |
|
|
i compare two float numbers but fcom gives me wrong results.
Code: | fld1 //load 1.0
fldpi //load 3.14159...
fcom st(0),st(1) // compare 3.14 , 1.0
je yes_it_is_equal
mov [equal],0
jmp exit
yes_it_is_equal:
mov [equal],1 |
result is equal = 1
|
|
Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 891
|
Posted: Thu Aug 06, 2015 5:57 pm Post subject: |
|
|
You evidently have to move the fpu status word to mem, then check its flags. See http://stackoverflow.com/a/7195713.
_________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on... |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Aug 06, 2015 6:03 pm Post subject: |
|
|
Don't forget to pop the stack too...
Code: | fld1
fldpi
fcomip st(1)
fstp st(0)
je yes_it_is_equal
mov [equal],0
jmp exit
yes_it_is_equal:
mov [equal],1 |
|
|
Back to top |
|
 |
gameplayer Advanced Cheater
Reputation: 2
Joined: 26 Jun 2011 Posts: 97 Location: Vietnam
|
Posted: Thu Aug 06, 2015 7:20 pm Post subject: |
|
|
You must store float-point status word into ax register and use "test ah,..." instruction. I couldn't remember exactly how to use the constants that follow in the "test" instruction. The code should be similar to the following
fcom st(0),st(1)
fnstsw ax
test ah,40 //the constant may be 40, 41 or 01
jne yes_equal
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Aug 07, 2015 7:59 am Post subject: |
|
|
Better use fcomi or fcomip.
And then use those jumps:
- JA, JNBE
- JAE, JNB, JNC
- JB, JNAE, JC
- JBE, JNA
- JE, JZ,
- JNE, JNZ
fcomi(p) sets only ZF, PF and CF flags. Above conditional jumps check those flags.
Do not use JG, JL, etc... (those check SF flag and other flags)
If you are perfectly sure that values you want to compare are always: bigger than zero, and those values aren't very high, something less than 1E8, you can use simple CMP and JA, JB, like before.
Example1:
fld [value1] // this value1 can be anything
fld [value2] // this value2 can be anything
fcomip st(0),st(1) // compare
fstp st(0)
je, ja, jb, ....
Example2:
mov eax,[value1] // this value1 is between 0 and 1E8
cmp eax,[value2] // this value2 is between 0 and 1E8
je, ja, jb, ...
_________________
|
|
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
|
|