diff --git a/ueforth/common/core.h b/ueforth/common/core.h index ad24705..bfe0c4d 100644 --- a/ueforth/common/core.h +++ b/ueforth/common/core.h @@ -190,11 +190,11 @@ static cell_t *evaluate1(cell_t *sp, float **fp) { static cell_t *forth_run(cell_t *initrp); static void forth_init(int argc, char *argv[], void *heap, - const char *src, cell_t src_len) { + const char *src, cell_t src_len) { g_sys.heap = ((cell_t *) heap) + 4; // Leave a little room. - cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_SIZE; - cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_SIZE; float *fp = (float *) (g_sys.heap + 1); g_sys.heap += STACK_SIZE; + cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_SIZE; + cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_SIZE; // FORTH vocabulary *g_sys.heap++ = 0; cell_t *forth = g_sys.heap; @@ -221,8 +221,8 @@ static void forth_init(int argc, char *argv[], void *heap, g_sys.base = 10; g_sys.tib = src; g_sys.ntib = src_len; - *++rp = (cell_t) sp; *++rp = (cell_t) fp; + *++rp = (cell_t) sp; *++rp = (cell_t) start; g_sys.rp = rp; g_sys.runner = forth_run; diff --git a/ueforth/common/interp.h b/ueforth/common/interp.h index bb07d48..09c2131 100644 --- a/ueforth/common/interp.h +++ b/ueforth/common/interp.h @@ -28,9 +28,7 @@ static cell_t *forth_run(cell_t *init_rp) { } register cell_t *ip, *rp, *sp, tos, w; register float *fp; - rp = init_rp; ip = (cell_t *) *rp--; sp = (cell_t *) *rp--; - fp = (float *) *rp--; - DROP; NEXT; + rp = init_rp; UNPARK; NEXT; #define X(name, op, code) OP_ ## op: { code; } NEXT; PLATFORM_OPCODE_LIST OPCODE_LIST diff --git a/ueforth/common/opcodes.h b/ueforth/common/opcodes.h index 2bf8693..bf215d7 100644 --- a/ueforth/common/opcodes.h +++ b/ueforth/common/opcodes.h @@ -31,7 +31,9 @@ typedef uintptr_t ucell_t; #define DOIMMEDIATE() (*g_sys.current)[-1] |= IMMEDIATE #define UNSMUDGE() (*g_sys.current)[-1] &= ~SMUDGE #define DOES(ip) **g_sys.current = (cell_t) ADDR_DODOES; (*g_sys.current)[1] = (cell_t) ip -#define PARK DUP; *++rp = (cell_t) fp; *++rp = (cell_t) sp; *++rp = (cell_t) ip + +#define PARK DUP; *++rp = (cell_t) fp; *++rp = (cell_t) sp; *++rp = (cell_t) ip +#define UNPARK ip = (cell_t *) *rp--; sp = (cell_t *) *rp--; fp = (float *) *rp--; DROP #ifndef SSMOD_FUNC # if __SIZEOF_POINTER__ == 8 diff --git a/ueforth/esp32/template.ino b/ueforth/esp32/template.ino index 074444b..712a7d6 100644 --- a/ueforth/esp32/template.ino +++ b/ueforth/esp32/template.ino @@ -599,9 +599,11 @@ static void InvokeWebServerOn(WebServer *ws, const char *url, cell_t xt) { cell_t code[2]; code[0] = xt; code[1] = g_sys.YIELD_XT; - cell_t stack[INTERRUPT_STACK_CELLS]; + cell_t fstack[INTERRUPT_STACK_CELLS]; cell_t rstack[INTERRUPT_STACK_CELLS]; + cell_t stack[INTERRUPT_STACK_CELLS]; cell_t *rp = rstack; + *++rp = (cell_t) (fstack + 1); *++rp = (cell_t) (stack + 1); *++rp = (cell_t) code; forth_run(rp); @@ -620,10 +622,12 @@ static void IRAM_ATTR HandleInterrupt(void *arg) { cell_t code[2]; code[0] = args->xt; code[1] = g_sys.YIELD_XT; - cell_t stack[INTERRUPT_STACK_CELLS]; + cell_t fstack[INTERRUPT_STACK_CELLS]; cell_t rstack[INTERRUPT_STACK_CELLS]; + cell_t stack[INTERRUPT_STACK_CELLS]; stack[0] = args->arg; cell_t *rp = rstack; + *++rp = (cell_t) (fstack + 1); *++rp = (cell_t) (stack + 1); *++rp = (cell_t) code; forth_run(rp); diff --git a/ueforth/windows/windows_interp.h b/ueforth/windows/windows_interp.h index 0a7d84b..08b61a7 100644 --- a/ueforth/windows/windows_interp.h +++ b/ueforth/windows/windows_interp.h @@ -39,9 +39,7 @@ static cell_t *forth_run(cell_t *init_rp) { } register cell_t *ip, *rp, *sp, tos, w; register float *fp; - rp = init_rp; ip = (cell_t *) *rp--; sp = (cell_t *) *rp--; - fp = (float *) *rp--; - DROP; + rp = init_rp; UNPARK; for (;;) { next: w = *ip++;