Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how fcom works? why i fail?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
ciglipaf
How do I cheat?
Reputation: 0

Joined: 26 Jul 2015
Posts: 6

PostPosted: Thu Aug 06, 2015 5:17 pm    Post subject: how fcom works? why i fail? Reply with quote

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 Confused
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Thu Aug 06, 2015 5:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Aug 06, 2015 6:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
gameplayer
Advanced Cheater
Reputation: 2

Joined: 26 Jun 2011
Posts: 97
Location: Vietnam

PostPosted: Thu Aug 06, 2015 7:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Aug 07, 2015 7:59 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites