/* A sometimes minimal FORTH compiler and tutorial for Linux / i386 systems. -*- asm -*-
By Richard W.M. Jones <rich@annexia.org> http://annexia.org/forth
This is PUBLIC DOMAIN (see public domain release statement below).
- $Id: jonesforth.S,v 1.37 2007-09-28 18:55:10 rich Exp $
+ $Id: jonesforth.S,v 1.38 2007-09-28 19:39:21 rich Exp $
gcc -m32 -nostdlib -static -Wl,-Ttext,0 -o jonesforth jonesforth.S
*/
- .set JONES_VERSION,37
+ .set JONES_VERSION,38
/*
INTRODUCTION ----------------------------------------------------------------------
\ A sometimes minimal FORTH compiler and tutorial for Linux / i386 systems. -*- asm -*-
\ By Richard W.M. Jones <rich@annexia.org> http://annexia.org/forth
\ This is PUBLIC DOMAIN (see public domain release statement below).
-\ $Id: jonesforth.f,v 1.7 2007-09-28 18:55:10 rich Exp $
+\ $Id: jonesforth.f,v 1.8 2007-09-28 19:39:21 rich Exp $
\
\ The first part of this tutorial is in jonesforth.S. Get if from http://annexia.org/forth
\
>DFA ( get the data address, ie. points after DOCOL | end-of-word start-of-data )
( now we start decompiling until we hit the end of the word )
- ( XXX we should ignore the final codeword if it is EXIT )
BEGIN ( end start )
2DUP >
WHILE
CFA> ( and force it to be printed as a dictionary entry )
ID. SPACE
ENDOF
+ ' EXIT OF ( is it EXIT? )
+ ( We expect the last word to be EXIT, and if it is then we don't print it
+ because EXIT is normally implied by ;. EXIT can also appear in the middle
+ of words, and then it needs to be printed. )
+ 2DUP ( end start end start )
+ 4 + ( end start end start+4 )
+ <> IF ( end start | we're not at the end )
+ ." EXIT "
+ THEN
+ ENDOF
( default case: )
DUP ( in the default case we always need to DUP before using )
CFA> ( look up the codeword to get the dictionary entry )