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 


I need help about float +/- value and compare in address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> Auto Assembler tutorials
View previous topic :: View next topic  
Author Message
dashmond
How do I cheat?
Reputation: 0

Joined: 14 Nov 2015
Posts: 3

PostPosted: Sat Nov 14, 2015 9:27 pm    Post subject: I need help about float +/- value and compare in address Reply with quote

Hi every, first I need tell you, I'm bad in eng but I very try to communicate, because I struck this point 3 days and very need to done.

so, overview...

1. player address stored in registersymbol(player_ptr) and already to use (float value)
2. player location x address = [player_ptr+120]
3. enemy address stored in rcx and already to use (float value)
4. enemy location x address = [rcx+90]

so, I need...

1. player location x minus with float 12500.0 (ex: current player locaton x = 100000.7 but i need value = 87500.7 for next process)
2. compare player location x (after minus) with enemy location x
3. if player > enemy jump to end
3. but else (player <= enemy) jump to next

this is my problem code.
Code:

                push rdx
                mov rdx,[player_ptr]
                add rdx,120
                sub ...
                cmp rdx,[rcx+90]
                jg end
                jmp next



Thank you very much for any help Very Happy
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Sun Nov 15, 2015 5:19 am    Post subject: Re: I need help about float +/- value and compare in address Reply with quote

Code:

// load player X
push rdx
mov rdx,[player_ptr]
fld dword ptr [rdx+120]
pop rdx

// subtract 12500
push (float)12500
fsub dword ptr [esp]
add esp,4

// load enemyX
fld dword ptr [rcx+90]

// now: ST(0)=enemyX, ST(1)=playerX-12500


fcomip ST(0),ST(1) // compare (enemyX) with (playerX-12500), and pop
fstp ST(0)         // pop
jb end             // jump if (enemyX) is below (playerX-12500)


// do stuff here





end:

_________________
Back to top
View user's profile Send private message MSN Messenger
dashmond
How do I cheat?
Reputation: 0

Joined: 14 Nov 2015
Posts: 3

PostPosted: Thu Nov 19, 2015 4:02 am    Post subject: Reply with quote

Thank for replied, but I do not understand this line

Code:

// subtract 12500
push (float)12500
fsub dword ptr [esp]
add esp,4



can you explain me?

Embarassed
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Thu Nov 19, 2015 11:21 am    Post subject: Reply with quote

push (float)12500 - this pushes the number 12500 as a single-precision floating point number onto the stack.

fsub dword ptr [esp] - esp is the stack pointer. This points to whatever is on the top of the stack. Since you just pushed (float)12500 onto it, [esp] = (float)12500. fsub takes whatever's on top of the fpu stack (in this case the player's X position) and subtracts it by that r/m ([esp]) and pushes it back onto the fpu stack.

add esp,4 - this just cleans up the stack. It kind of deallocates that part of the stack and allows it to be overwridden by another push. This is necessary because stuff like the return addresses for ret instructions would get messed up and the program would crash if you didn't clean up the stack.

By the way, I'm not that familiar with 64 bit stuff, but shouldn't you be using rsp instead of esp? The upper dword of rsp is probably 0, but still...

_________________
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
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Fri Nov 20, 2015 9:17 am    Post subject: Reply with quote

CE will use RSP anyway.
_________________
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 -> Cheat Engine Tutorials -> Auto Assembler tutorials 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