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 


XMM registers, float, etc.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Apr 02, 2016 5:44 pm    Post subject: XMM registers, float, etc. Reply with quote

Please take a look at the attached pictures. When I open the FPU window and select "Float", the value of xmm0 is 75.00, but that value will change to "42960000" if I select "4 Bytes". What's the connection between "75" and "42960000"?

Moreover, after this:

Code:
movss [ebp-14],xmm0


The value at "ebp-14" changes to "00 00 96 42", but not "75", why? Is it because "75.00" is a float-point number and it needs to be converted to hexdecimal?

Last question, why do we need XMM registers? To deal with floating-point number? If so, should I always select "Float" mode in the FPU window in CE?

Thanks in advance.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Apr 02, 2016 6:20 pm    Post subject: Reply with quote

Yes, floats are stored in a floating point notation due to having so many more possibilities than whole numbers.
Their computed value is an approximation of the real number they represent.

42960000 is the hexadecimal representation of the bytes for 75.0.
00 00 96 42 is the same value as seen in an array of bytes instead.

The XMM registers are used for floats/doubles as well as converting to/from integers.
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Apr 02, 2016 6:35 pm    Post subject: Reply with quote

Zanzer wrote:
Yes, floats are stored in a floating point notation due to having so many more possibilities than whole numbers.
Their computed value is an approximation of the real number they represent.

42960000 is the hexadecimal representation of the bytes for 75.0.
00 00 96 42 is the same value as seen in an array of bytes instead.

The XMM registers are used for floats/doubles as well as converting to/from integers.


Thanks Zaner. Very Happy

One more question though:
Do games usually use floating-point numbers to calculate damage or coordinates of a unit? So if I see xmm registers being used, can I assume that the purpose of the codes around them are used for calculating such values?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Apr 02, 2016 9:23 pm    Post subject: Reply with quote

Yes, most games use floats for that because there are often modifiers, status bars, or various other reasons to use a decimal value.
Unless you're playing a turn-based game with grid movement, you're not likely to have whole numbers representing the unit's movement.

If you see XMM registers you can pretty much guarantee that you're going to be doing some decimal calculations.
Sometimes it may first load an integer to convert into a decimal and then do some math.
For example, armor may be represented by a 4-byte integer.
In order to reduce the damage taken, it may need to be converted into its decimal notation.

Or lets say you have a float health, like in most games.
Well you don't want to display it to the player as 99.9842389402384.
So you'll take the float value and convert it into an integer for display purposes.
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Apr 02, 2016 11:02 pm    Post subject: Reply with quote

Zanzer wrote:
Yes, most games use floats for that because there are often modifiers, status bars, or various other reasons to use a decimal value.
Unless you're playing a turn-based game with grid movement, you're not likely to have whole numbers representing the unit's movement.

If you see XMM registers you can pretty much guarantee that you're going to be doing some decimal calculations.
Sometimes it may first load an integer to convert into a decimal and then do some math.
For example, armor may be represented by a 4-byte integer.
In order to reduce the damage taken, it may need to be converted into its decimal notation.

Or lets say you have a float health, like in most games.
Well you don't want to display it to the player as 99.9842389402384.
So you'll take the float value and convert it into an integer for display purposes.

Sorry for the late reply. Thanks for the explanation. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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