Lots of typos fixed.
[rrq/jonesforth.git] / jonesforth.S
index 04c3cf5158c8ea046c428fde65650f6821a88a16..d110e6c910b315d7e5797b142992d26330a17b5f 100644 (file)
@@ -1,10 +1,12 @@
 /*     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.17 2007-09-08 22:10:43 rich Exp $
+       $Id: jonesforth.S,v 1.20 2007-09-15 11:21:09 rich Exp $
 
        gcc -m32 -nostdlib -static -Wl,-Ttext,0 -o jonesforth jonesforth.S
-
+*/
+       .set JONES_VERSION,20
+/*
        INTRODUCTION ----------------------------------------------------------------------
 
        FORTH is one of those alien languages which most working programmers regard in the same
@@ -63,6 +65,8 @@
 
        Here is another "Why FORTH?" essay: http://www.jwdt.com/~paysan/why-forth.html
 
+       Discussion and criticism of this FORTH here: http://lambda-the-ultimate.org/node/2452
+
        ACKNOWLEDGEMENTS ----------------------------------------------------------------------
 
        This code draws heavily on the design of LINA FORTH (http://home.hccnet.nl/a.w.m.van.der.horst/lina.html)
            |
          LATEST
 
-       You shoud be able to see from this how you might implement functions to find a word in
+       You should be able to see from this how you might implement functions to find a word in
        the dictionary (just walk along the dictionary entries starting at LATEST and matching
        the names until you either find a match or hit the NULL pointer at the end of the dictionary);
        and add a word to the dictionary (create a new definition, set its LINK to LATEST, and set
@@ -993,6 +997,7 @@ var_\name :
        _Z
        S0              Stores the address of the top of the parameter stack.
        R0              Stores the address of the top of the return stack.
+       VERSION         Is the current version of this FORTH.
 
 */
        defvar "STATE",5,,STATE
@@ -1003,6 +1008,7 @@ var_\name :
        defvar "_Z",2,,TZ
        defvar "S0",2,,SZ
        defvar "R0",2,,RZ,return_stack
+       defvar "VERSION",7,,VERSION,JONES_VERSION
 
 /*
        RETURN STACK ----------------------------------------------------------------------
@@ -1477,7 +1483,7 @@ _TCFA:
        IMMEDIATE flag (F_IMMED in this code).  If a word in the dictionary is flagged as
        IMMEDIATE then the interpreter runs it immediately _even if it's in compile mode_.
 
-       I hope I don't need to explain that ; (SEMICOLON) just such a word, flagged as IMMEDIATE.
+       I hope I don't need to explain that ; (SEMICOLON) is just such a word, flagged as IMMEDIATE.
        And all it does is append the codeword for EXIT on to the current definition and switch
        back to immediate mode (set STATE back to 0).  Shortly we'll see the actual definition
        of ; and we'll see that it's really a very simple definition, declared IMMEDIATE.
@@ -1659,7 +1665,7 @@ _HIDDEN:
        BRANCH is an unconditional branch. 0BRANCH is a conditional branch (it only branches if the
        top of stack is zero).
 
-       The diagra below shows how BRANCH works in some imaginary compiled word.  When BRANCH executes,
+       The diagram below shows how BRANCH works in some imaginary compiled word.  When BRANCH executes,
        %esi starts by pointing to the offset field (compare to LIT above):
 
        +---------------------+-------+---- - - ---+------------+------------+---- - - - ----+------------+
@@ -1813,7 +1819,7 @@ interpret_is_lit:
        CHAR puts the ASCII code of the first character of the following word on the stack.  For example
        CHAR A puts 65 on the stack.
 
-       SYSEXIT pops the status off the stack and exits the process (using Linux exit syscall).
+       SYSEXIT exits the process using Linux exit syscall.
 */
 
        defcode "CHAR",4,,CHAR
@@ -1861,7 +1867,7 @@ interpret_is_lit:
        .data
        .align 4096
 buffer:
-       // Multi-line constant gives 'Warning: unterminated string; newline inserted' messages which you can ignore
+       // Multi-line constant gives 'Warning: unterminated string; newline inserted' messages which you can ignore.
        .ascii "\
 \\ Define some character constants
 : '\\n'   10 ;
@@ -2022,7 +2028,7 @@ buffer:
 \\ that the input buffer where the string comes from may be overwritten by the time we
 \\ come round to running the function).  We store the string in the compiled function
 \\ like this:
-\\   LITSTRING, string length, string rounded up to 4 bytes, EMITSTRING, ...
+\\   ..., LITSTRING, string length, string rounded up to 4 bytes, EMITSTRING, ...
 : .\" IMMEDIATE
        STATE @         \\ compiling?
        IF
@@ -2075,10 +2081,11 @@ buffer:
 
 \\ ALLOT is used to allocate (static) memory when compiling.  It increases HERE by
 \\ the amount given on the stack.
-: ALLOT HERE +! ;
+\\: ALLOT HERE +! ;
 
 
 \\ Finally print the welcome prompt.
+.\" JONESFORTH VERSION \" VERSION @ . CR
 .\" OK \"
 "