I have been trying to implement an assembly routine in MSP430 for division. I already got the code for the division from the Horner Division Algorithm. The problem is that I only got the integer part. How I can get the fractional part from a division? For example: 5/2 = 2.5. How do I get the 0.5 part?
You should get the remainder.
To turn that into a fraction you first need to decide between fixed and floating point; and if fixed, how many fractional bits.
Fixed point is easy : if you decide you want 8 fractional bits, just divide 2^8 * remainder / denominator, and use the size of that operation's remainder to determine rounding.
In your example, that would give
(256 * 1) / 2 = 128 as your fractional part, i.e. 128 / 256 = 0.5
Or for 3 fractional (decimal) digits, just compute 10^3 * remainder / denominator.
For floating point you would use a floating point library; it's far too complex to seriously consider rolling your own.
You can do
q =(num * 2^n)/ denom
as an integer division; the result will have
n extra, fractional, bits. So with n=8,
(5*256)/2 = 640
which is 2.5 * 256 or 2 * 256 + (128/256).