Adj
One instruction adds and jumps. To choose, a program jumps to a row number it has just computed.
2024 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Adj stands for add and jump, a = a + b; goto c. It dates from 2024, and its specification is written in a deliberately ornate English. There are three variables, a, b and c, each an integer of any size. Nearly everything is the one instruction ADJ, and its operands decide what it does. With 0 or 1 in the first place it prints or reads, and with X it leaves out the add or the jump.
Read the story
There is no condition. A jump can go to a row number held in a variable, so a program picks a row by computing its number.
The machine
| Row | Does |
|---|---|
ADJ a b c | Add b to the variable a, then jump to c |
ADJ a b X | Add b to a and go on to the next row |
ADJ X X c | Jump to c |
ADJ 0 b c | Print b as a number |
ADJ 1 b c | Read an integer into the variable b |
name: | A label |
b is a variable or a number. A jump target is a label, a row number, or a variable that holds one. Rows count from 1, blank rows and label rows too. A jump past the last row ends the program.
Example
Add 1 and 1.
Add 1 and 1.
Add two numbers from the input.
The truth machine sets b to 7 plus twice the input and jumps to row b. On 0 that is row 7, the label case_of_zero, and row 8 jumps to row 11, past the end. On 1 it is row 9, and row 10 prints 1 and jumps back to its own label forever.
Patterns it teaches
- One instruction: every command is
ADJ, and0,1andXin its operands make it print, read, or skip the add or the jump. - Counter machines: three counters, with a computed jump as the only test.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Adj
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: adj.
Command line
shib run adj -e 'ADJ 1 a X
ADJ X X a' --input '3'shib manual adjSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/adj.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org