Assembly Divisions: Algorithms & #s Not Fitting Registers

  • Thread starter Thread starter mtanti
  • Start date Start date
  • Tags Tags
    Assembly Division
Click For Summary
SUMMARY

This discussion focuses on efficient algorithms for dividing numbers in assembly language, specifically addressing the challenge of dividing large numbers that do not fit into a register. Multi-precision arithmetic is recommended for handling such cases, with the GNU Multiple Precision Arithmetic Library (GMP) provided as a resource. In assembly, integer division can be performed using the DIV instruction, while floating-point division utilizes the FDIV instruction. The conversation emphasizes the practicality of using C++ for high-speed arithmetic operations close to assembly performance.

PREREQUISITES
  • Understanding of assembly language instructions, specifically DIV and FDIV.
  • Familiarity with multi-precision arithmetic concepts.
  • Basic knowledge of C++ for performance comparison with assembly.
  • Awareness of the GNU Multiple Precision Arithmetic Library (GMP).
NEXT STEPS
  • Research multi-precision arithmetic algorithms and their implementations.
  • Explore the GNU Multiple Precision Arithmetic Library (GMP) for practical applications.
  • Learn about integer and floating-point division in assembly language.
  • Investigate performance comparisons between C++ and assembly for arithmetic operations.
USEFUL FOR

Software developers, particularly those working with low-level programming, assembly language enthusiasts, and anyone interested in optimizing arithmetic operations for large numbers.

mtanti
Messages
172
Reaction score
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!
 
Computer science news on Phys.org
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.
 
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

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:

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
8K
Replies
8
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
14
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K