View previous topic :: View next topic |
Author |
Message |
ExVault Newbie cheater
Reputation: 0
Joined: 14 Jun 2013 Posts: 14
|
Posted: Sun Jul 21, 2013 6:58 am Post subject: Whats the best way to nop the FSTP instruction? |
|
|
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 |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jul 21, 2013 10:06 am Post subject: |
|
|
_________________
|
|
Back to top |
|
 |
ExVault Newbie cheater
Reputation: 0
Joined: 14 Jun 2013 Posts: 14
|
Posted: Mon Jul 22, 2013 1:28 pm Post subject: |
|
|
Did not think that its possible to load a register into itself. Thx for the tip.
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Jul 22, 2013 3:53 pm Post subject: |
|
|
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 |
|
 |
|