# Szewczyk notation for Minsky machine

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

## Syntax

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`.

## Properties

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

```1 -1
1 1
1 1
```

## Interpreter

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

```#!/usr/bin/perl
use bignum;my(@a,@c,\$d);push(@a,0)for(1..\$ARGV);s/(-?[0-9]+)[ \t]+(-?[0-9]+)/push(@{\$c[\$d++]},(\$1,\$2));/ge while(<STDIN>);
for(\$d=0;\$d<@c;\$d++){\$a[\$c[\$d]]++if\$c[\$d]==-1;if(\$c[\$d]>=0){\$d=\$c[\$d]-1if(\$a[\$c[\$d]]==0);\$a[\$c[\$d]]--if(\$a[
\$c[\$d]]>0);}}print((shift@a)."\n")for(1..\$ARGV);
```

## Extensions

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