Extended Brainfuck Type I
Brainfuck with one spare byte, bit shifts, logic and a stop command.
Turing complete: yes · ●○○ easy · esolangs.org
Tested with 5 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Brainfuck can only add and subtract 1. Extended Brainfuck Type I keeps all eight commands and adds the operations a processor has. A storage byte sits beside the tape, and the cell can be shifted, inverted, or combined with storage by XOR, AND and OR. @ ends the program wherever it stands.
Read the story
Brainlove later borrowed its $ and !.
The machine
A tape of byte cells that wrap at 256, growing both ways, a pointer and one storage byte.
| Command | Does |
|---|---|
+ - < > . , [ ] | As in brainfuck |
@ | End the program |
$ | Copy the cell into storage |
! | Copy storage into the cell |
} { | Shift the cell one bit right or left |
~ | Invert every bit of the cell |
^ & \| | Cell becomes cell XOR, AND or OR storage |
Reading past the end of the input gives 0, and every other character is a comment.
Example
The first program stores a (97), reads a space (32) and XORs them into 65, A.
The first program stores a (97), reads a space (32) and XORs them into 65, A. A space is exactly the bit that tells lower case from upper case. The second doubles ! (33) to 66 with one shift left.
Patterns it teaches
- Turing tarpit: the new commands save loops but add no power; brainfuck can do all of them with spare cells.
See also
Extended Brainfuck Type I builds on Brainfuck.
Self-modifying
Brainfuck derivatives
Write your own in Run Convert a program from Extended Brainfuck Type I
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: extended-brainfuck-type-i.
Command line
shib run extended-brainfuck-type-i -e ',{.' --input '!'shib manual extended-brainfuck-type-iSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/extended-brainfuck-type-i.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org