BytFuck
Brainfuck with a second pointer, aimed at one bit of the current cell.
2020 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
BytFuck is brainfuck with one more pointer. The cell pointer picks a cell, as always, and a bit pointer picks one of that cell's 8 bits. Five new commands work on that bit, so a program can build a byte bit by bit and branch on a single bit, where brainfuck can only add and test for 0.
The machine
All eight brainfuck commands work as usual. These are the new ones.
| Command | Does |
|---|---|
≤ ≥ | Move the bit pointer left or right |
* | Flip the pointed bit |
! | Point at the first bit again |
( ... ) | Run the inside only when the pointed bit is 1 |
The first bit is the lowest. Left goes toward the high bits, the way a byte is written, so ≤≤≤ moves from bit 0 to bit 3. The specification leaves the rest open. In this implementation the bit pointer starts on bit 0, keeps its place when the cell pointer moves, and wraps around after 8 steps. Cells wrap at 256, the tape has no end, and the end of input reads as 0.
Example
The example sets bits 3 and 6, which is 01001000.
The example sets bits 3 and 6, which is 01001000. That is 72, an H, although the specification calls it the letter A. Setting bits 0 and 6 instead gives 65, the real A.
The truth machine tests the lowest bit of the character it reads. In 0 that bit is 0, so the parentheses are skipped and the 0 is printed once. In 1 it is 1, and [.] prints 1 forever.
The specification also has a cat that flips all 8 bits of every byte it reads, stopping at a null character.
Patterns it teaches
- Turing tarpit: brainfuck plus a finer pointer, still a handful of one-character commands.
Further
See also
BytFuck builds on Brainfuck.
Brainfuck derivatives
Write your own in Run Convert a program from BytFuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: bytfuck.
Command line
shib run bytfuck -e ',([.]).' --input '0'shib manual bytfuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/bytfuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org