[Top] [All Lists]

Re: Assembly macro with parameters

Subject: Re: Assembly macro with parameters
From: Fabrizio Fazzino <>
Date: Sat, 09 Jul 2005 09:22:08 +0200
In-reply-to: <>
Original-recipient: rfc822;
References: <> <> <> <> <> <> <> <>
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) : : 

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 Fazzino -
     Fazzino.IT -

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