Merlini Advanced Cheater Reputation: 2
Joined: 12 Jun 2016 Posts: 53
|
Posted: Tue Apr 18, 2017 1:47 am Post subject: Help with converting float to 80bit byte sequence. |
|
|
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. |
|