> The UNARY_NEGATIVE opcode pops value from the stack, negates it and pushes the result.<p>Why not have a top of stack register? Then all you need to put in your case statement (naively) is<p><pre><code> tos = -tos;
</code></pre>
thereby avoiding a pop and a push. In a virtual machine for a dynamically typed language such as Python, you'll need to handle different types, and for a statically typed language you'll need separate instructions for int and float, but in any case you avoid the pop and push. If the instruction takes more than one item from the stack, you at least have one fewer pop.<p>Incidentally, Burroughs mainframes were hardware stack machines and had two top of stack registers, A and B.