I believe the correct way to do this is the following:
const1: dq 1.2345
...
fld const1
However, I'm using Cheat Engine to reverse engineer a game (so I can understand it better). And it shows the following error:
Can someone please tell me what's wrong here? Ideally I would like the second command to be:
fstp dword [esi+ 3C]
But before I do this I need to load 93.5 value into the st(0) register. How can I achieve this?
There are a series of syntax related errors causing your problem.
"this instruction cannot be compiled" You're putting data in a code section. Define your variable outside of the newmem block and inside of a separate memory block. You're trying to define a memory block with "val:" but you haven't allocated that memory. You also can't reference it without registering a symbol.
To define a regular float you use a 4 byte variable not a 8 byte variable so you use "dd" not "dq", secondly you need to "cast" it to a float.
Your instruction you want to push a float onto the FPU stack is written like so: fld dword ptr [val]
Create the injection template as you have done previously and then insert this code at the top and continue what you were doing, it has everything I have noted in the answer and I tested it working:
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
alloc(val,8)
val:
dd (float)93.5
registersymbol(val)
newmem:
fld dword ptr [val]
Keep in mind you will need to use the rest of the generated template, this is just the code to fix the errors seen in your question.