Simon Felix wrote:
> basically you have two choices:
>
> full emulation: you read a byte from (emulated) ram and
> interpret/execute it (use a huge switch-statement). then advance to the
> next byte and interpret/execute it, ...
Not if you want to finish the run in your lifetime... For a simple byte
code, like 8080, you use an array of pointers to functions, so you can
just branch without doing any compares. For a machine with prefix codes,
like x86, when you decode the prefix you add another level of
indirection, and jump through a pointer to array of pointer to function.
That pointer sort of converts the emulation to a state machine.
Note that if you just want to run the program and get the right results,
this is relatively simple, although you need emulated hardware to go
with the i/o instructions, or with more effort and per-byte flags memory
mapped i/o.
If you want to handle timing, cache, etc, it's a BIG project!
--
bill davidsen
SBC/Prodigy Yorktown Heights NY data center
http://newsgroups.news.prodigy.com