NOR
A processor with one gate. Every other gate has to be built out of NOR.
Dylan Turner · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Dylan Turner made NOR to copy how a processor works at the level of its transistors, with a single universal gate instead of all of them. There are no variables and no pointer. Each numbered line that runs a NOR keeps the result as its own value, and other lines read it back as #line:default. The default is what a line gives before it has run, so a program can read lines that come later.
Read the story
Programs look like BASIC. The first line is the size of the input array, and the rest run in order of their line numbers, whatever order they are written in.
The machine
| Opcode | Does |
|---|---|
NOR a, b | Store the NOR of a and b as this line's value |
INP INn | Read a bit into the input array |
OUT a | Print a as 0 or 1 |
OLN | Print a line break |
JMP n | Jump to line n |
MUX a, j0, j1 | Jump to j0 if a is 0, to j1 if it is 1 |
RND | Set this line, or INn, to a random bit |
RST | Forget every line's value |
OFF | End the program |
REM | A comment |
A value is 0, 1, #n:d or INn. Text can only come out as bits, so the Hello prints five lines of eight bits, one for each letter of Hello.
Example
The truth machine without its comments.
The truth machine without its comments. Line 50 is the multiplexer that picks a path for the bit it read.
The countdown keeps two bits in the values of lines 10 and 20. Lines 24 to 26 are written after line 95 but run right after line 20, because lines run by number.
INP takes the next 0 or 1 of the input and gives 0 once it runs out. RND uses a generator with a fixed seed, so every run is the same.
Patterns it teaches
- Encoding tricks: text only as its bits, one
OUTper bit.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from NOR
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: nor.
Command line
shib run nor -e '1
0 REM Decreases line values from 11 -> 10 -> 0 -> 00
10 NOR #90:0, #90:0
20 NOR #60:0, #60:0
30 NOR #10:1, #20:1
40 MUX #30:0, 50, 100
50 NOR #20:1, 0
60 NOR #50:0, #50:0
70 NOR #10:1, #10:1
80 NOR #70:1, #50:0
90 NOR #80:1, #80:1
95 JMP 10
24 OUT #10:1
25 OUT #20:1
26 OLN
100 INP IN0'shib manual norSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/nor.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org