简体   繁体   中英

How can I load a constant value into the floating point register st0?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM