14 votes

Write your own virtual machine

4 comments

  1. kej
    Link
    Thanks for this; I wanted to read more about VM implementation after reading about this other minimal virtual machine earlier today: https://100r.co/site/uxn.html It's interesting how much you can...

    Thanks for this; I wanted to read more about VM implementation after reading about this other minimal virtual machine earlier today: https://100r.co/site/uxn.html

    It's interesting how much you can get out of such simple building blocks.

    3 votes
  2. text_garden
    Link
    On a tangential note, I recently learned of this from the winners of the IOCCC (International Obbfuscated C Code Contest). It's a single-instruction VM, using a variation of a subleq instruction...

    On a tangential note, I recently learned of this from the winners of the IOCCC (International Obbfuscated C Code Contest).

    It's a single-instruction VM, using a variation of a subleq instruction with indirect memory addressing, connected to basic I/O like keyboard, frame buffer and a clock. The author then went ahead and wrote an LLVM backend targeting the VM and (among other things) ported Linux and busybox to it. Yes it runs Doom!

    Even without the obfuscation this is a tiny, tiny C program that is surprisingly viable as a platform for much more complex programs.

    3 votes
  3. Crespyl
    Link
    I'm definitely saving this for later. VMs are an interest of mine, and I always love working on them. Wastl's Synacore puzzle and his 2019(?) Advent of Code Intcode problems were some of the most...

    I'm definitely saving this for later. VMs are an interest of mine, and I always love working on them. Wastl's Synacore puzzle and his 2019(?) Advent of Code Intcode problems were some of the most fun I've ever had programming.

    2 votes
  4. Areldyb
    Link
    Hey, I remember the LC-3! Good times. And an embarrassing number of hours in the computer lab.

    Hey, I remember the LC-3! Good times. And an embarrassing number of hours in the computer lab.

    1 vote