I have rewritten HybriC compiler in pure C (so it would be possible to integrate parts of it into virtual machine itself, probably, since virtual machine is written in C).
Along with that I changed how it generates code (it was an obvious change). Now it creates a code tree (which is pretty much one of cases of general syntax tree), then optimizes it, and writes down.
This is a bit different to alternate approach – generate code first, then optimize known patterns. But I think I’ll add both ways later.
To illustrate, here’s how it would compile expression R0 = (1 - R1*R2) + (R0 - R0):

Some leaves would be cut off, and here’s roughly the code it should generate:
mov R3,R1;
mul R3,R2;
mov R4,1;
sub R4,R3;
mov R0,R4;
Nice, i see the logics :) How do you make a compiler? :P
Write its code in C. There’s code in SVN, right here: https://anonsvn:anonsvn@svn.wireos.com:81/svn/os/hcomp/