diff --git a/mac.c b/mac.c index e07ff4d..1bd04be 100644 --- a/mac.c +++ b/mac.c @@ -49,22 +49,22 @@ void eval(int instr) { int val_popped = stack[sp--]; printf("popped %d\n", val_popped); break; - } - case ADD: { - // first we pop the stack and store it as a - int a = stack[sp--]; - - // then we pop the top of the stack and store it as b - int b = stack[sp--]; + } + case ADD: { + // first we pop the stack and store it as a + int a = stack[sp--]; - // we then add the result and push it to the stack - int result = b + a; - sp++; // increment stack pointer **before** - stack[sp] = result; // set the value to the top of the stack + // then we pop the top of the stack and store it as b + int b = stack[sp--]; - // all done! - break; - } + // we then add the result and push it to the stack + int result = b + a; + sp++; // increment stack pointer **before** + stack[sp] = result; // set the value to the top of the stack + + // all done! + break; + } } } @@ -73,4 +73,4 @@ int main() { eval(fetch()); ip++; // increment the ip every iteration } -} \ No newline at end of file +}