B i n a r y

NOTE: I AM STILL WORKING ON THIS ARTICLE. PLEASE DO NOT EDIT IT UNLESS YOU FIND A MISTAKE LIKE SAYING "Esotreic".
B i n a r y is an Esoteric programming language by 5anz. That's me, so I'm going to stop speaking in the third person. It's my first Esolang, but more importantly, it's inspired by Whitespace, but because it only has 3 symbols, and not because you can't see your program! The idea is to lower the number of valid symbols from 3 to 2, that's why I named it B i n a r y , It's Binary, but also, in a way, Whitespace! Lastly, B i n a r y is Stack based, though also has 256 cells.
==Commands==
===IMP===
Like in Whitespace, there are different kinds of commands in B i n a r y, you need to type the Instruction Modification Parameters (IMP), Actually, Just check the Whitespace article, the rest of this one will assume you understand Whitespace.
IMP	Command
000	I/O
001	Stack Manipulation
01 	Arithmetic
10 	Flow Control
11 	Grid Access
Also, every B i n a r y program begins at the first 1, everything before it (and that same 1) are ignored by the program, so 10010... and 010010... mean the exact same thing.
===Numbers===
Numbers can't just be in binary, while you could write "1100" in the real world and people understand what you mean (given context), that wouldn't work in B i n a r y, there's no way to stop writing! So B i n a r y uses a Balanced Ternary system, the way I did this was by combining 2 bits, and then using the following table to determine what they mean.
B i n a r y	Balanced Ternary
00 	0
01 	1
10 	Stop Number
11 	-1
Also, numbers are limited to 16 bits, meaning 01010010 and 010001000000110111000110 both just mean 12 (I made this decision after the idea of balanced ternary and never bothered to change it).
===I/O===
Commands	Parameters	Meaning
00 	- 	Take input as a number and push it onto the stack
01 	- 	Take input as an ASCII character and push it onto the stack
10 	- 	Pop a value off the stack and output it as a number
11 	- 	Pop a value off the stack and output it as an ASCII character
So yeah, generally, the first bit represent input/output, the second bit is number/character. also, outputting 0 as an ASCII character ends the program, as well as outputting what I call "fake 0" in anyway, but I'll get to that later. 
===Stack Manipulation===
Commands	Parameters	Meaning
000 	Number 	Push a number onto the stack
001 	- 	Pushes either a 1 or a 0 onto the stack randomly
01 	- 	Duplicate the top item on the stack
10 	- 	Swap the top 2 items on the stack
11 	- 	Pop the top item on the stack and do nothing with it
===Arithmetic===
The order in which you do subtraction division and modulo depends on what's larger, so whether you pop 5 or 12 first, your doing 12-5 either way (or 12/5 or 12%5 depending on the command)
Commands	Parameters	Meaning
000 	- 	Pops the top 2 values and adds them together
001 	- 	Pops the top 2 values and subtracts them
010 	- 	Takes the additive inverse of the top item
011 	- 	Pops the top 2 values and multiplies them together
100 	- 	Pops the top 2 values and divides
101 	- 	Takes the multiplicative inverse of the top item and multiplies it by 65,536 (2^16)
11 	- 	Pops the top 2 values and Does the modulo operation
Also, division rounds down automatically, decimal numbers don't exist.
===Control flow===
Labels are typed like normal binary numbers, as there are only 256, so 12 is 00001100 instead of 01010010, that would be 82, which isn't written 0100000110 unlike how it normally is.
Commands	Parameters	Meaning
00 	Label 	Mark a location
01 	Label 	Go to a label
10 	Label 	Pop a value off of the stack, if it's 0, go to a label
11 	Label 	Pop a value off of the stack, if it's not 0, go to a label
===Grid access===
The grid contains 256 cells, typed the same as a label. you can think of it like a storage system, kind off? The table should clear things up.
Commands	Parameters	Meaning
0 	Cell 	Pop a value off the stack and replace a cell with that value
1 	Cell 	Push the value of a cell to the stack
===Ending a program===
You don't actually NEED to end your program with 0, I figured since you can type ANY sequence of 1s and 0s and it will be a list of commands, I figured I'd keep that property by doing this, so ...00010 is the same as ...0001, similar to how 010010... is the same as 10010....
===Fake 0===
If you try to access an empty stack, you'll end up with fake 0, a weird number that interacts with commands... differently... A table is the only way I can explain this...
"Full" Command	Parameters	Fake 0 Meaning
0001... 	Both - 	End the program
00101 	- 	Does nothing
00110 	- 	Does nothing, whether there's 1 item or not
00111 	- 	Does nothing
01... 	All - 	Does nothing, yes, all of them
101... 	Both label	Acts as if it popped a 0
110 	Cell 	Replace the cell with 0
==Example Programs==
As no interpreters exist yet, all programs shown here will potentially not work (though I am working on one)
===B i n a r y===
We'll start off by printing B i n a r y, because not only is it functionally the same as a Hello, World! program, but I also get to show off cells.
 10010000111010100100001100100001011111101101111111111111111111000110010000101001100100001111111111111000110010101000111000111111111111100011
Note: This only writes "B i n " and sets cell 255 to 32 (ASCII value for space) so far.
Category:Languages Category:Stack-based Category:Cell-based Category:Works-in-Progress Category:Unimplemented