Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Simple float number calculation in xmm registers?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue Feb 28, 2017 9:38 pm    Post subject: Simple float number calculation in xmm registers? Reply with quote

In CE, I declared the following in Lua:

Code:

rate = 0.60


Then , I used this variable in Auto Assemble:
Code:

mulss xmm0,$rate


However, this line cannot be compiled. Did I do something wrong?

Thanks a lot.

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Tue Feb 28, 2017 11:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Wed Mar 01, 2017 12:33 am    Post subject: Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Mar 01, 2017 4:30 am    Post subject: Reply with quote

ParkourPenguin wrote:
If you need to access the value from Lua, register the symbol and use readFloat / writeFloat.

_________________
Back to top
View user's profile Send private message MSN Messenger
SunBeam
I post too much
Reputation: 65

Joined: 25 Feb 2005
Posts: 4023
Location: Romania

PostPosted: Wed Mar 01, 2017 4:43 am    Post subject: Reply with quote

Really fail to see what's up with people and 2-3 additional lines of code. Just cuz "they want it simpler" Smile
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Wed Mar 01, 2017 7:02 am    Post subject: Reply with quote

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. Smile

Thanks for reminding me.

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites