Inspired by Jos Dreesen's Lilith emulator and following his recent discovery of the ETHZ M2 single pass compiler sources, I decided to build my own take of a runtime environment for the compiler and the M-code object files it generates.
Instead of emulating the Lilith machine on a microcode level, my design interprets the M-code opcodes directly. Also, several core functions of Lilith's original Medos-2 operating system are carried out by the interpreter itself, which allows the design to become less dependent on the original Lilith machine architecture and also improves performance. The main areas concerned are object file loading and staging, memory management and OS-level file and device management.
The bottomline of this approach (and the most pronounced difference to Jos Dreesen's emulator) is that It no longer faithfully simulates the historic Lilith machine. In particular, the interpreter (currently) lacks the bit-mapped graphic capabilities of the original machine. On the plus side however, it is now possible to run (character-based) Modula-2 programs in a standard terminal environment. Also, we can read/write files in the UNIX file system directly. And finally, code and data no longer share the same limited address space as in the Lilith, although this advantage might be considered theoretical at best in 2022 :)
The interpreter is "Wirth Level 1 Compliant", which I define as the ability to execute N. Wirth's single pass compiler to compile its own sources :) The bootstrapping process to get there relied heavily on Jos' emulator, which I used to build the single pass compiler with the earlier multipass compiler (not so easy, by the way!). Also, I needed to adapt the initial set of M2 libraries required by the compiler to the specific environment of my interpreter before reaching the pivotal point where everything could compile itself under my interpreter.
(In the process, I could not resist to tweak Wirth's compiler to read files with standard UNIX LF characters, something which might have been considered a heresy back in the day :) )
Everything is still work in progress and there are plenty of rough edges, but you can check out a beta version at
The setup includes the interpreter, a minimal runtime environment with M2 libraries and the original single pass compiler, as well as my own very primitive command shell inspired by the "SEK.Comint" command line interpreter of Lilith's original Medos-2 OS.