SBL-X

SBL-X is a stack-based programming language, made by User:Alex s168, which focuses on being easy to use.
It consists of multiple code blocks, which can be called and executed. The code in a block will be executed instruction-by-instruction. One Line can contain multiple Operations by separating them with a space.
It has two stacks: a main stack and a data stack. Most operations run on the main stack.
Single-line comments are declared with ";"
==Instructions==
SBL-X has the following instructions:
Code	Description
r 	reverses the stack
r- 	reverses the top x elements of the stack (x is popped from the stack)
. 	pops and prints one element from the stack
.c 	pops and prints one element from the stack and outputs it as ASCII char
_ 	pops and prints x elements from the stack (x is popped from the stack)
_s 	pops and prints x elements from the stack and outputs them as ASCII string (x is popped from the stack)
\ 	prints a new line
__ 	dumps the whole stack to the console (doesn't clear the stack)
d_ 	dumps the whole data stack to the console (doesn't clear the data stack)
>d 	pops one element from the stack and pushes it onto the data stack
<d 	pops one element from the data stack and pushes it onto the stack
p 	peeks the top element on the stack and pushes it onto the stack (= copies the top element onto the stack)
p2 	peeks the second top element on the stack and pushes it onto the stack (= copies the second top element onto the stack)
ad 	pushes the address of the next instruction onto the stack
c 	clears the whole stack
c- 	clears the x elements from the top of the stack (x is popped from the stack)
s 	pushes the size of the stack onto the stack
s 	pushes the size of the data stack onto the stack
sw 	swaps the top two elements on the stack
> 	reads a input (console) and pushes the char(s) to the stack
>. 	reads one char from the input (console) and pushes it onto the stack
sc 	sets the condition flag
cc 	clears/unsets the condition flag
ic 	inverts the condition flag
cp 	compares the top two elements on the stack (and pops them) and if they are equal/not equal, sets/unsets the condition flag
ls 	compares the top two elements on the stack (and pops them) and if the first one is less than the second one, sets/unsets the condition flag
gr 	compares the top two elements on the stack (and pops them) and if the first one is greater than the second one, sets/unsets the condition flag
c> 	pushes the condition flag onto the stack (0 or 1)
c< 	pops the condition flag from the stack (0 or 1)
< 	jumps to the address x (x is popped from the stack) if the condition flag is 1 / true
<* 	jumps to the address x (x is popped from the stack) as a sub-routine if the condition flag is 1 / true
+ 	adds the top two elements on the stack and pushes the result onto the stack (a + b) (a is popped from the stack, then b)
- 	subtracts the top two elements on the stack and pushes the result onto the stack (a - b) (b is popped from the stack, then a)
* 	multiplies the top two elements on the stack and pushes the result onto the stack (a * b) (a is popped from the stack, then b)
/ 	divides the top two elements on the stack and pushes the result onto the stack (a / b) (b is popped from the stack, then a)
% 	applies the modulo operation on the top two elements on the stack and pushes the result onto the stack (a % b) (b is popped from the stack, then a)
 	bitwise or (and pop) the top two elements from the stack and pushes the result onto the stack
& 	bitwise and (and pop) the top two elements from the stack and pushes the result onto the stack
! 	bitwise not (and pop) the top element from the stack and pushes the result onto the stack
ld 	loads b bytes from the address a onto the stack (a is popped from the stack, then b)
sd 	stores b bytes to the address a from the stack (a is popped from the stack, then b)
The stack is a byte-stack, and objects can be pushed onto the stack by simply writing a number, a char (surrounded by ' ), a string (surrounded by " ), a code block name (pushes the address of the first instruction in the block onto the stack)
==Code blocks==
Code blocks are defined by using "name:", where "name" is a custom name.
block modifiers:
 (public) D-TO-S:
 do stuff
and:
 (data) COOLDATA:
 1 99 2 9 55 0 88
public code blocks can be used across all files that link this file as a library.
data code blocks can NOT contain instructions.
The code in a code block has to have an indent of at least 2 spaces!
The program will be executed from a code block named "start"
==Linking files as libraries==
Code blocks from other .sbl files (libraries) can be included by writing "link PATH" where "PATH" is the path to the file.
This includes all code blocks from the file.
The "link" command can only be used at the beginning, outside of code blocks!
==Built-in subroutine code-blocks==
There are currently two built-in code blocks.
Block name	Description
EXIT 	exits the program
DELAY 	waits x milliseconds (x is popped from the stack)
==Examples==
Hello world:
 start:
 "Hello, world!" r s _s
Category:Languages Category:Stack-based Category:Turing_complete