Question: I m trying to run the MIPS code below in SPIM but it doesn t work ( The picture below is the required I /

Im trying to run the MIPS code below in SPIM but it doesnt work (The picture below is the required I/O).
HERE IS THE CODE:
.data
msg_welcome: .asciiz "Quadratic Equation Solver v0.1 by F. Last
"
msg_a: .asciiz "Enter value for a?"
msg_b: .asciiz "Enter value for b?"
msg_c: .asciiz "Enter value for c?"
msg_not_quadratic: .asciiz "Not a quadratic equation.
"
msg_imaginary: .asciiz "Roots are imaginary.
"
msg_one_root: .asciiz "One solution x ="
msg_two_roots: .asciiz "x1="
msg_and: .asciiz " x2="
newline: .asciiz "
"
.text
.globl main
main:
# Print welcome message
li $v0,4
la $a0, msg_welcome
syscall
# Read coefficient a
li $v0,4
la $a0, msg_a
syscall
li $v0,6 # double reading syscall
syscall
mov.d $f12, $f0 # move input to $f12 for a
# Read coefficient b
li $v0,4
la $a0, msg_b
syscall
li $v0,6
syscall
mov.d $f14, $f0 # move input to $f14 for b
# Read coefficient c
li $v0,4
la $a0, msg_c
syscall
li $v0,6
syscall
mov.d $f16, $f0 # move input to $f16 for c
# Check for non-quadratic cases: a ==0
li $v0,4
l.d $f2, zero_double
c.eq.d $f12, $f2
bc1t check_linear
# Calculate discriminant b^2-4ac
mul.d $f2, $f14, $f14 # $f2= b^2
li.d $f4,-4.0
mul.d $f6, $f12, $f16 # $f6= ac
mul.d $f6, $f4, $f6 # $f6=-4ac
add.d $f2, $f2, $f6 # $f2= b^2-4ac, Discriminant
# Check discriminant for imaginary roots
li $v0,4
l.d $f4, zero_double
c.lt.d $f2, $f4
bc1t print_imaginary
# Calculate roots
sqrt.d $f6, $f2 # $f6= sqrt(discriminant)
li.d $f8,2.0
div.d $f10, $f14, $f8 # $f10= b/2
sub.d $f12, $f10, $f6 # $f12=(-b - sqrt(discriminant))/2a
add.d $f14, $f10, $f6 # $f14=(-b + sqrt(discriminant))/2a
div.d $f12, $f12, $f12 # $f12= x1
div.d $f14, $f14, $f14 # $f14= x2
# Print two roots
li $v0,4
la $a0, msg_two_roots
syscall
li $v0,3
mov.d $f12, $f12
syscall
li $v0,4
la $a0, msg_and
syscall
li $v0,3
mov.d $f12, $f14
syscall
li $v0,4
la $a0, newline
syscall
j exit
print_imaginary:
li $v0,4
la $a0, msg_imaginary
syscall
j exit
check_linear:
li $v0,4
la $a0, msg_not_quadratic
syscall
j exit
exit:
li $v0,10
syscall
.zero_double: .double 0.0
#I think syscalls for input (syscall 6 for double precision input) and floating-point operations must be accurately implemented for SPIM
Description:
Write a complete program that prompts the user for the coefficients a, b,
and c of a quadratic equation ax2+bx+c=0 and outputs the solutions as
shown. discriminant =b2-4ac
Must use double precision floating point.
Required I/0:
Quadratic Equation Solver v0.1 by F. Last
Enter value for a? #.#
Enter value for b? #.#
Enter value for c? #.#
I is a blank line. F. Last is your first initial and last name, #.# is user input.
If a=0 && b=0 :
Not a quadratic equation.
If discriminant 0 :
Roots are imaginary.
Otherwise
x1=#.#
2=#.#
#.# are replaced with calculated root(s).
(PLZ include a pic of the program working in SPIM)
 Im trying to run the MIPS code below in SPIM but

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!