2019-02-04 02:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-08-25 02:37:00 +00:00
|
|
|
#define MEM_SIZE 24576
|
2019-02-04 02:04:02 +00:00
|
|
|
#define STACK_SIZE 64
|
2019-05-09 00:37:40 +00:00
|
|
|
#define RSTACK_SIZE 64
|
2019-02-04 02:04:02 +00:00
|
|
|
|
2019-04-10 02:00:32 +00:00
|
|
|
void f_init(char *exe);
|
2019-02-04 02:04:02 +00:00
|
|
|
|
2019-02-10 02:52:12 +00:00
|
|
|
void f_cdef();
|
2019-02-04 02:04:02 +00:00
|
|
|
void f_immediate();
|
|
|
|
|
|
|
|
void f_loadfile(char *filename);
|
|
|
|
void f_runstring(char *s);
|
|
|
|
|
|
|
|
void f_quiet();
|
|
|
|
void f_loud();
|
|
|
|
void f_interpreter();
|
|
|
|
|
|
|
|
union cell_union;
|
|
|
|
typedef union cell_union cell;
|
|
|
|
|
|
|
|
union cell_union {
|
|
|
|
int i;
|
|
|
|
unsigned int u;
|
|
|
|
cell *p;
|
|
|
|
char *s;
|
|
|
|
void (*f)();
|
|
|
|
FILE *fp;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern char mem[MEM_SIZE];
|
|
|
|
extern cell *HERE;
|
|
|
|
extern cell *LATEST;
|
|
|
|
extern cell IP;
|
|
|
|
extern cell W;
|
|
|
|
extern cell *rstack;
|
|
|
|
extern cell *stack;
|
|
|
|
|
2019-09-29 03:19:02 +00:00
|
|
|
#define F_NAMELEN_MASK 0x7f
|
2019-02-04 02:04:02 +00:00
|
|
|
#define F_IMMEDIATE 0x80
|
|
|
|
|
|
|
|
#define CELL_OFFSET(cp, b) ((cell*)(((char *)(cp)) + b))
|
|
|
|
#define TOP() (*(stack - 1))
|
|
|
|
#define ST1() (*(stack - 2))
|
|
|
|
#define ST2() (*(stack - 3))
|
|
|
|
void DROP(int n);
|
|
|
|
void PUSHC(cell c);
|
|
|
|
void PUSHI(int i);
|
|
|
|
void PUSHU(unsigned int u);
|
|
|
|
void PUSHCP(cell *c);
|
|
|
|
#define PUSHP(p) PUSHCP((cell*)p)
|
|
|
|
void PUSHS(char *s);
|
|
|
|
void RPUSH(cell c);
|
|
|
|
#define RPOP() (--rstack)
|
|
|
|
#define RTOP() (*(rstack - 1))
|
|
|
|
|
|
|
|
void f_key();
|
|
|
|
void f_word();
|
|
|
|
void f_emit();
|
|
|
|
void f_puts();
|
|
|
|
void f_dot();
|
|
|
|
void f_cr();
|
|
|
|
void f_comma();
|
|
|
|
void f_bcomma();
|
|
|
|
void f_create(); // name --
|
|
|
|
void f_cdef(); // func name --
|
2019-02-26 03:19:08 +00:00
|
|
|
void f_doconst();
|
2019-02-04 02:04:02 +00:00
|
|
|
void f_compileword();
|
|
|
|
|
2019-03-31 23:29:16 +00:00
|
|
|
cell f_lookupcp(char *name);
|
|
|
|
void f_execcp(cell cp);
|
|
|
|
|
2019-02-26 03:19:08 +00:00
|
|
|
#define CDEF(name, def) PUSHP(def); PUSHS(name); f_cdef()
|
|
|
|
#define ICONST(name, v) CDEF(name, f_doconst); PUSHI(v); f_comma()
|
|
|
|
#define PCONST(name, p) CDEF(name, f_doconst); PUSHP(p); f_comma()
|