Non-restoring division algorithm

前端 未结 2 895
执念已碎
执念已碎 2021-02-06 06:45

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 = 10111

2条回答
  •  囚心锁ツ
    2021-02-06 07:12

    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.

提交回复
热议问题