Annotation of gforth/forth.h, revision 1.20
1.19 anton 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.
1.1 anton 20: */
21:
22: typedef void *Label;
23:
1.2 pazsan 24: /* symbol indexed constants */
25:
26: #define DOCOL 0
27: #define DOCON 1
28: #define DOVAR 2
29: #define DOUSER 3
1.8 anton 30: #define DODEFER 4
1.16 anton 31: #define DOFIELD 5
1.14 pazsan 32: #define DODOES 6
33: #define DOESJUMP 7
1.6 benschop 34:
1.1 anton 35: #include "machine.h"
36:
37: /* Forth data types */
1.20 ! pazsan 38: typedef Cell Bool;
1.1 anton 39: #define FLAG(b) (-(b))
1.5 pazsan 40: #define FILEIO(error) (FLAG(error) & -37)
41: #define FILEEXIST(error) (FLAG(error) & -38)
1.1 anton 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:
1.4 anton 56: Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp);
1.1 anton 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 */
1.2 pazsan 75: #define MAKE_DOES_CF(cfa,does_code) ({MAKE_CF(cfa,symbols[DODOES]); \
1.1 anton 76: ((Cell *)cfa)[1] = (Cell)does_code;})
77: /* the does handler resides between DOES> and the following Forth code */
1.13 pazsan 78: #define DOES_HANDLER_SIZE (2*sizeof(Cell))
1.1 anton 79: #define MAKE_DOES_HANDLER(addr) 0 /* do nothing */
80: #endif
81:
82: #ifdef DEBUG
1.18 pazsan 83: # define NAME(string) fprintf(stderr,"%08lx: "string"\n",(Cell)ip);
1.1 anton 84: #else
85: # define NAME(string)
86: #endif
1.2 pazsan 87:
88: #define CF(const) (-const-2)
89:
90: #define CF_NIL -1
1.3 pazsan 91:
1.15 anton 92: #ifndef FLUSH_ICACHE
1.16 anton 93: #warning flush-icache probably will not work (see manual)
1.17 pazsan 94: # define FLUSH_ICACHE(addr,size)
1.15 anton 95: #endif
96:
97: #ifdef DIRECT_THREADED
98: #define CACHE_FLUSH(addr,size) FLUSH_ICACHE(addr,size)
99: #else
1.17 pazsan 100: #define CACHE_FLUSH(addr,size)
1.3 pazsan 101: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>