feat: add comma, fix allot, and support bare-metal custom memory

Co-authored-by: aider (openrouter/moonshotai/kimi-k2.6) <aider@aider.chat>
This commit is contained in:
2026-05-03 23:07:26 +03:00
parent 1c0c6daf4f
commit 19c8608c76
4 changed files with 38 additions and 3 deletions
+14 -2
View File
@@ -456,13 +456,25 @@ void do_here(Word* w) {
void do_allot(Word* w) {
(void)w;
int64_t n = data_pop();
if (here + n > user_mem + user_mem_size) {
forth_printf("User memory overflow\n");
int64_t idx = here - user_mem;
if (idx + n < 0 || idx + n > user_mem_size) {
forth_printf("User memory out of bounds\n");
return;
}
here += n;
}
void do_comma(Word* w) {
(void)w;
int64_t val = data_pop();
if (here + 1 > user_mem + user_mem_size) {
forth_printf("User memory overflow\n");
return;
}
here->num = val;
here++;
}
// Variable and constant
void do_variable(Word* w) {
(void)w;