I am trying to write a program in MIPS assembly language that implements the restoring division algorithm.
Here;s Algorithm:
Kod:
Sequential Restoring Division
1. Load the 2n dividend into both halves of shift register,
and add a sign bit to the left
2. add a sign bit to the left of the divisor
3. generate the 2’s complement of the divisor
4. shift to the left
5. add 2’s complement of the divisor to the upper
half of the shift register including sign bit (subtract)
6. if sign of the result is cleared (positive)
then set LSB of the lower half of the shift
register to one
else clear LSB of the lower half and add
the divisor to upper half of shift register (restore)
7. repeat from 4. and perform the loop n times
8. after termination:
lower half of shift register⇒quotient
upper half of shift register⇒ remainder
and example of usage : http://imagizer.imageshack.us/v2/800...0/703/buy4.png
Source: http://www.engineering.uiowa.edu/~ca...060301-prn.pdf
i got few questions according to that:
- 1.In my opinion we use here system of presentation is that right?
i think that way, beacuse
Kod:
6 is: 0110 and -6 is: 1010.
- 2.How could we write C2 number in MIPS assembly![Pytajnik](images/smilies/pytajnik.gif)
-3. as you can see in example:
Kod:
sign: 0 rest: 1 0 0 1 1 1 0 0
add to upper_ half:sign:1 1 0 1 0
result 0 0 1 1
Kod:
now we keep 1 in memory, so wen we add to [Sign], 0 changes to '1'
Kod:
sign: 1
add to upper_ half:sign:1
and now we have result but as you can see in example, the only one written down is why we don;t write in Front?
4. -How could we have Upper and lower half of of divdend in MIps Assembly?