File:  [gforth] / gforth / Attic / forth.h
Revision 1.1: download - view: text, annotated - select for diffs
Fri Feb 11 16:30:46 1994 UTC (30 years, 2 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Initial revision

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

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