xEec has a set of 9 instructions. Some of them work with parameters that specify its behavior. All instructions must be separated by white spaces. xEec is not case sensitive.
xEec operates on a single Stack of 64 bit wide unsigned integers. It has an internal flag (Carry Flag) that will be set every time an arithmetic operation overflows.
Semicolons are used to mark a comment. Everything after a semicolon, will be ignored by xEec.
If xEec encounters a jump instruction but cannot find the matching label for this jump, the program will terminate.
From here on, let us assume that the right most item of a list is the top of the stack, consequently, that is the value the next POP instruction will discard.
So, if we have the Stack: [1,2,3] and we call POP, 3 will come out, leaving [1,2] behind.
The opposite is true for PUSH: same stack: [1,2,3], PUSH 4, stack is now: [1,2,3,4].
+------------+---------+---------------------------------------------------------------------------+ | | |Pushes a number or a char onto the stack h#9 pushes a 9, h$0 pushes 48 | | | Push | h |(ASCII code for 0) and h? will push 1 if the Carry is set, 0 otherwise. | | | | | | +------------+---------+---------------------------------------------------------------------------+ | | |Discards the top of the stack. | | Pop | p | | | | | | +------------+---------+---------------------------------------------------------------------------+ | | |Creates a jump label. >lbl creates a label called lbl. | | Label | > | | | | | | +------------+---------+---------------------------------------------------------------------------+ | | |Inputs a number or a char and place it on top of the stack. | | Input | i |i# inputs a number and i$ inputs a char. | | | | | +------------+---------+---------------------------------------------------------------------------+ | | |Outputs the top of the stack as number or char. o# for numbers - o$ | | Output | o |for chars. This instruction does not perform a pop. | | | | | +------------+---------+---------------------------------------------------------------------------+ | | |Jumps to a label. jz will jump if top of the stack is zero, jn otherwise. | | Jump | j |jzlbl will jump to label lbl if top of the stack is zero. | | | |This instruction does not perform a pop. | +------------+---------+---------------------------------------------------------------------------+ | | |Rolls the stack 1 position to the left. | | Roll | r |Before: [1,2,3] After [2,3,1]. | | | | | +------------+---------+---------------------------------------------------------------------------+ | Copy | |Copies the top of the stack to its tail. Before: [1,2,3] After: [3,1,2,3] | | to | t | | | tail | | | +------------+---------+---------------------------------------------------------------------------+ | | |Performs one of the two possible arithmetic operations in xEec: | | Arithmetic | m |ma addition or ms subtraction. | | | |These instructions will pop the top two elements of the stack and push into| | | |it the result of that operation. | +------------+---------+---------------------------------------------------------------------------+
There is a simple interpreter written in C++ here(Windows version).
As I said, it is very very simple - it just execute your xEec programs.
The source code is here, if you are feeling like implementing some Debuging features, please, be my guest!