LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-27-2005, 07:23 PM   #1
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Rep: Reputation: 30
Please help me with my assembly program


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

Last edited by flamesrock; 01-27-2005 at 07:24 PM.
 
Old 01-27-2005, 09:05 PM   #2
Snargle
LQ Newbie
 
Registered: Jan 2005
Location: North Carolina
Distribution: fc3
Posts: 1

Rep: Reputation: 0
don't you have to run it through a macro processor?

> m4 test.s>filename

I may be wrong.
 
Old 01-30-2005, 11:27 PM   #3
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Original Poster
Rep: Reputation: 30
So sorry for the late response...

You we're right! I feel like such a dumbass.

Now I just need to figure out how to use the gdb and I'm set. And I might actually have the assignment done BEFORE the due date this time, hehe
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash routine into assembly program rblampain Linux - Security 3 08-06-2005 02:49 AM
Problem linking assembly program with C lib. 95se Programming 1 03-08-2005 10:44 PM
puzzle about g++ compile options for inline assembly program markbeth Programming 2 09-20-2004 05:30 AM
Assembly jinksys Programming 3 09-14-2003 05:33 PM
I need help for Assembly skb Programming 10 08-01-2003 05:51 PM


All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration