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 


add [ecx+94],(float)50000 dont work! Why?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 81

PostPosted: Mon Oct 15, 2012 3:46 am    Post subject: add [ecx+94],(float)50000 dont work! Why? Reply with quote

Hi.

I want to add (float)50000 to [eax] with this asm:

add [ecx+94],(float)50000

But it dont work.

If i use mov, it writes the value perfect.

how can I add (float) 50000 to eax?
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: Mon Oct 15, 2012 6:02 am    Post subject: Reply with quote

You wrote, "add to [eax]"

solution 1:
add [eax],(float)50000



Then you wrote, "add to eax"

solution 2:
add eax,(float)50000

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25794
Location: The netherlands

PostPosted: Mon Oct 15, 2012 6:19 am    Post subject: Reply with quote

ADD doesn't work with a floating point addition

I usually use ADDSS

I guess the usual fpu instructions can be used as well, but I find them more complex to use than sse

_________________
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
View user's profile Send private message MSN Messenger
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 81

PostPosted: Mon Oct 15, 2012 10:40 am    Post subject: Reply with quote

Hi Dark Byte.

If i use addss [edx+000000C4],(float)50000, i get an error: This instruction can't be compiled.

Whats wrong?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25794
Location: The netherlands

PostPosted: Mon Oct 15, 2012 11:29 am    Post subject: Reply with quote

the problem with addss (and other sse instructions) is that it must use a xmm register as destination and a memory address or other xmm register as source. No direct assignments either

so try something like this:
Code:

sub esp,#20 //allocate 20bytes for local storage (original xmm0 register(16) and temp float value(4))

movdqu [esp],xmm0 //save xmm0 (128 bit register, so 16 bytes)
mov [esp+10],(float)50000 //prepare an address with the float value 50000
movss xmm0,[esp+10] //write the float value into xmm0 (note that the upper bits of xmm0 will get erased by doing this, which is why we use movdqu to save it and not movss)
addss xmm0, [edx+c4] //increase xmm0 (50000.0) with the float value at edx+c4
movss [edx+c4],xmm0 //write the result of the calculation to edx+c4
movss xmm0,[esp] //restore with original

add esp,#20 //free local variable space


I haven't really tested it, but this is the general gist of it

_________________
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
View user's profile Send private message MSN Messenger
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 81

PostPosted: Mon Oct 15, 2012 12:31 pm    Post subject: Reply with quote

YEA!!! It works!!!

Dark Byte you are the godfather of ASM and GameHack!!!

Big THX Smile
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: Mon Oct 15, 2012 1:12 pm    Post subject: Reply with quote

uhm, sorry, I though it was integer. I just made quick reply too quick.


Btw. there are other ways. For example I used for other games where values were floats but they have always integer values.

And there is e.g.:
movss [edi+04],xmm0

and I want [edi+04] to be 5000 bigger, I use this

push eax
cvttss2si eax,xmm0
add eax,(int)5000
cvttsi2ss xmm0,eax
pop eax
movss [edi+04],xmm0

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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