File:  [gforth] / gforth / Attic / forth.h
Revision 1.12: download - view: text, annotated - select for diffs
Mon Dec 12 17:10:37 1994 UTC (24 years, 6 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Reorganized configuration: configure is now created by autoconf from
configure.in; I still left it in the CVS repository because not
everyone has autoconf. decstation.h renamed to mips.h and apollo68k to
m68k. Added general 32bit.h description, which the other machine
descriptions use. Created/copied replacement files install-sh memcmp.c
memmove.c select.c (carved out from ecvt.c) strtol.c
strtoul.c. Bytesex is now handled by configure.

Deciding the threading method is now done in machine.h, this should
also be done for USE_TOS and USE_FTOS.

    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	8
   63: #define MAKE_DOES_HANDLER(addr)	0 /* do nothing */
   64: #endif
   65: 
   66: #ifdef DEBUG
   67: #	define	NAME(string)	fprintf(stderr,"%08x: "string"\n",(int)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>