Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: axp-list@redhat.com
Subject: Re: GCC inline ASM is 'evil'
Date: 13 Nov 2002 01:32:06 +0100	[thread overview]
Message-ID: <871y5qpawp.fsf@student.uni-tuebingen.de> (raw)
In-Reply-To: <ODEEIIAMNNHHFAMGOBAPMEAMCFAA.voodoo@alphadriven.org>

"Peter Petrakis" <voodoo@alphadriven.org> writes:

>     asm ("mb;");

You need asm volatile here, or the compiler can optimize it away.

>     while (temp==0)
>     {
> //          ret= ASM("ldl_l   %v0,(%a0);", dest);
>             asm  ( "ldl_l %0,(%16)": "=r" (ret): "p"(dest) );
> 
>             temp= ASM("addl   %a0,1,%v0;\
>                   stl_c   %v0,(%a1) ;",ret,dest);
>     }
>     ASM ("mb;");
>     return ret;
> }
> 
> The ASM line that is commented out is DU inline ASM, which actually
> makes sense.  On the next line is my attempt :). I 'seem' to have my
> operands correctly constrained, as best as I can figure. The error I
> get is.
> 
> ../h/interlock.h:67: invalid `asm': operand number out of range
> 
> What does that mean???

Argument Nr. 16 does not exist, you only mention 2.

You probably want something like (untested):

long tmp;
asm volatile(
        "ldl_l  %2,%1\n"
        "addl   %2,1,%0\n"
        "stl_c  %0,%1\n"
        : "=r"(ret), "=m"(dest)
        : "r"(tmp));

-- 
	Falk




  reply	other threads:[~2002-11-13  0:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-13  0:04 GCC inline ASM is 'evil' Peter Petrakis
2002-11-13  0:32 ` Falk Hueffner [this message]
2002-11-14  6:51   ` Richard Henderson
2002-11-14  6:50 ` Richard Henderson
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox