Is it possible to use MIPS register names with GAS (GNU assembler)?

我与影子孤独终老i 提交于 2019-12-02 07:42:23

问题


If I use register names I get:

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

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


回答1:


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


来源:https://stackoverflow.com/questions/721192/is-it-possible-to-use-mips-register-names-with-gas-gnu-assembler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!