esolang

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

Expected: Hello World

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.

InstructionDoes
add 5 subAdd to or take from the cell, 1 without an argument
right 2 left head 3Move the pointer; head counts from cell 0
null rand 9Set the cell to 0, or to a random number up to 9, or 255
str str -1 stat 2Copy the cell to the next cell, to one that far away, or to cell 2
out cout posPrint the cell as a number or a character; print the pointer
pr Hello[]WorldPrint a word and a line break; [] is a space and {} a tab
inp 0 inp 1 inp 2Read a character, a number or a whole line onto the tape
macro f do f rtDefine a macro, call it, return
label L haltMark a place; end the program
send 2 replyCopy cells to the head and go there; copy them back and return
beep 440 waitMake 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.

Expected: Give me a word and I will say it back! hello

A loop to a label. Six times it adds 7 to the next cell, so that cell ends at 42.

Expected: 42

The truth machine. On 0 it prints 0 and halts; on 1 it prints 1 for ever.

Expected: Type a 0 or 1 into the truth machine. 0

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

Further

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 macrobeep

Source

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