SplitFuck

From Esolang
Jump to navigation Jump to search

SplitFuck is a derivative of Brainfuck whose commands make use of a byte split into two four-bit nibbles, which denote a command and the behavior of that command. This functionality is adapted from the 3-bit/5-bit command/behavior split of Brainfuck Assembly Language (BAL). Like BAL, it is meant to make hardware implementation of Brainfuck easier. However, it is also split in a sense that half of the 16 possible commands are directly inherited from Brainfuck (with the added functionality of BAL), but the other half are adapted to manipulate the memory pointer beyond simple incrementing and decrementing. This is roughly adapted from the additional commands of BrainGuck, and is also meant to make the language easier to use.

Language Overview

Commands are ran directly off of RAM, with the program loaded at the beginning of memory. The memory contains both the executable program and the brainfuck memory array. The program may edit itself during executing, similar to BAL. It makes use of three registers, one to keep track of the instruction pointer, another to keep track of the memory pointer, and another to keep track of loop start/end counting and traversal. The instruction set is as follows, adapted from the combined instruction sets and goals of Brainfuck, Brainfuck Assembly Language, and BrainGuck:

Command Behavior (based on argument n)
+n
n 0 Terminate program
n 1-15 Add n to the memory value
-n
Subtract n from the memory value
vn
Pull memory value from a byte of the memory pointer, starting at a bit index of n*8
~n
Swap memory value with a byte of the memory pointer, starting at a bit index of n*8
.n
Take the byte of memory value as output. Pass n as additional info to peripherals, which specify behavior.
,n
Take a byte of input and store it as the memory value. Pass n as additional info to peripherals, which specify behavior.
[n
n 0 Skip memory pointer to loop end if memory value is zero
n 1-15 Add n to memory pointer if memory value is zero
]n
n 0 Return memory pointer to loop start if memory value is not zero
n 1-15 Subtract n from memory pointer if memory value is not zero
>n
Add n to the memory address
<n
Subtract n from the memory address
^n
Pull the memory value into a byte of the memory pointer, starting at a bit index of n*8
|n
Pop the memory value into a byte of the memory pointer (resetting the memory value to 0), starting at a bit index of n*8
:n
Take the first byte of the memory address as output. Pass n as additional info to peripherals, which specify behavior.
;n
Take a byte of input and store it as the first byte of the memory address. Pass n as additional info to peripherals, which specify behavior.
{n
n 0 Skip memory pointer to loop end if memory address is zero
n 1-15 Add n to memory pointer if memory address is zero
}n
n 0 Return memory pointer to loop start if memory address is not zero
n 1-15 Subtract n from memory pointer if memory address is not zero

"A byte of the memory pointer, starting at a bit index" denotes where the read/written byte is located within the bits of the pointer address, treating the address as an essential array of bits with indices. In circumstances where a byte would overflow anywhere past the edge of the address, it should wrap back around to the front and continue from there, even if the whole pointer byte effectively takes place past the limits of the memory address. Due to the limitations of the Nibble-based "pointer address byte start index," only up to 128-bit pointer addresses are able to be fully supported by related commands (v~^|).


It is worth noting that the code to terminate any program is 00000000, the combined Byte code for adding 0.


Similar to Brainfuck Assembly Language, an implicit argument n is applied to any commands lacking an argument: 1 for +-[] and ><{}, and 0 for v~,. and ^|:;. Similar to BAL and other Brainfuck derivatives, addition and subtraction are subject to wrapping, and such is considered a feature. Any characters besides the listed commands are treated as comments.


The commands +, -, >, <, ., ,, [, and ] are sourced from Brainfuck.


The commands v, ^, {, and } are sourced from BrainGuck.


The commands ~, |, :, and ; are original to SplitFuck.

Implementations

Similar to Brainfuck Assembly Language, SplitFuck leaves room for differentiation in its specifications. Variations include the memory word size (usually 8 bit, to be more like Brainfuck itself), memory size (recommended 256 B to retain a single byte address), and interpretation of arguments passed into inputs and outputs. Some implementations, their values, and instructions:

Logic World
Information
Author User:TechieOpsoss
Link Currently in development.
Word Size 8-bit
Memory Size 64 kiB
Arguments for , and ; (input)
n 0 Read when held
n 1 Read when pressed
n 2 Read when released
n 3 Read when pressed or released
n 4 Read random input
n 5-15 No-op
Arguments for . and : (output)
n 0 Output as ASCII
n 1 Output to screen as color
n 2-15 No-op

Credit where it's due

I heavily based the content of this article off of the article for Brainfuck Assembly Language.