Nybblang

From Esolang
Jump to navigation Jump to search

Nybblang is an esolang created by User:PythonshellDebugwindow. Its name is a portmanteau of 'nybble' (4 bits) and 'esolang'.

Program structure

A Nybblang program is composed of four bits—a nybble. Each command is two bits long, therefore a program has two instructions.

Memory

Nybblang uses a stack of nybbles. When a digit is pushed to it, it first goes into a temporary variable, which will also hold the next two digits pushed. When it reaches four digits—a nybble—that nybble will be pushed to the stack and the temporary variable set to 0 (0000).

Program import

The interpreter should be given these command-line arguments: main *others, where main is the filename of the first program to be run and others are the programs in the sequence. Alternatively, a directory may be supplied with the programs in it as these files, e.g. nybblang my/directory

Program import sequence

If the interpreter is run with nybblang main.nyb sub1.nyb sub2.nyb, then main.nyb is run first, and the running sequence (for the 11 command) is main.nyb, sub1.nyb, sub2.nyb, main.nyb, sub1.nyb, sub2.nyb, main.nyb, ..., wrapping and repeating forever.

Commands

Command Meaning
00 Push 0 to the memory
01 Push 1 to the memory
10 Output the Nth character of the sequence ETAOINSRHDLspaceWU.newline, where N is (POP stack)
11 Import the next program in the sequence (wrapping)

Any non-0-or-1 characters in the source code raise an error.

Examples

Each file in the sequence is on a different line; these files are arranged in sequential order.

"HELLO"

0111
0011
0011
0111
1011
0111
0011
0011
0011
1011
0111
0011
0111
0111
1011
0111
0011
0111
0111
1011
0011
0011
0111
0010

Turing-Complete Nybblang

If a Nybblang program could be of infinite length, then imports would be unnecessary, so the command 11 could be turned into a (1-index-based) conditional jump: IF stack.bottom > 0 THEN GOTO instruction n where n is the item directly on top of the bottom of the stack (or the bottom of the stack if the stacks has only 1 item), and if n is 0 or greater than the program’s length then the program should exit. From what I understand, this would make Nybblang Turing-complete. Here's a truth-machine in this version of the language that outputs E or T instead of 0 or 1:

0000000x0000000x1011

Replace both of the xs with 0 for input 0 or 1 for input 1. If you use 1, the stack would infinitely grow larger as there are two PUSH operations but only one POP.