

That is why, so far, I have only done emulators or static recompilers for msp430, 6502, and thumb.less typing. However they can be done as a second set of computations like the res =. Also note that a jump instruction is just an add instruction with the program counter as one of its operands.įor CISC archs like Z80 (or the GB variant thereof) or x86, you're also going to have to deal with condition code flags. This code is of course over-simplified, but can be expanded to deal with memory operands, etc. If I were to do it today, I'd get rid of the whole "opcode switch/jumptable" idiom except for obscure/rare opcodes, and write common branchless code for all the normal arithmetic/logical ops using some small lookup tables based on the opcode number. I've done this kind of thing before and the way I did it was with macros, but doing it that way you end up with a whole lot of code duplication that overflows the cpu cache and makes things slow.
