esolang

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

Expected: 2

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

RowDoes
ADJ a b cAdd b to the variable a, then jump to c
ADJ a b XAdd b to a and go on to the next row
ADJ X X cJump to c
ADJ 0 b cPrint b as a number
ADJ 1 b cRead 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.

Expected: 7

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.

Expected: 0

Patterns it teaches

  • One instruction: every command is ADJ, and 0, 1 and X in 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

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 adj

Source

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