Objective Write a software implementation of floating point addition for 32-bit
ID: 3625140 • Letter: O
Question
ObjectiveWrite a software implementation of floating point addition for 32-bit (single-precision) floating point numbers.
Design Requirements
Your program will prompt the user for two floating point numbers. It will then compute and display the sum. Here’s example I/O from four runs (you only need to prompt once per execution run of your program):
Enter a floating-point value: 1
Enter a floating-point value: 1
2.000000000000000000
Enter a floating-point value: 2.2
Enter a floating-point value: 1.4
3.599999904632568400
Enter a floating-point value: -1.34
Enter a floating-point value: 3.4
2.059999942779541000
Enter a floating-point value: 10.5
Enter a floating-point value: 100.2
110.69999694824219000
Some issues you will have to resolve:
How will you deal with negative numbers?
How will your normalizing algorithm work?
You are not required to detect overflow or underflow, and you can always round down.
***You may not use any floating point instructions for this project!***
Explanation / Answer
#Initialize variables add $s0,$t0,$zero #first integer value add $s1,$t1,$zero #second integer value add $s2,$zero,$zero #initialize sum variable to 0 add $t3,$zero,$zero #initialize SUM OF SIGNIFICANDS value to 0 #get EXPONENT from values sll $s5,$s0,1 #getting the exponent value srl $s5,$s5,24 #$s5 = first value EXPONENT sll $s6,$s1,1 #getting the exponent value srl $s6,$s6,24 #$s6 = second value EXPONENT #get SIGN from values srl $s3,$s0,31 #$s3 = first value SIGN srl $s4,$s1,31 #$s4 = second value SIGN #get FRACTION from values sll $s7,$s0,9 srl $s7,$s0,9 #$s7 = first value FRACTION sll $t8,$s1,9 srl $t8,$s1,9 #$t8 = second value FRACTION #compare the exponents of the two numbers compareExp: ###################### beq $s5,$s6, addSig blt $s5,$s6, shift1 #if firstRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.