Brainbash
Brainfuck with a second tape, numbers in and out, and an if.
Conor O'Brien · Turing complete: yes · ●●○ moderate
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Brainbash keeps the eight brainfuck commands and adds a second tape with its own pointer. ~ moves the focus to the other tape, and * does the same while bringing the pointer along. ; and # print and read decimal numbers, and { } runs its body once, only when the cell is not 0.
The machine
Two tapes of 30,000 byte cells that wrap at 256. This implementation follows the C interpreter in Conor O'Brien's repository Brainbash, which is what TIO runs.
| Command | Does |
|---|---|
+ - < > . , [ ] | As in brainfuck, on the tape in focus; , gives 255 at the end |
~ | Focus the other tape |
* | Focus the other tape and move its pointer to the old one's place |
; | Print the cell as a decimal number |
# | Read a decimal number into the cell, modulo 256 |
{ } | Skip to the } when the cell is 0 |
Example
The first program reads 17 on one tape and 25 on the other, moves the 25 across one at a time, and prints…
The first program reads 17 on one tape and 25 on the other, moves the 25 across one at a time, and prints the sum as a number.
Patterns it teaches
- Turing tarpit: any brainfuck program runs unchanged.
Further
- The interpreter, in C
See also
Also in Turing tarpits
Write your own in Run Convert a program from Brainbash
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: brainbash.
Command line
shib run brainbash -e ',+[-.,+]' --input 'cat'shib manual brainbashSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/brainbash.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language