esolang

Ascii²

Every character is a variable, and every instruction is two of them. H holds 72, so H and a backtick print H.

Rphii, 2021 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, World!

The idea

Rphii made Ascii², also called Ascii2 or AsciiAscii, in 2021. Every character but the backtick is a variable, and each one starts out holding its own character code. The digits 0 to 9 are the exception. They hold 0 to 9 and print as numbers. A program is read two characters at a time, and only the shape of a pair says what it does. So the shortest Hello World is the text itself with a backtick after each character.

The machine

PairDoes
abAdd b to a, or set a to 0 when b is 0
a` 1` Print a character, or a digit's number
`a `1 Read a line of text into a, or a number into 1
aa three timesA loop, as FOR, ELSE and END
`` Switch banks

At FOR a variable that is not 0 takes one step toward 0 and the code up to ELSE runs, and ELSE goes back to FOR. When the variable reaches 0 it is set to minus the value it began with. The specification calls this the LEAI instruction, for loop, else and invert. The code after ELSE runs only when the body never ran at all.

Variables also live in numbered banks. The first variable of a pair comes from the source bank and the second from the other bank, and both start at bank 0. A line of input fills one variable across the banks, a character in each and a 0 at the end. A backtick pair switches the source bank to the value of the variable used last, and a second one right after it swaps the two banks. While a loop runs, its variable stays in the bank it had at FOR.

Example

The one line Hello World ends by building a line feed in a.

The one line Hello World ends by building a line feed in a. a0 sets a to 0, because 0 holds 0, and a9 and a1 add 9 and 1.

The truth machine reads a number into 2. On 0 the loop on 2 never runs its body, so the part after ELSE prints 0. On 1 the body adds the 1 back each time and prints 1 forever.

Expected: 0

The cat reads a line into I, one character in each bank, while L counts the banks. Each turn switches to bank L, prints I there and adds 2 to L, and the loop on L takes 1 away again.

Expected: Hello, cat!

The ASCII table program counts ~ from 127 down to 0 to make it minus 127, then prints 95 lines, from 32: and a space to 126: ~.

Further

Pattern-based

Write your own in Run Convert a program from Ascii²

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run ascii2 -e '`222211`220`22' --input '0'
shib manual ascii2

Source

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

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

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