Lab Sheet 4
Lab Sheet 4
4
IOE, Pulchowk
Lab Sheet- 4
Objective:
To implement restoring division algorithm in digital computer.
When the division is implemented in a digital computer, restoring and non- restoring
algorithms are frequently used. In this lab session we are dealing with first. Here division
process requires controlled subtract-restore operations. Whether the next operation is a
subtraction or restoration, is controlled by the result of the current operation. Consider two
binary numbers A and B. A is the dividend, B the divisor and Q = A / B the quotient. We
assume that Α>Β and B! =0. The flow chart of the algorithm used, is given in figure 4.1.
1)
Dividend (Register - A) = 12 Equivalent binary representation is 1100 and
divisor (Register - B) = 4 Equivalent binary representation is 0100.
Subtraction may be achieved by adding 2’s complement of B as we have done in lab 3 and
here it is 1100. Double length dividend is stored in registers AQ.
A Q
Remainder Quotient
2)
Dividend (Register - A) = 8 Equivalent binary representation is 1000 and
divisor (Register - B) = 3 Equivalent binary representation is 00011.
Subtraction may be achieved by adding 2’s complement of B as we have done in lab 3 and
here it is 11101. Dividend is stored in registers AQ.
A Q
Remainder Quotient
Let the number of bits stored in register Q is n Registers AQ is now shifted to the left with
zero insertion into QLSB . Initialize the counter to zero value. And divisor is subtracted by
adding 2’s complement value. If AMSB =1,set QLSB with value 0 and then increment the
counter value by 1.The value of B is added to restore the partial remainder in A to its
previous value. The partial remainder is shifted to the left and process is repeated until count
= n-1 i.e. all quotient bits are formed. While the partial remainder is shifted left, the quotient
bits are also shifted. Finally Quotient is in Q and the final remainder is in A.
START
Q dividend
Count 0
B divisor
A 0
A A-B
Yes Q(0) 0
A(MSB) = 1 A A+B
No
Q(0) 1
No
Count = n-1? Count Count +1
Yes
Quotient in Q
END
Remainder in A
Figure 4.1