Features

There are many different types of microprocessor; there are complex ones, e.g. CISC – like x86, and there are reasonably simple ones e.g. RISC – ARM, and simpler variants like DLX.  At the bottom of this pile are VERY simple ones; like subleq.

Subleq is a single processor instruction set; everything is then built on top of this.  You can summarise how this instruction works as follows:

mem[inst.dst] = mem[inst.dst] – mem[inst.src]
if mem[inst.dst] <= 0:
    ip = inst.jmp
else:
    ip = ip + sizeof(inst)

This particular implementation also supports dereferencing of memory.  Basically, if inst.src or inst.dst is negative the respective term becomes:

mem[mem[abs(inst.src)]]

The main differences between my implementation and everyone else is that:

  • mine actually calls C functions directly – and thus is better (see the details page for more info).
  • mines got a cool command line debugger

System Requirements

  • Requires Python 2.7; it should work on most platforms but only tested so far on 10.7 (Lion)
  • The inline assembler needs gcc; the OSX version of the module comes pre-built
  • Python running as 32bit; try using “export VERSIONER_PYTHON_PREFER_32_BIT=yes"

Download

subleq-v1.0

Release Notes

  • Initial, public, release
  • the assembler; subleq-asm.py
  • the debugger/runtime; subleq-dbg.py
  • a simple “hello world” example; just to prove it works

Links

Here are a few links to other information that I found interesting/useful.