Oh happy that I have done the agonizing machine exercise on time!!!
Hopefully all Inputs would work (Please Do!!!)
We were asked to make a program that does Floating Point Addition and Subtraction. The Floating Point Numbers should be in IEEE Notation and Truncates using Rounding Off to the nearest even. The machine exercise actually have a procedure in our text book so it;s just a matter of how to translate the procedure into code.. ^_^… It’s super confusing!!! I reached 120+ lines! So basically there’s brute force that is involved in my code so it’s somehow inefficient.
Here’s a glimpse of my documentation
Flow of Code:
· Input to Data registers
· Extract Exponents -> E1 and E2 to D4 and D5
· Extract Mantissas – > M1 and M2 to D6 and D7
· Check if Inputs D1 and D2 is Not a Number or Infinity
· Determine real operation (operation x sign of operand2)
· Equate both exponents (lower exponent to higher and shift it’s mantissa). Set the exponent of result,D5, to higher exponent.
o involves Rounding Off (subroutine)
· Perform addition or subtraction
o In addition, get the sign of any operand
o In subtraction, if negative result, negate mantissa and let S=1 else retain and S=0. S->D2
· Normalization
o Normalization_Add – shift once to right to form 1.xxxx, involves rounding off
o Normalization_Subtract – shift to left until 1.xxxx is reached
· Build Final Answer in IEEE Floating Point notation using D5(exponent),D6(mantissa),D2(sign)