How can I execute MIPS assembly programs on an x86 linux?

22,407

Solution 1

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.

Solution 2

Incidentally, Spim does not require X Windows. It has a console interface as well. Run either spim or xspim.

Solution 3

MARS made my assembly programming for MIPS architecture so much easier. If you would like a GUI/IDE, I would recommend MARS for sure.

Solution 4

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

Solution 5

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.

  • Share:
    22,407

    Related videos on Youtube

    Dennis Kioko
    Author by

    Dennis Kioko

    Updated on July 16, 2021

    Comments

    • Dennis Kioko
      Dennis Kioko almost 3 years

      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.

      • XTL
        XTL over 9 years
        Also, there is no such thing as "X windows".
      • Michael Petch
        Michael Petch over 8 years
        @XTL X-Windows is an informal name for X11 or X
    • Serafina Brocious
      Serafina Brocious over 15 years
      Oh, and hi again. Apparently we're both emulator dorks on a similar sleep schedule ;)
    • Serafina Brocious
      Serafina Brocious over 15 years
      This focuses on system emulation, not userland emulation. That is, that reference is good if you want to emulate a complete MIPS box, not just a given MIPS app.
    • Dennis Kioko
      Dennis Kioko over 15 years
      @Cody Brocious, Hi, lol. Have you written your own disassembler or assembler? Is it worth writing either as a learning exercise? I have so many questions I want to throw your way, lol.
    • Serafina Brocious
      Serafina Brocious over 15 years
      I've done both on various occasions (written quite a few disasms while doing decompiler dev). Feel free to AIM me at bloomfilter to ask any questions you have.
    • Nils Pipenbrinck
      Nils Pipenbrinck over 15 years
      Qemu + CodeSourcery fits all needs!
    • Dennis Kioko
      Dennis Kioko about 15 years
      If you ever find yourself without those, I found MARS to be much supieror to SPIM. It is a Java .jar file so it works across linux/windows. The reason I like it is it has a built in debugger and I can step through my code or codebreak, and see the value of all registers. Helps a ton in debugging.
    • Kim Stebel
      Kim Stebel about 15 years
      Thanks, that's actually what our university uses. But I wanted to be able to call c functions from assembly code and I don't think MARS supports this. ;) Also, it's nice to be able to examine the output of "gcc -S somecprog.c".
    • new123456
      new123456 almost 13 years
      Where did you get the ISO for FreeBSD? I see that it's actively developed, but I don't see where to get the CD image. I'm trying Debian now, anyway.
    • new123456
      new123456 almost 13 years
      xspim now has it's own punchline: "The 90's called - they want their spim GUI back."