PZAB

PZAB is a programming language created by Zac Herd in 2013. The idea was to create a language that forced the programmer to manipulate memory and registers on a binary level. PZAB, like all good esoteric languages, was designed to be essentially unreadable.

Language Overview
The language is based around a simple computer architecture, in which memory is arranged into a one dimensional array of 'cells' that each contain a value. The interpretation of those values is entirely up to the programmer.

The PZAB language is written in such a way that the programmer is addressing a virtual machine. This machine has 256 bytes of memory and five registers.

PZAB Machine


The P0 register points to a cell in memory. If P0 was set to 00000000(0) then it would be pointing to memory cell 0, the first cell of memory. Similarly, if it was set to 11111111(255) then it would be pointing to cell 255, the last.

The P1 register points to a bit in a memory cell. If P0 was set to 00000000(0) and P1 was set to 000(0), then we would be referencing bit 0 of memory cell 0. If P0 was set to 11111111(255) and P1 was set to 111(7), we would be referencing bit 7 of memory cell 255.

The Z register is used as an accumulator. It only holds one bit, and cannot be assigned to directly. Rather, it takes the value of the results of logical operations performed on it and the A and B registers. The Z register can be used to assign values to bit P1 of memory cell P0, or to assign values to A and B directly. Z can have the logical NOT operation performed on it.

The A and B registers are essentially the inverse of Z; they can be assigned values, but their contents cannot be assigned to anything else. A and B can have logical operations performed on them (AND, OR, XOR) and the results placed in Z.

All memory and registers are initialised with a value of zero.

PZAB Instruction Set
All PZAB instructions are single ASCII characters. All 'non PZAB' characters are ignored by the interpreter (this includes spaces, tabs, line breaks, Etc.).

The instructions for the PZAB interpreter are as follows:

Example Code
Hello World:

<<Z>>!Z!>Z>>Z; !Z!<>Z>Z; !Z>>Z>Z!; Z>Z>Z<<<>Z!>Z; !Z>Z>>Z!<<<Z>Z>!Z; <>>>Z!>>Z;

Adder (accepts two integers and calculates their sum):

.+.- A+B_++Z-&Z 7--B<_+Z&-aB|Z0 +:

Subber (accepts two integers and subtracts one from the other):

+++++.-. 8A|!+Z-<0 ++>>>>>>>ab_!Z- A+B_++Z-&Z 7--B<_+Z&-aB|Z0 >>>>>>>+A+B_++Z-&Z 7--B<_+Z&-aB|Z0 +:

Implementations

 * PZAB Interpreter in C on GitHub