Szewczyk notation for Minsky machine

From Esolang
Jump to navigation Jump to search

Szewczyk notation is a tool invented by Kamila Szewczyk of thought useful when describing counter machines. Simply put, this notation for Minsky machines is a minimalistic representation of its capabilities.


Minsky machine code is represented by a list of pairs separated from each other. The text representation looks like this:

a0 a1
b0 b1
c0 c1

Each row is given an unique, consecutive ID. The notation supports two instructions:

  • inc rX => X -1: increment register rX
  • dec rX, Y => X Y: decrement register rX if rX > 0, else jump to row with ID Y.


Numbers can be assumed of infinite precision. The ID's are 0 indexed and registers are initialized to 0


Infinite loop:

1 -1
1 1
1 1


A tiny, 321 byte Perl emulator for the Minsky machine code (assuming Szewczyk notation).

use bignum;my(@a,@c,$d);push(@a,0)for(1..$ARGV[0]);s/(-?[0-9]+)[ \t]+(-?[0-9]+)/push(@{$c[$d++]},($1,$2));/ge while(<STDIN>);


An I/O extension can be implemented as x1 equal to -2 (for output) and -3 (for input) to a given register.