Counter machine

An implementation of a minimal counter machine.

Manual and instructions

This machine has two instructions:

  1. INC a, which increments counter number a. Written as +2.
  2. JZDEC a i, which decrements counter number a if it's nonzero, and jumps to instruction i otherwise. Written as -2?5.

Note that counters are numbered from 0, while instructions start at 1.

Source code on GitHub.

Input:

Output: