diff --git a/njvm.c b/njvm.c index 2835de1..b2bd442 100644 --- a/njvm.c +++ b/njvm.c @@ -189,6 +189,12 @@ void execute(struct program program) { case DROP: *stack.current = *stack.current - SIGN_EXTEND(IMMEDIATE(program.program[i])); 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) printStack(stack, fp);