LC-3 VM Mojo Implementation

I really liked this guide on how to Write your Own Virtual Machine for the LC-3 architecture.

I made a Mojo port of it: TylerHillery/write-your-own-vm/src/vm.mojo

The only part I wasn’t sure how to implement natively in Mojo was input buffering, since the C version relies on POSIX APIs like termios, select, fd_set, and signal handling. For now I used Mojo’s Python interop to handle that.

Here is a video of the VM running an assembled version of the 2048 game.

mojo-lc3-vm-2048

Great stuff! I’ve got some C FFI bindings for Termios in my mist package. You could add it to your project as a dependency or just copy over the code you need so you don’t have to use Python interop.

Nice! I copied over just the termios module since I didn’t need all of Mist for this project, and added attribution/license info. Now I have a 100% native Mojo implementation :fire:

Glad to hear it! I had the termios in that package for convenience, but I’ve pulled it out into it’s own package now as well in case anyone does want to just that part of it.