cmp [rcx],(float)61 vs cmp [rcx],rbx, different result

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
User avatar
oLaudix
Cheater
Cheater
Posts: 33
Joined: Tue Dec 12, 2017 5:34 pm
Reputation: 20

cmp [rcx],(float)61 vs cmp [rcx],rbx, different result

Post by oLaudix »

When I manualy compare [rcx] (that holds 61 in float) to (float)61 it passes the compare without a problem:

Image

but when I'm doing compare to a register that is 61 in float the check fails:

Image

What am I doing wrong? :|

User avatar
sub1to
Cheater
Cheater
Posts: 47
Joined: Sat Aug 01, 2020 9:37 pm
Reputation: 87

Re: cmp [rcx],(float)61 vs cmp [rcx],rbx, different result

Post by sub1to »

One issue is that rbx is a 64 bit register, so it will compare the upper 32bits of rbx against the bits that are in memory pointed at by rcx. You should compare it against a 32bit register instead:

Code: Select all

cmp [rcx], ebx

User avatar
SunBeam
Administration
Administration
Posts: 4932
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4630

Re: cmp [rcx],(float)61 vs cmp [rcx],rbx, different result

Post by SunBeam »

I strongly suggest using SSE/SSE2 instructions, as we're in 2023:

Code: Select all

code:
xorps xmm14,xmm14 // if you wanna have it clean, although it doesn't matter
movss xmm14,[myFloat]
cmpss xmm14,[rcx]
jne bla

myFloat:
dd (float)2.0
You can safely use xmm10...xmm15, as I doubt you'll find a game/program with functions that have that many args.

Post Reply

Who is online

Users browsing this forum: No registered users