Argh!

From Esolang
(Redirected from Aargh!)
Jump to navigation Jump to search

Argh! and its successor Aargh!, both invented by Sascha Wilde, are Befunge-like esoteric programming languages, laid out in two dimensions. Each is limited to 80 columns wide, but Aargh! has an unlimited number of rows, whereas Argh! is limited to 40. The idea was to make sure Aargh! was Turing-complete.

Each character of the grid is either a one-cell wide command or value. The language also supports a stack of unbounded size. It has 27 documented commands.

Instructions

Argh! has the following commands:

Letter Befunge equivalent Description
A add value of the cell above the current cell to the value on top of the stack (see "R")
a add value of the cell below the current cell to the value on top of the stack
D delete top value off stack
d : duplicate top value on stack
E insert value of system EOF in cell above
e insert value of system EOF in cell below
F fetch (pop) value from top of stack and store to cell above
f fetch (pop) value from top of stack and store to cell below
G get one byte from stdin and store in cell above
g get one byte from stdin and store in cell below
H jump (move instruction pointer) left to the next cell whose value matches the value on top of the stack, and set execution direction to "left"
h < set execution direction to "left"
J jump down to the next cell whose value matches the value on top of the stack, and set execution direction to "down"
j v set execution direction to "down"
K jump up to the next cell whose value matches the value on top of the stack, and set execution direction to "up"
k ^ set execution direction to "up"
L jump right to the next cell whose value matches the value on top of the stack, and set execution direction to "right"
l > set execution direction to "right"
P send value above the current cell to stdout (does not remove the value[citation needed])
p send value below the current cell to stdout
q @ quit: end program execution
R reduce the value on top of the stack by the value of the cell above (see "A")
r reduce the value on top of the stack by the value of the cell below
S store (push) value of the cell above the current cell to stack (does not remove the value[citation needed])
s store (push) value of the cell below the current cell to stack
X if the value on top of the stack is negative, turn the execution direction 90 degrees to the left
x if the value on top of the stack is positive, turn the execution direction 90 degrees to the right
# behaves just like 'j', but only if its position in the code/data array is 0,0 (the left/top corner) and only if there is a '!' in the cell on its right side.

Examples

The following program prints out "hello, world":

j       world
lppppppPPPPPPsrfj
 hello,      *  j
              qPh

Execution begins with the j in the top left corner, which indicates the starting direction of execution is down. The next command is an l, which means to now process commands to the right. Each p indicates that the value below it should be printed; each P indicates that the value above it should be printed.

The next part is more interesting: the goal is to output a linefeed (ASCII value 10, often written as "\n"). This special character has to be generated: the s stores the character below (<"*", ASCII 42) on the stack, the r reduces the value on the stack by the value of the character below (42 minus " ", ASCII 32, is 10), the f fetches the top value from the stack and inserts it below, so the cell below the f will hold the value 10, which is ASCII linefeed. The following j lead us down (we already know this) and the h sets the execution direction to go left and the P finally prints the linefeed. The q (for quit) command ends the program.

A program that tries to leave the grid or execute a value that isn't a command causes the language's standard error message, "Argh!" or "Aargh!" as appropriate, to be emitted, followed by the program terminating.

External resources