View previous topic :: View next topic |
Author |
Message |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Thu Oct 29, 2015 2:45 pm Post subject: Question about quadword |
|
|
So I have this one instruction "movq [esi+30],xmm0", and through some reading I found that means move quadword. So I registered a symbol and initialized it with "dq:". Yet when I do this Code: | movq [esi+30],xmm0
fld [esi+30]
fstp [mySymbol] | I end up getting weird values, how to fix?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Thu Oct 29, 2015 3:36 pm Post subject: |
|
|
The bytecode of those instructions might give you the answer.
If fld and/or fstp is using the byte D9, then it's trying to load and store a single precision floating point value. Doubles would use the byte DD for both of those instructions.
If this is the case, try using this mnemonic instead:
Code: | movq [esi+30],xmm0
fld qword ptr [esi+30]
fstp qword ptr [mySymbol] |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Thu Oct 29, 2015 3:38 pm Post subject: |
|
|
Probably the fld need to specific the size, ie.
Code: |
fld dword ptr [esi+80] // or
fld qword ptr [esi+80] |
depends on the previous usage of xmm0.
xmm can be interpret as 16xbyte, 8xshort, 4xdword & 4xfloat or 2xdouble.
If xmm0 is used as single(one,1x,the lower one of four/two) float(also called 'single')/double previously, it can be store to a memory as
Code: |
movss dword ptr[esi+80],xmm0 // float or
movsd qword ptr[esi+80],xmm0 // double
|
ADDED:
hmmm... why not
Code: |
movq qword ptr [MySymbol],xmm0
| ?
bye~
_________________
- Retarded. |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Thu Oct 29, 2015 3:56 pm Post subject: |
|
|
panraven wrote: | ADDED:
hmmm... why not
Code: | movq qword ptr [MySymbol],xmm0 | ? |
movq stands for "move quadword". It can't access any other size of data, so qword ptr is already implied in the instruction's mnemonic.
For instructions like fstp and fld, they can store/load a variable number of bytes, so interpreters need to add dword ptr or qword ptr to distinguish how many bytes those instructions are working with.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Oct 29, 2015 4:03 pm Post subject: |
|
|
Just to point this out, for this specific example.
movq [esi+30],xmm0
is populating the value of [esi+30] at this moment
If you wanted your variable to have the same value, you could simply repeat the command.
movq [mySymbol],xmm0
And I assume at some point you'll want to overwrite the register with whatever value you stored previously:
movq xmm0,[mySymbol]
movq [esi+30],xmm0
|
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Thu Oct 29, 2015 4:10 pm Post subject: |
|
|
ParkourPenguin wrote: | panraven wrote: | ADDED:
hmmm... why not
Code: | movq qword ptr [MySymbol],xmm0 | ? |
movq stands for "move quadword". It can't access any other size of data, so qword ptr is already implied in the instruction's mnemonic.
..snip..
|
yes, you are right, it is redundant.
_________________
- Retarded. |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Oct 29, 2015 4:15 pm Post subject: |
|
|
Also note that the value isn't necessarily a double.
Could just as easily be an 8-byte long.
|
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Thu Oct 29, 2015 4:16 pm Post subject: |
|
|
Zanzer wrote: | Just to point this out, for this specific example.
..snip..
And I assume at some point you'll want to overwrite the register with whatever value you stored previously:
movq xmm0,[mySymbol]
movq [esi+30],xmm0 |
...but I'll paranoiac on overwrite xmm's if it is just use as temporary storage for transferring. May be easily push/pop regular integer registers better suit this role.
_________________
- Retarded. |
|
Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Thu Oct 29, 2015 4:42 pm Post subject: |
|
|
well, this is embarrassing , I actually did try using Code: | movq [esi+30],xmm0
fld qword ptr [esi+30]
fstp qword ptr [mySymbol] | before I posted the topic but I still got weird results, turns out, I was viewing the wrong data type. Was double, not float, woops. Still weird though, because I did initially search for it under float, and the values did make sense at the time, guess not. Thanks for the help though guys.
|
|
Back to top |
|
 |
|