View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Feb 28, 2017 9:38 pm Post subject: Simple float number calculation in xmm registers? |
|
|
In CE, I declared the following in Lua:
Then , I used this variable in Auto Assemble:
However, this line cannot be compiled. Did I do something wrong?
Thanks a lot.
_________________
**************
A simple example is better then ten links.  |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4695
|
Posted: Tue Feb 28, 2017 11:28 pm Post subject: |
|
|
Inside an AA script, $var will try to translate the global Lua variable var into some value. In this case, it doesn't matter how this is done- all that matters is that it's an immediate, and there is no instruction that multiplies an xmm register with an immediate operand.
Do something like this instead:
Code: | alloc(multiplier,4)
...
code:
mulss xmm0,[multiplier]
...
multiplier:
dd (float)0.60 |
If you need to access the value from Lua, register the symbol and use readFloat / writeFloat.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Wed Mar 01, 2017 12:33 am Post subject: |
|
|
ParkourPenguin wrote: | Inside an AA script, $var will try to translate the global Lua variable var into some value. In this case, it doesn't matter how this is done- all that matters is that it's an immediate, and there is no instruction that multiplies an xmm register with an immediate operand.
Do something like this instead:
Code: | alloc(multiplier,4)
...
code:
mulss xmm0,[multiplier]
...
multiplier:
dd (float)0.60 |
If you need to access the value from Lua, register the symbol and use readFloat / writeFloat. |
Thanks, Penguin. I used to use the solution you suggested. But now, I want to let the users to define that number instead of pre-defining it in AA script, is there a way to do it?
_________________
**************
A simple example is better then ten links.  |
|
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: Wed Mar 01, 2017 4:30 am Post subject: |
|
|
ParkourPenguin wrote: | If you need to access the value from Lua, register the symbol and use readFloat / writeFloat. |
_________________
|
|
Back to top |
|
 |
SunBeam I post too much
Reputation: 65
Joined: 25 Feb 2005 Posts: 4023 Location: Romania
|
Posted: Wed Mar 01, 2017 4:43 am Post subject: |
|
|
Really fail to see what's up with people and 2-3 additional lines of code. Just cuz "they want it simpler"
|
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Wed Mar 01, 2017 7:02 am Post subject: |
|
|
mgr.inz.Player wrote: | ParkourPenguin wrote: | If you need to access the value from Lua, register the symbol and use readFloat / writeFloat. |
|
Sorry, I missed that line.
Thanks for reminding me.
_________________
**************
A simple example is better then ten links.  |
|
Back to top |
|
 |
|