Re: Assembly macro with parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
     Fazzino.IT - http://www.fazzino.it
============================================



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux