linux-mips
[Top] [All Lists]

Re: Assembly macro with parameters

To: linux-mips@linux-mips.org
Subject: Re: Assembly macro with parameters
From: Fabrizio Fazzino <fabrizio@fazzino.it>
Date: Sat, 09 Jul 2005 09:22:08 +0200
In-reply-to: <Pine.LNX.4.61L.0507041306440.32001@blysk.ds.pg.gda.pl>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <425573AD.9010702@fazzino.it> <20050407182549.GA24235@linux-mips.org> <4256B5BE.8070708@fazzino.it> <20050408165717.GA8157@nevyn.them.org> <42C429C3.2090905@fazzino.it> <Pine.LNX.4.61L.0507010927130.30138@blysk.ds.pg.gda.pl> <42C7BE64.7020102@fazzino.it> <Pine.LNX.4.61L.0507041306440.32001@blysk.ds.pg.gda.pl>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
Maciej W. Rozycki wrote:
Fabrizio Fazzino wrote:

By the way, is there any quick way of writing a setreg(reg_num,reg_val)
C macro to set the value of a register?

Hi guys,
just to let you know that I solved my problem this way:

   // Set a register to the desired value
   #define setreg(regnum,value) asm("move $" #regnum ", %0" : : "r"(value) : 
"$" #regnum)

   // Move the content of a register to the desired variable
   #define reg2var(regnum,var) asm("sw $" #regnum ", %0" : "=m"(*var) : : 
"memory")

BTW, how about adding support for opcodes you are interested in to binutils instead? It would make interfacing them to GCC much easier.

The CPU I'm working on will never "exist"... I'm just simulating it
as VHDL code, so I just needed a quick-and-dirty way of generating
inside my very short test programs the new opcodes added as an extension.

Thanks to all for your precious support!

Cheers and regards,

        Fabrizio


--
============================================
   Fabrizio Fazzino - fabrizio@fazzino.it
     Fazzino.IT - http://www.fazzino.it
============================================


<Prev in Thread] Current Thread [Next in Thread>