Hacker News new | past | comments | ask | show | jobs | submit login

Everyone should do this once! I picked MSP430 because it was the simplest instruction set that GCC would compile for, and the process of building the emulator was every bit as pleasant as I'd hoped --- I got the compiler working, wrote a disassembler, and then iteratively built the emulator to get successively more interesting C programs to run on it. Took 2 weekends altogether. One of the best learning experiences of my career.



It's a good exercise, and one of those experiences that helps to take the magic out of things (which for many people is an intimidating barrier preventing further understanding and growth). Like writing a compiler, various network protocols, file parsers, operating system, or directly writing assembler (especially if you've always used higher level languages before).


For what it's worth, I found the emulator way easier than the codegen step for the compiler, and it's probably easier than the AST generation too. Can't say enough good things about banging out a crappy emulator sometime when you're bored. It's not a huge commitment!


Yea, it's a lot of fun. I did this with a 6502 over Christmas vacation years ago. Mind, it was a 6502 emulator, not a specific system. My goal was to get Fig Forth up and running on it. I wrote it in Java, and had my own console, as well as CPU level breakpoints and such for testing. It supported the simple "serial" console and simple block disk I/O.

So, not only did I write the emulator, I wrote an assembler to assemble the stock Fig source code.

It's hard to express how interesting it was testing unknown source code, with a buggy assembler, on a buggy CPU. For extra loads of laughs, my "benchmark" system that I happened to be testing opcodes and such against (for flags and what not) was a buggy web emulator. You just never knew what was going to go wrong where. Amazingly, I sussed it all out.

The good news is that the Fig source pretty much worked out of the box. Outside of my minor changes to adapt to my "I/O", it worked really well.




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

Search: