Objective Write a software implementation of floating point addition for 32-bit
ID: 3625457 • 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
li $v0, 7 # read_float
syscall
move $t1,$v0
beqz $t2,else
beqz $t1,else
add $t2,$t0,$t1
la $a0,Sum _msg
li $v0,4
syscall
move $a0,$t2 # output sum
li $v0,1
syscall
else: la $a0,Error_msg
li $v0,4
syscall
li $v0,10 # exit
syscall
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.