From owner-freebsd-mips@FreeBSD.ORG Thu Feb 25 16:48:05 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 5D60B106566B for ; Thu, 25 Feb 2010 16:48:05 +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 1CDBE8FC17 for ; Thu, 25 Feb 2010 16:48:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o1PGcrvg079048; Thu, 25 Feb 2010 09:38:54 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 25 Feb 2010 09:39:05 -0700 (MST) Message-Id: <20100225.093905.864843819598471490.imp@bsdimp.com> To: mahan@mahan.org From: "M. Warner Losh" In-Reply-To: <201002251525.o1PFPgOD028776@ns.mahan.org> References: <19077.1267079184@mahan.org> <98a59be81002242231mc491517sa5d752cb870c1f9@mail.gmail.com> <201002251525.o1PFPgOD028776@ns.mahan.org> 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 16:48:05 -0000 In message: <201002251525.o1PFPgOD028776@ns.mahan.org> Patrick Mahan writes: : > On Thu, Feb 25, 2010 at 11:56 AM, Patrick Mahan w= rote: : > > : > >>> Now my problem is I still need to force the value pointed to "a= ddr" into : > >>> a specific register because there is a jalr to a function else = where : > >>> 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, =A0but have you tried : : > >> : > >>__asm__ __volatile__( : > >> =A0 =A0 =A0 =A0 =A0 "ld =A0 =A0 $8, 0(%0)\n\t" : > >> =A0 =A0 =A0 =A0 =A0 "jalr =A0 $8\n" : > >> =A0 =A0 =A0 =A0 =A0 : : "r"(addr) : "$8"); : > >>} : > >> : > >>Or is there a reason this will not work? : > >> : > > : > > This is the equivalent of "ld t0, 0(a0)", yes? : > = : > Yes that should be equivalent, but assemblers don't know about 't0'= only '$8' : > = : > > No I tried that method as well, but without success. =A0(or so it= : > > seemed to me). : > = : > I was trying to see what the issue with this method is. Do you get = a : > compiler error, or is it incorrect code? Usually you can figure out= : > what is going wrong by looking at the objdump or the output of 'cc = -S' : > to see if the requested register was used. : > : = : No compiler error but the code does not seem to execute, and I am get= ting : no 'illegal instruction' error. My concern is coming from the issue = that : using binutils built by the manufacturer of the chip (cavium) which o= nly : run on a linux platform, I tried to disassemble the .o containing the= = : asm statement, but it does not decode to the expected instruction. S= o I : am leary that I have correctly generated the asm (inline asm's not my= : strong suit...) I've used those binutils on FreeBSD with the linuxulator... Warner