esolang

Bout

Seven opcodes, a tape of numbers, and a minus sign that reads a cell.

PythonshellDebugwindow, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

PythonshellDebugwindow made Bout in 2020. It looks like assembly, with one opcode and its arguments on every line. An argument is a number, or a number after a minus sign, which means what that cell holds, or $, which reads a number from the input.

Read the story

The opcodes that change a cell take its address as an argument, and that argument can itself be -0. So cell 0 can hold a pointer, and A -0 adds 1 to the cell it points at. That is how the specification turns brainfuck into Bout to show that it is Turing complete.

The machine

OpcodeDoes
W a bSet cell a to b
A a D aAdd 1 to cell a, or take 1 from it, never below 0
R aPrint a
J aJump to line a
N a bJump to line a if b is not 0
HHalt

Lines count from 0. Every argument goes through the same rule, so 5 is 5, -5 is what cell 5 holds and $ is a number read from the input. An input line that is not a number gives 0. Each number printed ends with a line feed.

Example

The first is a truth machine.
Expected: 5 3

The first is a truth machine. It keeps the input in cell 0. On 0 it falls through to print 0 and halt; on 1 it jumps to line 4, which prints 1 and jumps back to itself. The second is a numeric cat, which echoes numbers until it reads a 0.

Expected: 2

Cell 0 points at cell 5, as a brainfuck pointer does, so each A -0 adds 1 to cell 5.

Patterns it teaches

Further

Cell-based

Write your own in Run Convert a program from Bout

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: bout.

Command line

shib run bout -e 'W 0 $
N 3 -0
H
R -0
J 0' --input '5
3
0'
shib manual bout

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/bout.js

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

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