0

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

quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
Clinteney Hui
  • 4,385
  • 5
  • 24
  • 21

1 Answers1

1

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).

Community
  • 1
  • 1
Andy
  • 4,789
  • 23
  • 20