Stakc

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Stakc (pronounced "Stacks") - is a Stack-based Virtual machine (VM), which is intended as an intermediate representation (IR) between a high-level, non-esoteric language and an esoteric one.

Documentation

VM uses Reverse Polish Notation (or postfix) as well as a Stack, which can also be used as a RAM. At the moment it has following commands:

FALSE - push false
TRUE - push true
PUSH x - push number x
POP - pop
GET x - push value of the stack from index x to 
the top
STORE x - pop top of the stack and store it at 
index x
GET_TOP - pop an index and push value from that 
index
STORE_TOP - pop top of the stack and index and 
store value in that index
START_IF - if top is true
CLOSE_IF - closes if body (used if there is an 
else block)
END_IF - end if
START_ELSE - starts else
OUT - outputs top of the stack as a number
OUT_CHAR - outputs top of the stack as a 
character
IN - input a number and store it at the top
IN_CHAR - input a character and store it at the 
top
START_WHILE - while true
END_WHILE - end while
ADD - pop top two values and add them
SUB - pop top two values and subtract them
EQ, GT, LT, GE, LE, NE - pop top two values, 
compare them, and push FALSE or TRUE
LBL x - declare label x
JMP x - jump to label x
JMP_TRUE x - jump if true
NOT - NOT top of the stack