Information Technology Reference
In-Depth Information
(but little or no guarantee is given to timing and accuracy of the execution of the
instructions).
Instruction emulation is achieved by mapping the operation codes (Op Codes),
which are the part of the instruction set that specifies the operation to be per-
formed, from the instruction set to a set of functions in software. Typically software
instruction emulators are written in C or C++ to maximise speed. For example, the
instruction for adding two 32 bit floating point numbers together on an Intel 32 bit
i386 CPU takes two 32 bit floating point numbers and returns another 32 bit floating
point number as the result; the addition is done in a very few machine cycles using
the built-in hardware on the chip . It is relatively easy to emulate this by writing a
software function in, say, the C language, that takes the two 32 bit floating point
numbers and adds them together; however running this simple function takes many
machine cycles.
The simplest form of an emulated CPU is a software program loop that reads the
instructions (Op Codes) from memory (also emulated) and matches it to the relevant
function that implements that Op Code.
Other peripheral hardware needs to be emulated too, this is done in a similar
way to the CPU, as each piece of hardware will have an “instruction set” where
the appropriate instructions from the software are passed to the hardware to be
“executed”. For example, graphics cards can perform a number of (usually math-
ematical/geometrical) operations on image data before it is displayed. Once the
emulation code has been written, then any compiler for the language that the emu-
lator is written in can be used to transform the emulation software code to the
instruction set of a new computer hardware system.
The performance of running software on an instruction emulator is in the order of
5-500 times slower than running it on the original hardware, depending on the tech-
niques used to write the emulator and the accuracy and timing required. Assuming
that computing performance continues to roughly double every 2 years then an
instruction emulator will run software at the speed it ran on the original hardware in
about 4-18 years.
Most instruction emulators are modular in nature, that is, they have separate soft-
ware code for each of the components of a computer system (CPU, Memory, BIOS
etc). This means that, for example, CPUs can be interchanged providing an emulator
that can run a variety of operating systems and software from built for many differ-
ent systems with different instruction sets. Typically in modern desktop systems it
is only the CPU instruction set that differs, most of the other hardware is similar
and can be interchanged between the different systems. The emulator called QEMU
[ 22 ] takes advantage of this and emulates a variety of different computer systems
such as SPARC, Intel x86 etc (QEMU will be discussed later).
Virtualisation is a form of emulation where all the hardware is emulated except
the CPU. This means a virtualiser can only run on systems with one specific type of
CPU. It means one can run a variety of different operating systems and software as
long as they are built for the CPU that the virtualiser runs on. Typical examples of
virtualiser software are VMware [ 87 ] and Xen [ 88 ].
Search WWH ::




Custom Search