|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
vng21092 Grandmaster Cheater Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Oct 17, 2014 1:36 pm Post subject: Question on FPU stack? |
|
|
I'm not very clear on this so correct me if I'm wrong, from what I understand FLD loads a floating point value from the top of the FPU Stack (and converts it, something like that)? And a FSTP usually follows somewhere down the line, and FSTP is suppose to use the value the FLD retrieved. So in the case of this:
fld [eax+04]
fstp [eax+08]
What are the dangers of taking out FSTP and replacing it with something like
mov [eax+08],some_value
I'm asking because I've read FSTP retrieves the value THEN pops the stack, what are the risks of not popping the stack? Whats a workaround? I'd like a better understanding of this
|
|
Back to top |
|
|
Geri Moderator Reputation: 111
Joined: 05 Feb 2010 Posts: 5636
|
Posted: Fri Oct 17, 2014 2:07 pm Post subject: |
|
|
FLD will put a value from an address in the stack. (FILD is converting an integer into a float and put it into the stack, FLD is not converting.)
And FSTP will copy the value from the stack to an address and remove it from the stack.
FST will copy the value from the stack but it will not remove it from the stack.
If you remove an FSTP, you mess up the stack and the floating point instructions will work with wrong values.
But if you put your
mov [eax+08],some_value
instruction right after the FSTP instruction, it will immediately overwrite the value on [eax+08] anyway, so you don't need to remove the FSTP.
If you just want to "delete" the value from the stack, use
fstp st(0)
but as I said above, it's better if you just leave that fstp alone and overwrite the value with your mov.
_________________
|
|
Back to top |
|
|
vng21092 Grandmaster Cheater Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Oct 17, 2014 2:24 pm Post subject: |
|
|
hmm, so if I were to leave the FSTP alone and put a MOV right after it, I'm essentially writing to that address twice? Oh, another thing also, does "ffree st(0)" do the same thing as "fstp st(0)"?
|
|
Back to top |
|
|
Geri Moderator Reputation: 111
Joined: 05 Feb 2010 Posts: 5636
|
Posted: Fri Oct 17, 2014 5:24 pm Post subject: |
|
|
vng21092 wrote: | hmm, so if I were to leave the FSTP alone and put a MOV right after it, I'm essentially writing to that address twice? |
Yes. And only the second value will be used, the first one is simply overwritten.
Quote: | Oh, another thing also, does "ffree st(0)" do the same thing as "fstp st(0)"? |
Intel Instruction Set Reference about ffree:
Quote: | Sets the tag in the FPU tag register associated with register ST(i) to empty (11B).
The contents of ST(i) and the FPU stack-top pointer (TOP) are not affected. |
_________________
|
|
Back to top |
|
|
|
|
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
|
|