Well, I don’t know if it would make things faster, nor do I propose it as a final solution. I’m just discussing the different methods since I find it worth while. With the switch statement working through a lookup, I think it’s hard to find something that works faster.
I agree it’s not optimal to emulate close to the hardware in many cases. However in the particular case of part of the decode circuitry it appears to me it could be good. But I’m just imagining a particular type of decode circuitry. One that would look like an opcode search tree.
Using a search tree, one could be garanteed that it would find the code for an opcode within, say, 8 or so tree lookups max, for 8 bit opcodes. It also seems flexible enough to account for different bit sizes in opcodes naturally.
This tree wouldn’t have to exist as a complete tree either. It’s only the search that’s structured hierarchically, starting by verifying the most significant bits first, not necessarily one bit at a time.
Different points in this hierarchical decode I suggested one could implement either with switch statements or with jump tables. But, as you said, it can all be done with switch if being careful. You’re right, it’s not that hard to maintain that code, just gotta’ know how to get the compiler to compile right.
Seb