What Does Processor Emulation Mean?
Processor emulation is a virtualization process and technology that allows software that has been compiled for a specific processor or operating system (OS) to run on a different system that has a different processor and OS. This is done by dynamically translating the processor instructions and all associated operating system calls of a program into the instructions of the processor and OS where it is running.
Techopedia Explains Processor Emulation
Processor emulation allows the execution of programs written for one processor to execute on a different processor with a different architecture and instruction set. A good basic example is a game console emulator, which allows users to play console games such as Nintendo Entertainment System and PlayStation games on their PC. The processor used by a game console is very different from that of a PC, so to be able to play console games on a PC, the processor of the game console must be emulated.
The basic idea is that every individual action and behavior of the program that needs to run must be converted to the equivalent instruction set and/or operating system calls of the host system. The main goal is to execute code that modifies processor states and interacts with the hardware, and this must be done for each instruction of the running program.
Ways of handling processor emulation:
- Dynamic recompilation -- A list of operations is created by running the code, and when a branch instruction is reached, the list is compiled to the instruction code of the host platform. This is then cached for future use. Alternatively, each code could simply be compiled on the fly, but this approach is hard to optimize.
- Static recompilation -- This is also known as static binary translation where code is first converted into the code of the target machine or architecture without running the code, as is done in dynamic recompilation. Problems can arise, however, since not all of the target codes can be determined by the translator during compile time since some of them may only be found in indirect branches, which, in turn, may only be determined at run time.
- Interpretation -- Each code is read from memory using the instruction pointer and then is executed according to the CPU instruction set of the host computer. In other words, the instructions are translated one to one and then executed natively. The biggest drawback here is performance.