The following is the MIPS program to compute the 1/3 using the single-precision
ID: 3914953 • Letter: T
Question
The following is the MIPS program to compute the 1/3 using the single-precision format.
Re-write the program to compute 1/3 using the double-precision format.
Submit:
1. program source file (10 pt).
2. MARS screen shots that show the results of 1/3 by your double-precision program (3pt)
3. The results of 1/3 produce by the single-precision program. (1pt) The answer has to be in the format of 0.xxxxxxxx
4. The results of 1/3 produced by the double-precision program. (1pt) The answer has to be in the format of 0.xxxxxxxxxxxxxxxx
.data
ONE: .float 1
THREE: .float 3
.text
l.s $f0, ONE
l.s $f2, THREE
div.s $f12, $f0, $f2
li $v0, 2
syscall # print out 0.33333334
Explanation / Answer
Screenshot
----------------------------------------------------------------
Program
#Declare variables 1 and 3 as double
.data
ONE: .double 1
THREE: .double 3
#Main program
.text
#Looad double value(1) into f0
l.d $f0, ONE
#Looad double value(3) into f1
l.d $f2, THREE
#divide 1/3 and store into f12
div.d $f12, $f0, $f2
#Print result
li $v0, 3
syscall
#end
li $v0,10
syscall
---------------------------------------
Output
0.3333333333333333
-- program is finished running --
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.