Hacker News new | past | comments | ask | show | jobs | submit login
16-Bit VM in JavaScript (francisstokes.wordpress.com)
84 points by mzehrer on July 22, 2017 | hide | past | favorite | 11 comments



Something I've always wanted to do (16 bit as well, even) but never got around to. Thanks for the writeup!


Congratulations! I've been working on a similar (though less well-documented) project in Rust: https://github.com/jasonhansel/kineticvm


Ah very cool! Rust seems like an awesome language, especially for something like this. I'l going to take a dive into your project at some point in the week


Props for choosing `->` instead of either of the historical mistakes `opcode s, d` or `opcode d, s`.


Is this a VM in the sense the JVM is a VM, or is it a VM in the sense of a CPU emulator?

It seems to be the former, but I'm not well read in VM implementation.


That's a very fuzzy, if not non-existent, distinction. The only real difference is the designers' original intention. Of course the Java VM was originally only destined to exist only in software, but hardware versions do exists [1]. And of course x86 was always destined for hardware, but there's more software implementations of that than can be counted. There's also a third type in the LLVM sense, where the VM is just an intermediate step in compiling from a high level language down to machine code. And that's where the JVM (mostly) falls today.

The VM described in the OP could easily fit in any of the three.

[1] http://www.jopdesign.com/


This is in a way that they make emulators in Javascript like that too? Might be possible to emulate Mame and Mess machines if they haven't already?


Indeed, the core concepts are essentially exactly the same. This is a lot simpler of course because it doesn't need to do anything with drawing or sound.

I really like this project https://github.com/juchi/gameboy.js/ . I'd like to do something similar myself but more in the coding style I've used on the 16-bit VM.


Yes, there are some similarities to how you would write an emulator for a real piece of hardware. It would be possible to write an emulator for whatever hardware you can find enough information about.


Very interesting read and props for choosing opcode D, S.


Thanks, I've had mixed feedback about that choice!




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: