Kautenja / RackNES

A Nintendo Entertainment System (NES) emulator module for VCV Rack.
Other
98 stars 3 forks source link

Opcode Lookup #43

Closed Kautenja closed 4 years ago

Kautenja commented 4 years ago

Currently, opcode lookup is accomplished through a series of functions where each function is responsible for a set of opcodes. Each function returns true if the opcode was decoded and executed, false otherwise. A single logical statement calls each of these functions in a short circuit series to stop when the first function that can decode the opcode is found. Typically, large switch operations like this are just handled by a single C++ switch statement that the compiler can hopefully optimize into a one-shot lookup table. Does moving towards this design improve the performance of opcode lookup? In theory, it seems like the answer is yes, but practically, is not known. Assuming performance is not hurt by the change to a switch statement, this design should be favored for reduced function call overhead and better readability.

Kautenja commented 4 years ago
Kautenja commented 4 years ago

Experiments in the opcodeLookup branch suggest that this method wont improve performance. Most of the short circuit functionality is based on a simplified mapping of the instruction set based on groups of instructions that is more streamlined than individually unwrapping each instruction.