| View previous topic :: View next topic |
| Author |
Message |
h3x1c Master Cheater
Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Mon Jul 20, 2015 2:47 pm Post subject: Quick question about fild |
|
|
I've been studying the FPU lately, but I can't quite pin down what's going on to cause my game to crash when trying to modify a particular fild instruction.
Take this bit of code (assume the referenced memory addresses are in a currently-running instance of the game):
| Code: | fild dword ptr [007E562C] //1 is what resides in 007E562C
fadd qword ptr [007E5540]
fstp qword ptr [007E5540] |
How am I using fild incorrectly by replacing fild dword ptr [007E562C] with my own code injection consisting of the following (using the same value as what already resides in [007E562C], just to try to keep everything the same value-wise for testing purposes):
| Code: | push ebx
mov ebx,1
fild dword ptr [ebx]
pop ebx |
If I keep the original fild instruction intact but simply add a mov [007E562C],1 before it, everything still works wonderfully, like so:
| Code: | mov [007E562C],1 //I can place up to FF here and it works great
fild dword ptr [007E562C]
fadd qword ptr [007E5540]
fstp qword ptr [007E5540] |
Thanks for any help! I know it's something stupidly simple, but I'm not finding it at the moment...
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25828 Location: The netherlands
|
Posted: Mon Jul 20, 2015 3:44 pm Post subject: |
|
|
fild dword [address] will load a 4 byte signed integer from the address, and convert it internally to a floating point value (ext-double)
| Code: |
push ebx
mov ebx,1
fild dword ptr [ebx]
pop ebx
|
this code can be rewritten as:
Which is very doubtful that's what you wish to do (address 1 isn't often readable)
Your second solution is the best solution (and you should be able to go to 7fffffff without issue)
alternatively, you can use an self allocated address with the value
| Code: |
alloc(myvalue,4)
myvalue:
dd (int)1000
...
fild dword ptr [myvalue]
...
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
h3x1c Master Cheater
Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Mon Jul 20, 2015 3:55 pm Post subject: |
|
|
OHHHHHH, so the issue is basically that I'm trying to load 1 from a CPU register instead of 1 from an address in RAM?
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25828 Location: The netherlands
|
Posted: Mon Jul 20, 2015 3:56 pm Post subject: |
|
|
Yes. FILD only takes addresses as parameter
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
h3x1c Master Cheater
Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Mon Jul 20, 2015 3:57 pm Post subject: |
|
|
Excellent stuff. That's all I needed for it to click. Thanks for replying, Dark Byte!
EDIT: Good grief, it was right under my damn nose the whole time, lmao. From the very top of here:
| Quote: | | "Integer data cannot be transferred directly between the CPU and FPU registers." |
_________________
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Mon Jul 20, 2015 4:07 pm Post subject: |
|
|
| Just to clarify, your code was trying to read data from the address [00000001].
|
|
| Back to top |
|
 |
h3x1c Master Cheater
Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Mon Jul 20, 2015 4:20 pm Post subject: |
|
|
| Zanzer wrote: | | Just to clarify, your code was trying to read data from the address [00000001]. |
Yep, got it. Thanks for the additional feedback!
_________________
|
|
| Back to top |
|
 |
|