Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
944 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...