0

I was studying about MIPS assembly Language. I heard that there is a gcc command for converting c source code to MIPS Assembly code.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
kp9393
  • 21
  • 1
  • 1
  • 1
    simple google searching led me here - https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html ... but I don't understand how you plan to study MIPS with this. – chronodekar Aug 28 '14 at 07:50
  • `I was studying about MIPS assembly Language.` Typically assembly generated by compilers are for assembler to read not for human. I don't think this is a good way to learn it. – starrify Aug 28 '14 at 07:57

1 Answers1

1

If you use gcc -S file.c, gcc will convert the C code to assembly.

You'll need to be running on a MIPS system, or have a MIPS cross-compiler, for this to work! In other words, plain out-of-the-box GCC on an x86 system cannot do this because it is set up only to build x86 code.

Here are some resources for getting MIPS cross-compilers set up on various Linux OSs: http://www.linux-mips.org/wiki/Toolchains

(BTW, MIPS code is highly optimizable, so you should play around with the -O flags to see the effects of different kinds of optimizations.)

There are many other threads on setting up MIPS cross-compilers, e.g. Is there a way to use gcc to convert C to MIPS?

Community
  • 1
  • 1
Dan Lenski
  • 76,929
  • 13
  • 76
  • 124