|
|
|
@ -538,18 +538,17 @@ static enum fh_error w_two_swap(struct fh_thread_s *fh, const struct fh_word_s * |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
|
enum fh_error rv; |
|
|
|
|
if (fh->data_stack_top < 4) { |
|
|
|
|
LOG("DS two-swap UNDERFLOW"); |
|
|
|
|
return FH_ERR_DS_UNDERFLOW; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t n = fh->data_stack_top - 4; |
|
|
|
|
uint32_t a = fh->data_stack[n]; |
|
|
|
|
uint32_t b = fh->data_stack[n + 1]; |
|
|
|
|
fh->data_stack[n] = fh->data_stack[n + 2]; |
|
|
|
|
fh->data_stack[n + 1] = fh->data_stack[n + 3]; |
|
|
|
|
fh->data_stack[n + 2] = a; |
|
|
|
|
fh->data_stack[n + 3] = b; |
|
|
|
|
uint32_t a, b, c, d; |
|
|
|
|
TRY(ds_pop(fh, &a)); |
|
|
|
|
TRY(ds_pop(fh, &b)); |
|
|
|
|
TRY(ds_pop(fh, &c)); |
|
|
|
|
TRY(ds_pop(fh, &d)); |
|
|
|
|
|
|
|
|
|
TRY(ds_push(fh, b)); |
|
|
|
|
TRY(ds_push(fh, a)); |
|
|
|
|
TRY(ds_push(fh, d)); |
|
|
|
|
TRY(ds_push(fh, c)); |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -719,14 +718,6 @@ static enum fh_error wp_putc(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_space(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
|
(void) fh; |
|
|
|
|
FHPRINT(" "); |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_debug_dump(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
@ -996,6 +987,20 @@ static enum fh_error w_see(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_pad(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
|
enum fh_error rv; |
|
|
|
|
uint32_t addr = fh->here + PAD_OFFSET; |
|
|
|
|
if (addr + 84 >= HEAP_SIZE) { |
|
|
|
|
LOGE("Heap overflow, PAD is too small!"); |
|
|
|
|
return FH_ERR_HEAP_FULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TRY(ds_push(fh, addr)); |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error wp_const(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
enum fh_error rv; |
|
|
|
@ -1177,6 +1182,7 @@ enum fh_error register_builtin_words(struct fh_thread_s *fh) |
|
|
|
|
{"hex", wp_setbase, 0, 16}, |
|
|
|
|
{"base", wp_const, 0, MAGICADDR_BASE}, |
|
|
|
|
{"here", wp_const, 0, MAGICADDR_HERE}, |
|
|
|
|
{"pad", w_pad, 0, 0}, |
|
|
|
|
{"false", wp_const, 0, 0}, |
|
|
|
|
{"true", wp_const, 0, 0xFFFFFFFF}, |
|
|
|
|
{"+", w_plus, 0, 0}, |
|
|
|
|