| 1 : |
anton
|
1.1
|
/* |
| 2 : |
|
|
Copyright 1992 by the ANSI figForth Development Group |
| 3 : |
|
|
*/ |
| 4 : |
|
|
|
| 5 : |
|
|
/* common header file */ |
| 6 : |
|
|
|
| 7 : |
|
|
typedef void *Label; |
| 8 : |
|
|
|
| 9 : |
pazsan
|
1.2
|
/* symbol indexed constants */ |
| 10 : |
|
|
|
| 11 : |
|
|
#define DOCOL 0 |
| 12 : |
|
|
#define DOCON 1 |
| 13 : |
|
|
#define DOVAR 2 |
| 14 : |
|
|
#define DOUSER 3 |
| 15 : |
anton
|
1.8
|
#define DODEFER 4 |
| 16 : |
anton
|
1.16
|
#define DOFIELD 5 |
| 17 : |
pazsan
|
1.14
|
#define DODOES 6 |
| 18 : |
|
|
#define DOESJUMP 7 |
| 19 : |
benschop
|
1.6
|
|
| 20 : |
anton
|
1.1
|
#include "machine.h" |
| 21 : |
|
|
|
| 22 : |
|
|
/* Forth data types */ |
| 23 : |
|
|
typedef int Bool; |
| 24 : |
|
|
#define FLAG(b) (-(b)) |
| 25 : |
pazsan
|
1.5
|
#define FILEIO(error) (FLAG(error) & -37) |
| 26 : |
|
|
#define FILEEXIST(error) (FLAG(error) & -38) |
| 27 : |
anton
|
1.1
|
|
| 28 : |
|
|
#define F_TRUE (FLAG(0==0)) |
| 29 : |
|
|
#define F_FALSE (FLAG(0!=0)) |
| 30 : |
|
|
|
| 31 : |
|
|
typedef unsigned char Char; |
| 32 : |
|
|
typedef double Float; |
| 33 : |
|
|
typedef char *Address; |
| 34 : |
|
|
|
| 35 : |
|
|
#ifdef DIRECT_THREADED |
| 36 : |
|
|
typedef Label Xt; |
| 37 : |
|
|
#else |
| 38 : |
|
|
typedef Label *Xt; |
| 39 : |
|
|
#endif |
| 40 : |
|
|
|
| 41 : |
anton
|
1.4
|
Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp); |
| 42 : |
anton
|
1.1
|
|
| 43 : |
|
|
#ifndef DIRECT_THREADED |
| 44 : |
|
|
/* i.e. indirect threaded */ |
| 45 : |
|
|
/* the direct threaded version is machine dependent and resides in machine.h */ |
| 46 : |
|
|
|
| 47 : |
|
|
/* PFA gives the parameter field address corresponding to a cfa */ |
| 48 : |
|
|
#define PFA(cfa) (((Cell *)cfa)+2) |
| 49 : |
|
|
/* PFA1 is a special version for use just after a NEXT1 */ |
| 50 : |
|
|
#define PFA1(cfa) PFA(cfa) |
| 51 : |
|
|
/* CODE_ADDRESS is the address of the code jumped to through the code field */ |
| 52 : |
|
|
#define CODE_ADDRESS(cfa) (*(Label *)(cfa)) |
| 53 : |
|
|
/* DOES_CODE is the Forth code does jumps to */ |
| 54 : |
|
|
#define DOES_CODE(cfa) (cfa[1]) |
| 55 : |
|
|
#define DOES_CODE1(cfa) DOES_CODE(cfa) |
| 56 : |
|
|
/* MAKE_CF creates an appropriate code field at the cfa; |
| 57 : |
|
|
ca is the code address */ |
| 58 : |
|
|
#define MAKE_CF(cfa,ca) ((*(Label *)(cfa)) = ((Label)ca)) |
| 59 : |
|
|
/* make a code field for a defining-word-defined word */ |
| 60 : |
pazsan
|
1.2
|
#define MAKE_DOES_CF(cfa,does_code) ({MAKE_CF(cfa,symbols[DODOES]); \ |
| 61 : |
anton
|
1.1
|
((Cell *)cfa)[1] = (Cell)does_code;}) |
| 62 : |
|
|
/* the does handler resides between DOES> and the following Forth code */ |
| 63 : |
pazsan
|
1.13
|
#define DOES_HANDLER_SIZE (2*sizeof(Cell)) |
| 64 : |
anton
|
1.1
|
#define MAKE_DOES_HANDLER(addr) 0 /* do nothing */ |
| 65 : |
|
|
#endif |
| 66 : |
|
|
|
| 67 : |
|
|
#ifdef DEBUG |
| 68 : |
pazsan
|
1.13
|
# define NAME(string) fprintf(stderr,"%08x: "string"\n",(Cell)ip); |
| 69 : |
anton
|
1.1
|
#else |
| 70 : |
|
|
# define NAME(string) |
| 71 : |
|
|
#endif |
| 72 : |
pazsan
|
1.2
|
|
| 73 : |
|
|
#define CF(const) (-const-2) |
| 74 : |
|
|
|
| 75 : |
|
|
#define CF_NIL -1 |
| 76 : |
pazsan
|
1.3
|
|
| 77 : |
anton
|
1.15
|
#ifndef FLUSH_ICACHE |
| 78 : |
anton
|
1.16
|
#warning flush-icache probably will not work (see manual) |
| 79 : |
anton
|
1.15
|
# define FLUSH_ICACHE(addr,size) 0 |
| 80 : |
|
|
#endif |
| 81 : |
|
|
|
| 82 : |
|
|
#ifdef DIRECT_THREADED |
| 83 : |
|
|
#define CACHE_FLUSH(addr,size) FLUSH_ICACHE(addr,size) |
| 84 : |
|
|
#else |
| 85 : |
|
|
#define CACHE_FLUSH(addr,size) 0 |
| 86 : |
pazsan
|
1.3
|
#endif |