From 936971c1a3abe4bd5f197bad65dc8330fb4a22dc Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 22 Oct 2023 18:04:00 +0100 Subject: Changed formats for vm_print_(stack|program) Easier to read now --- src/runtime.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/runtime.c b/src/runtime.c index 0a8a40a..77af177 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -156,15 +156,14 @@ void vm_print_stack(vm_t *vm, FILE *fp) fprintf(fp, "]\n"); return; } + printf("\n"); for (size_t i = stack.ptr; i > 0; --i) { byte b = stack.data[i - 1]; - fprintf(fp, "{%lu: %X}", stack.ptr - i, b); + fprintf(fp, "\t%lu: %X", stack.ptr - i, b); if (i != 1) fprintf(fp, ", "); - - if (((stack.ptr - i + 1) % 4) == 0) - fprintf(fp, "\n"); + fprintf(fp, "\n"); } fprintf(fp, "]\n"); } @@ -174,15 +173,8 @@ void vm_print_program(vm_t *vm, FILE *fp) struct Program program = vm->program; fprintf(fp, "Program.max = %lu\nProgram.ptr = " - "%lu\nProgram.instructions = [", + "%lu\nProgram.instructions = [\n", program.max, program.ptr); - if (program.ptr == 0) - { - fprintf(fp, "]\n"); - return; - } - - fprintf(fp, "\n"); size_t beg = 0; if (program.ptr >= VM_PRINT_PROGRAM_EXCERPT) { -- cgit v1.2.3-13-gbd6f