Aaron Kaluszka 14 Dec 2001 How to Design a Computer Emulator The most basic type of software emulator is known as an interpreter. To emulate a microprocessor using this method, each operational code (op code) must be interpreted and an action must take place that is equivalent to what the real chip's action would be. In the most basic sense, a CPU emulator would consist of infinite loop with a case by case analysis of each op code and a way to break out of the loop when an interrupt is called. The action taken during the execution of an op code could include modifying registers, memory, and I/O. This type of emulator is the easiest to write and debug, but because of its interpretive nature, a large number of commands on the host machine are required to emulate a single op code of the emulated microprocessor. This means that the emulated device can be hundreds of times slower than the real machine. While this may be acceptable for running novelty devices, it is not when it comes to commercial applications.
More advanced software emulators include static and dynamic recompilers. These types of emulators tend to run much faster than interpreters. In static recompilation, each op code of the emulated microprocessor is directly translated into an equivalent op code on the host machine. This generates a new program which can be executed directly on the host machine. Unfortunately, pure static recompilation is usually not possible. This technique can be integrated into other forms of emulation, such as dynamic recompilation. Dynamic recompilation is the same as static recompilation except that translation of op codes is done at run time. It can translate sections of code while executing others leading to faster execution. Dynamic recompilation techniques are used in most modern emulators. Source:
© 2001, Aaron Kaluszka. All Rights Reserved.
|