It is possible for the memory subsystem emulation to be reduced to
simply an array of elements each sized like an emulated word;
however, this model falls very quickly as soon as any location in
the computer's logical memory does not match physical memory.
This clearly is the case whenever the emulated hardware allows for
advanced memory management (in which case, the MMU logic can be
embedded in the memory emulator, made a module of its own, or
sometimes integrated into the CPU simulator).
Even if the emulated computer does not feature an MMU, though, there
are usually other factors that break the equivalence between logical
and physical memory: many (if not most) architecture offer
memory-mapped I/O; even those that do not almost invariably have a
block of logical memory mapped to ROM, which means that the
memory-array module must be discarded if the read-only nature of ROM
is to be emulated. Features such as bank switching or segmentation
may also complicate memory emulation. As a result, most emulators
implement at least two procedures for writing to and reading from
logical memory, and it is these procedures' duty to map every access
to the correct location of the correct object. |
|