Wed Jan 3 00:08:04 1996 Karl Fogel * init_prims.c: removed, since auto-generated from prims.awk. Wed Mar 15 15:19:33 1995 Karl Fogel * soforth.fth: Define `sq'. * prims.c (init_words): don't use build_word anymore -- it's broken at the moment. Comment back in when ready to debug. BELOW TWO ENTRIES INDICATE START OF CVS REVISION MANAGEMENT: * ChangeLog, DESIGN, Makefile, TODO, arith.c, compile.c, control.c, dict.c, forth.c, forth.h, init_prims.c, logic.c, memory.c, prims.awk, prims.c, print.c, soforth.fth, stack.c, strings.c, system.c: Import of soforth. * ChangeLog, DESIGN, Makefile, TODO, arith.c, compile.c, control.c, dict.c, forth.c, forth.h, init_prims.c, logic.c, memory.c, prims.awk, prims.c, print.c, soforth.fth, stack.c, strings.c, system.c: Initial revision Sun Nov 27 19:22:42 1994 Karl Fogel (kfogel@phylo) * forth.h (ALIGN_STRING): corrected math. * strings.c (Fstring): took out testing code. (Fgnirts): completely rewritten to handle standard counted strings. Doesn't seem to work quite yet, though. * strings.c (Fgnirts): cast the result of ALIGN_STRING. (Fstring): new prim. Has explicit testing code in it, which must go eventually. (Ftype): new prim. * prims.c (init_prims): add string. * prims.c: Include "strings.c". * system.c (Fcount): don't cast addr unnecessarily. * prims.c (init_prims): add gnirts and type. * soforth.fth (string): preliminary definition. * memory.c (Fcstore): new prim. (Fcfetch): new prim. * prims.c (init_prims): init Fcstore and Fcfetch. * Makefile: Deal with new source arrangement (no subdirs anymore). (install): chmod u+rw soforth.fth after installation. * prims.c: Just include "forth.h". Wed Nov 23 00:12:45 1994 Karl Fogel (kfogel@phylo) * strings.c: Initial revision Tue Nov 22 23:52:19 1994 Karl Fogel (kfogel@phylo) * forth.h (ALIGN_STRING): new macro, still untested. Tue Nov 22 01:36:16 1994 Karl Fogel (kfogel@phylo) * forth.h (STD_LIB): only conditionally define this. * Makefile (STD_LIB): new def for compilation command-line. (install): make directories if they don't exist. * soforth.fth (bl): defined. Mon Nov 21 00:53:01 1994 Karl Fogel (kfogel@phylo) * Makefile: Be a realer Makefile. Mon Nov 21 00:52:38 1994 Karl Fogel (kfogel@phylo) * prims.c: Include "../main/forth.h", not "../forth/forth.h". * prims.c: Include "../forth/forth.h", not "../forth.h". * compile.c (Fcolon): use BL instead of Fbl. * system.c (Finterpret): use BL instead of Fbl. * prims.c (init_prims): don't add Sbl -- it doesn't exist anymore. * system.c (Fbl): eliminated. * prims.c: Include "../forth.h", not "forth.h". * dict.c, compile.c, system.c, memory.c, stack.c, print.c, logic.c, arith.c: Don't include "forth.h". * prims.c: Moved most functions to other files. Just include those files here. * forth.h (BL): new macro, does the work of Fbl. * forth.h: Added prototype for start_word. * arith.c, logic.c, print.c, stack.c, memory.c, system.c, compile.c, dict.c: Include "forth.h". * dict.c, compile.c: Initial revision * control.c (Frparen, Fskip_line): put into this file. * system.c, control.c: Initial revision Sun Nov 20 23:59:06 1994 Karl Fogel (kfogel@phylo) * memory.c, stack.c, print.c, logic.c, arith.c: Initial revision Sun Nov 20 21:08:14 1994 Karl Fogel (kfogel@phylo) * prims.c: Comment change. * forth.c (handle_command_line): reset infile on failure. (load_library): same. * prims.c (Flsh, Frsh): changed names to "lsh" and "rsh". * prims.c: Cleaned up some typos and misquotes. * prims.c: (Fgt, Flt, Fgte, Flte, Fand, For, Fxor, Ftwiddle, Fnot, Flsh, Frsh): new prims. * prims.c (Fskip_line): new prim. Sun Nov 20 20:14:54 1994 Karl Fogel (kfogel@phylo) * prims.c: Comment changes. Sun Nov 20 20:12:09 1994 Karl Fogel (kfogel@phylo) * soforth.fth: Generally reorganized the file, inlined comments, etc. (else): made this work. (pri): got rid of this -- of what use was it? * forth.c (handle_command_line): include a period and newline in the error message. (load_library): same. * forth.c (handle_command_line): print a formatted string directly to stderr, include the name of the problem file in the error message. (load_library): new func. (main): call above before calling handle_command_line(). * forth.h (STD_LIB): define to be "soforth.fth". Later, we'll have an install dir or something. * soforth.fth (then): added a dp+ just before restoring return stack and ending. (else): started defining. * prims.c (init_words): got rid of a comment. * prims.c (init_words): don't build "foo" and "bar". Do build "sq", but note that it would be a lot faster as a real primitive. * prims.c (Fprint_rstack): new prim. Sat Nov 19 19:57:48 1994 Karl Fogel (kfogel@phylo) * soforth.fth: Got rid of extra close paren in a comment. Sat Nov 19 19:46:43 1994 Karl Fogel (kfogel@phylo) * soforth.fth (rswap): deleted. (if): restored definition that doesn't use rswap. Erased old def instead of commenting out. (then): same. Same. * soforth.fth (push_branch): used to have the same name as push_bze -- which caused problems! * soforth.fth (rswap): uncommented (it is defined again). (if): restored old version, then one using rswap. (then): same. * soforth.fth (rswap): commented out. (if): do the rswapping by hand. (then): same. (pri): (immediate) 10 print_rstack. (else): Started defining. * soforth.fth: Initial revision * forth.h (PRINT_RSTACK): new macro. Fri Nov 18 19:01:40 1994 Karl Fogel (kfogel@phylo) * prims.c (Fpop): new prim. * forth.c (address_interpreter): RPUSH (pc), not (pc + 1). * prims.c (Fliteral): be NON_IMMEDIATE. Fri Nov 18 01:30:03 1994 Karl Fogel (kfogel@phylo) * prims.c (Fallot): increment by bytes, not words. * prims.c (Fbeq): increment pc even if didn't assign to it, so we still get past the address stored in the PF. (Fbze): same. (Fbnz): same. * prims.c (Fbranch): new prim. * prims.c (init_prims): add Srparen. * prims.c (Fword): removed an fflush(). (Frparen): new prim. I love this language! The comment starter is an immediate word. It's like (defmacro ; ...) TODO: Eventually, this will be defined out in the forth library. * prims.c (Frecurse): deleted -- we're going to define this in Forth now. Thu Nov 17 16:47:35 1994 Karl Fogel (kfogel@phylo) * prims.c (Flast): new prim. (Frecurse): added important comment. Comment shows how to define recurse in Forth. It works -- you tested it. The next thing to do is to start writing a forth lib and loading it on startup. * prims.c (Frecurse): assign to *dp, not dp. * prims.c (Frecurse): new prim. * forth.c (handle_command_line): new func. (main): call above. Thu Nov 17 16:20:15 1994 Karl Fogel (kfogel@phylo) * prims.c (Finterpret): Compactified the code, got rid of obsolete comments, generally dusted things off. * prims.c (Finterpret): POP before continuing or returning, if Fword leaves a 0. Return instead of continuing after resetting infile. * forth.h: Include errno.h. * forth.h (colon_jump_buf): don't declare here, no need. Thu Nov 17 02:56:43 1994 Karl Fogel (kfogel@phylo) * prims.c (Fallot): don't cast the integral right side. (Farena): new prim. * prims.c: Just a spacing change. * prims.c (Fhere): new prim. (Fallot): new prim. (Fbeq): new prim. (Fbnz): new prim. (Fbze): new prim. * prims.c (init_prims): add Fimmediate. Yay, it works! * prims.c (Fto_r): new prim. (Fr_from): new prim. (Fr_fetch): new prim. (Fstore): new prim. (Ffetch): new prim. Wed Nov 16 18:08:17 1994 Karl Fogel (kfogel@phylo) * forth.c: Comment change. Tue Nov 15 23:49:52 1994 Karl Fogel (kfogel@phylo) * forth.h: Added comment. Tue Nov 15 23:24:02 1994 Karl Fogel (kfogel@phylo) * forth.c (main): comment eliminated. * prims.c (init_words): comment change. * forth.c (address_interpreter): cast arg to RPUSH. * forth.h (pc): funcptr **, not funcptr *. * forth.c (pc): declare as funcptr **, not funcptr *. (address_interpreter): deal with above. * prims.c (Fexecute): deal with pc's new type. Tue Nov 15 17:54:46 1994 Karl Fogel (kfogel@phylo) * prims.c (Fcolon): compile in the address of the *word* "literal", not Fliteral itself. Use dict_lookup for this (as in the earlier change to build_word). Tue Nov 15 17:40:24 1994 Karl Fogel (kfogel@phylo) * forth.c (address_interpreter): cast pc before calling its pointee. * prims.c (build_word): take strings, not funcs, as args. (Fcolon): don't dereference *sp after all. * forth.c (main): do call init_words here. * forth.c (dict_lookup): comment change. * prims.c (init_prims): call init_words after adding all the primitives. * forth.c (main): don't call init_words here. Tue Nov 15 05:09:49 1994 Karl Fogel (kfogel@phylo) * prims.c (Fliteral): don't increment pc twice -- address_interpreter will do it the second time! Tue Nov 15 04:37:12 1994 Karl Fogel (kfogel@phylo) * prims.c (Fexecute): reorganized things a bit. (init_words): init word bar too. Changed foo's definition to be the same as bar's. They both now square and print the stacktop. (Fcolon): dereference *sp (as left by Fword) before compiling it into the word-in-progress. Mon Nov 14 05:56:22 1994 Karl Fogel (kfogel@phylo) * prims.c (Fexecute): use only one level of dereferencing, not two. This change seems to have broken real words. Try setting pc to sp before assigning fp to anything at all. * forth.h (ENTRY_IMMEDIATE_P): don't cast return value. The correct power of 2 is 128, not 256. (ENTRY_NAME_LENGTH): The correct power of 2 is 127, not 255. (CFA_ENTRY): param's name is cfa. Cast it before doing pointer arithmetic. (ENTRY_IMMEDIATE_P): index dict_entry like an array, after casting to char *. * prims.c: Replaced all "255"s with "127". (add_primitive): removed debugging messages. (Fliteral): yikes, increment the pc twice, not once. (Fcolon): cast the POP when compiling in a word's address. (build_word): debugging message in the while loop. (start_word): new func. (build_word): make use of above. * forth.c (main): set infile and outfile before calling ANYTHING. Mon Nov 14 03:04:52 1994 Karl Fogel (kfogel@phylo) * prims.c (add_primitive): length should be char, not int. Debugging message (only temporary). (build_word): replaces hand_build_word. All callers changed. Take a length arg, possibly zero, though. (Fcolon): new prim. (Fsemicolon): new prim. (Fliteral): new prim. (Fimmediate): new prim. * forth.h: Include setjmp.h. (colon_jump_buf): new extern var, type jump_buf. (CFA_ENTRY): new macro, does the reverse of ENTRY_CFA. * forth.c (display_dictionary): try to print immediateness too. * forth.c: Added comment to top of file. Sun Nov 13 20:18:27 1994 Karl Fogel (kfogel@phylo) * forth.c (dict_lookup): got rid of extra parens. Sun Nov 13 20:14:26 1994 Karl Fogel (kfogel@phylo) * forth.c (main): just call Finterpret now. * prims.c (Finterpret): took loop from main and made this prim from it. Don't exit, just return. Mon Nov 7 00:27:18 1994 Karl Fogel (kfogel@phylo) * prims.c (Fword): return if EOF is read. Don't print anything out. (Fprint_dict): new prim. (Fprint_stack): new prim. * forth.c: No change. * forth.h (PRINT_STACK): i is long, not int. Mon Nov 7 00:04:59 1994 Karl Fogel (kfogel@phylo) * forth.h (RUN): PUSH dict_lookup's return value now, since dict_lookup doesn't do any pushing for us. * forth.c (dict_lookup): don't affect the stack, just return an address or NULL. * prims.c (Fword): rewritten for robustitude. Don't ever exit -- that's main()'s job. (Ffind): totally rewritten. (Fnumber): new primitive. Sun Nov 6 23:02:11 1994 Karl Fogel (kfogel@phylo) * forth.c (pc): declared as extern funcptr *. (rp): same, but two *'s. (init_arena): cast assignment to rp. (address_interpreter): cast assignment to pc as funcptr *. * prims.c (Fexecute): cast pc assignment to funcptr *. * forth.h: Space deleted. * forth.h (rp): **, not *. * forth.h: Moved some stuff around. * forth.h (rp): declared as extern funcptr * as well. * forth.h (pc): declared as extern funcptr *. Tue Nov 1 02:12:30 1994 Karl Fogel (kfogel@phylo) * forth.c (main): push 12 and 42 before looping. * prims.c (Fword): Oops. = has lower precedence than !=. Duh. * forth.h (TB_SIZE): define to be 100. (tb): declare extern. * prims.c (Fbl): new op. (Fword): new op. (Fcount): new op. (Ffind): new op. * forth.c (init_arena): init tb. (main): run a loop after testing. Mon Oct 31 20:44:28 1994 Karl Fogel (kfogel@phylo) * prims.c (hand_build_word): new function. (init_words): new function. * forth.c: Comment update. * forth.c (main): call init_words. Don't call add_foo. * forth.h (hand_build_word): take char immediate_p argument. (init_words): prototype. * forth.h (hand_build_word): new func prototyped. (add_foo): no need for this anymore. Mon Oct 31 17:41:03 1994 Karl Fogel (kfogel@phylo) * forth.c (address_interpreter): cast *pc before incrementing, so it increments by word size (4) instead of by (literally) 1. (main): PUSH (31) before running "foo". * prims.c (Fexecute): make fp doubly indirect, so pc can be set to it. * forth.c (address_interpreter): when setting pc, set it to *pc + 1, not *pc. * prims.c (Fexecute): but do initialized pc! * prims.c (Fexecute): don't copy *sp to dp. Just use a local C var fp to hold the address to be executed. Sun Oct 30 23:21:25 1994 Karl Fogel (kfogel@phylo) * prims.c (Fexecute): don't declare fp. * prims.c (Fexecute): don't set dp[1] to END_OF_PARAMS. It isn't necessary. * forth.c (main): uncommented call to add_foo and RUN("foo"). (address_interpreter): removed var fp; just cast the *function call now. * prims.c (add_foo): added comments. (Fexecute): removed var fp; just cast the *function call now. * prims.c (Fexecute): set pc to dp, not dp - 1. Introduce interim variable fp. There should be no need to do this; figure out how to call pc directly. * forth.c (address_interpreter): don't increment pc first. Introduce technically unecessary interim var fp. (main): commented out add_foo and the RUN ("foo"). * forth.h: Declare add_foo(). * forth.c (main): RUN "foo". * prims.c (add_primitive): cast length to a char before masking it. Mask it in the strncpy, too. (add_foo): new testing function. * forth.h (run_primitive): don't declare what doesn't exist. (PRINT_STACK): distinguish singular depth from plural depth. * forth.h (FORCE_RETURN): removed this now-unused macro. (PRINT_STACK): print depth, not depth - 1. It's less confusing this way. Made all macros deal with interleaved stacks. Ah haha-haha haaaa... * forth.c (main): don't RPUSH (pc) before starting the tests. * forth.c (init_arena): init the stacks to be interleaved. (main): added some more PRINT_STACKs. * prims.c: Made all prims deal with the interleaved stack. * prims.c: Expanded a comment. * forth.c: Replaced `printf's with `fprintf's directed to outfile. Sun Oct 30 01:22:23 1994 Karl Fogel (kfogel@phylo) * prims.c, forth.c: Deleted old, #def'd out code. * prims.c (add_primitive): just make the CFA point to the primitive itself, and have a null PFA. (run_primitive): no need for this function anymore. (Fexecute): start pc at dp - 1. * forth.c (address_interpreter): modified Red Herring version. Sat Oct 29 18:12:14 1994 Karl Fogel (kfogel@phylo) * forth.c (main): added calls to cr. * forth.c (address_interpreter): completely rewritten, as per discussion with Jim in the Red Herring. This new version is still commented out, however. Sat Oct 29 17:48:43 1994 Karl Fogel (kfogel@phylo) * prims.c (PRIMITIVE): deal with forward-running dictionary entries. * forth.h (ENTRY_IMMEDIATE_P): deal with forward-running dictionary entries. (ENTRY_NAME_LENGTH): same. (ENTRY_NAME): same. (ENTRY_LINK): same. (ENTRY_PFA): same. (MIN): defined. (MAX): defined. (last_dp): new extern unsigned long *. Made all global pointer vars unsigned. * forth.c (address_interpreter): deal with forward-running dictionary entries. (dict_lookup): don't compare this_dp against dict_bottom, just ask if non-zero, since last_dp is initialized to zero. Init this_dp to last_dp. (display_dictionary): don't compare this_dp against arena, just ask if non-zero, since last_dp is initialized to zero. Init this_dp to last_dp. (dict_bottom): eliminated this var. Fri Oct 28 22:33:59 1994 Karl Fogel (kfogel@phylo) * prims.c (Femit): don't print a newline. (Fcr): new prim. * forth.c (address_interpreter): declare fp as (funcptr *), then no need for the horrifying cast. Fri Oct 28 17:35:37 1994 Karl Fogel (kfogel@phylo) * forth.c (main): Use the RUN macro. Put in PRINT_STACK calls. * forth.h (RUN): new testing macro. (PRINT_STACK): new testing macro. * prims.c (init_prims): init the new prims. * forth.h (POP): return a value, now. (RPOP): same. (RPUSH): assign before decrementing rp. Fri Oct 28 05:58:43 1994 Karl Fogel (kfogel@phylo) * forth.c (address_interpreter): cast the function call correctly. (main): corrected order of arguments to the long printf. Test the interpreter more extensively. * prims.c: Replaced "sp++" with POP where appropriate. * forth.h (PUSH): don't decrement sp until after the assignment. * prims.c: Fixed typo. * prims.c (Fexecute): copy the address on the stack to the top of the dictionary and execute it like a word, complete with an END_OF_PARAMS marker. (Fabs, Fneg, Fmax, Fmin): new functions. (Fdup, Fover, Fswap, Frot): new functions. * forth.h: Include stdlib.h. Mon Oct 24 14:50:54 1994 Karl Fogel (kfogel@phylo) * forth.c: Changed print statements. * forth.c (main): print out stack and pc info just before calling execute. * forth.c (display_dictionary): print out arena, dict_bottom, and dp first. * forth.c (main): correct syntax for printf. * forth.c (display_dictionary): put quotes around names. * forth.h: Comment change. * prims.c (Fexecute): filled in definition. * forth.c (main): use Fexecute to run things now. (display_dictionary): only print out the first pfa. Print CFA, as well as this_dp. Sun Oct 23 22:34:59 1994 Karl Fogel (kfogel@phylo) * forth.h (PRIMITIVE): accept and toss a "stack_effect" arg. (ENTRY_CF): removed this for now. * prims.c: Gave stack effect comments to all primitives. * forth.c (display_dictionary): print out PFA information. * forth.c (display_dictionary): print more prettily. (dict_bottom): new var. (dict_lookup): Compare against new var `dict_bottom', not `arena'. Push address if found, else push zero. (address_interpreter): new function. (main): test the address_interpreter. * forth.h: Added prototypes for address_interpreter() and run_primitive(); (RPUSH, RPOP): new macros, for the return stack. (ENTRY_CFA): return the CFA itself, not its contents. (ENTRY_CF): new macro, returns the *contents* of the CFA. * prims.c: Removed spurious +'s from instances of "sp[+1]". (Fdot): replaces old, misnamed Femit. Prints out a character, not a number. (Femit): new function, prints a number. (run_primitive): new function. (add_primitive): put above in the CFA and the primitive itself in the PFA. Removed FORCE_RETURNS from primitives; only run_primitive need do that now. Mon Oct 10 02:59:53 1994 Karl Fogel (kfogel@phylo) * forth.h: Adjusted the ENTRY* macros for the fact that the dictionary grows UP, not down, and sometimes converts between bytes and longs. * forth.c (display_dictionary_linear): deleted this func. (display_dictionary): don't forget to increment this_dp. Prettier output. * prims.c (add_primitive): remember that you want to set 1 byte back from dp to the name length. * forth.c (display_dictionary_linear): prettier output. * forth.c (display_dictionary_linear): new func. (main): call it at end. * forth.c (display_dictionary): added last_addr test. * prims.c (add_primitive): don't display the dict every time we add a primitive, after all. * prims.c (Fmod): visible name is now "mod", not "%". (add_primitive): display the dict every time we add a primitive, for testing only. * forth.c (display_dictionary): new func. (main): display the dict just before exiting. * forth.h (display_dictionary): added prototype. * forth.c, prims.c, forth.h: Initial revision