LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-29-2004, 09:46 PM   #1
Annie0716
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Rep: Reputation: 0
Unhappy undefined reference to ... when using inline assembly in C


I am tring to use assembly inline in C, but errors occured when compiling, the messages are as below, could anyone tell me what' s the causes and how to corrct it?

The code is:
mdct( long *in, long *out) /*sorry, I forget the type, it' s long*/
{
__asm__("

movea in, %a1;
movea out, %a2;
...

");
}

Thank you!

/HHCF5249-HDDMP3-R3/uClinux-dist/lib/zlib -o MP3_ENC main.o bitstream.o formatBitstream.o l3bitstream.o layer3.o l3loop.o tables.o error.o huffman.o l3mdct.o
portableio.o ieeefloat.o l3subband.o reservoir.o wave.o -lm -lc
MP3_ENC.elf2flt: In function `mdct':
/HHCF5249-HDDMP3-R3/uClinux-dist/user/MP3ENC/l3mdct.c:686: undefined reference to `out'
/HHCF5249-HDDMP3-R3/uClinux-dist/user/MP3ENC/l3mdct.c:686: undefined reference to `in'

Last edited by Annie0716; 07-29-2004 at 10:02 PM.
 
Old 07-29-2004, 09:48 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
why do *in and *out not have types?
 
Old 07-29-2004, 09:53 PM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
inline asm doesn't work that way. read the gcc info pages, specifically the section on extended asm to see how to use C variables in asm code. usually it looks like this:
Code:
#define l2b(x) asm("movl %0, %%eax; bswap %%eax; movl %%eax, %1;"   \
                        : "=r" ((x))                                  \
                        : "r" ((x))                                   \
                        : "%eax"                                    \
                )
that swaps the byte order of x. read the info page to see what's going on.
 
Old 08-01-2004, 12:50 AM   #4
Annie0716
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Thank you so much!

It worked.
 
  


Reply



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
g++: inline functions can cause an undefined reference when linking? R00ts Programming 5 06-21-2005 03:13 AM
inline assembly in gcc gursev Programming 2 03-04-2005 02:17 AM
Inline Assembly Question tjt Programming 3 08-08-2004 04:38 AM
Assembly/C - error: undefined reference to sizeof jrtayloriv Programming 9 07-13-2004 07:43 PM
subrouine_call in gcc inline assembly sakeeb Programming 4 08-15-2002 10:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 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
Open Source Consulting | Domain Registration