View previous topic :: View next topic |
Author |
Message |
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Mon Jan 31, 2022 4:51 am Post subject: How to Negate XMM Register? |
|
|
Having trouble with this one.
I have this code segment:
Code: | sub rsp,#20
movdqu [rsp],xmm0
movss xmm0,[speed_lmodifier] ///////////Need to be able to negate custom input here
movss [rsp+10],xmm0
movss xmm0,[rsp+10]
addss xmm0,[rdi+70]
movss [rdi+70],xmm0
movdqu xmm0,[rsp]
add rsp,#20 |
The [speed_lmodifier] is being used for custom/user input, and occurs multiple times throughout the script. In some places, the value needs to be positive, and in other places, the value needs to be negative.
I have tried doing this many different ways that I can think of, but nothing I have done is working 100% as it should.
Thanks.
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 943
|
Posted: Mon Jan 31, 2022 6:28 am Post subject: |
|
|
If there is a near memory that can store a float value -1,
Code: |
...
movss xmm0,[MinusOne] /// MinusOne stored (float)-1
mulss xmm0,[speed_lmodifier]
addss xmm0,[rdi+70]
movss [rdi+70],xmm0
...
|
else may need an extra register
Code: |
...
mov eax,(float)-1
movd xmm0,eax /// use rax & movq for double
mulss xmm0,[speed_lmodifier]
addss xmm0,[rdi+70]
movss [rdi+70],xmm0
...
|
there should be other ways.
_________________
- Retarded. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25298 Location: The netherlands
|
Posted: Mon Jan 31, 2022 7:40 am Post subject: |
|
|
if you're lazy
Code: |
{$ccode val=XMM0.0}
val=-val;
{$asm}
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Mon Jan 31, 2022 11:37 am Post subject: |
|
|
panraven wrote: |
Code: |
...
mov eax,(float)-1
movd xmm0,eax /// use rax & movq for double
mulss xmm0,[speed_lmodifier]
addss xmm0,[rdi+70]
movss [rdi+70],xmm0
...
|
| -Thank you. This works. When I tried this before, it did not work. I realized that I needed to remove some lines.
I cannot +rep you yet, but I will not forget.
Dark Byte wrote: | Code: |
{$ccode val=XMM0.0}
val=-val;
{$asm}
|
| -Thank you. How to implement? Does this have to wrap the specific xmm0 register that I am trying to manipulate, or is val used as a variable?
I appreciate everyone's help. Thank you.
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Mon Jan 31, 2022 12:24 pm Post subject: |
|
|
++METHOS wrote: |
Dark Byte wrote: | Code: |
{$ccode val=XMM0.0}
val=-val;
{$asm}
|
| -Thank you. How to implement? Does this have to wrap the specific xmm0 register that I am trying to manipulate, or is val used as a variable?
I appreciate everyone's help. Thank you. |
Like this for example:
Code: |
...
newmem:
sub rsp,#20
movss xmm0,[speed_lmodifier] ///////////Need to be able to negate custom input here
{$ccode val=XMM0.0}
val=-val;
{$asm}
movss [rsp+10],xmm0
movss xmm0,[rsp+10]
addss xmm0,[rdi+70]
movss [rdi+70],xmm0
movdqu xmm0,[rsp]
add rsp,#20
...
|
Val is just an arbitrary name for something you recognise. It is essentially giving the xmm0 register an identifier which can be used within the scope of the in-line block.
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Mon Jan 31, 2022 12:39 pm Post subject: |
|
|
Thanks. So, the code is only executed where it is placed and is no longer applied throughout? In other words, wherever it is placed is basically like doing the following:
or
Thanks for your help.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25298 Location: The netherlands
|
Posted: Mon Jan 31, 2022 12:47 pm Post subject: |
|
|
yes, unlike lua blocks ccode (and luacode) blocks execute only when the code reaches that point
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4307
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue Feb 01, 2022 1:32 pm Post subject: |
|
|
Thank you all for your help. I really appreciate it.
|
|
Back to top |
|
|
|