I’m reading http://0x10c.com/doc/dcpu-16.txt, The DCPU-16 Specification. A small computer for Notch’s next game. Notch is the guy who built Minecraft.
Instructions are simple 16 bits words with the following format (bits):
oooo is a 4 bits op code;
b’s are two 6 bits operand. The
instruction format is a little more complicated than that, but that’s roughly
To me this looks like a pretty good candidate for a perfect hash function like the ones created by Gperf. What kind of tree do we have?
The 4 bits values spawn 16 branches. 6 bits value spawn –according to my quick glance at the spec– 12 branches. That’s 16 * 12 * 12 = 2304. Quite a bit more than I expected. Gperf might not be such a good idea after all.