

With the NES, you have the PPU (pixel processing unit) which requires that the CPU put pixels into its memory at precise moments. This really has two sides:Ĭertain platforms - especially older consoles like the NES, SNES, etc - require your emulator to have strict timing to be completely compatible. The other side to processor emulation is the way in which you interact with hardware. For more information, Michael Steil has done some great research into static recompilation - the best I've seen. These combine to make static recompilation completely infeasible in 99% of cases.
#HOW DOES DOLPHIN EMULATOR WORK CODE#
It's been proven that finding all the code in a given binary is equivalent to the Halting problem.compressed, encrypted, generated/modified at runtime, etc) won't be recompiled, so it won't run Code that isn't in the program to begin with (e.g.This would be a great mechanism if it weren't for the following problems: You end up building a chunk of code that represents all of the code in the program, which can then be executed with no further interference. With static recompilation, you do the same as in dynamic recompilation, but you follow branches.

(BTW, most people don't actually make a list of instructions but compile them to machine code on the fly - this makes it more difficult to optimize, but that's out of the scope of this answer, unless enough people are interested) Then when you hit a given instruction group again, you only have to execute the code from the cache. Once you reach a branch instruction, you compile this list of operations to machine code for your host platform, then you cache this compiled code and execute it. With dynamic recompilation, you iterate over the code much like interpretation, but instead of just executing opcodes, you build up a list of operations. The core problem with interpretation is that it's very slow each time you handle a given instruction, you have to decode it and perform the requisite operation. Your code parses this instruction and uses this information to alter processor state as specified by your processor. With interpretation, you start at the IP (instruction pointer - also called PC, program counter) and read the instruction from memory.
#HOW DOES DOLPHIN EMULATOR WORK PC#
For the 6502, you'd have a number of 8-bit integers representing registers: A, X, Y, P, and S you'd also have a 16-bit PC register. Processor state is a conglomeration of the processor registers, interrupt handlers, etc for a given processor target.

With all of these paths, you have the same overall goal: execute a piece of code to modify processor state and interact with 'hardware'. There are three ways of handling processor emulation: You build each individual piece of the system and then connect the pieces much like wires do in hardware. Basic idea:Įmulation works by handling the behavior of the processor and the individual components.

If I'm a bit too vague on certain things, please ask questions so I can continue to improve this answer. Many of the things I'm going to describe will require knowledge of the inner workings of processors - assembly knowledge is necessary. I'm going to break it into pieces and then fill in the details via edits. Here are the basic ideas and functional components.
