collapseos/apps/forth/dictionary.txt

33 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-03-08 04:13:15 +11:00
Stack notation: "<stack before> -- <stack after>". Rightmost is top of stack
(TOS). For example, in "a b -- c d", b is TOS before, d is TOS
after. "R:" means that the Return Stack is modified.
*** Native Words ***
2020-03-08 10:53:20 +11:00
: x ... ; -- Define a new word
. n -- Print n in its decimal form
@ a -- n Set n to value at address a
! n a -- Store n in address a
2020-03-08 11:42:07 +11:00
+ a b -- c a + b -> c
- a b -- c a - b -> c
* a b -- c a * b -> c
/ a b -- c a / b -> c
CREATE x -- Create cell named x
DUP a -- a a
2020-03-08 04:13:15 +11:00
EMIT c -- Spit char c to stdout
EXECUTE a -- Execute word at addr a
EXIT R:I -- Exit a colon definition
HERE -- a Push HERE's address
QUIT R:drop -- Return to interpreter promp immediately
2020-03-08 04:13:15 +11:00
KEY -- c Get char c from stdin
INTERPRET -- Get a line from stdin, compile it in tmp memory,
then execute the compiled contents.
OVER a b -- a b a
SWAP a b -- b a
*** Core-but-Forth Words ***
? a -- Print value of addr a
+! n a -- Increase value of addr a by n
ALLOT n -- Move HERE by n bytes