File:  [gforth] / gforth / Attic / forth.h
Revision 1.20: download - view: text, annotated - select for diffs
Thu Nov 9 19:37:02 1995 UTC (23 years, 10 months ago) by pazsan
Branches: MAIN
CVS tags: gforth-0_1beta, HEAD
Made gforth run on Alpha (changed Bool to Cell and worked around
malloc(0)=0).

    1: /* common header file
    2: 
    3:   Copyright (C) 1995 Free Software Foundation, Inc.
    4: 
    5:   This file is part of Gforth.
    6: 
    7:   Gforth is free software; you can redistribute it and/or
    8:   modify it under the terms of the GNU General Public License
    9:   as published by the Free Software Foundation; either version 2
   10:   of the License, or (at your option) any later version.
   11: 
   12:   This program is distributed in the hope that it will be useful,
   13:   but WITHOUT ANY WARRANTY; without even the implied warranty of
   14:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15:   GNU General Public License for more details.
   16: 
   17:   You should have received a copy of the GNU General Public License
   18:   along with this program; if not, write to the Free Software
   19:   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   20: */
   21: 
   22: typedef void *Label;
   23: 
   24: /* symbol indexed constants */
   25: 
   26: #define DOCOL	0
   27: #define DOCON	1
   28: #define DOVAR	2
   29: #define DOUSER	3
   30: #define DODEFER	4
   31: #define DOFIELD	5
   32: #define DODOES	6
   33: #define DOESJUMP	7
   34: 
   35: #include "machine.h"
   36: 
   37: /* Forth data types */
   38: typedef Cell Bool;
   39: #define FLAG(b) (-(b))
   40: #define FILEIO(error)	(FLAG(error) & -37)
   41: #define FILEEXIST(error)	(FLAG(error) & -38)
   42: 
   43: #define F_TRUE (FLAG(0==0))
   44: #define F_FALSE (FLAG(0!=0))
   45: 
   46: typedef unsigned char Char;
   47: typedef double Float;
   48: typedef char *Address;
   49: 
   50: #ifdef DIRECT_THREADED
   51: typedef Label Xt;
   52: #else
   53: typedef Label *Xt;
   54: #endif
   55: 
   56: Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp);
   57: 
   58: #ifndef DIRECT_THREADED
   59: /* i.e. indirect threaded */
   60: /* the direct threaded version is machine dependent and resides in machine.h */
   61: 
   62: /* PFA gives the parameter field address corresponding to a cfa */
   63: #define PFA(cfa)	(((Cell *)cfa)+2)
   64: /* PFA1 is a special version for use just after a NEXT1 */
   65: #define PFA1(cfa)	PFA(cfa)
   66: /* CODE_ADDRESS is the address of the code jumped to through the code field */
   67: #define CODE_ADDRESS(cfa)	(*(Label *)(cfa))
   68:       /* DOES_CODE is the Forth code does jumps to */
   69: #define DOES_CODE(cfa)           (cfa[1])
   70: #define DOES_CODE1(cfa)          DOES_CODE(cfa)
   71: /* MAKE_CF creates an appropriate code field at the cfa;
   72:    ca is the code address */
   73: #define MAKE_CF(cfa,ca) ((*(Label *)(cfa)) = ((Label)ca))
   74: /* make a code field for a defining-word-defined word */
   75: #define MAKE_DOES_CF(cfa,does_code)	({MAKE_CF(cfa,symbols[DODOES]);	\
   76: 					  ((Cell *)cfa)[1] = (Cell)does_code;})
   77: /* the does handler resides between DOES> and the following Forth code */
   78: #define DOES_HANDLER_SIZE	(2*sizeof(Cell))
   79: #define MAKE_DOES_HANDLER(addr)	0 /* do nothing */
   80: #endif
   81: 
   82: #ifdef DEBUG
   83: #	define	NAME(string)	fprintf(stderr,"%08lx: "string"\n",(Cell)ip);
   84: #else
   85: #	define	NAME(string)
   86: #endif
   87: 
   88: #define CF(const)	(-const-2)
   89: 
   90: #define CF_NIL	-1
   91: 
   92: #ifndef FLUSH_ICACHE
   93: #warning flush-icache probably will not work (see manual)
   94: #	define FLUSH_ICACHE(addr,size)
   95: #endif
   96: 
   97: #ifdef DIRECT_THREADED
   98: #define CACHE_FLUSH(addr,size) FLUSH_ICACHE(addr,size)
   99: #else
  100: #define CACHE_FLUSH(addr,size)
  101: #endif

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