From owner-freebsd-mips@FreeBSD.ORG Thu Feb 25 15:21:33 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 31B181065670 for ; Thu, 25 Feb 2010 15:21:33 +0000 (UTC) (envelope-from mahan@mahan.org) Received: from ns.mahan.org (ns.mahan.org [67.116.10.138]) by mx1.freebsd.org (Postfix) with ESMTP id 07D0E8FC12 for ; Thu, 25 Feb 2010 15:21:32 +0000 (UTC) Received: from mahan.org (crowTrobot [67.116.10.140]) by ns.mahan.org (8.13.6/8.13.6) with ESMTP id o1PFPgOD028776; Thu, 25 Feb 2010 07:25:42 -0800 (PST) (envelope-from mahan@mahan.org) Message-Id: <201002251525.o1PFPgOD028776@ns.mahan.org> To: "C. Jayachandran" In-reply-to: <98a59be81002242231mc491517sa5d752cb870c1f9@mail.gmail.com> References: <17060.1267061906@mahan.org> <201002250236.o1P2a2oX024250@ns.mahan.org> <98a59be81002242126k5bbf5167p7cba4917c13d1256@mail.gmail.com> <19077.1267079184@mahan.org> <98a59be81002242231mc491517sa5d752cb870c1f9@mail.gmail.com> Comments: In-reply-to "C. Jayachandran" message dated "Thu, 25 Feb 2010 12:01:47 +0530." Date: Thu, 25 Feb 2010 07:21:27 -0800 From: Patrick Mahan 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 15:21:33 -0000 > On Thu, Feb 25, 2010 at 11:56 AM, Patrick Mahan wrote: > > > >>> 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 where > >>> that I only have binary access too and it expects it's a value in > >>> that register.  Can 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? > >> > > > > 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.  (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 getting no 'illegal instruction' error. My concern is coming from the issue that using binutils built by the manufacturer of the chip (cavium) which only run on a linux platform, I tried to disassemble the .o containing the asm statement, but it does not decode to the expected instruction. So I am leary that I have correctly generated the asm (inline asm's not my strong suit...) Thanks, Patrick