ADJUST
A Divergent Jumble of Unrelated Symbolic Terms. Every printable character is an instruction, and what it does depends on its prime factors.
Scott Feeney, 2005 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Scott Feeney made ADJUST in 2005. It is two dimensional and starts in the lower left corner, moving diagonally up and to the right. Every character from space to ~ is valid, and none of them was chosen for its meaning. Instead a character's ASCII code is split into prime factors, and each prime is a command. A is 65, which is 5 × 13, so it runs command 13 and then command 5.
Read the story
So the effect of a letter is a jumble of turning, pushing, popping and bit twiddling. Primes above 67 load themselves into the accumulator, which is how a program gets its numbers. I is the prime 73, and flipping its lowest bit gives 72, H.
The machine
There is an 8-bit accumulator and two stacks of bytes. One stack is called lighter, the empty one if the other is not, else the one with the larger top. Many commands push to or pop from the lighter or the heavier stack, and some turn depending on which was which.
| Prime | Does |
|---|---|
| 2 | Rotate the accumulator 3 bits right |
| 3 | Push it on the lighter stack, turn by a rule, move |
| 5 | Flip bit 0 |
| 7 | Move once per set bit |
| 11 | Pop the heavier stack into the accumulator |
| 13 | Pop stack 2 and print it |
17 19 | Read a byte (or take one from stack 2) onto stack 1; at the end, turn and move by the bits |
| 23 | Shift 5 bits left |
| 29 | If the accumulator is 0, side-step diagonally |
| 31 | Move |
37 41 47 | Copy the lighter top to the heavier stack, drop the heavier top, pop the lighter |
| 43 | Shift right; at 0, move and turn left |
| 53 | Reverse four of the bits |
| 59 | Turn right once per set bit |
| 61 | Swap the stacks |
| 67 | Exit |
| above 67 | Load the prime itself |
Short lines are padded with !, 33, which is 3 × 11. Leaving the rectangle is an error.
Example
The pointer starts on }, 125, which is 5 × 5 × 5, and three flips leave the accumulator at 1.
The pointer starts on }, 125, which is 5 × 5 × 5, and three flips leave the accumulator at 1. ; is 59, which turns right once per set bit, so the pointer now runs along the top line. I loads 73, and -, 45 or 5 × 3 × 3, flips it to 72 and pushes it. Each letter after that comes from a prime such as e, 101, or from a small sum. In the second program O loads 79 instead, and the same - makes 78, N.
Patterns it teaches
- Two-dimensional control flow: eight directions, and turns hidden inside arithmetic.
- Encoding tricks: a character's meaning is its factorisation.
- Hostile design: no character was given its job on purpose.
Further
- esolangs.org/wiki/ADJUST
- The Esoteric File Archive, with the original interpreter
See also
Two-dimensional languages
Stack-based
Write your own in Run Convert a program from ADJUST
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: adjust.
Command line
shib run adjust -e ' ;I- & e$ & m- & g2Ph$ & a2$ & n$ & e2+- & g2Ph$ & OPh$ & m- & e- & n-
} AgR}; AgR}; A=AgR}; AgR}; AgR}; AgR}; AgR}; AgR}; AgR}; AgR}; AgR}; AC'shib manual adjustSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/adjust.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org