Hacker News new | past | comments | ask | show | jobs | submit login
Emulating Linux MIPS in Perl – Part 1: ELF loader (schmorp.de)
77 points by draegtun on July 5, 2015 | hide | past | favorite | 13 comments



A tiny mips emulator I wrote which can boot a linux kernel:

https://github.com/andrewchambers/cmips


This series of posts is amazingly well-written, it explains the steps involved really well IMO, thoughtfully ordering the code snippets to make understanding each step simple.

As a perl user, I'm also highly biased as it's nice to see a perl article on HN once in a while :)


The next step along this path would be to run Perl inside this VM, and then run the emulator in it...

MIPS is certainly one of the simplest instruction sets. A while ago I decided to write one too, for fun, after having done ones for a few other CPUs (Z80, 6502, 8086), and MIPS was by far the simplest, almost to the point of being boring. Getting the branch delay slots right (see http://www.pagetable.com/?p=313 for some details) was the hardest part.


W.r.t. branch delay slots.

An interesting idea: instead of fixing a number of branch delay slots (or none), what about splitting branches? That is - you have a branch_commit instruction, and anything between the branch and the branch_commit is treated as (a) branch delay slot(s), with the processor either filling in pipeline bubbles or stalling the branch as necessary. If you want to get fancy about it you can start doing matched branch / commit pairs (like nesting brackets), or potentially even start dealing with general matching.

Although the decreased instruction density may kill the benefits.


If you like challenge, MIPS can be exceptionally hard and complicated if you want to implement an OoO superscalar core.


I came across the phrase "XY problem" the other day http://www.perlmonks.org/?node=XY+Problem

> You want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.

If we allow "ask" to include asking oneself, then this seems like a great example :)


Ironic; I put together a MIPS based Linux distro about eight years ago, and Perl was one of the items that wouldn't cross-compile to it.

How you get Perl on MIPS is by compiling on a MIPS machine, or in an emulated chroot environment (QEMU on x86, say). Now Perl can maybe supply that environment.


Speaking of MIPS, has anyone had success emulating IRIX?


Am I reading this correctly??

Emulating a whole processor to run a shell script on Windows.... Seriously??

Strikes me that someone didn't research the options correctly or just wants an excuse to play...


Playing aka learning in this profession. Some still care to work towards being able to contribute to the "options" that are in play. This is how those developers and new options are born.


Am I reading this correctly??

Complaining about hackers being hackers on a site called Hacker News... Seriously??


What's wrong with writing an emulator just for the fun of it?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: