From 6fcac410e1bae5c9f8a9f4182633ff6361fca288 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Thu, 7 Jan 2021 09:13:21 -0800 Subject: [PATCH] Make arduino build. --- ueforth/Makefile | 2 +- ueforth/arduino/arduino.template.ino | 14 +++++++++++++- ueforth/common/opcodes.h | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ueforth/Makefile b/ueforth/Makefile index f3b9881..786a6c0 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -4,7 +4,7 @@ RES = $(OUT)/resources WEB = $(OUT)/web POSIX = $(OUT)/posix WINDOWS = $(OUT)/windows -ARDUINO = $(OUT)/arduino +ARDUINO = $(OUT)/arduino/ueforth CFLAGS = -Wall -Werror \ -O2 \ diff --git a/ueforth/arduino/arduino.template.ino b/ueforth/arduino/arduino.template.ino index 8b302db..adb6f58 100644 --- a/ueforth/arduino/arduino.template.ino +++ b/ueforth/arduino/arduino.template.ino @@ -1,5 +1,16 @@ {{opcodes}} +#if defined(ESP32) +# define HEAP_SIZE (100 * 1024) +# define STACK_SIZE 512 +#elif defined(ESP8266) +# define HEAP_SIZE (40 * 1024) +# define STACK_SIZE 512 +#else +# define HEAP_SIZE 2 * 1024 +# define STACK_SIZE 32 +#endif + #define PLATFORM_OPCODE_LIST \ X("GPIO", OP_GPIO, ) \ @@ -7,7 +18,8 @@ {{boot}} void setup() { - ueforth(boot, sizeof(boot)); + cell_t *heap = (cell_t *) malloc(HEAP_SIZE); + ueforth(0, 0, heap, boot, sizeof(boot)); } void loop() { diff --git a/ueforth/common/opcodes.h b/ueforth/common/opcodes.h index da15fe8..0ff4d2c 100644 --- a/ueforth/common/opcodes.h +++ b/ueforth/common/opcodes.h @@ -70,7 +70,7 @@ typedef uint64_t udcell_t; X("CREATE", OP_CREATE, DUP; DUP; tos = parse(32, (cell_t *) ((cell_t) sp | 0))|0; \ create((const char *) (*sp | 0), tos|0, 0, && OP_DOCREATE); \ COMMA(0); --sp; DROP) \ - X("DOES>", OP_DOES, DOES((cell_t *) ((cell_t) ip|0)); ip = (void *) (*rp | 0); --rp) \ + X("DOES>", OP_DOES, DOES((cell_t *) ((cell_t) ip|0)); ip = (cell_t *) (*rp | 0); --rp) \ X("IMMEDIATE", OP_IMMEDIATE, IMMEDIATE()) \ X("'SYS", OP_SYS, DUP; tos = (cell_t) &g_sys) \ X(":", OP_COLON, DUP; DUP; tos = parse(32, (cell_t *) ((cell_t) sp | 0))|0; \ @@ -80,6 +80,6 @@ typedef uint64_t udcell_t; DUP; sp = (cell_t *) ((cell_t) evaluate1((cell_t *) ((cell_t) sp | 0))|0); \ w = (*sp | 0); --sp; DROP; \ if (w) goto **(void **) w) \ - X("EXIT", OP_EXIT, ip = (void *) (*rp | 0); --rp) \ + X("EXIT", OP_EXIT, ip = (cell_t *) (*rp | 0); --rp) \ X(";", OP_SEMICOLON, COMMA(g_sys.DOEXIT_XT | 0); g_sys.state = 0) \