是否有可能与GAS(GNU汇编器)使用MIPS寄存器的名字呢?

问题描述:

如果我用寄存器名字,我得到:

If I use register names I get:

Error: illegal operands `add $t0,$zero,$zero'

如果我使用注册号( $ 8个而不是 $ T0 $ 1,0 而不是 $零),它的工作原理。
(我使用的binutils 2.17)。

If I use register number ($8 instead of $t0 and $0 instead of $zero) it works. (I'm using binutils 2.17).

GNU汇编不直接支持符号寄存器名称。一种常见的方法,如果使用gcc来驱动的汇编,是用于汇编源文件中的.S扩展(GCC讲述通过汇编器之前的C preprocessor源)和#包括一个头包含文件定义,如:

The GNU assembler doesn't support symbolic register names directly. A common approach, if using gcc to drive the assembler, is to use the ".S" extension for the assembler source file (which tells gcc to pass the source through the C preprocessor before the assembler) and #include a header file containing definitions like:

#define zero $0
#define v0   $2
#define v1   $3

然后汇编源可以有这样的语句

Then the assembler source can have statements like

add v0, zero, zero