From: rich Date: Tue, 25 Sep 2007 09:50:54 +0000 (+0000) Subject: Comment changes. X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=f1cc78565d2ec5b015e78fba19756ee573f3c957;p=rrq%2Fjonesforth.git Comment changes. --- diff --git a/jonesforth.S b/jonesforth.S index 44e837b..7b6a757 100644 --- a/jonesforth.S +++ b/jonesforth.S @@ -1,11 +1,11 @@ /* A sometimes minimal FORTH compiler and tutorial for Linux / i386 systems. -*- asm -*- By Richard W.M. Jones http://annexia.org/forth This is PUBLIC DOMAIN (see public domain release statement below). - $Id: jonesforth.S,v 1.29 2007-09-24 00:37:01 rich Exp $ + $Id: jonesforth.S,v 1.30 2007-09-25 09:50:54 rich Exp $ gcc -m32 -nostdlib -static -Wl,-Ttext,0 -o jonesforth jonesforth.S */ - .set JONES_VERSION,29 + .set JONES_VERSION,30 /* INTRODUCTION ---------------------------------------------------------------------- diff --git a/jonesforth.f b/jonesforth.f index e3140c4..7f20517 100644 --- a/jonesforth.f +++ b/jonesforth.f @@ -2,7 +2,7 @@ \ A sometimes minimal FORTH compiler and tutorial for Linux / i386 systems. -*- asm -*- \ By Richard W.M. Jones http://annexia.org/forth \ This is PUBLIC DOMAIN (see public domain release statement below). -\ $Id: jonesforth.f,v 1.2 2007-09-24 00:37:01 rich Exp $ +\ $Id: jonesforth.f,v 1.3 2007-09-25 09:50:54 rich Exp $ \ \ The first part of this tutorial is in jonesforth.S. Get if from http://annexia.org/forth \ @@ -438,10 +438,10 @@ First ALLOT, where n ALLOT allocates n bytes of memory. (Note when calling this that it's a very good idea to make sure that n is a multiple of 4, or at least that next time - a word is compiled that n has been left as a multiple of 4). + a word is compiled that HERE has been left as a multiple of 4). ) : ALLOT ( n -- addr ) - HERE @ SWAP ( here n -- ) + HERE @ SWAP ( here n ) HERE +! ( adds n to HERE, after this the old value of HERE is still on the stack ) ; @@ -476,7 +476,7 @@ Notice that 'VAL' on its own doesn't return the address of the value, but the value itself, making values simpler and more obvious to use than variables (no indirection through '@'). The price is a more complicated implementation, although despite the complexity there is no - particular performance penalty at runtime. + performance penalty at runtime. A naive implementation of 'TO' would be quite slow, involving a dictionary search each time. But because this is FORTH we have complete control of the compiler so we can compile TO more @@ -598,8 +598,8 @@ BEGIN DUP 0<> ( while link pointer is not null ) WHILE - DUP ?HIDDEN NOT IF - DUP ID. ( print the word ) + DUP ?HIDDEN NOT IF ( ignore hidden words ) + DUP ID. ( but if not hidden, print the word ) THEN SPACE @ ( dereference the link pointer - go to previous word )