undefined reference to... when using intel inline asm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux