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 


Floor in FPU

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Tue Mar 17, 2015 8:57 am    Post subject: Floor in FPU Reply with quote

Hello,I want to calculate the floor of the float value located at ST(0),I found this while searching:
frndint instruction
https://courses.engr.illinois.edu/ece390/archive/spr2002/books/labmanual/inst-ref-frndint.html
But I have no idea on how to edit the 'FPU control word'.
Thanks for any help.
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Tue Mar 17, 2015 9:13 am    Post subject: Reply with quote

hmm not sure why you would need to edit that but I just wanted to try it out here's how it turned out

Cool find, I have a thing for whole numbers Laughing I don't think its something you can edit, its preset. Like if float is "x.5" it'll round up or round down, something like that.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Tue Mar 17, 2015 10:58 am    Post subject: Reply with quote

vng21092 wrote:
hmm not sure why you would need to edit that but I just wanted to try it out here's how it turned out
picture
Cool find, I have a thing for whole numbers Laughing I don't think its something you can edit, its preset. Like if float is "x.5" it'll round up or round down, something like that.


It rounds up or down?
floor(-1.06) = -2
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Tue Mar 17, 2015 11:06 am    Post subject: Reply with quote

I'm guessing it just hops to the closest whole number. Judging from the other two values, we have -239.8 --> -240, and -270.6 --> -271. The link you posted says it rounds the number according to the current rounding mode. Here are two links that covers it slightly, hope it helps.

http://cs.fit.edu/~mmahoney/cse3101/float.html (All the way at the bottom "Rounding Control")

http://www.website.masmforum.com/tutorials/fptute/fpuchap1.htm (Near the middle "Control Word")
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Wed Mar 18, 2015 6:45 am    Post subject: Reply with quote

vng21092 wrote:
I'm guessing it just hops to the closest whole number. Judging from the other two values, we have -239.8 --> -240, and -270.6 --> -271. The link you posted says it rounds the number according to the current rounding mode. Here are two links that covers it slightly, hope it helps.

http://cs.fit.edu/~mmahoney/cse3101/float.html (All the way at the bottom "Rounding Control")

http://www.website.masmforum.com/tutorials/fptute/fpuchap1.htm (Near the middle "Control Word")


Thanks for your help,I was hoping to find a function that does floor on floats (like ntdll.Floor),or a way to change the rounding mode to make frndint always round down,thanks anyway.
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Wed Mar 18, 2015 3:00 pm    Post subject: Reply with quote

There's nothing preventing you from using a floor function in a loaded DLL (or loading a dll for the function you want). I don't know offhand how the native floor works, but I think that the msvcrt exports a floor function that takes a 4-byte float.
_________________
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: Wed Mar 18, 2015 7:00 pm    Post subject: This post has 1 review(s) Reply with quote

This... should work. Smile

Code:
alloc(myint,4)
alloc(rounddown,4)

rounddown:
  dd (float)0.5

newmem:
  // float already on stack
  fsub [rounddown]
  fistp [myint]
  fild [myint]
  // floor value now on stack
Back to top
View user's profile Send private message
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