From owner-freebsd-mips@FreeBSD.ORG Thu Feb 25 05:42:10 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 3202C106564A for ; Thu, 25 Feb 2010 05:42:10 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id E2E398FC15 for ; Thu, 25 Feb 2010 05:42:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o1P5ZTBY070445; Wed, 24 Feb 2010 22:35:30 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 24 Feb 2010 22:35:40 -0700 (MST) Message-Id: <20100224.223540.319083499807541849.imp@bsdimp.com> To: c.jayachandran@gmail.com From: "M. Warner Losh" In-Reply-To: <98a59be81002242126k5bbf5167p7cba4917c13d1256@mail.gmail.com> References: <201002250236.o1P2a2oX024250@ns.mahan.org> <98a59be81002242126k5bbf5167p7cba4917c13d1256@mail.gmail.com> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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 05:42:10 -0000 In message: <98a59be81002242126k5bbf5167p7cba4917c13d1256@mail.gmail.co= m> "C. Jayachandran" writes: : On Thu, Feb 25, 2010 at 8:01 AM, Patrick Mahan wrot= e: : > : > > %[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. =A0Consider: : > > : > > The brackets with the input and output parameters specify what na= mes : > > 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 necessar= y.) : > > : > : > Ah Sooo <*whack!*>...... : > : > I did not even twig on that... I had gotten it in my head that %[rt= ] : > was something special to the compiler that caused a certain behavio= r : > to occur. : > : > Now my problem is I still need to force the value pointed to "addr"= into : > a specific register because there is a jalr to a function else wher= e : > that I only have binary access too and it expects it's a value in : > that register. =A0Can I coerce this? : = : I may be missing something here, but have you tried : : = : __asm__ __volatile__( : "ld $8, 0(%0)\n\t" : "jalr $8\n" : : : "r"(addr) : "$8"); : } : = : Or is there a reason this will not work? Which register do you need to force it into? Maybe it is something as simple as: register_t r =3D *(register_t *)addr; foo(r); if that register is a0... Warner