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 


Help with converting float to 80bit byte sequence.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Merlini
Advanced Cheater
Reputation: 2

Joined: 12 Jun 2016
Posts: 53

PostPosted: Tue Apr 18, 2017 1:47 am    Post subject: Help with converting float to 80bit byte sequence. Reply with quote

Please disregard.
I was not cleaning up my memory properly.









==========================

Hello,

I have been trying to convert floats to match the 80-bit byte sequences
given by the CE debugger FPU registers in its context.

As a test case, I have stored a float of 2.1 (0x40066666) into memory,
then loaded into FPU stack using fld dword ptr [eax].
CE debugger shows byte sequence of:
Code:
00 - 00 - 00 - 00 - 00 - 66 - 66 - 86 - 00 - 40 - 00 - 00 - 00 - 00 - 00 - 00

Under "extended" dropdown list selection, FPU window properly shows 2.10.

I have written a c++ code with inline asm to get double from the above tbytes with:
Code:
mov eax, pContextBytes //pContextBytes points to the tbytes above
fld tbyte ptr [eax]
mov eax, pContextDouble //pContextDouble points to a double allocation
fstp qword ptr [eax]

which properly returns ~2.1 into pContextDouble.

The problem occurs when I try to do the inversion. I.e. if I load a
float literal then try to get tbytes from that, I get a result different from
the one given by CE's debugger context.
For example,
Code:
mov eax, pTestFloat
fld dword ptr [eax]
mov eax, pTestBytes
fstp tbyte ptr [eax]
results in byte sequence of
Code:
00 - 00 - 00 - 00 - 00 - 66 - 66 - 86 - 00 - 40 - 20 - 02 - 00 - 00 - 00 - 00

Further, the sequence changes from run to run. Please refer to the pic.
(The byte sequence generated by the debugger is always the same.)
Good thing is that when converted to double, all these different
sequences converge to a value of 2.1 to sane approximation.

Has anyone worked with x87 FPU registers before and experienced
something like this?

Thanks in advance for any tips.
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