Implement half precision floating point addition in MIPS assembly language. Prom
ID: 3533188 • Letter: I
Question
Implement half precision floating point addition in MIPS assembly language. Prompt user to
input two floating point (decimal) numbers and compute and display the sum. Use algorithm
depicted in figure 3.15, pg 252 in the textbook.
In half precision format, 16 bits are used to represent a floating point number. The exponent field
is 5 bits wide while the significand field has 10 bits.
You will need to convert single precision floating point number to half-precision floating point
number and then perform your calculations.
Your program should be able to handle negative numbers as well. Also, if user enters an out of
range number for half precision format, your program must raise an exception message.
You MUST NOT use the MIPS floating point instructions.
As always, after one set of inputs, program must ask if the user wants to enter more numbers
Explanation / Answer
For Example:
Enter a floating-point value: 1
Enter a floating-point value: 1
Sum: 2.000000000000000000
Enter a floating-point value: 2.2
Enter a floating-point value: 1.4
Sum: 3.599999904632568400
Enter a floating-point value: -1.34
Enter a floating-point value: 3.4
Sum: 2.059999942779541000
Enter a floating-point value: 10.5
Enter a floating-point value: 100.2
Sum: 110.69999694824219000
###### Data segment ############
.data
Prompt1:.asciiz "Enter a floating-point value:"
Prompt2:.asciiz "Enter a floating-point value:"
Pro_msg: .asciiz "product:"
Sum_msg: .asciiz "Sum:"
Error_msg:.asciiz "Input Zero"
######## Code segment ########
.text
.globl main
main:
la $a0,prompt1 # display prompt string
li $v0,4
syscall
li $v0,5 # read 1st integer into $t0
syscall
move $t0,$v0
la $a0,prompt2 #display prompt string
li $v0,4
syscall
li $v0,5 # read 1st integer into $t0
syscall
move $t1,$v0
beqz $t2,else
beqz $t1,else
#calculate product
add $t2,$t0,$t1
la $a0,Sum _msg
# display prompt string
li $v0,4
syscall
move $a0,$t2 # output sum
li $v0,1
syscall
else: la $a0,Error_msg
# display prompt string
li $v0,4
syscall
li $v0,10 # exit
syscall
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.