diff --git a/forth.h b/forth.h index 608cbbc..dd781a0 100644 --- a/forth.h +++ b/forth.h @@ -11,6 +11,43 @@ // Configuration (all hard limits removed) #define MAX_NAME_LEN 31 +/* Portable panic hook. Override for bare-metal reset/handling. */ +#ifndef forth_panic +#define forth_panic() do { for (;;) ; } while (0) +#endif + +/* Portable I/O hooks. Define FORTH_CUSTOM_IO before including this header + * to provide bare-metal UART (or other) implementations. */ +#ifndef FORTH_CUSTOM_IO +#define forth_putchar(c) putchar(c) +#define forth_getchar() getchar() +#define forth_printf(...) printf(__VA_ARGS__) +#define forth_fflush() fflush(stdout) +#endif + +/* Static memory sizes (override before including forth.h) */ +#ifndef FORTH_DATA_STACK_SIZE +#define FORTH_DATA_STACK_SIZE 128 +#endif +#ifndef FORTH_RET_STACK_SIZE +#define FORTH_RET_STACK_SIZE 128 +#endif +#ifndef FORTH_COMPILE_STACK_SIZE +#define FORTH_COMPILE_STACK_SIZE 64 +#endif +#ifndef FORTH_COMPILE_BUF_SIZE +#define FORTH_COMPILE_BUF_SIZE 256 +#endif +#ifndef FORTH_USER_MEM_CELLS +#define FORTH_USER_MEM_CELLS (1024 * 1024) +#endif +#ifndef FORTH_MAX_WORDS +#define FORTH_MAX_WORDS 256 +#endif +#ifndef FORTH_MAX_WORD_BODY_CELLS +#define FORTH_MAX_WORD_BODY_CELLS 4096 +#endif + #define F_IMMEDIATE (1 << 7) #define F_HIDDEN (1 << 6)