Morf

Copyright © 1993–2025 J. M. Spivey
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-part else else-part fi
do [cond while] body od
n times body repeat
n 0 for i body repeat
x case lab1 => body1 | lab2 => body2 | ... | default esac
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
['] word
compile word
quote 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 redefine y as a synonym for x.

min max abs

Strings

char [char] strlen putstr puttok

" text"
." text"

. dump clear spaces


Local variables

{ }

->