flat assembler
Message board for the users of flat assembler.

Index > Main > Optimization, MUL & DIV help needed

Author
Thread Post new topic Reply to topic
r22



Joined: 27 Dec 2004
Posts: 805
r22
I need the algorithm or program that tells how much to shift and what to add after the shift when dividing or multiplying by a certain number.

For example
mov eax, dword[SomeNumber]
mov ecx, ????
div ecx
/\/
mov eax,dword[SomeNumber]
shr eax, ????
add eax, ????

Thanks for the help in advance
Post 27 Dec 2004, 04:53
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
Search for AMD's optimization manual.

UPDATE: The file I have is named 22007.pdf, but I guess there's a newer version of it with a different name. Title: "AMD Athlonâ„¢ Processor - x86 Code Optimization Guide". I could post the (small) code here, but you'll appreciate read the manual. Wink


Last edited by beppe85 on 27 Dec 2004, 20:37; edited 1 time in total
Post 27 Dec 2004, 07:53
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
howdy r22
its a problem , because you cannot always replace a mul by shl and add in the way you wanna.

you can use this optimization only if you are multiplying by the same number, ex.: 10, or 320
Post 27 Dec 2004, 11:50
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
The Svin's magic divider will convert div to mul and shifts. Source code included.
Post 27 Dec 2004, 12:28
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
You should check that site I have as a signature.
It is NOT in vain my idol Wink
direct link to MUL:
http://www.azillionmonkeys.com/qed/amult.html
---and DIV:
http://www.azillionmonkeys.com/qed/adiv.html

P.S. you might have interest in SQRT too:
http://www.azillionmonkeys.com/qed/sqroot.html

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 28 Dec 2004, 10:12
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.