N Bits, N2^(N-1) Bytes

From Esolang
Jump to navigation Jump to search

N Bits, N2N-1 Bytes is an attempt at a _ Bits, _ Bytes esolang that can increase its amount of bits per command over time, made by User:PkmnQ. It starts out with 2 bits for a command, but contains an "expand" command that expands the amount of bits per command. Its expansion command is also vaguely inspired by Finite-state mach... wait, WHAT!?.

Control Flow

If the program is empty, it halts immediately. Otherwise, the program is looped infinitely, so the program 01101 is ran as 011010110101101.... This is true even if it splits between a command and an argument, or even inside a command/argument.

Initial Commands

Bits Name Description
00 EXP EXPands the language, redefining commands based on the current memory units (e.g. If the language is currently at 3 bits and the first three memory units are 000001 010011 100101, 0000 is defined as running 000 001, 0001 is defined as running 010 011, and 0010 is defined as running 100 101.) The current expansion buffer is erased and used as the new program. Control does not return to the original program after the expanded program halts.
01 INC Takes a memory quarter as an argument and INCrements it.
10 JMP Takes a memory quarter as an argument, and if the memory quarter is 0, JuMPs forward to after the next JuMP command and its argument, otherwise doing nothing.
11 BUF Takes a memory quarter as an argument and appends its bits to the expansion BUFfer.

Memory

Memory is entirely made up of bits, which can either be divided into 4 quarters of 2nn bits for INC, JMP, and BUF, or into 2n+1 units of 2n bits for EXP if n is the amount of bits each command has. In total, there are 2n+2n bits, or 2n-1n bytes of memory. For example, for 3 bits, memory is split into units like this:

000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000

And this is how it is split into quarters:

000000000000000000000000 000000000000000000000000 000000000000000000000000 000000000000000000000000

After Expansions

Memory is transferred between expansions based on units. Each unit has 2 0's prepended to it making the first half, and the latter half of units are filled with all 0's. For example, from 2 bits to 3 bits:

  abcd   efgh   abcd   efgh   abcd   efgh   abcd   efgh
00abcd 00efgh 00abcd 00efgh 00abcd 00efgh 00abcd 00efgh 000000 000000 000000 000000 000000 000000 000000 000000