From 21994864559386f1d11c001d6d27714cbf624a15 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 21 Jun 2024 12:56:30 +0100 Subject: add tests, and make dumping disasm optional --- vm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 1dc40e0..667ceed 100644 --- a/vm.c +++ b/vm.c @@ -57,7 +57,10 @@ int runvm(State *S) { int status = 1; - disasm_chunk(ch); + if (S->do_disasm) { + disasm_chunk(ch); + puts("---"); + } #define RBYTE() (ch->bc.d[th->ip++]) #define RSHORT() (th->ip += 2, (uint16_t)( ch->bc.d[th->ip-2] | ch->bc.d[th->ip-1] << 8 )) @@ -66,13 +69,11 @@ int runvm(State *S) { #define POP() (th->stack[--th->sp]) #define PEEK() (th->stack[th->sp-1]) - puts("---"); while (1) { uint8_t instr = RBYTE(); switch (instr) { case OP_RET: status = 0; - printf("done!\n"); goto done; break; case OP_LOADK: { -- cgit v1.2.3