BitP
BitP is an estoteric programming language (who would've guessed!) that uses 16 commands, stored as nybbles. It was originally intended as a more readable assembly language, but, uh... it's here now, so you can guess what it has become.
Notes
All programs in BitP are compiled down to nybbles before running. These nybbles are themselves interpreted. This means that comments are not ignored, but removed. This is important.
The only data type is a single 8-length 64-bit stack, called a 'disc' (because it loops around).
Everything is 0-indexed, even when it doesn't make sense to 0-index it. Also, everything is in hex.
Though each command has a single character associated with it that the compiler will recognize, using its hex code will also work. However, values A-F hex must be capitalized.
Also, programs are self-modifying. It is possible to edit the program itself. While this can lead to very bizarre or compact programs (in theory), its main use is mundane; since the disc is useless for long-term storage, often times the best place to put them is in unused space within the program.
Command List
BIN | HEX | Character | Name | Description |
---|---|---|---|---|
0000
|
0
|
#
|
VALUE | Gets the value of the next function and puts it on the disc, left shifting the previous value by 4. |
0001
|
1
|
,
|
NEXT | Moves the pointer to the next value in the disc. |
0010
|
2
|
{
|
REMEMBER | Remembers the previous disc value as the location of a bit in the program, and current disc value as the number of bits after that one to also edit. |
0011
|
3
|
}
|
COMMIT | Overwrites a position in the program determined by REMEMBER with the current disc value. |
0100
|
4
|
~
|
NOT | Flips all bits on the current disc value. |
0101
|
5
|
^
|
XOR | Performs a bitwise XOR between the previous and current disc values, stored in the previous. Also moves the pointer to the previous value in the disc and clears the current. |
0110
|
6
|
&
|
AND | Performs a bitwise AND between the previous and current disc values, stored in the previous. Also moves the pointer to the previous value in the disc and clears the current. |
0111
|
7
|
/
|
OR | Performs a bitwise OR between the previous and current disc values, stored in the previous. Also moves the pointer to the previous value in the disc and clears the current. |
1000
|
8
|
<
|
LSHIFT | Performs a left shift on the previous disc value, the number of times defined by the current (unsigned), stored in the previous. Also moves the pointer to the previous value in the disc and clears the current. |
1001
|
9
|
>
|
RSHIFT | Performs a right shift on the previous disc value, the number of times defined by the current (unsigned), stored in the previous. Also moves the pointer to the previous value in the disc and clears the current. |
1010
|
A
|
@
|
IF-GOTO | Goes to the index specified by the current disc value if the previous is not zero, continuing normally otherwise. Also moves the pointer to the previous value and clears both. |
1011
|
B
|
=
|
IF-THREAD | Creates a new thread at the index specified by the current disc value if the previous is not zero, continuing normally otherwise. Also moves the pointer to the previous value and clears the current, storing the index of the new thread at the previous. |
1100
|
C
|
:
|
READ | Reads a range of values in the code. Indexed the same way as REMEMBER. |
1101
|
D
|
%
|
PORT | Specifies the hardware device with which to interact with for I/O. Does nothing in v0.7.0. |
1110
|
E
|
[
|
INPUT | Takes a single character of input. If there is no input left, it will request a new string. All strings are appended with NUL. |
1111
|
F
|
]
|
OUTPUT | Prints the current disc value as output. |