[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++ to MIPS assembly or binary



--- On Fri, 2/25/11, hana aliee <hanaal2003@yahoo.com> wrote:

>Thank you very much for your help.
>I have a MIPS simulator in vhdl language which gets a binary mips >instructions as input.
>I want to convert my c++ code to binary or assembly code of mips to >pass it to this simulator. 
>However, I didn't understand your points exactly.
>Should I run "g++ -S <file.cpp>" in debian environment?
>Does it return the binary format of my code in MIPS?
>
>Regards
>Hana

For your needs, sounds like the gcc route is the way to go.  First, you will need to obtain a mips cross compiler.  That is basically a special build of gcc that would run on your desktop PC, but builds mips binaries as its default target.  You can find instructions to obtain a pre-built or build your own from here:

http://www.linux-mips.org/wiki/Toolchains

Once you have that, then you will have a set of executables that look something like "mips-linux-gnu-gcc", "mips-linux-gnu-as", "mips-linux-gnu-objdump", etc...

Use those as your compiler.  The -S option simply stops gcc at the assembly phase so you have the output that would normally go to the assembler, and finally the linker.  This is all documented in the relevant man pages, and gnu-info pages.  (Try "info gcc".)

Regards,

-S-

      


Reply to: