View previous topic :: View next topic |
Author |
Message |
Xenocritus Cheater Reputation: 0
Joined: 27 Dec 2020 Posts: 25
|
Posted: Wed Feb 17, 2021 2:33 am Post subject: [Solved] AA: How to multiply x1.7 with integer result? |
|
|
Hi,
I want to adjust/balance some game aspects and decided for example, x1.7 is a good multiplier for a specific variable. And I want to do it in auto assembler script.
My value EAX is 4 bytes Integer, and multipliying x1.7 is always 4 bytes number, but I don't know how to multiply x1.7 nor how to round the result.
So, in pseudocode I wanted some like:
EAX = floor(EAX * 1.7)
Note: The round can be whatever, truncate, floor, ceil, near...
Thanks!
Last edited by Xenocritus on Wed Feb 17, 2021 1:51 pm; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Wed Feb 17, 2021 3:17 am Post subject: |
|
|
multiply by 17 followed by divide by 10
Code: |
push edx
push ecx
mov ecx,#17
mul ecx //multiply eax with ecx and store the result in eax:edx
mov ecx,#10
xor edx,edx
div ecx //divide eax:edx by 10 and store the result in eax
pop ecx
pop edx
|
next version you can do
Code: |
{$ccode value=EAX}
*value=*value*1.7;
{$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 |
|
|
Xenocritus Cheater Reputation: 0
Joined: 27 Dec 2020 Posts: 25
|
Posted: Wed Feb 17, 2021 1:51 pm Post subject: |
|
|
Many thanks!!
I learned a lot with that respone lol.
- Now I know I can use Push/Pop instead of creating a variable to backup my values, lol
- I assume xor edx, edx is just an alternative to mov edx, 0.
[solved]
|
|
Back to top |
|
|
|