Question: can someone please help me fix my MIPS CODE so that it will print the results as shown in the picture. This is the code:
can someone please help me fix my MIPS CODE so that it will print the results as shown in the picture. This is the code:
# Project Part B Template
# Cube root of floating point numbers in Single Precision IEEE floating point format
data
zeroFloat: float
threefloat: float
hdeFloat: float # Hardcoded half debiased estimate of user input sobtained from PartA
newLine: asciiz
text
# For output purposes
lwc $f zeroFloat # $f
lwc $f hdeFloat # $f
# read float syscall, the float to find the cube root of
li $v # read float
syscall
mtc $t $f # copy Coproc reg. $f to reg. $t $t input number
mtc $s $f # copy Coproc reg. $f to reg. $s $s input number to calculate half debiased estimate HDE
# the HDE value serves as the first educated guess for the Newton's Method approximation
mfc $t $f
# read integer syscall, the number of iterations to run Newton's method
li $v # read integer
syscall
move $t $v # move the integer read into $t $t iterations
# loop for calling Newton's method $t times
loop:
jal cbrt # call cbrt to calculate the next iteration of Newton's Method
mtc $t $f # copy answer of Newton's estimate from $t to $f
# print the output of the current iteration of Newton's Method as a float
li $v # print float
add.s $f $f $f # $f $f $f $f $f
syscall
# print a new line
li $v # print string
la $a newLine # load new line string
syscall
# decrement iteration counter $t
subi $t $t # $t $t
beq $t $ exit # if $t exit the program
bne $t $ loop # else loop again
exit:
# exit the program
li $v # exit
la $a$v # load exit
syscall
cbrt:
mtc $t $f # copy original user input number to find cube root of from $t to Coproc reg $f
mtc $t $f # copy the educated guess approximation HDE value from $t to Coproc reg. $f
lwc $f threefloat # load into Coproc reg. $f
# xn xn xn N xn
NewtonsMethod:
mul.s $f$f$f # $f $f $f ie $f x
mul.s $f $f$f # $f $f $f ie $f x
sub.s $f $f $f # $f $f $f
div.s $f $f $f # $fx N
mul.s $f $f $f # $f
div.s $f $f$f # $fx N x
add.s $f $f $f # $f xn xn N xn
# copy answer for the next iteration of Newton's Method from Coproc reg. $f to reg. $t
mfc $t $f # $t answer
# Netwon's Method sqrt estimate answer is in $f
jr $ra
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
