Hello again!
I am currently writing the opcode handling routine, and I fear the routine is going to blow up into a massive switch-case-web. So, in the light of optimizing, is it worth rewriting the part that I have (approximately 40 opcodes) into a different format?
I am thinking of replacing the case-statements with a label prefix and executing a (computer science course teachers, please beware) goto at the beginning of the handling routine. I understand that this will introduce an additional jump-instruction at the start of each opcode, but it removes the need of comparing the fetched byte to each and every opcode. Additionally, this will make sure that the opcodes at the end of the list start almost as fast as those at the beginning. Ofcourse one could use a list of opcode stastistics (I swear I have seen one, I forgot where) to determine opcode placement in the switch-statement.
Can anybody shed some light on this issue? My arguments seem to favor the goto-approach, but I'd like to know if I'm forgetting something before making an important design decision like this one.
I am currently writing the opcode handling routine, and I fear the routine is going to blow up into a massive switch-case-web. So, in the light of optimizing, is it worth rewriting the part that I have (approximately 40 opcodes) into a different format?
I am thinking of replacing the case-statements with a label prefix and executing a (computer science course teachers, please beware) goto at the beginning of the handling routine. I understand that this will introduce an additional jump-instruction at the start of each opcode, but it removes the need of comparing the fetched byte to each and every opcode. Additionally, this will make sure that the opcodes at the end of the list start almost as fast as those at the beginning. Ofcourse one could use a list of opcode stastistics (I swear I have seen one, I forgot where) to determine opcode placement in the switch-statement.
Can anybody shed some light on this issue? My arguments seem to favor the goto-approach, but I'd like to know if I'm forgetting something before making an important design decision like this one.