EASy68K
http://www.easy68k.com/EASy68Kforum/

division without using divu
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1076
Page 1 of 1

Author:  etw3 [ Wed Feb 22, 2012 6:17 pm ]
Post subject:  division without using divu

I can figure out how to multiply by an integer without using mult.
but what about division?

Author:  profkelly [ Wed Feb 22, 2012 6:28 pm ]
Post subject: 

Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.

Author:  etw3 [ Wed Feb 22, 2012 7:25 pm ]
Post subject: 

profkelly wrote:
Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.


so to obtain a fraction:
you'd check if the n flag.
increase the counter by 1 to obtain the whole part.
then... somehow store the ratio of the remainder?

is there a standard way to store fractions?

Author:  profkelly [ Wed Feb 22, 2012 9:16 pm ]
Post subject: 

I don't recall a standard way to store fractions unless you want to use a floating point scheme.

http://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html#posfrac

Author:  clive [ Thu Feb 23, 2012 4:53 pm ]
Post subject: 

etw3 wrote:
is there a standard way to store fractions?

Fixed point representations, and floating point.

Fixed point tends to be implementation specific, based on the range of the numbers being used. With 32 bit you could use a 16.16 or 2.30 representation.

Author:  clive [ Thu Feb 23, 2012 5:00 pm ]
Post subject: 

profkelly wrote:
Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.

Kind of brute force, most 80's era 8-bit processors did long division in software using a shift and subtract algorithm.

http://courses.cs.vt.edu/~cs1104/Buildi ... e.030.html

Kind of how decimal long division is achieved when you don't have a calculator.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/