Question
Evaluate the polynomial: 30x3 - 45x2 + 28x - 15 Get the value for x from symbolic addresses x. Store the result at symbolic address
Evaluate the polynomial: 30x3 - 45x2 + 28x - 15
Get the value for x from symbolic addresses x. Store the result at symbolic address poly. Since load delays are turned on in SPIM be careful what instructions are placed in the load delay slot. Evaluate the polynomial by using Horners Method. This is a way of building up values until the final value is reached. First, pick a register, say $7, to act as an accumulator. The accumulator will hold the value at each step. Use other registers to help build up the value at each step.
First, put the coefficient of the first term into the accumulator: 30
Next, multiply that value by x: 30x Add the coefficient of the next term: 30x 45
Next, multiply that sum by x: 30x2 -45x Add the coefficient of the next term: 30x2 - 45x + 28
Next, multiply that sum by x: 30x3 - 45x2 + 28x Finally, add the coefficient of the last term: 30x3 - 45x2 + 28x - 15
Evaluating the polynomial in this way reduces the number of steps (and the amount of code).
A sample of the data section in your program is shown as below. .
data x: . word10
poly : . word 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started