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 IO
HERE IS THE CODE:
data
msgwelcome: asciiz "Quadratic Equation Solver v by F Last
msga: asciiz "Enter value for a
msgb: asciiz "Enter value for b
msgc: asciiz "Enter value for c
msgnotquadratic: asciiz "Not a quadratic equation.
msgimaginary: asciiz "Roots are imaginary.
msgoneroot: asciiz "One solution x
msgtworoots: asciiz x
msgand: asciiz x
newline: asciiz
text
globl main
main:
# Print welcome message
li $v
la $a msgwelcome
syscall
# Read coefficient a
li $v
la $a msga
syscall
li $v # double reading syscall
syscall
mov.d $f $f # move input to $f for a
# Read coefficient b
li $v
la $a msgb
syscall
li $v
syscall
mov.d $f $f # move input to $f for b
# Read coefficient c
li $v
la $a msgc
syscall
li $v
syscall
mov.d $f $f # move input to $f for c
# Check for nonquadratic cases: a
li $v
ld $f zerodouble
ceqd $f $f
bct checklinear
# Calculate discriminant bac
mul.d $f $f $f # $f b
lid $f
mul.d $f $f $f # $f ac
mul.d $f $f $f # $fac
add.d $f $f $f # $f bac Discriminant
# Check discriminant for imaginary roots
li $v
ld $f zerodouble
cltd $f $f
bct printimaginary
# Calculate roots
sqrtd $f $f # $f sqrtdiscriminant
lid $f
div.d $f $f $f # $f b
sub.d $f $f $f # $fb sqrtdiscriminanta
add.d $f $f $f # $fb sqrtdiscriminanta
div.d $f $f $f # $f x
div.d $f $f $f # $f x
# Print two roots
li $v
la $a msgtworoots
syscall
li $v
mov.d $f $f
syscall
li $v
la $a msgand
syscall
li $v
mov.d $f $f
syscall
li $v
la $a newline
syscall
j exit
printimaginary:
li $v
la $a msgimaginary
syscall
j exit
checklinear:
li $v
la $a msgnotquadratic
syscall
j exit
exit:
li $v
syscall
zerodouble: double
#I think syscalls for input syscall for double precision input and floatingpoint operations must be accurately implemented for SPIM
Description:
Write a complete program that prompts the user for the coefficients a b
and of a quadratic equation and outputs the solutions as
shown. discriminant
Must use double precision floating point.
Required I:
Quadratic Equation Solver v by F Last
Enter value for a ##
Enter value for b ##
Enter value for ##
I is a blank line. F Last is your first initial and last name, ## is user input.
If && :
Not a quadratic equation.
If discriminant :
Roots are imaginary.
Otherwise
##
##
## are replaced with calculated roots
PLZ include a pic of the program working in SPIM
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
