StackLang is a ... Stack based language!
All operands are based on pushing and popping values off the stack.
push "Hello World" call 13
push "Num1: " call 14 push "Num2: " call 14 call 15 call 6 call 15 call 6 call 15 call 1 call 7 call 13 call 0
-2 - Dumps stack
-1 - brt. Exits with error code pop. [i]
0 - ext. Exits
1 - add. Takes pop + pop, and pushes [i/f, i/f]
2 - sub. Take pop - pop, and subtracts them. [i/f, i/f]
NI 3 - mul. Takes pop * pop and pushes. [i/f, i/f]
NI 4 - div. Take pop / pop and pushes. [i/f, i/f]
5 - jnz - Jumps to line pop(), if pop() and pop() are equal [*, * lineno]
6 - toi - tries to convert to int
7 - tos - tries to convert to string
8 - tof - Tries to convert to float
9 - cat - Concats pop and pop together
10 - TBD
11 - TBD
12 - TBD
13 - prn. Prints pop to standard output. [String]
14 - inp - Pushes the user's input to prompt pop [String, String]
15 - swp - swaps first two values in the stack
Defining sections (Functions):
You define a section with:
push "Hello World"
You call a section using:
section hello_world push "Hello World" call 13 endsect call hello_world call 0
Including other files:
You include a file with
Filename has to have no spaces.
Anything in the %included file is executed.
header.stk: section mali call 15 endsect call mali
And any program that has:
Will have the stack changed.
End a program with
Do not name your sections after numbers.