I\'m in terrible need for help with this assembly language program. Please help,
ID: 3692509 • Letter: I
Question
I'm in terrible need for help with this assembly language program. Please help, I need the code ASAP.
This are the instructions for the program:
For programming assignment 4, you are required to develop MIPS assembly language programs that allow the user to create and evaluate polynomial functions of degree n.
All polynomial functions of variable x have the form
P(x) = a0 + a1x + a2x2 + … + an-1xn-1 + anxn
For this assignment, we will assume that all of the coefficients ai and the exponents of x are integers, and the largest exponent n – called the degree of the polynomial – is greater than or equal to 0. For example, the polynomial
P(x) = 3 + 5x + 2x3
is of degree 3 and has coefficients a0 = 3, a1 = 5, a2 = 0, and a3 = 2. An evaluation of this polynomial with variable x = 7 should produce the result 3 + 5 x 7 + 0 x 72 + 2 x 73 = 724.
For this assignment, you are required to write a MIPS assembly language program that accomplishes each of the following tasks:
1. First, your program should interactively prompt for and read an integer value between 0 and 10 representing the degree of a given polynomial. Display an appropriate error message and repeat this step until a valid degree has been entered.
2. Next, your program should interactively prompt for and read signed integer values representing each of the polynomial’s coefficients (a0 … an). Store the value of each coefficient in an array.
3. Next, your program should enter a loop that interactively reads integer values of x; for each value, your program should compute and interactively display the value of the result (P(x)) for the user-specified polynomial from step 2. Your program should then ask whether to compute P(x) for a different value of x, and repeat the process of calculating P(x) until the user says not to.
4. Finally, your program should ask the user whether he or she would like to evaluate a different polynomial, and repeat all of the above steps until the user says not to.
Your program will be expected to make use of subroutines, including (at a minimum):
1. getDegree
2. resetCoefficients
3. getCoefficients
4. evaluatePolynomial
I would be so thankful if you assis with this one, please!
Explanation / Answer
getDegree subroutine:
.data
degree: .asciiz " Please input the degree of the polynomial between 0 and 10 "
output: .asciiz " The degree of the polynomial is "
.globl main
.text
main: li $v0, 4 # system call to print the prompt
la $a0, degree # load the address of degree prompt
syscall # display the message
li $v0, 5 # system call to read the integer value
syscall # reads a value of N into v0
move $t1,$v0
li $v0,4 # display the string
la $a0,output
syscall
li $v0,1
move $a0,$t1
syscall
You can use the ble and bge to check whether the input is in the range of 1 to 10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.