0
votes

i am doing floating point addition using MARS.

  SameExponent:
  add $s6,$s4,$s5 

after I aligned the exponents, I added up the significands,but how do I detect if the sum is still normalized or not in order to shift the signicicand to the left or right? Thank you

1
Is this the MARS MIPS simulator? If so you might want to tag it with mips as well. - Andy

1 Answers

1
votes

If the significands are integers in the range -A ... +A, then the result of adding them together is in the range -2A ... +2A. To normalize the result you need to shift left or right to get the most-significant 1 bit back to the normalized position, keeping track of how much you shifted so you can adjust the exponent accordingly.

The maximum required right shift is one position; the left shift can be more if your arguments may be positive or negative. The simple way to do it is a while-style loop, shifting left by one until the MSB is where you want.

Algorithm for finding the smallest power of two that's greater or equal to a given value has some alternate possibilities if you want something faster (nothing for MIPS though).