Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Solved] AA: How to multiply x1.7 with integer result?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Xenocritus
Cheater
Reputation: 0

Joined: 27 Dec 2020
Posts: 25

PostPosted: Wed Feb 17, 2021 2:33 am    Post subject: [Solved] AA: How to multiply x1.7 with integer result? Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Wed Feb 17, 2021 3:17 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Xenocritus
Cheater
Reputation: 0

Joined: 27 Dec 2020
Posts: 25

PostPosted: Wed Feb 17, 2021 1:51 pm    Post subject: Reply with quote

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 Smile
- I assume xor edx, edx is just an alternative to mov edx, 0.

[solved]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites