Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Assembly division

  1. Jun 12, 2005 #1
    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.

  2. jcsd
  3. Jun 12, 2005 #2


    User Avatar
    Science Advisor
    Homework Helper

    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.
  4. Jun 12, 2005 #3


    User Avatar
    Staff Emeritus

    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: May 2, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook