public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* undefined reference to... when using intel inline asm
@ 2009-07-02  8:04 Lennyk
  2009-07-02 19:52 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Lennyk @ 2009-07-02  8:04 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm having difficulties translating Windows-style intel assembler to 
Linux (with GCC).

Code (Window-style):
int bswap(int n)
{
    __asm
    {
       mov eax, n
       bswap eax
       mov n, eax
    }
    return n;
}

After looking at some guides/tutorials I've translated this code to Linux:
int bswap(int n)
{
    asm(".intel_syntax noprefix");
    asm("mov eax, n");
    asm("bswap eax");
    asm("mov n, eax");
    asm(".att_syntax noprefix");
    return n;
}

Compilation passes - but the linker shouts: "undefined reference to `n'"

What am I doing wrong? Shouldn't it be straight forward to translate 
these simple commands to Linux?

GCC version: 4.1.2 20080704 (Red Hat 4.1.2-44)
Target: i386-redhat-linux

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-07 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02  8:04 undefined reference to... when using intel inline asm Lennyk
2009-07-02 19:52 ` Ian Lance Taylor
2009-07-06  7:40   ` Lennyk
2009-07-06 15:07     ` Ian Lance Taylor
2009-07-07 10:51       ` Lennyk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).