esolang

naz

Every instruction is a digit and a letter. One register, and it only goes up to 127.

sporeball, 2019 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

sporeball made naz in 2019. A program is a string of pairs such as 9a or 1o, where the digit is the argument and the letter the instruction. All the work happens in one register that starts at 0 and may hold −127 to 127. Functions and variables are declared while the program runs, by switching the opcode.

Read the story

The output appears only when the program ends.

The machine

PairDoes
na ns nmAdd, subtract, multiply by n
nd npDivide by n rounding down; keep the remainder
noOutput n times, a digit for 0 to 9, a line feed for 10, the character for 32 to 126
nrRead the n-th input character and remove it
nf nv nnCall function n; load variable n; negate variable n
nxSet the opcode to n
nhHalt

In opcode 1, nf starts function n and every pair after it is added to the function until the line ends. In opcode 2, nv stores the register in variable n. In opcode 3, nv picks a variable and then nl, ne or ng calls function n if the register is less than, equal to or greater than it.

Example

The Hello, World! climbs to each character code by adding, multiplying and dividing.

The Hello, World! climbs to each character code by adding, multiplying and dividing.

A function declared in opcode 1 and called four times.

Expected: ABCDE

The alphabet stores 90 in variable 1, and two functions call each other while the register is less than it.

Expected: ABCDEFGHIJKLMNOPQRSTUVWXYZ

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from naz

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run naz -e '9a7m2a1o
1x1f1a1o
1f1f1f1f'
shib manual naz

Source

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

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

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