From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1355 invoked by alias); 2 Jul 2009 08:04:17 -0000 Received: (qmail 1346 invoked by uid 22791); 2 Jul 2009 08:04:16 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_53,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-ew0-f225.google.com (HELO mail-ew0-f225.google.com) (209.85.219.225) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Jul 2009 08:04:10 +0000 Received: by ewy25 with SMTP id 25so1996556ewy.8 for ; Thu, 02 Jul 2009 01:04:07 -0700 (PDT) Received: by 10.216.10.208 with SMTP id 58mr3060275wev.82.1246521847269; Thu, 02 Jul 2009 01:04:07 -0700 (PDT) Received: from ?192.168.43.19? ([212.143.139.215]) by mx.google.com with ESMTPS id 7sm4081193eyb.5.2009.07.02.01.04.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 02 Jul 2009 01:04:06 -0700 (PDT) Message-ID: <4A4C69F0.7040201@gmail.com> Date: Thu, 02 Jul 2009 08:04:00 -0000 From: Lennyk User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: undefined reference to... when using intel inline asm Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00033.txt.bz2 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!