Make "dump" print numbers as ASCII characters if they are printable
This commit is contained in:
parent
3d12a78090
commit
5ac9f3e5da
@ -3,6 +3,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -619,7 +620,13 @@ void execute(Stack *stack, Stack *originstack, char *modname)
|
|||||||
if (!strcmp(NAME, "dump"))
|
if (!strcmp(NAME, "dump"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < stack->pointer; i++)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user