esolang

Brainfuck extended

Brainfuck with a register beside the tape, so arithmetic stops being a loop.

None1, 2023 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 8 known programs · Test method

Run it

Expected: Hello World!

The idea

None1 made Bx in 2023 as a brainfuck that can do ordinary things directly. Next to the tape there is one byte register, and most new commands combine the register with the current cell to add, subtract, multiply, compare, and, or. Numbers can be read and printed in decimal or hex, a cell can be set with two hex digits, a whole string can be written at once, and there is an if-else. Brainfuck's + and - became / and \ to free the symbols for the register.

The machine

A tape of bytes that wrap at 256 and a register that starts at 0.

CodeDoes
/ \ < > , . [ ]Brainfuck's eight
@ % ~Cell to register, register to cell, swap
+ - * \| & ^ !Register plus, minus, times, greater than, and, or the cell; not
;Register to a random number from 0 to itself
( ) { }Read or print the cell in decimal, or in hex
_hhSet the cell to a two-digit hex number
?a:b'If the cell is not 0 run a, else b
$text$Write the text and a 0 from the pointer on
#...#A comment

Example

The factorial reads 5 into the cell and copies it to the register.
Expected: 5
Expected: 120

The factorial reads 5 into the cell and copies it to the register. Then it lowers the cell by one and multiplies the register by it until the cell is 0, and prints 120. For 0 it takes the other branch and prints 1.

Further

Ideas it shows

Brainfuck extended builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from Brainfuck extended

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: brainfuck-extended.

Command line

shib run brainfuck-extended -e '$4$.'
shib manual brainfuck-extended

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/brainfuck-extended.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org