Writing a register based VM in less than 125 lines of C code

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • gigatron-rom

    System, apps and tooling for the Gigatron TTL microcomputer

  • lc3-vm

    A LC3 virtual machine implementation in a few lines of C code

  • I haven't read the whole article yet, I just want to report what seems to be a small error:

    > The code is written in C11, and it will probably compile on most operating systems. The repo can be found here, and the exact source code is vm.c:

    The link on "here" is broken, it's https://github.com/,nomemory/lc3-vm (with a comma before your github username) instead of (I think) https://github.com/nomemory/lc3-vm.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Puts Debuggerer

    Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.

  • I haven't read the whole article yet, I just want to report what seems to be a small error:

    > The code is written in C11, and it will probably compile on most operating systems. The repo can be found here, and the exact source code is vm.c:

    The link on "here" is broken, it's https://github.com/,nomemory/lc3-vm (with a comma before your github username) instead of (I think) https://github.com/nomemory/lc3-vm.

  • lc3as.py

    An assembler for the LC-3 fictitious computer.

  • Ah the LC-3! I wrote an assembler for it a little while ago: https://github.com/pepaslabs/lc3as.py

    I’ll definitely be digging into this article!

  • Papers

  • Further to this: this kind of thing is something the Forth community takes seriously. They call these threaded code techniques. [0] (The Gforth interpreter, for instance, gives you the choice of various different techniques.)

    Anton Ertl of Gforth fame published a microbenchmark performance comparison of toy interpreters, written in C, run on various CPUs. [1] As you say, the approach using function pointers (call threading) scores poorly.

    Interestingly, direct threading and indirect threading are extremely close, with the winner seeming to depend on the specific CPU. [1] Branch-prediction differences seem to be the main reason. There was a 2001 paper on this. [2]

    [0] https://www.complang.tuwien.ac.at/forth/threaded-code.html

    [1] https://www.complang.tuwien.ac.at/forth/threading/

    [2] https://github.com/ForthPapersMirror/Papers/blob/master/Conv...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts