Pirandello

Pirandello is a two-dimensional esoteric programming language by Abraham Karplus, which uses six characters often associated with arithmetic for completely different purposes. Any other characters encountered while running the program are an error. User:Marinus has written an implementation in Python.
== Data ==
The data is stored in a left-infinite tape of bytes, initialized to 0 and numbered starting at 0. The data pointer (DP) begins at byte 3 (the fourth).
== Code ==
The instruction pointer (IP) begins in the top-left corner, pointing down. Each step, it executes the current command (which may turn or move it), then advances one character in the direction it is pointing.
== Instructions ==
The six characters used in the instructions are
 + - / * % =
Of these, only two have the same function throughout the program:
 = No operation (NOP)
 % Cycle mode (MOD)
There are four modes, each with different meanings for the remaining four characters. The program begins in Flow mode.
=== Flow Mode ===
 * Skip Instruction (SKP)
Move the IP on square in the direction it is currently facing. Note that since it will then move another square, this skips the next instruction.
 / Conditional Turn (TRN)
Execute the Turn Left command if byte 0 is greater than zero, otherwise execute the Turn Right command.
 + Turn Left (LEF)
Rotate the IP 90 degrees counterclockwise. For example, if it was facing down, it is now facing right.
 - Turn Right (RIG)
Rotate the IP 90 degrees clockwise. For example, if it was facing up, it is now facing right.
=== Data Mode ===
 + Advance (ADV)
Move the DP one byte to the right.
 - Retreat (RET)
Move the DP one byte to the left, if possible.
 * Increment (INC)
Increase the value of the byte at the DP by one.
 / Decrement (DEC)
Decrease the value of the byte at the DP by one.
=== Interaction Mode ===
 + Input Character (INP)
Read one character from input and set byte 1 to its value. Byte 2 is unchanged, except on EOF where it is set to 1.
 - Output Character (OUT)
Output byte 1 as a character.
 / Escape (ESC)
Send an escape (not the character) that can be used to communicate with the OS, say to open a file or for graphics.
 * Exit (EXT)
Exit the program immediately.
=== Register Mode ===
 + Store in Register (SRG)
Stores the value at the DP in the register.
 - Load from Register (LRG)
Loads the value from the register into the byte at the DP.
 / Skip if Register (RSK)
Executes the Skip command if the value in the register is not zero.
 * Add from Register (ADD)
Adds the value in the register to the byte at the DP (still wrapping mod 256).
== Escapes ==
The escape command (written / in Interaction mode) has several uses, only one of which is currently defined. (Note: values in escape sequences refer to numeric values and not characters.)
=== File I/O ===
A file can be opened by sending an escape, followed by the value 5, the name of the file, another escape, and the mode. (The 5, name of the file, and mode are sent using standard output.) This will change standard output, input, or both to read or write from the given file. Modes are read (value 1), write (value 2), and append (value 3). To close a file, send escape then value 6.
=== Buffering ===
Escape followed by 4 and another value changes the I/O buffering. The codes are
# Toggle input blocking (starts blocking). In nonblocking mode, input will return 0 instead of waiting if no input is available.
# Flushes input, discarding any unread characters.
# Flushes output.
== Examples ==
=== Cat ===
 %
 -
 % *
 % %
 % %
 +*-%%+%+%%--%%-%/
 -======%%-%++%-
Route of IP:
 v
 v
 v O
 v ^
 v ^
 >>>>>>>>>>>>>>>>?
 ^<<<<<<<<<<<<<<
Category:Languages
Category:2011
Category:Cell-based
Category:Turing complete
Category:Brainfuck derivatives
Category:Two-dimensional languages
Category:Implemented