MacroBeep
Brainfuck's tape, spelled out one plain word per line, with branches named after the planets.
PixelatedStarfish, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
PixelatedStarfish began MacroBeep in December 2021 for people who are learning to program. There is no punctuation to miss and no brace to count. A program is one instruction per line, a word with at most one argument, and a macro is a named list of instructions that do calls. Underneath is a tape of bytes and a pointer, as in brainfuck, and the specification proves MacroBeep Turing complete by turning each brainfuck command into one instruction.
The machine
The tape holds bytes from 0 to 255 and runs right from cell 0, the head. A run starts at macro main.
| Instruction | Does |
|---|---|
add 5 sub | Add to or take from the cell, 1 without an argument |
right 2 left head 3 | Move the pointer; head counts from cell 0 |
null rand 9 | Set the cell to 0, or to a random number up to 9, or 255 |
str str -1 stat 2 | Copy the cell to the next cell, to one that far away, or to cell 2 |
out cout pos | Print the cell as a number or a character; print the pointer |
pr Hello[]World | Print a word and a line break; [] is a space and {} a tab |
inp 0 inp 1 inp 2 | Read a character, a number or a whole line onto the tape |
macro f do f rt | Define a macro, call it, return |
label L halt | Mark a place; end the program |
send 2 reply | Copy cells to the head and go there; copy them back and return |
beep 440 wait | Make a sound; wait 100 ms |
Eight branches jump when a test holds. solar and lunar test the cell for more than 0 and for 0. venusian, martian, jovian, plutonic, vestian and sednian compare it with the next cell for equal, not equal, greater, less, at least and at most. A branch names a label or a number of instructions, counted from the next one; the cat only loops back to cout that way.
This implementation is a subset. include, which reads other files, stops the run. beep makes no sound, as in the online version, and wait does not wait.
Example
Hello World.
Hello World.
The cat. inp 2 puts the line on the tape from cell 0, and solar -3 jumps back to cout while the cell is not 0.
A loop to a label. Six times it adds 7 to the next cell, so that cell ends at 42.
The truth machine. On 0 it prints 0 and halts; on 1 it prints 1 for ever.
The sum of numbers program also works. Its macro sum sends two cells to the head, adds them there and replies with the result, and it prints 53, the sum of 1, 2, 3, 5, 8, 13 and 21.
Patterns it teaches
- Turing completeness: by a table that turns brainfuck into MacroBeep.
Further
See also
Cell-based
Stack-based
Write your own in Run Convert a program from MacroBeep
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: macrobeep.
Command line
shib run macrobeep -e 'macro main
pr Hello[]World
# Note that the [] is printed as a space'shib manual macrobeepSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/macrobeep.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org