From 5ac9f3e5da19c15f9c8777713e2e64325d2f81c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Thu, 20 Jun 2024 01:38:25 +0500 Subject: [PATCH] Make "dump" print numbers as ASCII characters if they are printable --- src/execute.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/execute.c b/src/execute.c index 6d526e8..2fad22d 100644 --- a/src/execute.c +++ b/src/execute.c @@ -3,6 +3,7 @@ #else #include #endif +#include #include #include #include @@ -619,7 +620,13 @@ void execute(Stack *stack, Stack *originstack, char *modname) if (!strcmp(NAME, "dump")) { for (int i = 0; i < stack->pointer; i++) - printf("%d: %d\n", i, stack->memory[i]); + { + // Almost all printable ASCII symbols are bigger than 32 and smaller than 126 + if (stack->memory[i] >= 32 && stack->memory[i] <= 126) + printf("%d: (%c) %d\n", i, stack->memory[i], stack->memory[i]); + else + printf("%d: %d\n", i, stack->memory[i]); + } continue; }