Added DUB

This commit is contained in:
Nils Polek 2023-12-10 00:24:17 +01:00
parent bdb0ce63b8
commit 60bdfd7843

6
njvm.c
View File

@ -189,6 +189,12 @@ void execute(struct program program) {
case DROP: case DROP:
*stack.current = *stack.current - SIGN_EXTEND(IMMEDIATE(program.program[i])); *stack.current = *stack.current - SIGN_EXTEND(IMMEDIATE(program.program[i]));
break; break;
case DUP:
temp = pop(stack);
push(stack, temp);
push(stack, temp);
break;
} }
if (debug == 1) printf("=== DEBUG: Stack after instruction %i ===\n", i); if (debug == 1) printf("=== DEBUG: Stack after instruction %i ===\n", i);
if (debug == 1) printStack(stack, fp); if (debug == 1) printStack(stack, fp);