aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 19:28:45 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 19:28:45 +0100
commit33364fddabb25b2e419a672b80ee1f2bf3e82f68 (patch)
tree83180e2fc2f39a1ce5240569256cf960f2cfc3d6
parented630259277deb8a17d993574cec93397183c26d (diff)
downloadovm-33364fddabb25b2e419a672b80ee1f2bf3e82f68.tar.gz
ovm-33364fddabb25b2e419a672b80ee1f2bf3e82f68.tar.bz2
ovm-33364fddabb25b2e419a672b80ee1f2bf3e82f68.zip
Fix bug where accessing byte/hword registers > 8 wouldn't work
This is because we were checking them as if they were word registers.
-rw-r--r--src/runtime.c4
1 files 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))