From owner-freebsd-mips@FreeBSD.ORG Thu Feb 25 02:07:49 2010 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BB99106564A for ; Thu, 25 Feb 2010 02:07:49 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-fx0-f223.google.com (mail-fx0-f223.google.com [209.85.220.223]) by mx1.freebsd.org (Postfix) with ESMTP id 1F6C68FC13 for ; Thu, 25 Feb 2010 02:07:48 +0000 (UTC) Received: by fxm23 with SMTP id 23so331208fxm.3 for ; Wed, 24 Feb 2010 18:07:44 -0800 (PST) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.102.14.13 with SMTP id 13mr413949mun.32.1267063663072; Wed, 24 Feb 2010 18:07:43 -0800 (PST) In-Reply-To: <17060.1267061906@mahan.org> References: <17060.1267061906@mahan.org> From: Juli Mallett Date: Wed, 24 Feb 2010 18:07:23 -0800 X-Google-Sender-Auth: 1b1abe6ece401c9d Message-ID: To: Patrick Mahan Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-mips@freebsd.org Subject: Re: Writing MIPS assembler instructions in C X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2010 02:07:49 -0000 Hi Patrick, On Wed, Feb 24, 2010 at 17:38, Patrick Mahan wrote: > part of some code built on the linux platform and > there they are using "%[rt]" which I cannot find > a description. %[foo] can be used to refer to named parameters (input or output, maybe even clobbered) of inline assembly instructions rather than using %0, %1, etc., which can be hard to read. Consider: %%% static inline bool atomic_cmpset64(volatile uint64_t *p, uint64_t o, uint64_t v) { uint64_t temp; int res; asm volatile ( "1:\n\t" "move %[res], $0\n\t" "lld %[temp], %[p]\n\t" "bne %[temp], %[o], 2f\n\t" "move %[temp], %[v]\n\t" "li %[res], 1\n\t" "scd %[temp], %[p]\n\t" "beqz %[temp], 1b\n\t" "2:\n\t" : [res] "=&r"(res), [temp] "=&r"(temp), [p] "+m"(*p) : [o] "r"(o), [v] "r"(v) : "memory" ); return (res != 0); } %%% The brackets with the input and output parameters specify what names to use to refer to them in the assembly listing (here they happen to be mostly the same as the variable names, but that's not necessary.) Juli.