C <del>924</del> <del>882</del> <del>622</del> <del>603</del> <del>587</del> 569 chars = With obvious newlines removed (retained for readability). #define A sbrk(8);signal(11,S); #define W(x)write(1,x,1); #define P (t>s?*--t:0) #define U *t++ #define B(x,y)else if(b==(w=w+1 x)){w=P;y;U=w;} *t,*s,w,a,c,d;char b;S(x){A} p(x){if(x<0){W("-")x=-x;}if(x>9)p(x/10);b=48+x%10;W(&b)} main(){t=s=A U=0; while(read(0,&b,1)){w=47;if(0); B(,w+=P*pow(10,w?ceil(log10(w)):1)) B(,++w) B(,--w) B(,w*=P) B(,w=P/w) B(,w+=P) B(,w=P-w) B(,w=pow(P,w)) B(,w=P%w) B(,*t=w;w=*s;memmove(s,s+1,t-s<<2)) B(+7,memmove(s+1,s,t++-s<<2);*s=w;w=P) B(,U=w) B(,a=P;U=a;U=w;U=a) B(,a=P;U=w;w=a) B(,a=P;c=P;d=P;U=a;U=w;U=c;w=d) B(,w=P)} for(W("[")t>s;)p(P),W(" ") W("]")} This implements the "underflow pushes zero" interpretation from Jan Dvorak's comment. Ungolfed: #include<math.h> #include<signal.h> void S(int x){signal(SIGSEGV,S);sbrk(8*8*8);} int*s,*t,*i,w,a,c,d; //stack top index working accumulator count data u(x){*t++=x;} //push() o(){return t>s?*--t:0;} //pop() p(x){ //print() if(x<0){ //negative? W(*"-") //output '-' x=-x; //negate } if(x>9) //more than one digit? p(x/10); //recurse after integer-divide b=48+x%10; //isolate and convert single digit to ascii W(b) //output ascii digit } main(){ char b[1]; signal(SIGSEGV,S); //auto-allocate memory for stack t=s=sbrk(8*8*8); //get start of memory and allocate while(read(0,b,1)){ write(1,b,1); //for debugging: echo the command being executed switch(*b){ case '0': w=o(); a=o(); for(c=ceil(log10(w));c>0;c--) a*=10; u(a+w); break; case '1': u(o()+1); break; case '2': u(o()-1); break; case '3': w=o(); u(o()*w); break; case '4': w=o(); u(o()/w); break; case '5': u(o()+o()); break; case '6': w=o(); u(o()-w); break; case '7': c=o();a=1; for(w=o();c>0;c--) a*=w; u(a); break; case '8': w=o(); u(o()%w); break; case '9': w=*s; memmove(s,s+1,4*(t-s-1)); t[-1]=w; break; case 'A': w=t[-1]; memmove(s+1,s,4*(t-s-1)); *s=w; break; case 'B': w=o(); u(w); u(w); break; case 'C': w=o(); a=o(); u(a); u(w); u(a); u(w); break; case 'D': w=o(); a=o(); u(w); u(a); break; case 'E': w=o(); a=o(); c=o(); d=o(); u(a); u(w); u(d); u(c); break; case 'F': o(); break; } } write(1,"\n[",2); //dump the stack i=t; do { p(*--i); } while(i>s && write(1,",",1)); write(1,"]\n",2); }