Here is a quick definition of words in uForth. You can place it in init.f (for BOOTSTRAP versions) or pass it to "uforth_interpret()". It depends on a few words I've already shipped in init.f:
( Implementation of words in pure uForth! )
create _ ( dummy "known length" entry )
variable last_word
variable ccnt ( keep track of # of characters on a line)
: words ( -- )
_ 6 - @ last_word ! ( We know where the prev word link is inside of _ )
0 ccnt !
last_word @ ( pointer to last word )
begin
dup ( keep it on the stack )
1+ count 63 and dup ccnt +! ( get length of word's name )
ccnt @ 70 > if cr 0 ccnt ! then ( 70 characters per line )
type 32 emit 32 emit ( print word's name )
2 ccnt +! ( add in spaces )
@ ( get prev link from last word )
dup -1 = ( -1 link means no more words! )
until
drop ;
No comments:
Post a Comment