Nested Multiplication Subroutine
You will write a assembly language procedure to compute the value of a polynomial and a C++ routine to exercise it. This will use floating point instructions.
Consider the following polynomial:
4x3 + 2.5x2 + 5x – 3
The usual way we would evaluate this is to use the following formula:
4*x*x*x + 2.5*x*x+5*x-3
Although this does yield the correct result (barring overflow) it is not very efficient. It takes 6 multiplies which is one of the slowest integer instructions and much worse when done in floating point.
The better way is to use Horner’s rule (also known as nested multiplication) which would be something like this:
(4 * x + 2.5) * x + 5) * x - 3
This requires the same number of adds but half the multiplies. It also has other numerical advantages if the signs of the computed terms disagree.
You are to write a C++ program which will accept any one-variable polynomial up to degree 10 as well as a the value for X. It will then pack these into an array. The first item should be X, the second the leading coefficient with the trailing coefficients following. It will then pass this array and a length argument to your assembly subroutine for evaluation. It will then display the results.
This will be due on Thursday, April 3.