C/C++ to MIPS Assembly

感情迁移 提交于 2019-12-29 08:54:15

问题


I know that to compile to assembly, I should use the -Soption with gcc or g++, but how do I get MIPS assembly?

I tried

g++ -march=mips2 dll.c 

but that gives the error

dll.c:1:0: error: bad value (mips2) for -march= switch

I saw a suggestion of the compile command mips_gcc, but I can't find how to install that compiler.

I'm using Ubuntu 64-bit, if that helps.


回答1:


You need a version of gcc that is built as a MIPS cross compiler. You can download the free Mentor/Codesourcery MIPS gnu/gcc cross compilation tool chain from here. This toolchain is available for both Windows and Linux.

After downloading, installing and adding the tool chain to your path you would say:

mips-linux-gnu-g++ -march=mips32r2 -S dll.c

to compile your code to MIPS32R2 assembly.

UPDATE 8/2017: It looks like Sourcery CodeBench free cross compiler for MIPS is no longer available at Mentor's site. Try the free toolchain at Imagination's site.



来源:https://stackoverflow.com/questions/12982857/c-c-to-mips-assembly

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