Jump to content
  • 0

Arm64 patch does not quite work


Bixxler
 Share

Question

Hello, I'm trying to adjust the running speed via assembly in the game.

The game runs on armv8 base. My assembly code looks like this:  

floatvalue = 0.06

~A8 MOV x8, #0xC28F
~A8 MOVK x8, #0x3D75, LSL #16
~A8 FMOV s0, w8
~A8 ret

The character should now run much slower, but it does not.

The character now runs much too fast . If I set the float value significantly higher, nothing changes.

I have checked the values with Inline Assembly in C. There they seem to be ok.
What else can be the problem ?

 

Thanks for your help.

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
53 minutes ago, Bixxler said:

Hello, I'm trying to adjust the running speed via assembly in the game.

The game runs on armv8 base. My assembly code looks like this:  

floatvalue = 0.06

~A8 MOV x8, #0xC28F
~A8 MOVK x8, #0x3D75, LSL #16
~A8 FMOV s0, w8
~A8 ret

The character should now run much slower, but it does not.

The character now runs much too fast . If I set the float value significantly higher, nothing changes.

I have checked the values with Inline Assembly in C. There they seem to be ok.
What else can be the problem ?

 

Thanks for your help.

you are using register X8 then sending register W8 to the fpu and this is wrong try this instead : 
FMOV S0, #0xC28F3D75
ret
or try to change W8 to X8

Link to comment
Share on other sites

  • 0
9 hours ago, XEKEX said:

you are using register X8 then sending register W8 to the fpu and this is wrong try this instead : 
FMOV S0, #0xC28F3D75
ret
or try to change W8 to X8

I tried that, however as you can see your attempt is not valid. On my Linux environment with aarch64 it works fine. (Your instruction does not ) 

Change W8 to X8 does not work either.

Feel free to test the code. 

image.thumb.png.c4139b2f67e19eb8e9985424deb0dee8.png

 

 

Edited by Bixxler
Link to comment
Share on other sites

  • 0
4 hours ago, Bixxler said:

I tried that, however as you can see your attempt is not valid. On my Linux environment with aarch64 it works fine. (Your instruction does not ) 

Change W8 to X8 does not work either.

Feel free to test the code. 

image.thumb.png.c4139b2f67e19eb8e9985424deb0dee8.png

 

 

I'm not a 64 user I can't test it however ,the error you're encountering is likely due to the fact that the value 0xC28F3D75 cannot be directly used as a floating-point constant in the FMOV instruction
In AArch64 assembly, when using immediate values with FMOV, you typically need to represent the floating-point constant in a specific format: 0.06
FMOV S0, #0.06 or FMOV S0, 0.06 ( depending on the system )
In the 1st case #0xC28F3D75 is a 32bit value and the your instruction set it to 64bit value with the register X 
The third line (FMOV s0, w8) moves the value in register w8 into scalar floating-point register s0. This might be an issue depending on the context. If w8 contains a valid 32-bit integer, this conversion could be appropriate. However, if w8 contains a floating-point value, this operation might lead to unexpected results

 You should use W register instead to convert the register W8 to a valid 32bit floating-point:

MOV w8, #0xC28F
MOVK w8, #0x3D75, LSL #16
FMOV s0, w8
ret
 

Link to comment
Share on other sites

  • 0
15 minutes ago, XEKEX said:

MOV w8, #0xC28F
MOVK w8, #0x3D75, LSL #16
FMOV s0, w8
ret
 

The instruction also causes the character to run too fast. 

 

Strangely why works : "FMOV S0, #1" but not my 0.06(with w8 etc)

I no longer understand the world 😄

Link to comment
Share on other sites

  • 0
26 minutes ago, Bixxler said:

The instruction also causes the character to run too fast. 

 

Strangely why works : "FMOV S0, #1" but not my 0.06(with w8 etc)

I no longer understand the world 😄

when dealing with processor you need to be more strict even an upper and lower naming can affect the instructions you can learn more about arm: 
https://developer.arm.com/documentation
it's too complicated topic and not simple

Link to comment
Share on other sites

  • 0
2 minutes ago, XEKEX said:

when dealing with processor you need to be more strict even an upper and lower naming can affect the instructions you can learn more about arm: 
https://developer.arm.com/documentation
it's too complicated topic and not simple

Thanks for your help...
Arm is not easy, and it does not seem to have become easier with arm64. Floats and doubles are killing me. The rest is easier ... I am now making my own Unity program to test on.

Link to comment
Share on other sites

  • 0
Just now, Bixxler said:

Thanks for your help...
Arm is not easy, and it does not seem to have become easier with arm64. Floats and doubles are killing me. The rest is easier ... I am now making my own Unity program to test on.

Good luck , if you have any other questions feel free to ask.

Link to comment
Share on other sites

  • 0

There are no issues with initial version of your code, it correctly sets value of S0 register to 0.06. It may be that you just need different value to make the character run slower. Does setting the value to 2 increase movement speed or decrease?

Link to comment
Share on other sites

  • 0
On 10/10/2023 at 2:02 PM, XEKEX said:

Good luck , if you have any other questions feel free to ask.

I have now been able to test my ARM64 (my own Unity testapp). Funny enough I get with the following instruction:

~A8 MOV w8, #0xC28F
~A8 MOVK w8, #0x3D75, LSL #16
~A8 FMOV s0, w8
~A8 ret

following values  : 

Screenshot_20231022-151050.thumb.png.ff11fa68bfd4f4513601c3a34d2ca871.png

 

This explains why the character runs too fast. There is still something wrong with the ARM code ...

Edited by Bixxler
Link to comment
Share on other sites

  • 0

Ok, is this a bug from GG? If I patch pure with bytes it works, if I use GG syntax it does not work ???

 

Working

60668652r
6010A872r
0000271Er
C0035FD6r

 

image.thumb.png.4e7d6776f6ba159f393c8f01eefb96d7.png

 

Not Working :

~A8 MOV W0, #0x3333
~A8 MOVK W0, #0x4083, LSL #16
~A8 FMOV S0 ,W0

-A8 RET 

 

Why ??

Link to comment
Share on other sites

  • 0
14 hours ago, XEKEX said:

try this instructions (both are the same ) 
~A8 MOV W0, #0x3333, LSL #16
~A8 MOVK W0, #0x4083, LSL #32
~A8 FMOV S0, W0
~A8 RET

I have already tried. Unfortunately it does not work either. But it doesn't matter, I have no problem to patch with bytes. My arm code is sometimes 10-16 lines long.

Edited by Bixxler
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.