esolang

ABFC (Another BrainFuck Clone)

Brainfuck's tape, but every command takes a number, and the loops are gotos.

Nurdle, 2022 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: HELLO WORLD

The idea

Nurdle made ABFC in 2022, in about six hours, after brainfuck. The tape has 4,096 cells instead of 30,000. Where brainfuck adds 1, ABFC adds any number, +7, and the pointer can jump straight to a cell with @. There are no brackets. Control flow is a numbered label, a goto, and one comparison against a single stored value.

The machine

CommandDoes
@n >n <nSet the pointer, move it right, move it left
=n +n -nSet, add to or subtract from the cell
*n /n %nMultiply, divide and round, take the remainder
#cSet the cell to the code of the character c
.0 .1Print the cell as a character or as a number
,Read a character into the cell
$Store the cell's value
xIn place of a number, the stored value
:Declare a label
;nGo to label n
?nGo to label n if the cell equals the stored value
~ ... ~A comment

Labels count from 0 in the order they appear. The specification writes them as :0 and :1 in one version of its truth machine and as a bare : in the other, so the number after : does nothing.

Example

The Hello World sets letters with # and walks between them with + and -.

The Hello World sets letters with # and walks between them with + and -. A space is # followed by a space.

The truth machine stores the input, puts the character 0 in the cell and compares. On 0 it jumps past the loop to print 0 and a line feed. On 1 it falls into the loop at the first label and prints 1 forever.

Expected: 0

Numbers print with .1, and x reads back what $ stored. The countdown stores 0, then loops until the cell meets it.

Expected: 42
Expected: 321

Patterns it teaches

  • Turing tarpit: a brainfuck tape with arguments, and gotos in place of brackets.

Further

ABFC (Another BrainFuck Clone) builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from ABFC (Another BrainFuck Clone)

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run abfc-another-brainfuck-clone -e ',$@0#0?1:#1.0;0:#0.0=10.0' --input '0'
shib manual abfc-another-brainfuck-clone

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/abfc-another-brainfuck-clone.js

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

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