Are there any command line interpreters or any other set of programs around for x86 linux in order to run MIPS assembly programs?
I'd like to be able to write simple MIPS assembly programs and run them from the console on my local machine.
I know of SPIM but it requires X Windows and I'm curious if there are better options out there.
Edit: Turns out it doesn't require X Windows. I still have issues with SPIM. Not the best in my humble opinion. Qemu / Cross compiled toolchain is a little more work but I have less quirks.
You will need either a cross compilation toolchain, or to build your own cross binutils.
For a prebuilt toolchain, you can visit code sourcery. If you just want to compile assembly, then all
you need is binutils. There are some guidelines on the Linux Mips wiki
For the emulation part, QEmu would be my choice.
Incidentally, Spim does not require X Windows. It has a console interface as well. Run either spim
or xspim
.
MARS made my assembly programming for MIPS architecture so much easier. If you would like a GUI/IDE, I would recommend MARS for sure.
I was in the same situation yesterday. I also didn't like SPIM, so this is what I did:
installed gxemul and gxemul-doc (those are the package names on debian)
installed netbsd on an emulated MIPS machine following the detailed instructions in the documentation
since netbsd already includes the standard gcc toolchain and vi, you're good to go.
Setting up networking is pretty easy and well documented, too. This has the advantage of not needing to fiddle with cross compilation.
You could use gxemul, which emulates a MIPS machine (among others, including Dreamcast), and is able to run many Operating systems (included linux, netbsd and some more).
gxemul-wikipedia
gxemul-home page
QEmu has a good MIPS emulator. Combine that with a cross-compiled GCC/binutils (technically you only need binutils to get GAS, the GNU assembler) and you're good to go.
Maybe you can take a look at these emulators? I'm not an expert but the list seems good.
Assuming you wish to use GCC.
Steps for compiling for MIPS on an x84-64 system, and then running the executable using an emulator:
Use a cross-compilation toolchain to produce an executable.
If you are on Debian/Ubuntu, install a cross-compilation toolchain for MIPS. For example, either of these APT packages: gcc-mips-linux-gnu
(MIPS big endian) or gcc-mipsel-linux-gnu
(MIPS little endian).
Compile using mips-linux-gnu-gcc
(mipsel-linux-gnu-gcc
for little endian MIPS); assemble using mips-linux-gnu-as
; link using mips-linux-gnu-gcc
.
Run the executable using an emulator.
- Install an emulator that can launch Linux processes compiled for one CPU (e.g. MIPS) on another CPU (e.g. x84-64):
sudo apt-get install qemu-user
.
- Run your executable compiled for MIPS using the emulator:
qemu-mips ./a.out
(or qemu-mipsel ./a.out
for little endian MIPS). Simply running ./a.out
also works; the emulator will be used.