

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 TO CHANGE SNES EMULATORS 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.
