Assembly division

  • Thread starter mtanti
  • Start date
172
0
First of all i'de like to know if there is an efficiant algorithm which assembly uses to divide two numbers.
Second I'de like to know how do you divide numbers which don't fit into a register. I'm talking about an array of bytes in RAM to be divided.

10x!
 

saltydog

Science Advisor
Homework Helper
1,582
2
mtanti said:
First of all i'de like to know if there is an efficiant algorithm which assembly uses to divide two numbers.
Second I'de like to know how do you divide numbers which don't fit into a register. I'm talking about an array of bytes in RAM to be divided.

10x!
Well, you could use multi-precision arithmetic if it's really large numbers or very high precision. I tell you what though, that would be quite a neat challenge in assembly. What about just C++? You know that's pretty close to assembly speed. Anyway, just search the web for "multi-precision arithmetic". The algorithm is straight-forward and intuitive once you work with it for a while.

As far as what assembly does, 2's compliments come to mind but I'd really have to review on that one.
 

dduardo

Staff Emeritus
1,894
3
In ASM you can do integer division by using DIV. If you want to do floating point division use FDIV.

Here is a C library for doing arbitrary precision arithmetic:

http://www.swox.com/gmp/index.orig.html [Broken]

There are more specialized libraries depending on how many bits of precision you really need. This is just a general case library.
 
Last edited by a moderator:

Related Threads for: Assembly division

  • Posted
Replies
2
Views
2K
  • Posted
Replies
2
Views
7K
Replies
6
Views
4K
Replies
8
Views
3K
Replies
3
Views
570

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top