- Note that naz is typically lowercased, even at the start of a sentence.
naz is an esoteric programming language designed by sporeball in 2019. Each instruction in a naz program is given by one number, from 0 to 9 (referred to as n), and one letter, from A to Z.
naz programs operate on a single register, whose value starts at 0 and can be between -127 and 127, inclusive. A number of arithmetic instructions can be used to manipulate this value, and custom variables and functions can be declared during runtime to allow for more complex programs. Final output, if any, is only shown once a program finishes running.
List of instructions
0-9 - A number literal; exactly one of these must be placed before every instruction.
a - Adds n to the register.
s - Subtracts n from the register.
m - Multiplies the register by n.
d - Divides the register by n, rounding down.
p - Divides the register by n, then sets the register equal to the remainder.
o - Outputs a value n times. The value that is output depends on the value in the register:
- 0-9 - Outputs that number.
- 10 - Outputs a newline.
- 32-126 - Outputs the character with that ASCII value.
r - Sets the register equal to the ASCII value of the n-th character in the input string, then removes that character from the input string.
l - Executes the n-th function if the value in the register is less than the value of a specific variable.
e - Executes the n-th function if the value in the register is equal to the value of a specific variable.
g - Executes the n-th function if the value in the register is greater than the value of a specific variable.
The 3 commands above can only be run in opcode 3.
f - Function command:
- If run in opcode 0, this command executes function n.
- If run in opcode 1, this command begins declaration of function n.
v - Variable command:
- If run in opcode 0, this command sets the register equal to the value of variable n.
- If run in opcode 2, this command sets variable n equal to the value of the register.
x - Sets the current opcode.
h - Halts program execution.
0 - Default operation. Commands will execute one at a time, in order.
1 - Function write. Commands will become part of the first function referenced through use of the
f command until a newline is parsed or the opcode is explicitly set to 0.
2 - Variable write. The interpreter must parse a call to the
v command; once it does, it will return to opcode 0.
3 - Conditional opcode. The interpreter must parse a call to the
v command, followed by a call to a conditional instruction; after it finishes executing (or not executing) the given function, the interpreter returns to opcode 0.
This program outputs
9a8m1o 9a9a9a2a1o 7a2o 3a1o 3d7a1o 9s3s1o 8a2m7a1o 9a9a6a1o 3a1o 6s1o 8s1o 3d1o
This program outputs
A, then defines a function that can be reused to output subsequent letters; the final output is
9a7m2a1o 1x1f1a1o 1f1f1f1f
A number of concepts are illustrated in this program:
- Two functions are defined, creating a loop where the register value can be incremented and output on each step.
- Opcode 2 is used to set the value of variable 1 equal to 90.
- Opcode 3 is used in one of the functions to check that the register is less than variable 1.
The final output of this program is
9a9m9a2x1v 1x2f3x1v1l 1x1f1a1o2f 9s9s8s 3x1v1l
The following naz program produces valid dd output given any input file terminated with the control character STX (U+0002):
2a2x1v 9a9m1a2x2v 9a9a9a2x3v 1x1f2v2o2f 1x2f1r3x1v5e3x2v3e3x3v4l 1x3f1r3x1v5e3x2v1e3x3v2l 1x4f2f 1x5f0a 2f
- naz's source code can be found on GitHub.