Morf
Jump to navigation
Jump to search
Mike's Own Reimplementation of Forth
Kernel
quit main execute + - * 1+ 1- = < u< and or xor lsl lsr asr ! ch
ch! tok@ tok!
dup ?dup over pick rot pop swap tuck nip r> >r r rpop rp
rp! branch0 branch lit
lit2 align gentok
word create find number
def ... ;
Control structures
- cond
if
then-partelse
else-partfi
do
[condwhile
] bodyod
- n
times
bodyrepeat
- n 0
for
i bodyrepeat
- x
case
lab1=>
body1|
lab2=>
body2|
...|
defaultesac
exit
Tracing and debugging
trace
word- Execute word but trace each action (including actions of recursively invoked words) on the console.
see
word
names
#
invert 2/ 4/ cell cell+ cell- cells tok tok+ tok- toks MEM+ uxth sxth space aligned on off not > <= >= != u> nl inc dec incr decr 0< negate div mod udiv umod
Stack manipulations
-rot
2pop
2dup
Quotations
'
word[']
wordcompile
wordquote
word[lit]
Storage allocation
here align , constant variable allot
Dictionary layout
getdef tok>next tok>flags tok>action tok>data tok>name
is
word- Say
' x is y
to redefiney
as a synonym forx
.
min max abs
Strings
char [char] strlen putstr puttok
"
text"
."
text"
. dump clear spaces
Local variables
{ }
->