Assembly Divisions: Algorithms & #s Not Fitting Registers

  • Thread starter Thread starter mtanti
  • Start date Start date
  • Tags Tags
    Assembly Division
AI Thread Summary
Efficient algorithms for division in assembly language typically involve using the DIV instruction for integer division and FDIV for floating-point division. For dividing large numbers that exceed register capacity, multi-precision arithmetic is recommended. This method allows for handling arrays of bytes in RAM. Resources such as the GMP library can assist with arbitrary precision arithmetic, providing a straightforward approach once familiarized. Exploring multi-precision arithmetic can be a valuable challenge for those interested in assembly programming.
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:
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
This week, I saw a documentary done by the French called Les sacrifiés de l'IA, which was presented by a Canadian show Enquête. If you understand French I recommend it. Very eye-opening. I found a similar documentary in English called The Human Cost of AI: Data workers in the Global South. There is also an interview with Milagros Miceli (appearing in both documentaries) on Youtube: I also found a powerpoint presentation by the economist Uma Rani (appearing in the French documentary), AI...

Similar threads

Replies
30
Views
6K
Replies
7
Views
3K
Replies
5
Views
6K
Replies
3
Views
2K
Replies
6
Views
3K
Replies
4
Views
5K
Back
Top