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