I'm guessing that after every run of the loop, you would take the result for y and compare it to what is in ymax. If y is larger than ymax, then it should be replaced by y, and the loop run again. Im just not sure how to do this in assembly though. Also, I have no clue how to find the x value that corresponds with the largest y. I already know that the largest x will produce the largest y, just by looking at the equation. But my goal is to find the x value that corresponds to the largest y value, so just finding the largest x will not do. Here is what I have so far:

/* cs32114 CSC 3210 Program #2 Due Date Feb 10, 2009 This program will calculate y=(x^6)-(14x^2)+56x for x=-2,-1,0,1,2,3,4 */ /*Constants are:*/ define(a2,56) define(a1,14) /*X and Y variable*/ define(x_r,l0) define(y_r,l1) define(xmax, l2) define(ymax, l3) .global main main: save %sp, -96, %sp mov -2, %x_r .global loop loop: cmp %x_r, 5 bge done mov %x_r, %o0 !This will compute x^6, the first part of equation mov %x_r, %o1 call .mul nop mov %x_r, %o1 call .mul nop mov %x_r, %o1 call .mul nop mov %x_r, %o1 call .mul nop mov %x_r, %o1 call .mul nop mov %o0, %y_r !completes first part of equation and stores in y. mov %x_r, %o1 !This will computer 14x^2 mov %x_r, %o0 call .mul nop mov a1, %o1 call .mul nop sub %y_r, %o0, %y_r !completes first two parts of equation mov a2, %o0 !computes 56x. mov %x_r, %o1 call .mul nop add %y_r, %o0, %y_r !equation complete. Store result in y_r. add %x_r, 1, %x_r !x++ ba loop nop done: mov 1, %g1 ta 0

This post has been edited by **mattpd**: 02 February 2009 - 06:35 PM