ReadWrite
Two instructions, READ and WRITE. Printing, input and jumps are all addresses.
Dominicentek, 2021 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Dominicentek made ReadWrite in 2021. It has one register, a memory of numbered addresses and two instructions. READ copies an address into the register and WRITE copies the register out. Everything else lives at four negative addresses. Writing to -1 prints a number, writing to -4 prints a character and writing to -3 jumps to that line. Reading -2 skips the next line when it holds 0, and that is the only condition in the language.
The machine
| Line | Does |
|---|---|
READ a | Copy address a into the register |
WRITE a | Copy the register to address a |
WRITE a v | Write the value v to address a |
v | Put the value v in the register |
| Address | Written | Read |
|---|---|---|
-1 | Print a number | Read a number |
-2 | Keep the value | Give it, and skip the next line if it is 0 |
-3 | Jump to that line | The current line |
-4 | Print a character | Read a character |
A value is a number, # for the register, or one calculation such as 0 + 1 or ! 2. Inside a calculation a number is an address, so 0 + 1 adds what is stored at 0 and at 1. Lines count from 1. The specification leaves the size of a number open, and whether a printed number gets a line feed. Numbers are 32-bit integers that wrap, and a number is printed bare.
Example
The truth machine stores the number it reads at -2 and reads it back.
The truth machine stores the number it reads at -2 and reads it back. On 0 that skips the jump to line 6, so line 5 jumps to line 8, which prints 0. On 1 lines 6 and 7 print 1 forever.
Arithmetic goes through memory. This stores 6 and 7 at the addresses 0 and 1 and multiplies what is there.
The calculator reads two numbers and then 1 to 5 for add, subtract, multiply, divide and modulo. It keeps a 1 at address 2 and takes it off the choice until a READ of -2 finds 0. All five branches work.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from ReadWrite
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: readwrite.
Command line
shib run readwrite -e 'READ -1
WRITE -2
READ -2
WRITE -3 6
WRITE -3 8
WRITE -1 1
WRITE -3 6
WRITE -1 0' --input '0'shib manual readwriteSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/readwrite.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org