For some inexplicable reason, my perfectly typed assembly program (for SPARC) isn't compiling. I run the command 'gcc test.s' which gives the following output:
> gcc test.s
test.s: Assembler messages:
test.s:6: Fatal error: Unknown opcode: `define(a1, 4)'
Code:
/*This program finds the maximum of the expression:
y=x^3 - 14x^2 + 56x - 64
-2<x<8
define the two integer values that we'll be using
*/
define(a1, 4)
define(a2, 14)
/*Variables x and y are stored in %11 and %12. Result store in 10*/
define(r_r, 10)
define(x_r, 11)
define(y_r, 12)
.global main
main:
save %sp, -96 %sp
clr %x_r !initialize x to zero
mov -2, %x_r
.global loop
/*
To simplify, the problem can also be written as:
x(x-14(x+4))
or
x^x - 14*x * x+4
*/
loop:
/* x+4 */
add %x_r, a1, %o3
mov %x_r, %o2
call .mul
nop
/* *(x*14) */
mov %x_r, %02
call .mul
nop
mov a2, %02
call .mul
nop
/* Now move the answer to a different register, clear %o0 for the second
part of the equation. */
mov %o0, %o2
clr %o0
mov %x_r, %o0
mov %x_r, %o1
call .mul
nop
sub %o0, %o3, %o0
mov %o0, %y_r
/*do..while condition. Check if the max for this value of x is greater than
anything before it */
cmp %y_r, %10
ble next
nop
mov %o0 %10
next:
clr %o0
clr %01
clr %02
clr %03
add %x_r, 1, %x_r
cmp %x_r, 8
b1 loop
mov %y_r, %o0
mov 1, %g1
ta 0
I have NO clue as to what the problem is. The text is formatted correctly. Why isn't it accepting a1 as the name for a variable?
-thanks in advance for any help