From 33364fddabb25b2e419a672b80ee1f2bf3e82f68 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 22 Oct 2023 19:28:45 +0100 Subject: Fix bug where accessing byte/hword registers > 8 wouldn't work This is because we were checking them as if they were word registers. --- src/runtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime.c b/src/runtime.c index 77ad109..67ea779 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -382,7 +382,7 @@ void vm_push_word_register(vm_t *vm, byte reg) data_t vm_mov_byte(vm_t *vm, byte reg) { - if (reg >= VM_REGISTERS) + if (reg >= (VM_REGISTERS * 8)) // TODO: Error (reg is not a valid byte register) return DBYTE(0); else if (vm->stack.ptr == 0) @@ -396,7 +396,7 @@ data_t vm_mov_byte(vm_t *vm, byte reg) data_t vm_mov_hword(vm_t *vm, byte reg) { - if (reg >= VM_REGISTERS) + if (reg >= (VM_REGISTERS * 2)) // TODO: Error (reg is not a valid hword register) return DHWORD(0); else if (vm->stack.ptr < sizeof(f64)) -- cgit v1.2.3-13-gbd6f