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 


Whats the best way to nop the FSTP instruction?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
ExVault
Newbie cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 14

PostPosted: Sun Jul 21, 2013 6:58 am    Post subject: Whats the best way to nop the FSTP instruction? Reply with quote

Hello there, I am new to assembly and have one question.

Lets say you have something like this:
Code:
fstp dword ptr [some_mem]

As Intel developer manual states, the fstp instruction marks the ST(0) register as empty and increments the stack pointer (TOP) by 1.
So, as I can assume one cannot just replace this instruction with nops.
What I am doing now is:
Code:
alloc(stub,4)
...
fstp dword ptr [stub]
...
dealloc(stub)


It works fine, but I am curious is there any better way to do that?
Thank you.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Jul 21, 2013 10:06 am    Post subject: Reply with quote

Code:
fstp st(0)

_________________
Back to top
View user's profile Send private message MSN Messenger
ExVault
Newbie cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 14

PostPosted: Mon Jul 22, 2013 1:28 pm    Post subject: Reply with quote

Did not think that its possible to load a register into itself. Thx for the tip.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Jul 22, 2013 3:53 pm    Post subject: Reply with quote

fst instruction copies the value in the ST(0) register to the destination operand. If we choose ST(0) as destination ( which means ST(0) is source and ST(0) is destination ) we do not change anything.

fstp instruction performs the same operation and then pops the register stack.


You can NOP almost any FPU instruction.
But you can not simply NOP those: fstp, fsubp, fmulp, fdivp, ...........


Sometimes it is better to leave original instruction, and then overwrite memory with desired value. You have two options:

-
Code:
newmem:
(...)
fstp dword ptr [XXXXXXXX]
mov dword ptr [XXXXXXXX],(float)5.0    // or whatever value you want
(...)



-
Code:
newmem:
(...)
fstp ST(0)
mov dword ptr [XXXXXXXX],(float)5.0    // or whatever value you want
(...)

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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