aboutsummaryrefslogtreecommitdiff
path: root/spec.md
blob: 19678d44ce712a38aa18fd4bc0ba586aa8f52419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# MEM
16^2 sized shared program and heap memory
16^2 sized stack
16^2 sized return stack

# OPS
NOP    ( -- ) sit back and do nothing
LIT x  ( -- x ) push x to top of the stack
POP    ( a -- ) remove top of the stack
NIP    ( a b -- b ) remove second value from top of the stack
SWP    ( a b -- b a ) swap top two values of the stack
ROT    ( a b c -- b c a ) rotates top three values of the stack to the left
DUP    ( a -- a a ) duplicates top of the stack
OVR    ( a b -- a b a ) duplicates second value at the top of the stack
EQU    ( a b -- bool ) push 0001 if a == b, 0000 otherwise
NEQ    ( a b -- bool ) push 0001 if a != b, 0000 otherwise
GTH    ( a b -- bool ) push 0001 if a > b, 0000 otherwise
LTH    ( a b -- bool ) push 0001 if a < b, 0000 otherwise
JEZ x  ( cond -- ) conditional jump to x if cond != 0
JNZ x  ( cond -- ) conditional jump to x if cond == 0
JMP x  ( -- ) jump to x
JRT x  ( -- ) jump to x and store PC+2 to return stack
RET    ( -- ) return from call, or quit if not in call
LDA    ( addr -- value ) push value at absolute address to top of the stack
STA    ( val addr -- ) write a value to an absolute address
RED    ( -- value ) read byte from stdin
WRT    ( value -- ) write byte to stdout
ADD    ( a b -- a+b )
SUB    ( a b -- a-b )
MUL    ( a b -- a*b )
DIV    ( a b -- a/b )
AND    ( a b -- a&b )
ORA    ( a b -- a|b )
XOR    ( a b -- a^b )
LSF    ( a shift -- c ) left shift
RSF    ( a shift -- c ) right shift
SLP    ( -- ) give control back to the interpreter
INC    ( a -- a+1 )
DEC    ( a -- a-1 )
DBG    ( -- ) output debug informations, can be omitted in release builds