![Cheat Engine Forum Index](templates/subSilver/images/logo_phpBB.gif) |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Zazary How do I cheat?
Reputation: 0
Joined: 05 Jul 2024 Posts: 1
|
Posted: Fri Jul 05, 2024 2:03 am Post subject: Please help me understand xmm. |
|
|
Hi everyone, I'm just learning and please explain how to extract numbers from xmm? Here is an example of xmm0: 1522.66 - 56.23 - 68.30 - 0.00. I want to extract Y and do movss xmm0, [allocaddress], and is it possible to extract even more values? Also, how do I determine the axes? I only figured out that X is 1522.66, Z is 56.23, and Y is 68.30. Do I need to determine this myself, or is there a more accurate way? (I would like examples as I have been trying to understand xmm for 3 days and still can't figure it out.)
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
ParkourPenguin I post too much
Reputation: 146
Joined: 06 Jul 2014 Posts: 4462
|
Posted: Fri Jul 05, 2024 11:00 am Post subject: |
|
|
XMM registers store 16 bytes of data. This can be integer data of various sizes, 4 floats, or 2 doubles. In this case, that's 4 floats.
Vector operations on xmm registers operate on all the values at the same time. e.g. `movups` (move unaligned packed singles) moves 4 floats at once, `addps` (add packed singles) adds 4 floats to 4 other floats at the same time, etc.
Scalar operations on xmm registers operate on the first value in the xmm register. e.g. `movss` (move scalar single) moves 1 float, `addss` (add scalar single) adds 1 float to 1 other float, etc. Sometimes these operations zero the other values in the xmm register to eliminate false dependencies (e.g. `movss` when moving from a memory location into an xmm register).
Operating on individual elements of a packed xmm register is a little tricky. Compilers will shuffle values in an xmm register as needed- e.g. `shufps` for floats. For humans writing assembly by hand, it's typically easier to store it into memory and operate on the floats individually using scalar operations.
https://forum.cheatengine.org/viewtopic.php?p=5790301
X, Y, and Z are arbitrary names given to axes. They can mean different things to different people. Some people might think differently from you and say Y is 56.23 and Z is 68.30.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
luigimud Newbie cheater
Reputation: 0
Joined: 04 Jul 2024 Posts: 10
|
Posted: Mon Jul 08, 2024 12:07 am Post subject: |
|
|
I think I understand it better now thanks to you. So, if I want to work with just the Y value (68.30 in my example), I should probably use a combination of movaps to move the entire xmm register into memory, then access the specific float I need, correct?
To confirm my understanding: shufps xmm0, xmm0, 0x4E, This instruction shuffles the values in xmm0. The immediate value 0x4E is a control byte that specifies how to shuffle the values. In this case, it moves the third float to the first position.
movss [allocaddress], xmm0: This moves the first float in xmm0 (which is now 68.30) to the memory address allocaddress.
What I came up with to extract the Y value:
; Allocate memory for storing the xmm register values
alloc(mem, 16)
registersymbol(mem)
; Move the entire xmm0 register to memory
movaps [mem], xmm0
; Now move the Y value (68.30) into xmm1
movss xmm1, [mem+8]
Is this the right approach? Also, if I want to put this Y value back into xmm0, should I use the same method, just reversed?
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
ParkourPenguin I post too much
Reputation: 146
Joined: 06 Jul 2014 Posts: 4462
|
Posted: Mon Jul 08, 2024 1:00 am Post subject: |
|
|
Use movups
movaps will complain and probably crash the process if the address you're accessing isn't properly aligned
luigimud wrote: | To confirm my understanding: shufps xmm0, xmm0, 0x4E, This instruction shuffles the values in xmm0. The immediate value 0x4E is a control byte that specifies how to shuffle the values. In this case, it moves the third float to the first position. | That rotates all the values by 2. e.g. if xmm0 was {1,2,3,4}, it's now {3,4,1,2}
Code: | shufps xmm0,xmm0,4E
4E = 01001110
10 = 2, 11 = 3, 00 = 0, 01 = 1
xmm0.f0 = xmm0.f2
xmm0.f1 = xmm0.f3
xmm0.f2 = xmm0.f0
xmm0.f3 = xmm0.f1 |
"Move the third float to the first position" is E6
Code: | shufps xmm0,xmm0,E6
E6 = 11100110
10 = 2, 01 = 1, 10 = 2, 11 = 3
xmm0.f0 = xmm0.f2
xmm0.f1 = xmm0.f1
xmm0.f2 = xmm0.f2
xmm0.f3 = xmm0.f3 | Note that this destroys the first value. If you want to swap the first value and the third value, use C6
luigimud wrote: | What I came up with to extract the Y value:
<code that's not in a code tag>
Is this the right approach? Also, if I want to put this Y value back into xmm0, should I use the same method, just reversed? | I'd use the stack instead of allocated memory. Look at the post I linked to.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|
|