MIPS32 Assembly Language Programming 15 A third degree polyn

MIPS32 Assembly Language Programming


15. A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x^3 + c2x^2 + c1x + c0, where x and the
four coefficients are integers for this exercise. Suppose the values of the coefficients c0, c1, c2, and c3 have been loaded
into registers $t0, $t1, $t2, and $t3, respectively. Suppose the value of x is in $t7. Write the MIPS32 instructions that
would evaluate this polynomial, placing the result in $t9.

Solution

The following is the required code:

mult $t9,$t7,$t1 #$t9 = x*t1

add $t9,$t9,$t0 #$t9 = (x*t1)+t0

mult $t7,$t7,$t7 #x= x*x

mult $t6,$t7,$t2 #t6 = (x*x)*t2

add $t9,$t9,$t6 #$t9 =(x*x)*t2 + (x*t1) + t0

mult $t7,$t7,$t7 #x = x * x * x

mult $t6,$t7,$t3 #t6 = (x*x)*t3

add $t9,$t9,$t6   #$t9 = (x*x)*t3 + (x*x)*t2 + (x*t1) + t0

MIPS32 Assembly Language Programming 15. A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x^3 + c2x^2 + c1x + c0, where x and the f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site