esolang

Mogus

Five letters, a stack, and every number built from 1 by subtraction.

VilgotanL, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: amogus

The idea

VilgotanL made Mogus in 2021. It has five instructions and no literals but 1. Zero is mmo, one minus one. Taking 1 away is mo, and adding 1 is mmomoo, which subtracts minus one. The only jump goes to a line by its number, so a program is a list of lines and a number on the stack says which comes next.

Read the story

The specification proves it Turing complete with a Python script by TriMill that turns any cyclic tag program into Mogus.

The machine

LetterDoes
mPush 1
oPop A, then B, and push B-A
sMove the bottom of the stack to the top
gPop n and go to line n, counting from 1
uPop n; print character n, or read a character when n is 0

Every other character is ignored, and the run ends after the last line. The specification leaves the end of input open; this implementation ends the run on a read after the last byte, so the cat stops.

Example

The cat pushes 0, reads a character, prints it, then pushes 1 and goes to line 1.

The cat pushes 0, reads a character, prints it, then pushes 1 and goes to line 1.

To print a character the program pushes 0 twice, counts the top down to minus its code with mo, and takes that from 0. This is 33 steps down, an exclamation mark.

Expected: !

The Hello World is fourteen such lines, one per character, and prints Hello, world! with a line feed.

The truth machine reads a digit and takes 46 from its code, so 0 goes to line 2 and 1 to line 3. Line 2 prints 0 and goes to the empty line 4, which ends the run. Line 3 prints 1 and goes to itself.

Expected: 0

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Mogus

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run mogus -e 'mmouumg' --input 'abc'
shib manual mogus

Source

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

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

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