From b6e359f5ebf914ecbe2b4c68d7d800e32005a7cd Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 22:54:45 +0000 Subject: Fixed issue where sometimes vm_print_registers wouldn't work for bytes Happened because we weren't printing all relevant words due to naturally flooring the result of division. Here I ceil the division to ensure we get the maximal number of words necessary. --- vm/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm') diff --git a/vm/runtime.c b/vm/runtime.c index 421256a..1f5396a 100644 --- a/vm/runtime.c +++ b/vm/runtime.c @@ -371,7 +371,7 @@ void vm_print_registers(vm_t *vm, FILE *fp) vm->registers.available / HWORD_SIZE, vm->registers.available / WORD_SIZE); fprintf(fp, "Registers.reg = ["); - for (size_t i = 0; i < (reg.used / WORD_SIZE); ++i) + for (size_t i = 0; i < ceil((long double)reg.used / WORD_SIZE); ++i) { fprintf(fp, "{%lu:%lX}", i, VM_NTH_REGISTER(reg, i)); if (i != reg.used - 1) -- cgit v1.2.3-13-gbd6f