Page 1 of 1

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

Posted: Sun Oct 01, 2023 4:44 pm
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? :|

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

Posted: Sun Oct 01, 2023 5:34 pm
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

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

Posted: Mon Oct 02, 2023 11:47 pm
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.