vm_execute_all: Print every cycle on VERBOSE >= 2, just print final state otherwise

Changed VERBOSE checks to ensure a degree of information.
This commit is contained in:
2023-10-31 20:59:31 +00:00
parent 4d8b855d87
commit 036d3dcfba

View File

@@ -231,15 +231,17 @@ err_t vm_execute_all(vm_t *vm)
{
struct Program *program = &vm->program;
err_t err = ERR_OK;
#if VERBOSE == 1
#if VERBOSE >= 1
size_t cycles = 0;
#endif
#if VERBOSE >= 2
struct Registers prev_registers = vm->registers;
size_t cycles = 0;
size_t prev_sptr = 0;
#endif
while (program->instructions[program->ptr].opcode != OP_HALT &&
program->ptr < program->max)
{
#if VERBOSE >= 1
#if VERBOSE >= 2
fprintf(stdout, "[vm_execute_all]: Trace(Cycle %lu)\n", cycles);
fputs(
"----------------------------------------------------------------------"
@@ -269,6 +271,8 @@ err_t vm_execute_all(vm_t *vm)
"----------\n",
stdout);
}
#endif
#if VERBOSE >= 1
++cycles;
#endif
err = vm_execute(vm);