File:  [gforth] / gforth / Attic / forth.h
Revision 1.18: download - view: text, annotated - select for diffs
Thu Oct 26 22:48:39 1995 UTC (23 years, 10 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Changed threading ifdefs.
Requires debugging !!!!!!
Perhaps change concepts with LONG_LATENCY
on RISCs.
Added sokoban.fs as a nice little game.

    1: /*
    2:   Copyright 1992 by the ANSI figForth Development Group
    3: */
    4: 
    5: /* common header file */
    6: 
    7: typedef void *Label;
    8: 
    9: /* symbol indexed constants */
   10: 
   11: #define DOCOL	0
   12: #define DOCON	1
   13: #define DOVAR	2
   14: #define DOUSER	3
   15: #define DODEFER	4
   16: #define DOFIELD	5
   17: #define DODOES	6
   18: #define DOESJUMP	7
   19: 
   20: #include "machine.h"
   21: 
   22: /* Forth data types */
   23: typedef int Bool;
   24: #define FLAG(b) (-(b))
   25: #define FILEIO(error)	(FLAG(error) & -37)
   26: #define FILEEXIST(error)	(FLAG(error) & -38)
   27: 
   28: #define F_TRUE (FLAG(0==0))
   29: #define F_FALSE (FLAG(0!=0))
   30: 
   31: typedef unsigned char Char;
   32: typedef double Float;
   33: typedef char *Address;
   34: 
   35: #ifdef DIRECT_THREADED
   36: typedef Label Xt;
   37: #else
   38: typedef Label *Xt;
   39: #endif
   40: 
   41: Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp);
   42: 
   43: #ifndef DIRECT_THREADED
   44: /* i.e. indirect threaded */
   45: /* the direct threaded version is machine dependent and resides in machine.h */
   46: 
   47: /* PFA gives the parameter field address corresponding to a cfa */
   48: #define PFA(cfa)	(((Cell *)cfa)+2)
   49: /* PFA1 is a special version for use just after a NEXT1 */
   50: #define PFA1(cfa)	PFA(cfa)
   51: /* CODE_ADDRESS is the address of the code jumped to through the code field */
   52: #define CODE_ADDRESS(cfa)	(*(Label *)(cfa))
   53:       /* DOES_CODE is the Forth code does jumps to */
   54: #define DOES_CODE(cfa)           (cfa[1])
   55: #define DOES_CODE1(cfa)          DOES_CODE(cfa)
   56: /* MAKE_CF creates an appropriate code field at the cfa;
   57:    ca is the code address */
   58: #define MAKE_CF(cfa,ca) ((*(Label *)(cfa)) = ((Label)ca))
   59: /* make a code field for a defining-word-defined word */
   60: #define MAKE_DOES_CF(cfa,does_code)	({MAKE_CF(cfa,symbols[DODOES]);	\
   61: 					  ((Cell *)cfa)[1] = (Cell)does_code;})
   62: /* the does handler resides between DOES> and the following Forth code */
   63: #define DOES_HANDLER_SIZE	(2*sizeof(Cell))
   64: #define MAKE_DOES_HANDLER(addr)	0 /* do nothing */
   65: #endif
   66: 
   67: #ifdef DEBUG
   68: #	define	NAME(string)	fprintf(stderr,"%08lx: "string"\n",(Cell)ip);
   69: #else
   70: #	define	NAME(string)
   71: #endif
   72: 
   73: #define CF(const)	(-const-2)
   74: 
   75: #define CF_NIL	-1
   76: 
   77: #ifndef FLUSH_ICACHE
   78: #warning flush-icache probably will not work (see manual)
   79: #	define FLUSH_ICACHE(addr,size)
   80: #endif
   81: 
   82: #ifdef DIRECT_THREADED
   83: #define CACHE_FLUSH(addr,size) FLUSH_ICACHE(addr,size)
   84: #else
   85: #define CACHE_FLUSH(addr,size)
   86: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>