Add DEBUG compile option
This commit is contained in:
parent
c4c1bd5fba
commit
92e7f2d95b
@ -5,5 +5,3 @@
|
||||
#define MAX_LABELS 256
|
||||
#define MAX_MODULES 256
|
||||
#define MAX_BF_LOOPS 256
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
|
@ -142,6 +142,10 @@ void execute(Stack *stack, Stack *originstack, char *modname)
|
||||
|
||||
for (; stack->program_counter < stack->program_size; stack->program_counter++)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Inst: %s, IP: %d, Stack top: %d, Module: %s\n", NAME, stack->program_counter,
|
||||
stack_peek(stack), modname);
|
||||
#endif
|
||||
prefix_operator(stack, NAME[0]);
|
||||
|
||||
if (NAME[0] == '#' || NAME[0] == '$')
|
||||
|
@ -44,10 +44,10 @@ uint16_t stack_peek(Stack *stack)
|
||||
|
||||
void kms(Stack *stack, const char *err)
|
||||
{
|
||||
if (DEBUG_MODE)
|
||||
for (int i = 0; i < stack->pointer; i++)
|
||||
printf("%d: %d\n", i, stack->memory[i]);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < stack->pointer; i++)
|
||||
printf("%d: %d\n", i, stack->memory[i]);
|
||||
#endif
|
||||
fprintf(stderr, "%s", err);
|
||||
free(stack);
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user