B2C
Brainfuck with two cells, and one command to hop between them.
None1, 2023 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
None1 cut the brainfuck tape down to two byte cells. With only two places to go, < and > become one command, |, which moves the pointer to the other cell. Two cells of 8 bits make 65,536 states, so B2C is a finite state machine. It is still enough for a loop that multiplies, which is how its Hello World builds each letter.
The machine
| Command | Does |
|---|---|
+ - | Add or take one; wraps between 0 and 255 |
\| | Move to the other cell |
, | Read a byte; 0 at the end of the input |
. | Print the cell |
[ ] | Loop while the cell is not 0 |
Everything else is a comment. The cat +[,.] prints a 0 byte at the end, because , stores 0 at the end of the input and . prints it before the loop sees it.
Example
The second program adds 8 to the other cell 9 times, then prints 72.
The second program adds 8 to the other cell 9 times, then prints 72.
Further
Ideas it shows
See also
B2C builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from B2C
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: b2c.
Command line
shib run b2c -e '+[,.]' --input 'abc'shib manual b2cSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/b2c.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org