From af142e71ffa8e4c130cba150203f163739b3aee0 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 29 Nov 2023 23:10:32 +0000 Subject: Fixed issues with getting and setting words for heap pages Because I was using the hword macros instead of word macros, this causes truncation of bytes when I didn't want it. --- vm/runtime.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'vm/runtime.c') diff --git a/vm/runtime.c b/vm/runtime.c index 006ce6b..33ae383 100644 --- a/vm/runtime.c +++ b/vm/runtime.c @@ -842,7 +842,7 @@ err_t vm_mset_word(vm_t *vm, word nth) page_t *page = (page_t *)ptr.as_word; if (nth >= (page->available / WORD_SIZE)) return ERR_OUT_OF_BOUNDS; - ((word *)page->data)[nth] = byte.as_hword; + ((word *)page->data)[nth] = byte.as_word; return ERR_OK; } @@ -870,7 +870,7 @@ err_t vm_mget_hword(vm_t *vm, word n) page_t *page = (page_t *)ptr.as_word; if (n >= (page->available / HWORD_SIZE)) return ERR_OUT_OF_BOUNDS; - return vm_push_byte(vm, DHWORD(((hword *)page->data)[n])); + return vm_push_hword(vm, DHWORD(((hword *)page->data)[n])); } err_t vm_mget_word(vm_t *vm, word n) @@ -880,10 +880,11 @@ err_t vm_mget_word(vm_t *vm, word n) err_t err = vm_pop_word(vm, &ptr); if (err) return err; + printf("%lx\n", ptr.as_word); page_t *page = (page_t *)ptr.as_word; if (n >= (page->available / WORD_SIZE)) return ERR_OUT_OF_BOUNDS; - return vm_push_byte(vm, DHWORD(((word *)page->data)[n])); + return vm_push_word(vm, DWORD(((word *)page->data)[n])); } err_t vm_pop_byte(vm_t *vm, data_t *ret) -- cgit v1.2.3-13-gbd6f