This article was copied from http://www.geocities.com/qpliu/nouse/nouse.html on 2009-08-23, to save it from the impending GeoCities shutdown. The original author is Q.P.Liu

The nouse programming language

nouse is pronounced like noose. It is spelled nouse because it's not useful.

The inspiration for creating this language came while reading a description of Befunge, in which the flow of control can go left, right, up, or down in a torus. So I figured it would be even more perverse if the flow of control depended on something like the current size of the stack.

The nouse virtual machine consists of a ring of bytes and a stack of bytes. Execution continues as long as the instruction ring is not empty, and begins at instruction 0 with an empty stack.

Instructions

Each byte in the ring is an instruction. Each instruction is composed of two parts. The byte modulus 7 specifies the instruction. The byte divided by seven specifies the skip multiplier.

The skip

The skip of the instruction is the skip multiplier multiplied by size of the stack before the operation is executed.

For example, if the instruction is write 4, where write is the operation, and 4 is the skip multiplier, and if the stack contains 3 bytes, then the skip is 12.
The skip is used to determine the next instruction and, if necessary, the operand of the instruction. The read, write, and swap operations have no operand, and, when the stack is empty, the add and test operations become noops with no operand. When there is no operand, the next instruction is determined by skipping skip bytes after the current instruction. When there is an operand with the add, test, add operations, the operand location is determined by skipping skip bytes after the current instruction, and the next instruction is determined by skipping skip bytes after the operand location. The cut, paste, and swap operations change the instruction ring; the descriptions of these operations will specify how the operand and next instruction are determined from the skip.

The operations

The operations are

Syntax

There are two syntaxes: the assembly syntax, and the line-noise syntax. The simple interpreter in OCaml and the interpreter in C support only the line-noise syntax. The fancier interpreter in OCaml supports both syntaxes, and can convert between the two.

Assembly syntax

Line-noise syntax

Examples

Ideas for adding perversity