Nybblang
A program is four bits long. Anything bigger has to be a chain of programs.
PythonshellDebugwindow, 2020 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
PythonshellDebugwindow named Nybblang after the nybble, four bits. A program is exactly one nybble, so it holds two commands of two bits each. To do more, the interpreter is given a sequence of files, and the command 11 hands control to the next one. The last file wraps round to the first.
Read the story
Bits pushed one at a time collect in a buffer, low bit first, and every fourth bit pushes a whole nybble to the stack. A nybble picks one of 16 characters to print. Nothing reads the stack except printing, so the specification concludes that Nybblang cannot compute at all.
The machine
| Bits | Does |
|---|---|
00 01 | Push a 0 or a 1 into the buffer |
10 | Pop a nybble and print that letter of ETAOINSRHDL WU. and line feed |
11 | Go on with the next file of the sequence |
Each line of the source is one file. A file that ends without 11 ends the run.
The specification also sketches a modification. If a program could be longer than four bits, 11 could become a jump to instruction n whenever the bottom of the stack is above 0. A single line that is not four bits long runs that way.
Example
The HELLO takes 24 files.
The HELLO takes 24 files. Four files push the bits of 8 one by one, and the fifth prints H.
The truth machine of the modification. With both x set to 0 it pushes two nybbles of 0, prints E and stops, as the bottom of the stack is 0. With both set to 1 it prints T forever.
Patterns it teaches
- Encoding tricks: a four-bit limit turns one program into a chain of files.
Further
See also
Stack-based
Write your own in Run Convert a program from Nybblang
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: nybblang.
Command line
shib run nybblang -e '00000000000000001011'shib manual nybblangSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/nybblang.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org