BFASM
An assembly language for people who would rather not move brainfuck's pointer themselves.
Waffelz, 2025 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Waffelz made BFASM in 2025, and its name joins brainfuck and assembly. A program is a list of named byte variables and 12 statements, and the compiler turns it into brainfuck. It keeps every variable in its own cell at the start of the tape, copies the operands to free cells to the right, computes there and moves the result back. The Hello World program becomes 1,068 brainfuck commands.
Read the story
The author believes it is only as strong as a finite state machine. There are at most 10,000 variables and each holds one byte, so that is right for the language as written.
The machine
One statement a line, its arguments split by spaces. Every variable starts with %.
| Statement | Does |
|---|---|
set %x n | Set x to a number from 0 to 255 |
add sub mul div mod %x %y %z | Put x op y into z |
out %x inp %x | Print the byte in x; read a byte into x |
cmp %x %y %z %w %v | Set z to 1 if x = y, w if x > y, v if x < y, the others to 0 |
if %x ... end | Run the lines once if x is not 0 |
while %x ... end | Repeat the lines while x is not 0 |
Values wrap at 256, as the cells of the brainfuck do. Dividing by 0 gives 0 and leaves the whole number as the remainder; that is what the generated brainfuck does. Errors such as a missing % or an unmatched end stop the program before it runs.
Example
Six times seven is 42, the code of *.
Six times seven is 42, the code of *.
The decimal printer reads one character and prints its code. It splits the number into hundreds, tens and ones with div and mod, adds 48 to each to make digits, and uses cmp and if to leave out leading zeros.
The cat sets %t to 1 and loops while %t around inp and out. Nothing ever sets %t back to 0, so it never stops.
Further
See also
Cell-based
Write your own in Run Convert a program from BFASM
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: bfasm.
Command line
shib run bfasm -e 'set %c 72
out %c
set %c 101
out %c
set %c 108
out %c
out %c
set %c 111
out %c
set %c 44
out %c
set %c 32
out %c
set %c 87
out %c
set %c 111
out %c
set %c 114
out %c
set %c 108
out %c
set %c 100
out %c
set %c 33
out %c'shib manual bfasmSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/bfasm.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org