This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Using inline assembly with specific register indices
- From: Daniel Jacobowitz <drow at false dot org>
- To: nkavv at physics dot auth dot gr
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 5 Apr 2005 00:25:05 -0400
- Subject: Re: Using inline assembly with specific register indices
- References: <1112675084.4252130c91181@mail.physics.auth.gr>
On Tue, Apr 05, 2005 at 07:24:44AM +0300, nkavv@physics.auth.gr wrote:
> Hi guys/ladies,
>
> I'm currently designing an ISA add-on to the MIPS architecture. My
> intention is to use it (it is an algorithm accelerator actually) as a
> COP2 (coprocessor #2). The corresponding microarchitecture is stable
> (works at register-transfer level, not subject to change). Plus, I
> would be happy NOT TO CHANGE my ISA add-on.
>
> My problem is that I would like to access specific indices in the data
> register file of COP2, i.e. registers c2r0 to c2r31. This should be
> done in inline assembly or else I'll have to put down probably 2k-3k
> C-lines in assembly :-)
>
> Is it possible to write down something like this:
>
> asm("cop2a %0, %1;", :: "r" (cp2rb(i)) : "r" (cp2rb(j)));
If GCC knows about the registers on the coprocessor, then you can use
local register variables for this:
long c2r0 asm ("c2r0");
If it doesn't, then you should probably not be telling GCC about them.
Assuming i is constant:
asm volatile ("cop2a c2r" STRINGIFY(i) ", c2r" STRINGIFY(j) );
--
Daniel Jacobowitz
CodeSourcery, LLC