Whirl

Appeared in:
July 9, 2004
Paradigm:
Typing discipline:
File extensions:
.wrl
Versions and implementations (Collapse all | Expand all):
Programming language

Whirl is an esoteric programming language which uses only 0s and 1s for source code and a pretty weird way to convert them into commands.

Whirl was created by Sean Heber in 2004. The weirdness of the language earned some devoted followers who created several implementations and quite a lot of helpful tools.

The language is based on two rings with 12 commands on each, grouped by topic: math and “operational”. Each ring has a pointer to the current command (initially each pointer is set to Noop, a no-action command), direction of rotation (initially clockwise) and a memory cell. The language also provides random-access memory.

All activity of the program is based on these rings and changes in their state. Characters of the program change their state as follows. 1 always rotates the active ring one command in its current direction of rotation. 0 reverses the direction of rotation of the active ring. Besides, if the current 0 command was preceded by another 0 which didn’t trigger command execution, the current command on the active ring is executed, and the active ring changes. All characters of the program which are not 0 or 1 are ignored.

Commands

Here value denotes the value in the memory cell of the active ring, memval — the value in the current cell of random access memory. The commands of each ring are given in clockwise order. Several commands (memory access, setting constants) are duplicated on both rings, as they are necessary for functioning of the program.

Operations ring:

  • Noop No action
  • Exit Stop program execution
  • One Set value to 1
  • Zero Set value to 0
  • Load Set value to memval
  • Store Set memval to value
  • PAdd Unconditional jump: add value to current program position pointer
  • DAdd Add value to current memory cell pointer
  • Logic Logical AND: set value to (memval AND value)
  • If Conditional jump: if memval is not 0, add value to current program position pointer
  • IntIO If value equals 0, read an integer from standard input stream and assign it to memval, otherwise print memval as an integer
  • AscIO If value equals 0, read a character from standard input stream and assign its ASCII-code to memval, otherwise print memval as a character

Math ring:

  • Noop No action
  • Load Set value to memval
  • Store Set memval to value
  • Add Set value to value + memval
  • Mult Set value to value * memval
  • Div Set value to value / memval
  • Zero Set value to 0
  • < Set value to 1, if value < memval, and 0 otherwise
  • > Set value to 1, if value > memval, and 0 otherwise
  • = Set value to 1, if value = memval, and 0 otherwise
  • Not Set value to 1, if value = 0, and 0 otherwise
  • Neg Multiply value by -1

A prototype of Whirl machine
A prototype of Whirl machine

Examples:

Hello, World!:

Example for versions Whirl

This program was written by Kang Seonghoon.

110011100111000001111100000001000011111000011111100000000010
000011001111100001100010000010011111000100000000000001001111
100000111110001000000000000000001000111110010000001100001111
100011000000000100111110011100111000111000001000111000001111
100000111110010000011111000110011111100001111000001111000001
110011111100001111000110011100000111000100011111000001111100
100000110000000111000001110001111100011111000111000001000001
000011000111110001000001000000011100000111001000111110001111
000001111000011111100001111110000011110000000000000000011110
000011100111000011110011111000111110001111100000100000000000
000000000000111110001110000001110000011100011100111110001000
100000000011100001111100110000000010011111000111100000111100
111100010011100000111110000011111001100111100010001111000000
000001000111110010000010011110011001110001000111110001100000
100011111000011110011100111111000111100000111100011111000000
011110000011100100001111000100011111001100011111000111100000
111001110001100111100100000000000000011111000001111100010010
000011100001111100100000100011100000111000110011110001001111
110001100000111100011111000111100000111001000011110001001111
100000111110000000011110000011110000000000000000111000001110
000011000001100000111000111000001100111110000111111001001110
000011111000001100011000001001111110000011100110011111000000
000111000001110000111100001100