View previous topic :: View next topic |
Author |
Message |
dashmond How do I cheat? Reputation: 0
Joined: 14 Nov 2015 Posts: 3
|
Posted: Sat Nov 14, 2015 9:27 pm Post subject: I need help about float +/- value and compare in address |
|
|
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
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Nov 15, 2015 5:19 am Post subject: Re: I need help about float +/- value and compare in address |
|
|
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 |
|
|
dashmond How do I cheat? Reputation: 0
Joined: 14 Nov 2015 Posts: 3
|
Posted: Thu Nov 19, 2015 4:02 am Post subject: |
|
|
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?
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4291
|
Posted: Thu Nov 19, 2015 11:21 am Post subject: |
|
|
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 |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Nov 20, 2015 9:17 am Post subject: |
|
|
CE will use RSP anyway.
_________________
|
|
Back to top |
|
|
|