PlutoBoy icon indicating copy to clipboard operation
PlutoBoy copied to clipboard

CPU rewrite

Open RossMeikleham opened this issue 10 years ago • 0 comments

There are a number of optimisations that can be done to speed up emulation, however these require the CPU core to be pretty much completely rewritten. For these to be implemented the current CPU structure needs to be modified from a jump table of instructions to a switch statement.

Possible optimisations include:

  • Use gotos to shared code segments, many instructions share the same "ending", for example jumps. Place them after the switch block and perform a goto to them from the instructions. Although it's very easy to make the code for the CPU really messy using this method.
  • Profile emulation and find instructions with higher call rates and place these close together at the top of the switch statement. This hopefully will reduce cache misses.
  • Predetermine when the next interrupt will occur and run for that many cycles without constantly checking for interrupts and synchronisation with video/sound/button input. Certain instructions will cause an interrupt, so break from the execution loop and return the remaining number of cycles in that case.
  • Deferring status flag calculations, most times flag calculations are redundant so need a way to only perform them when we know the value will be needed for a conditional jump.

At this point I would like the emulator to run comfortably at full speed on the original raspberry pi, and still retain complete portability. An overall speedup of at least x2 would be nice.

RossMeikleham avatar Feb 08 '15 10:02 RossMeikleham