// Simple program to see how JAVA virtual machine works WITH stacks.
#include <stdio.h>
#define MAX_SIZE 400
#define OPCODE_ADD +
//
int stackCount = 0;
int stackList[MAX_SIZE];
// OUR function declarations.
void pushToStack(int *);
int popStack();
// program MAIN body
int main(void) {
int value1 = 10;
int value2 = 11;
// Lets pop value1 to stack.
pushToStack(&value1);
pushToStack(&value2);
int PROCESSOR_RESULT = popStack() OPCODE_ADD popStack();
if(PROCESSOR_RESULT == 02)
printf("KERNEL ERROR LOLZ!!");
else
printf("Answer of big maths processor : %d",PROCESSOR_RESULT);
return 0; // We had no errors with program!
}
void pushToStack(int *value) {
if(stackCount > MAX_SIZE)
stackList[stackCount] = *value;
else
stackList[stackCount++] = *value;
}
int popStack() {
if(stackCount >= 0 && stackCount <= MAX_SIZE)
return stackList[--stackCount];
return 02;
}