On 01-Nov-04 Richard Kettlewell wrote:
(Ted Harding) Ted.Harding@nessie.mcc.ac.uk writes:
But I'd first learned the chip on the Sinclair ZX-81, actually disassembling the ROM by hand with pencil and paper (and the Z80 ref manual to hand). Incidentally, the ZX-81 stored numbers, and did arithmetic on them, in a very strange format. Not BCD at all, and not straight binary floats either, but binary floats with weird extras. I never worked out why they did it that way.
I believe it used the same mechanism as the Spectrum, which used binary floating point with a one byte exponent and a 4 byte mantissa, but could also represent integers in [-65535,65535] as straight integers for faster calculation (and got the conversion wrong at one of the edge cases).
Yes, you're right! The exponent is 1 byte, and its value is 0x80 + the true binary exponent relative to binary 0.1... (so 1/8 has exponent 0x80 + (-2) = 0x7E, 1 has exponent 0x81). Hence the exponent can range from -127 to +127 (a zero value in this byte is reserved for an exact zero, represented as 00 00 00 00 00). The mantissa is 4 bytes, with the highest-order bit equal to 1 -- except that it is also used as a "sign" flag for the number, being 1 only for *negative* numbers and being set to 0 for *positive*.
I've verified this by digging another book out of the "CP/M" box, and now I recall why I remember this as "weird extras" -- the explanation in this book was a spelt-out pencil-and-paper algorithm for working out what the binary representation should be, which managed to avoid describing the basic structure of the representation, and therefore managed to confuse me at the time!
Cheers, Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 01-Nov-04 Time: 14:38:07 ------------------------------ XFMail ------------------------------