A division algorithm provides a quotient and a remainder when we divide two number. They are generally of two type slow algorithm and fast algorithm. Slow division algorithm are restoring, non-restoring, non-performing restoring, SRT algorithm and under fast comes Newton–Raphson and Goldschmidt.
In this article, will be performing restoring algorithm for unsigned integer. Restoring term is due to fact that value of register A is restored after each iteration.
Here, register Q contain quotient and register A contain remainder. Here, n-bit dividend is loaded in Q and divisor is loaded in M. Value of Register is initially kept 0 and this is the register whose value is restored during iteration due to which it is named Restoring.
Let’s pick the step involved:
- Step-1: First the registers are initialized with corresponding values (Q = Dividend, M = Divisor, A = 0, n = number of bits in dividend)
- Step-2: Then the content of register A and Q is shifted left as if they are a single unit
- Step-3: Then content of register M is subtracted from A and result is stored in A
- Step-4: Then the most significant bit of the A is checked if it is 0 the least significant bit of Q is set to 1 otherwise if it is 1 the least significant bit of Q is set to 0 and value of register A is restored i.e the value of A before the subtraction with M
- Step-5: The value of counter n is decremented
- Step-6: If the value of n becomes zero we get of the loop otherwise we repeat from step 2
- Step-7: Finally, the register Q contain the quotient and A contain remainder
Perform Division Restoring Algorithm Dividend = 11 Divisor = 3
|00011||00001||011_||shift left AQ|
|00011||00001||0110||Q=0 And restore A|
|3||00011||00010||110_||shift left AQ|
|2||00011||00101||100_||shift left AQ|
|1||00011||00101||001_||shift left AQ|
Remember to restore the value of A most significant bit of A is 1. As that register Q contain the quotient, i.e. 3 and register A contain remainder 2.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Implementation of Non-Restoring Division Algorithm for Unsigned Integer
- Non-Restoring Division For Unsigned Integer
- 8086 program to sort an integer array in ascending order
- 8086 program to sort an integer array in descending order
- 8085 program to print the table of input integer
- 8086 program to print the table of input integer
- Computer Network | Leaky bucket algorithm
- Program for Least Recently Used (LRU) Page Replacement algorithm
- Peterson's Algorithm in Process Synchronization
- Program for SSTF disk scheduling algorithm
- C-SCAN Disk Scheduling Algorithm
- Banker's Algorithm in Operating System
- Dekker's algorithm in Process Synchronization
- Bakery Algorithm in Process Synchronization
- Multiplication Algorithm in Signed Magnitude Representation
- RC4 Encryption Algorithm
- Computer Organization | Booth's Algorithm
- Back-off Algorithm for CSMA/CD
- Deadlock Detection Algorithm in Operating System
- Algorithm for Dynamic Time out timer Calculation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.