Non-restoring division algorithm

 ̄綄美尐妖づ 提交于 2019-12-20 21:56:12

问题


Does anyone know the steps for dividing unsigned binary integers using non-restoring division?

It's hard to find any good sources online.

i.e if A = 101110 and B = 010111

how do we find A divided by B in non-restoring division? What do the registers look like in each step?

Thanks!


回答1:


(My answer is a little late-reply. But I hope it will be useful for future visitors)

Algorithm for Non-restoring division is given in below image :

In this problem, Dividend (A) = 101110, ie 46, and Divisor (B) = 010111, ie 23.

Initialization :

Set Register A = Dividend = 000000
Set Register Q = Dividend = 101110
( So AQ = 000000 101110 , Q0 = LSB of Q = 0 )
Set M = Divisor = 010111, M' = 2's complement of M = 101001
Set Count = 6, since 6 digits operation is being done here.

After this we start the algorithm, which I have shown in a table below :

In table, SHL(AQ) denotes shift left AQ by one position leaving Q0 blank.

Similarly, a square symbol in Q0 position denote, it is to be calculated later

Hope all the steps are clear from the table !!!




回答2:


1) Set the value of register A as 0 (N bits)
2) Set the value of register M as Divisor (N bits)
3) Set the value of register Q as Dividend (N bits)
4) Concatenate A with Q {A,Q}
5) Repeat the following “N” number of times (here N is no. of bits in divisor):
  If the sign bit of A equals 0,
   shift A and Q combined left by 1 bit and subtract M from A,
  else shift A and Q combined left by 1 bit and add M to A
  Now if sign bit of A equals 0, then set Q[0] as 1, else set Q[0] as 0
6) Finally if the sign bit of A equals 1 then add M to A.
7) Assign A as remainder and Q as quotient.



来源:https://stackoverflow.com/questions/12133810/non-restoring-division-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!