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 


Question on FPU stack?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Fri Oct 17, 2014 1:36 pm    Post subject: Question on FPU stack? Reply with quote

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
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Oct 17, 2014 2:07 pm    Post subject: Reply with quote

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.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Fri Oct 17, 2014 2:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Oct 17, 2014 5:24 pm    Post subject: Reply with quote

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.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
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