Mercurial > sos > sos
view src/operations.c @ 2:b6182f00de82
The work I have so far
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Tue, 01 Mar 2011 02:39:27 -0500 |
parents | |
children | 0aa0ad9e1cc3 |
line wrap: on
line source
//#include <operations.h> #include <std.h> #include <stack.h> void print(struct Stack *stack) { eltType val = pop(stack); char output[10]; itoa(val, output); sPrint(output); sPrint("\n"); } void add(struct Stack *stack) { eltType first = pop(stack); eltType sec = pop(stack); push(stack, sec + first); //yeah, this should be obvious } void sub(struct Stack *stack) { eltType first = pop(stack); eltType sec = pop(stack); push(stack, sec - first); } void mult(struct Stack *stack) { eltType first = pop(stack); eltType sec = pop(stack); push(stack, sec*first); } void div(struct Stack *stack) { eltType first = pop(stack); eltType sec = pop(stack); push(stack, sec/first); } void dup(struct Stack *stack) { eltType val = pop(stack); push(stack, val); push(stack, val); }