Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I want to write an emulator as a learning experience. Any tips how should I start?


I recently posted about emulating the NES with JavaScript.

http://blog.alexanderdickson.com/javascript-nes-emulator-par...

Part 2 will be posted when it's done. :)

If you want to get something done much quicker, have a go at emulating the Chip-8 VM.

I also have a post, but it's less hand-holding than the first.

http://blog.alexanderdickson.com/javascript-chip-8-emulator

Good luck!


I really like your tutorial. I been trying to learn assembly and your tutorial is really helping me put the big picture together. I hope you continue to work on making it better.


I have a heap on my plate right now but will hope to do part 2 before the end of the year. Glad you enjoyed it.


I'd like to think of myself as an experienced programmer, but I still loved your tutorial ! Brilliant ! Keep up the good work.



You want to write an emulator, but you probably don't want to write one for x86. A nice architecture would be 8 bit AVR microprocessors, for example.


There are two sensible approaches: interpretation or dynamic translation.

If you want to write one as a learning experience for how the platform you're emulating works and how an emulator could work in principle, you probably want to write an interpreter: find out how the platform boots, build something to start reading and interpreting instructions, start adding emulated hardware devices, and you'll get an increasingly functional interpreter.

For a start, you could ignore emulation of devices, and just write a CPU core that interprets instructions.

If you want to learn how modern (but still non-hardware-assisted) emulation works, read about how qemu's dynamic code translator and other JIT compilers work, and build a CPU emulator based on that.


I'm not the OP but check out the book: "The Elements of Computing Systems: Building a Modern Computer from First Principles" It's quite comprehensive, not exactly about writing an emulator, but it should give you what you need.






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

Search: