Roedy said:
On every instruction, you first of all have to decode the instruction.
That in itself could take a fair number Java statements. The fields
are variable and packed on odd boundaries. Have a look at the bit
packing for all the variants of the mov instruction. (This is not
exactly fresh, but I wrote an assembler for the 8086 and 8087). Then
you have to simulate the instruction itself. Some are easy like 16 bit
add. Then there is the effect on the condition code registers to
simulate. You have to be detect -ve and overflow. You would be doing
well to simulate with only 1000 machine instructions per original.
Does anyone have an estimate of how well hotspot does in lines of java
= machine instructions average or java byte codes = machine
instructions average?
Well, let's not forget that if we were to hypothetically target the
8086 and have it run on modern hardware that there isn't a 1:1 speed
relationship.
The 8086 itself couldn't decode and run an instruction in a single
clock cycle. Many of the instructions took 3 or more cycles to decode
and execute. There was only one pipeline, so you couldn't do parallel
decodes/operations like you can on modern processors.
I think that the issue of speed isn't going to be a stumbling block in
this hypothetical project -- instead, the biggest problem is going to be
/timing/. The original PC's clock ran at 1 431 818 Hz. That's one
cycle in just under 7*10e-7 seconds (or 7*10e-3 milliseconds). That's
going to be rather difficult to emulate under Java on a modern
multitasking OS -- my desktop OS of choice (OS/2), for example, has an
8ms granularity.
This can obviously be somewhat fudged, and for many application it
simply won't matter. For anything timing-dependant, however, it may be
an issue.
Memory allocation might also be an issue. Emulating the system RAM and
ROM might require a 1MB byte array. And the ROM itself might pose an
issue, as getting a ROM image for such a system might be tricky -- we'd
have to produce our own reverse-engineered version.
I'd be tempted to join such a project if it's initial goals were low --
to emulate an IBM PC with a monochrome graphics adapter. Such a
reference platform is very well documented, and makes for a realistic
first attempt. Everything could be expanded from there.
Brad BARCLAY