1     Okay, I guess I lied. I'm back sooner than I thought.
     
2 
     3     In addition to cleaning up, I've made a much-needed
     
4     improvement. I now load _all_ of jonesforth.f upon
     
5     start, so there's no need for the line limit. So I'm
     
6     properly checking for EOF while reading that file and
     
7     closing it.
     
8 
     9     It takes a lot of lines of assembly to produce a nice
    
10     error message. See the label ".loadjf_open_fail" in
    
11     nasmjf.asm for the listing. (It's not complicated, just
    
12     long.)
    
13 
    14     Here's how it looks:
    
15 
    16 $ nasmjf/nasmjf
    
17 ERROR Could not open 'jonesforth/jonesforth.f'.
    
18 
    19     But it still runs fine from the nasmjf/ dir:
    
20 
    21 $ cd nasmjf
    
22 $ ./nasmjf
    
23 JONESFORTH VERSION 48
    
24 20643 CELLS REMAINING
    
25 OK
    
26 
    27     And I really love being able to run the test suite to
    
28     make sure I haven't messed anything up!
    
29 
    30 $ ./test.sh
    
31 Testing: jonesforth/test_assembler.f
    
32 Testing: jonesforth/test_comparison.f
    
33 Testing: jonesforth/test_exception.f
    
34 Testing: jonesforth/test_number.f
    
35 Testing: jonesforth/test_read_file.f
    
36 Testing: jonesforth/test_stack.f
    
37 Testing: jonesforth/test_stack_trace.f
    
38 
    39     In theory, my Forth source reading mechanism could be
    
40     used _within_ Forth to load source files on the fly. I
    
41     think I'll leave that as an "exercise for the reader" as
    
42     they say. :-)
    
43 
    44     I've started inserting comments in the source to explain
    
45     how stuff works. I don't want to duplicate Jones's
    
46     explanations too much.
    
47 
    48     It's helpful to refresh my own understanding. I've
    
49     understood each part separately, but it's easy to lose
    
50     the forest for the trees because the way Forth works is
    
51     so gosh darned clever. Like, painfully clever.
    
52 
    53     I also finally tried something I've wanted to try for a
    
54     while: using one of NASM's excellent macro features to
    
55     perform a string length count so I can get rid of the
    
56     hard-coded name lengths. It turned out to be super easy:
    
57 
    58         %strlen namelen %1
    
59 
    60     I've converted a couple macros. DEFCODE and DEFWORD are
    
61     the big ones. I'll do them next.
    
62 
    63     I think I would also like to swap the order of the label
    
64     and flag parameters on these macros to make them
    
65     prettier to look at...
    
66 
    67     Two nights later: done! That was a royal pain, but
    
68     between sed on the command line piping to intermediate
    
69     files and then some simpler find/replace in Vim, I
    
70     managed to automate 99% of it.
    
71 
    72     And another night: added way more comments. I'm glad I
    
73     didn't put too much work into them when i first started
    
74     because I undertand it so much better now.
    
75 
    76     Also renamed 'r' script to 'build.sh' to make it clearer
    
77     what it is. Also added a test option to the script for a
    
78     total of four ways to play:
    
79 
    80         # Usage:
    
81         #
    
82         #   build.sh        Assemble, link
    
83         #   build.sh gdb    Assemble, link, and debug
    
84         #   build.sh test   Assemble, link, and test
    
85         #   build.sh run    Assemble, link, and run
    
86 
    87     Always good to keep honing the dev environment to keep
    
88     fast iterations as painless as possible.
    
89 
    90     Later: more comments in. Making steady progress. Now
    
91     trying to figure out if I should arrange the word
    
92     definitions in an attempt to explain them, or just put
    
93     all the code words at the front and all the regular
    
94     words at the end?
    
95 
    96     Several more nights later: Done! It may not be perfect
    
97     and perhaps I'll come back with more explanations and
    
98     check over all of my comments again. But I'm calling
    
99     this thing complete for now.
   
100 
   101     I hope it was fun following along.
   
102 
   103         Happy hacking!
   
104 
   105         -Dave