File:  [gforth] / gforth / Attic / forth.h
Revision 1.3: download - view: text, annotated - select for diffs
Thu May 5 17:05:34 1994 UTC (29 years, 11 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Got direct threading to work!

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

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