File:  [gforth] / gforth / Attic / forth.h
Revision 1.13: download - view: text, annotated - select for diffs
Thu Jan 19 17:48:02 1995 UTC (24 years, 5 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
float.fs: Added f~ (f-proximate)
wordsets.fs: Added missing float words
Added 16 bit and 64 bit support in cross.fs
Fixed some bugs which asume sizeof(int)=sizeof(Cell)

    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 DODOES	5
   17: #define DOESJUMP	6
   18: 
   19: #include "machine.h"
   20: 
   21: /* Forth data types */
   22: typedef int Bool;
   23: #define FLAG(b) (-(b))
   24: #define FILEIO(error)	(FLAG(error) & -37)
   25: #define FILEEXIST(error)	(FLAG(error) & -38)
   26: 
   27: #define F_TRUE (FLAG(0==0))
   28: #define F_FALSE (FLAG(0!=0))
   29: 
   30: typedef unsigned char Char;
   31: typedef double Float;
   32: typedef char *Address;
   33: 
   34: #ifdef DIRECT_THREADED
   35: typedef Label Xt;
   36: #else
   37: typedef Label *Xt;
   38: #endif
   39: 
   40: Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp);
   41: 
   42: #ifndef DIRECT_THREADED
   43: /* i.e. indirect threaded */
   44: /* the direct threaded version is machine dependent and resides in machine.h */
   45: 
   46: /* PFA gives the parameter field address corresponding to a cfa */
   47: #define PFA(cfa)	(((Cell *)cfa)+2)
   48: /* PFA1 is a special version for use just after a NEXT1 */
   49: #define PFA1(cfa)	PFA(cfa)
   50: /* CODE_ADDRESS is the address of the code jumped to through the code field */
   51: #define CODE_ADDRESS(cfa)	(*(Label *)(cfa))
   52:       /* DOES_CODE is the Forth code does jumps to */
   53: #define DOES_CODE(cfa)           (cfa[1])
   54: #define DOES_CODE1(cfa)          DOES_CODE(cfa)
   55: /* MAKE_CF creates an appropriate code field at the cfa;
   56:    ca is the code address */
   57: #define MAKE_CF(cfa,ca) ((*(Label *)(cfa)) = ((Label)ca))
   58: /* make a code field for a defining-word-defined word */
   59: #define MAKE_DOES_CF(cfa,does_code)	({MAKE_CF(cfa,symbols[DODOES]);	\
   60: 					  ((Cell *)cfa)[1] = (Cell)does_code;})
   61: /* the does handler resides between DOES> and the following Forth code */
   62: #define DOES_HANDLER_SIZE	(2*sizeof(Cell))
   63: #define MAKE_DOES_HANDLER(addr)	0 /* do nothing */
   64: #endif
   65: 
   66: #ifdef DEBUG
   67: #	define	NAME(string)	fprintf(stderr,"%08x: "string"\n",(Cell)ip);
   68: #else
   69: #	define	NAME(string)
   70: #endif
   71: 
   72: #define CF(const)	(-const-2)
   73: 
   74: #define CF_NIL	-1
   75: 
   76: #ifndef CACHE_FLUSH
   77: #	define CACHE_FLUSH(addr,size)
   78: #endif

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