esolang

Wasm

Worst ASseMbly. Brainfuck with names, written out one word per line, or as bits.

jan Gamecuber, 2022 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: 0

The idea

jan Gamecuber made Wasm in 2022 to be a semi-realistic assembly language that still sucks to program in. The name stands for Worst ASseMbly. Its first eight commands are brainfuck's, so it is Turing complete for the same reason. The other eight move or count by six, read and print whole numbers, and add an If that runs its block once.

Read the story

Every command has a name and a four-bit code, and a program can be written either way. The cells hold whole numbers without a bound, and the tape runs on without end.

The machine

CodeWordDoes
0000 0001Right LeftMove one cell
0010 0011Inc DecAdd or take one
0100 0101OutUnicode InUnicodePrint or read a character
0110 0111While EndWhileRepeat while the cell is not 0
1000 1001Right6 Left6Move six cells
1010 1011Inc6 Dec6Add or take six
1100 1101OutNum InNumPrint or read a number
1110 1111If EndIfRun the block once if the cell is not 0

Words are split by white space and their case does not matter. The table also gives each code as one hex digit; this implementation reads the bits only. The cat has a fifth bit at the end of its bytecode; this implementation drops a last group short of four bits is dropped. At the end of the input both reads give 0.

Example

The truth-machine prints the number it reads, and then keeps printing it while it is not 0.

The truth-machine prints the number it reads, and then keeps printing it while it is not 0.

Expected: 0

Six times seven, with Inc6 to fill the counter and Inc6 Inc to add seven each time round.

Expected: 42

The Hello World in bytecode. Read as brainfuck it is >++++++++[-<+++++++++>]<.>>+>-[+]++>++>+++[>[->+++<<+++>]<<]>-----.>->+++..+++.>-.<<+[>[+>+]>>]<--------------.>>.+++.------.--------.>+.>+., 140 commands. It clears a cell with -[+], which needs no wrapping, and it ends with a line feed.

Expected: Hello World!

The same program in words takes 140 lines, one command each, and runs the same 813 steps.

Patterns it teaches

Further

Wasm builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from Wasm

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run wasm -e '1101 1100 0110 1100 0111' --input '0'
shib manual wasm

Source

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

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

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