0

Hello, I'm having a small problem with my program for assembly. I have to write an assembly language that finds the maximum of

y = x^6 – 14x^2 - 56x

for the range -4 ≤ x ≤ 6, by stepping one by one through the range.

Here is my code in macro:

```
/* Constants*/
define(a2,56)
define(a1,14)
/* x and y variables*/
define(x_r, l0)
define(y_r, l1)
define(xmax,l2)
define(ymax,l3)
.global main
main:
save %sp, -96, %sp
mov -4, %x_r !This line initializes -4
.global loop
loop:
cmp %x_r,7
bge done
mov %x_r, %o0 ! Compute x^6
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 !Complete x^6
mov %x_r, %o1 !Computes 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 !Completing the equation
cmp %y_r,%y_max
bg update
cmp %y_r,%y_max
ble loop
nop
update:
mov %y_r,%y_max !y_r was bigger and replaces y_max
mov %x_r,%x_max !x_r replaces x_max
add %x_r, 1, %x_r !x++
ba loop !Goes back to the loop
done:
mov 1, %g1
ta 0
```

I've converted into assembly and when I compiled it, I got these errors here:

compute.s:65: Error: Illegal operands

compute.s:67: Error: Illegal operands

compute.s:72: Error: Illegal operands

compute.s:73: Error: Illegal operands

I found that the errors are:

Line 65

`cmp %y_r,%y_max`

Line 67

`cmp %y_r,%y_max`

Line 72

`mov %y_r,%y_max`

Line 73

`mov %x_r,%x_max`

I don't know why they're wrong. Can someone help me out here. Please reply back. Thanks.