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 


How can i compact this code

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TwinShards
Newbie cheater
Reputation: 0

Joined: 23 Jan 2023
Posts: 11

PostPosted: Sun Sep 01, 2024 12:00 am    Post subject: How can i compact this code Reply with quote

I was wondering if there was any OpCode that can compare a full xmm register?

That's my code, which work but this take a lot of space.

Code:

newmem:
Coordinates:
dd (float)-1163.856689
dd (float)278.9642334
dd (float)-1801.525757
dd (float)25.4696312

newmem+100:
movss xmm0,[Coordinates]
comiss xmm0,[rsi]
jne originalcode
movss xmm0,[Coordinates+04]
comiss xmm0,[rsi+04]
jne originalcode
movss xmm0,[Coordinates+08]
comiss xmm0,[rsi+08]
jne originalcode
movss xmm0,[Coordinates+0C]
comiss xmm0,[rsi+0C]
jne originalcode
xorps xmm0,xmm0
jmp returnhere
originalcode:
movups xmm0,[r14]
subps xmm0,[rsi]
jmp returnhere
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3296

PostPosted: Sun Sep 01, 2024 1:39 pm    Post subject: Reply with quote

Have not done this before, so I am merely guessing...
Read up on PCMPEQB/PCMPEQW/PCMPEQD in Intel manual and take it from there?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 204

Joined: 25 Jan 2006
Posts: 8577
Location: 127.0.0.1

PostPosted: Sun Sep 01, 2024 3:21 pm    Post subject: Reply with quote

You could make use of SIMD to load and test all 4 coords at once.

You can use movaps ( https://www.felixcloutier.com/x86/movaps ) to load the current 4 coords you wish to compare at the same time.

You can use xorps ( https://www.felixcloutier.com/x86/xorps ) against your 'Coordinates' values to perform an XOR against all of the values at the same time.

You can use ptest ( https://www.felixcloutier.com/x86/ptest ) to test if any of the coords were different.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 150

Joined: 06 Jul 2014
Posts: 4641

PostPosted: Sun Sep 01, 2024 4:30 pm    Post subject: Reply with quote

Code:
cmpneqps xmm0,xmm1
movmskps eax,xmm0
test eax,eax
jnz notequal
// xmm0 == xmm1
...
notequal:
// xmm0 != xmm1
...

_________________
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
TwinShards
Newbie cheater
Reputation: 0

Joined: 23 Jan 2023
Posts: 11

PostPosted: Sun Sep 01, 2024 7:10 pm    Post subject: Reply with quote

Thank atom0s, exactly what i was looking for.
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 programming 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