esolang

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

Expected: Hello, World!

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.

PrimeDoes
2Rotate the accumulator 3 bits right
3Push it on the lighter stack, turn by a rule, move
5Flip bit 0
7Move once per set bit
11Pop the heavier stack into the accumulator
13Pop stack 2 and print it
17 19Read a byte (or take one from stack 2) onto stack 1; at the end, turn and move by the bits
23Shift 5 bits left
29If the accumulator is 0, side-step diagonally
31Move
37 41 47Copy the lighter top to the heavier stack, drop the heavier top, pop the lighter
43Shift right; at 0, move and turn left
53Reverse four of the bits
59Turn right once per set bit
61Swap the stacks
67Exit
above 67Load 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.
Expected: Nello, World!

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

Further

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 adjust

Source

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