Question: # Program: mlQuadratic.asm # Author: *********** # Date: ***** # Purpose: Practice floating point calculations #---------------------------------------------------------------- # Create assembler for the Quadratic solving # #include
# Program: mlQuadratic.asm
# Author: ***********
# Date: *****
# Purpose: Practice floating point calculations
#----------------------------------------------------------------
# Create assembler for the Quadratic solving
# #include
# #include
# using namespace std;
#
# 2x^2 -8x - 24 = 0
#
# -b +- SQR( b^2 - 4ac)
# x = ---------------------
# 2a
#
# x = 6.0, -2.0
#
# void main()
# {
# float a = 2.0, b = -8.0, c = -24.0;
# float sqroot = sqr( b*b - 4*a*c );
# float root1 = (-b + sqroot)/2*a;
# float root2 = (-b - sqroot)/2*a;
# cout << "Root1:\t" << root1 << endl;
# cout << "Root2:\t" << root2 << endl;
# }
# OUTPUT:
# Root1: 6
# Root2: -2
# THIS IS THE EXAMPLE OF WHAT THE CODE SHOULD DO IN C++ ABOVE
.data
.eqv SYS_PRINT_FLOAT 2 #float
.eqv SYS_PRINT_TEXT 4 #text (zero terminated)
.eqv SYS_EXIT 10 #terminate
endl: .asciiz " "
lblRoot1: .asciiz "Root1:\t"
lblRoot2: .asciiz "Root2:\t"
a: .float 2.0
b: .float -8.0
c: .float -24.0
mytwo: .float 2.0
myfour: .float 4.0
.text
.globl main
main:
#ANSWER THIS PORTION PLEASE in MIPS Assembly------------------
#
# Get Determinate: b^2 - 4ac into $f0(THIS).
#
#get square root(THIS).
jal sqrt #f0 input; f1 output
#
# plus root in $f0(THIS).
#-b + sqrt(b^2 - 4ac)
# /2a
#
# minus root in $f1(AND THIS).
#-b - sqrt(b^2 - 4ac)
# /2a
#
#END HERE -------------------------------------
# PRINT root1 in $f0
li $v0, SYS_PRINT_TEXT
la $a0, lblRoot1 #label
syscall
li $v0, SYS_PRINT_FLOAT #print
mov.s $f12, $f0
syscall
li $v0, SYS_PRINT_TEXT
la $a0, endl #endl
syscall
# PRINT root2 in f1
li $v0, SYS_PRINT_TEXT
la $a0, lblRoot2 #label
syscall
li $v0, SYS_PRINT_FLOAT #print
mov.s $f12, $f1
syscall
li $v0, SYS_PRINT_TEXT
la $a0, endl #endl
syscall
#------------------------
# terminate program.
li $v0, SYS_EXIT # call code for terminate
syscall # system call
#.end main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
