ADJUST

ADJUST, for A Divergent Jumble of Unrelated Symbolic Terms, is a two-dimensional esoteric programming language invented by Scott Feeney in 2005. All of the ASCII characters from 32 to 126 are valid instructions; each instruction carries out several operations depending on the prime factors of its ASCII value.

General operation
Execution starts in the lower left corner with the instruction pointer moving upwards and rightwards (that is, diagonally). At any point in time, aside from the stacks and accumulator register (see below), the program state includes the location of the instruction pointer, given by its x and y coordinates, and the direction of the instruction pointer, being any one of the following: left, up-left, up, up-right, right, down-right, down, down-left.

Valid characters are the ASCII characters 32 to 126, which are instructions, and ASCII linefeed characters (10), which separate lines of code. The effect of any other character is undefined. All lines are padded with exclamation marks to the length of the longest line in the code, making the code space rectangular. Leaving the rectangle of code space is an error and results in undefined behavior.

Each character, when encountered, is converted to the list of prime factors of its ASCII value. Each such prime factor is then executed as an instruction, starting with the largest. For example, A has the ASCII value 65, whose prime factorization is 5 x 13. So if an A is encountered, first the 13 command is executed, then the 5 command.

After executing each command for a character, the program moves forward one character, unless one of the commands executed made the program terminate.

Data storage
ADJUST provides two stacks of 8-bit bytes and an 8-bit accumulator register. Initially, the stacks are empty and the accumulator register is set to 0. At any point in time, one stack is said to be lighter than the other if either (1) it is empty, while the other stack has one or more bytes; or (2) the topmost byte on it is larger than the topmost byte on the other stack. Note that the lighter stack is undefined when both stacks are empty or when each stack contains the same topmost byte. When the lighter stack is defined, the heavier stack is defined as the stack that is not the lighter stack. The stacks are arbitrarily referred to as "stack 1" and "stack 2."

All arithmetic done on the accumulator treats the accumulator's value as signed and is computed modulo 256. Bits in a byte are considered to be numbered from 0 to 7, with 0 being the least significant.

Commands
All prime numbers greater than 67 set the accumulator to themselves.

External resources

 * ADJUST files from The Esoteric File Archive, including an interpreter.