Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a liitle formating is applied #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions mac.c
Expand Up @@ -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;
}
}
}

Expand All @@ -73,4 +73,4 @@ int main() {
eval(fetch());
ip++; // increment the ip every iteration
}
}
}