|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
paul44 Expert Cheater Reputation: 2
Joined: 20 Jul 2017 Posts: 179
|
Posted: Mon Nov 11, 2024 4:32 am Post subject: multiply (constant) float with packed xmm register [Closed] |
|
|
In this particular case, I made a Speed feature.
I found the location where the player's coordinates are increased by a step-value... which is maintained in a packed xmm register (basically 3 floats updating resp. x,y,z).
From a gamer perspective, s/he only needs to change the multiplier (1 float value), which then needs to be multiplied with them respective step-values.
How it is implemented now:
[code]fMultiplDef:
dd (float)2
fMultipl:
readMem(fMultiplDef,4)
readMem(fMultiplDef,4)
readMem(fMultiplDef,4)
dd 0
...
vmovups xmm0,[rdi]
mulps xmm0,[fMultipl]
[/code]
My question: can one "simply" multiply the ss_float to the ps_xmmo ?
(so that i do not need to define 2 vars here)
ps: above works fine. but since this is not the 1st time i had to do this, i figured to get "elevated" a bit
(google gives me either mulss or mulps)
Last edited by paul44 on Wed Nov 13, 2024 1:04 am; edited 1 time in total |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 147
Joined: 06 Jul 2014 Posts: 4536
|
Posted: Mon Nov 11, 2024 12:48 pm Post subject: |
|
|
If you don't care about whether or not the 4th packed single is 0:
Code: | alloc(newmem,2048,wherever)
alloc(speedMulti,4,wherever)
speedMulti:
dd (float)2
newmem:
vbroadcastss xmm0,[speedMulti]
vmulps xmm0,xmm0,[rdi]
jmp return |
If you need to zero the 4th value:
Code: | alloc(newmem,2048,wherever)
alloc(shuffleMask,16,wherever)
alloc(speedMulti,4,wherever)
shuffleMask:
db 00 01 02 03
db 00 01 02 03
db 00 01 02 03
db 80 80 80 80
speedMulti:
dd (float)2
newmem:
vmovd xmm0,[speedMulti]
vpshufb xmm0,xmm0,[shuffleMask]
vmulps xmm0,xmm0,[rdi]
jmp return |
You can do that with only a single variable (no shuffle mask), but the logic more difficult to follow:
Code: | alloc(newmem,2048,wherever)
alloc(speedMulti,4,wherever)
speedMulti:
dd (float)2
newmem:
sub rsp,20
vmovups [rsp],xmm1
vmovups [rsp+10],xmm2
vmovss xmm0,[speedMulti]
vxorps xmm2,xmm2,xmm2
vunpcklps xmm1,xmm0,xmm2
vunpcklps xmm0,xmm0,xmm0
vmovlhps xmm0,xmm0,xmm1
vmulps xmm0,xmm0,[rdi]
vmovups xmm2,[rsp+10]
vmovups xmm1,[rsp]
add rsp,20
jmp return |
Interesting note: `vmulps` can take an unaligned memory operand. The legacy SSE version `mulps` would've required [rdi] to be 16-byte aligned.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
paul44 Expert Cheater Reputation: 2
Joined: 20 Jul 2017 Posts: 179
|
Posted: Wed Nov 13, 2024 1:02 am Post subject: closed... |
|
|
^ i will definitely try out your 1st suggestion.
With coordinates, this situation is pretty common; and mostly/always the 4th value is "obsolete" (usually remains 0 or 1). I'm pretty sure changing the 4th value will have no effect at all...
I'm also guessing that - since CE is executing this opcode - it can also be used for non-AVX games (i've only seen "v'-instructions in AVX games, but i might be completely wrong in that respect). But then again: this would also exclude gamers with non-AVX cpu support, so...
thx for all them suggestions
ps: The other options tend to pass "my paygrade".
|
|
Back to top |
|
|
|
|
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
|
|