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 


Trying to compare XMM0 is greater than value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Zhuma
How do I cheat?
Reputation: 0

Joined: 11 Feb 2023
Posts: 5

PostPosted: Sat Feb 11, 2023 11:19 am    Post subject: Trying to compare XMM0 is greater than value Reply with quote

I tried to do it myself, but it didn't end well, also I found pretty much the same question (Can't post URL to this question `cause of the new account), but every thing recommended there didn't help me. What I want to do, is to compare the value in XMM register (XMM0), with float [rcx+30], if [rcx+30] is bigger, I want to run original code, otherwise, I want to jump to exit.
Original code:
Code:
originalcode:
movss [rcx+30],xmm0

Hope you can help me!


Last edited by Zhuma on Sat Feb 11, 2023 1:06 pm; edited 2 times in total
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sat Feb 11, 2023 12:36 pm    Post subject: Reply with quote

You could try this:
Code:

...
alloc(number,4)
number:
 dd (float) 0

newmem:
 movss [number],xmm0
 cmp [number],0
 je exit
 movss [rcx+30],xmm0
...
Back to top
View user's profile Send private message
Zhuma
How do I cheat?
Reputation: 0

Joined: 11 Feb 2023
Posts: 5

PostPosted: Sat Feb 11, 2023 1:04 pm    Post subject: Reply with quote

LeFiXER wrote:
You could try this:
Code:

...
alloc(number,4)
number:
 dd (float) 0

newmem:
 movss [number],xmm0
 cmp [number],0
 je exit
 movss [rcx+30],xmm0
...


Actually, I wrote topic wrong, I need to check, which of values [rcx+30] or XMM0 is greater, and if [rcx+30], then I need to skip running original code (To not set lower value to my money address). I tried your code, for some reason, it always returns only one result.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Sat Feb 11, 2023 3:04 pm    Post subject: Reply with quote

Zhuma wrote:
if [rcx+30] is bigger, I want to run original code
Zhuma wrote:
I need to check, which of values [rcx+30] or XMM0 is greater, and if [rcx+30], then I need to skip running original code
What?

Use `ucomiss`
Code:
newmem:
  ucomiss xmm0,[rcx+30]
  jae exit  // jump if (float) xmm0 >= [rcx+30]
  // original code:
  movss [rcx+30],xmm0
exit:
  jmp return
Maybe `jbe` is what you're looking for instead?
_________________
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
Zhuma
How do I cheat?
Reputation: 0

Joined: 11 Feb 2023
Posts: 5

PostPosted: Sun Feb 12, 2023 7:35 am    Post subject: Reply with quote

Actualy, it was so easy to make..
Code that works perfectly:
Code:
newmem:
 movss xmm15,xmm0
 cmpss xmm0,[rcx+30],4
 jl exit

originalcode:
movss [rcx+30],xmm15


Thanks for help!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Sun Feb 12, 2023 2:19 pm    Post subject: This post has 1 review(s) Reply with quote

For other people reading this: `cmpss` doesn't work that way. Use `ucomiss` instead.

`cmpss` compares the first value against the second value using the comparison operation defined by the third 8-bit immediate value. If the comparison is true, the first dword in the first parameter has all bits set to 1 (0xFFFFFFFF); if false, the bits are unset (0).

`cmpss` doesn't modify the eflags register. Instructions that use eflags (e.g. `jl`) don't work with cmpss.

Even if it did, the 8-bit immediate "4" means "not equal to". It has nothing to do with greater than or less than like OP presumably wanted.

Zhuma wrote:
Code:
newmem:
 movss xmm15,xmm0
 cmpss xmm0,[rcx+30],4
 jl exit

originalcode:
movss [rcx+30],xmm15
All this does is write 0xFFFFFFFF to xmm0 if (float)xmm0 != [rcx+30] and 0x00000000 otherwise. The `jl` instruction is meaningless in this context.
As for why this might work for OP, I'd guess the original code has some instruction that sets eflags before the injection point, and it just so happens to behave like OP wants.

_________________
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
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