2's Complement Division Algorithm
2's Complement Division Algorithm
Divisor M Dividend A, Q 1. Shift A, Q left 1 bit position 2. If M and A have the same signs, perform A A M; otherwise, A A + M 3. The preceding operation is successful if the sign of A is the same before and after the operation 1. If the operation is successful or A = 0, then set Q0 1. 2. If the operation is unsuccessful and A 0, then set Q0 0 and restore the previous value of A. 4. Repeat steps 1 through 3 as many times as there are bit positions in Q. 5. The remainder is in A. If the signs of the divisor and dividend were the same then the quotient is in Q; otherwise, the correct quotient is the twos complement of Q.
Note: I have also uploaded an implementation of the above division algorithm in C++ on Scribd, the link for the same is http://www.scribd.com/doc/106270951/2-s-Complement-Division-CProgram , Kindly check that code out in case you are interested to see how the algorithm works out on real time data.