> On Jul 19, 2017, at 12:42 PM, Douglas Taylor <[email protected]> wrote:
>
> On 7/18/2017 11:38 AM, Paul Koning via cctalk wrote:
>>> On Jul 18, 2017, at 11:04 AM, Douglas Taylor via cctalk
>>> <[email protected]> wrote:
>>>
>>> How does SIMH perform floating point operations for the PDP-11 simulation?
>>>
>>> If I run a numerical computation on real PDP-11 hardware and also on Simh
>>> how do you talk about the comparison?
>> You can look for yourself: PDP11/pdp11_fp.c. The code clearly implements
>> the floating point operations the hard way: picking apart the pieces and
>> manipulating them as needed.
>>
>> For stuff like this, the devil is always in the details. Some floating
>> point implementations have odd corner cases that aren't necessarily well
>> documented, if at all. But it's clear the intent is that SIMH should
>> produce the same answers as a real PDP-11.
>>
>> An example of floating point emulation that would be wrong is to convert to
>> IEEE and operate on "double" values, then convert back. I've done that in
>> the past as a first stab, but you can't do that if you want the emulation to
>> be anywhere near accurate.
>>
>> paul
>>
>>
> Paul
>
> The pdp11_fp.c code is quite intricate. If simh was a simple simulation it
> would take the easy route and use the intel fp co-processor as you point out,
> but it doesn't. It actually 'emulates' what the pdp11 would do in hardware.
> Very interesting, that way you can get the exact same answers from the
> emulator that you would from the real hardware.
>
> It would not be an interesting comparison if the two got slightly different
> numerical answers.
For PDP11, it may well be that IEEE is not far off. For some other machines,
IEEE isn't even in the same ballpark.
Simulating a machine, to me (and a lot of other people) means that the
simulation produces the same answers as the real hardware. Among other things,
it means producing the same answers when running the entire suite of
diagnostics. (Occasionally there are exceptions: the CDC 6000 simulator
DtCyber can't pass the exchange jump diagnostic because that depends on the
relative timing of the exchange and divide operations.)
PDP11 float is always normalized. IEEE usually is but not always. IEEE has
NaN, PDP11 doesn't. The ranges are different. So even on the PDP11 you can't
use IEEE.
An example where you'd be way off is the CDC 6000 series, which has integer
mantissas and doesn't necessarily normalize the answers. So even apart from
the encoding conversion, the answer won't match. Or the Electrologica X8,
which has an exponent range substantially larger than IEEE, uses integer
mantissa, and has a normalization rule entirely different from IEEE.
So unless your machine is actually IEEE, bug for bug compatible with your host,
you really need to do things the hard way.
paul