Question

Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly...

Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly way):  Greets the user, states the purpose of the program  Sequentially asks the user to provide integer coefficients A,B,C  Calculates discriminant D of quadratic polynomial. (Hint: D = B2 – 4×A×C)  Displays the calculated D value  Checks (in this order) whether discriminant is: o D = 0? Then, displays: “Quadratic polynomial has a sole root.” o D > 0? Then, displays: “Quadratic polynomial has two roots.” o Otherwise, displays: “Quadratic polynomial has no real roots.”  Properly terminates with appropriate closing message. Make sure to show the following items:  Source code in a readable, well-formatted (tabulated, commented) way  Screenshot of PC SPIM showing the emulator with your code successfully loaded  Screenshots of PC SPIM console displaying the results of running your program with the following test inputs: o A = 3; B = 4; C = 5 o A = 2; B = 6; C = 2 o A = 4; B = 8; C = 4

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data

msg1: .asciiz "Enter A: "

msg2: .asciiz "Enter B: "

msg3: .asciiz "Enter C: "

msg4: .asciiz "\nQuadratic polynomial has a sole root.\n"

msg5: .asciiz "\nQuadratic polynomial has two root.\n"

msg6: .asciiz "\nQuadratic polynomial has no real root.\n"

msg7: .asciiz "End of the program"

msg8: .asciiz "\nD = "

.text

main:

#print the msg1

li $v0, 4 #print string syscall value is 4

la $a0, msg1 #copy address of msg1 to $a0

syscall

#read value A

li $v0,5 #read integer syscall value is 5

syscall #read value stored in $v0

move $t0,$v0

#print the msg2

li $v0, 4 #print string syscall value is 4

la $a0, msg2 #copy address of msg2 to $a0

syscall

#read value B

li $v0,5 #read integer syscall value is 5

syscall #read value stored in $v0

move $t1,$v0

  

#print the msg3

li $v0, 4 #print string syscall value is 4

la $a0, msg3 #copy address of msg3 to $a0

syscall

#read value C

li $v0,5 #read integer syscall value is 5

syscall #read value stored in $v0

move $t2,$v0

mul $t3,$t1,$t1

li $s0,4

mul $t4,$s0,$t0

mul $t4,$t4,$t2

sub $t3,$t3,$t4

#print the msg8

li $v0, 4 #print string syscall value is 4

la $a0, msg8 #copy address of msg8 to $a0

syscall

#print D value

li $v0,1 #print integer syscall value is 1

move $a0,$t3 #copy $t3 to $a0

syscall

beq $t3,$zero,if

bgt $t3,$zero,else

# D < 0

#print the msg6

li $v0, 4 #print string syscall value is 4

la $a0, msg6 #copy address of msg6 to $a0

syscall

#jump tp exit

j exit

# D = 0

if:

#print the msg4

li $v0, 4 #print string syscall value is 4

la $a0, msg4 #copy address of msg4 to $a0

syscall

#jump to exit

j exit

# D > 0

else:

#print the msg5

li $v0, 4 #print string syscall value is 4

la $a0, msg5 #copy address of msg5 to $a0

syscall

exit:

#print the msg7

li $v0, 4 #print string syscall value is 4

la $a0, msg7 #copy address of msg7 to $a0

syscall

#terminate the program

li $v0, 10 #terminate the program syscall value 10

syscall

Hope this helps...!

Add a comment
Know the answer?
Add Answer to:
Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MIPS math quiz program in MARS. The program should start with a friendly user...

    Write a MIPS math quiz program in MARS. The program should start with a friendly user greeting. From there, it should generate a random arithmetic problem. Your program will need to generate three random things: the first and second operand and the operator to use. Your program should generate random positive integers no greater than 20 for the operands. The possible operators are +, -, * and / (division). The user should be prompted for an answer to the problem....

  • 4-6 on matlab 4. Write a program in a script file that determines the real roots...

    4-6 on matlab 4. Write a program in a script file that determines the real roots of a quadratic equation ax2+bx+c 0 When the file runs, it asks the user to enter the values of the constants a, b, and c. To calculate the roots of the equation the program calculates the discriminant D, given by: D b2-4ac When D 0, the program displays message "The equation has two roots," and the roots are displayed in the next line. When...

  • c++ language TECH 1211 Computer Programming Name Test 2 Hands-On-Program B Spring 2020 Write a program...

    c++ language TECH 1211 Computer Programming Name Test 2 Hands-On-Program B Spring 2020 Write a program that uses the quadratic formula to solve quadratic equations. Background Given the format for a quadratic equations: aX? +BX+C =0 The coefficient of the X term is the number a. The coefficient of the X term is the number b. The value of c is any non-zero constant. These values can be positive, negative or zero. You can find the solution to this equation...

  • 1. Write and debug a MIPS program that performs the following operations . Prompt for and...

    1. Write and debug a MIPS program that performs the following operations . Prompt for and input three integers "a", "b and "c" using syscalls (3 points) Print all numbers starting from "a" upto "b" (including, but not exceeding "b") at an increment equal to value of"c"(5 points) If ba, then no numbers are printed, and a message is printed to inform it to the user. (3 points) Print the number and average of the generated numbers printed. (3 points)...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT