Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-27-2005, 06:23 PM   #1
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)'

/*This program finds the maximum of the expression:
y=x^3 - 14x^2 + 56x - 64

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
  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 * x+4

  /* x+4 */
  add       %x_r, a1, %o3
  mov       %x_r, %o2
  call      .mul
  /*  *(x*14) */
  mov       %x_r, %02
  call      .mul
  mov       a2, %02
  call      .mul
  /* 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
  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
  mov       %o0 %10
  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 06:24 PM.
Old 01-27-2005, 08:05 PM   #2
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, 10:27 PM   #3
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


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 01:49 AM
Problem linking assembly program with C lib. 95se Programming 1 03-08-2005 09:44 PM
puzzle about g++ compile options for inline assembly program markbeth Programming 2 09-20-2004 04:30 AM
Assembly jinksys Programming 3 09-14-2003 04:33 PM
I need help for Assembly skb Programming 10 08-01-2003 04:51 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 PM.

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