[Coco] Convert floating point formats

Alex Evans varmfskii at gmail.com
Wed Aug 21 09:39:18 EDT 2019


Looks like multiple versions because that was typed looking directly
at my manual and I double checked that it said PDP-11 and not PDP-1.

On Tue, Aug 20, 2019 at 8:16 PM <wrcooke at wrcooke.net> wrote:
>
>    To the best of my knowledge there was no C compiler for a PDP-1,
>    especially in 1985ish.
>
>      On August 20, 2019 at 7:07 PM Walter Zambotti
>      <[1]zambotti at iinet.net.au> wrote:
>      I'm looking at the manual now. I definitely have read it correctly.
>      If you are also correct then we have a case of multiple manual
>      versions!
>      And if you look at the one on the CoCo archive
>      [2]http://www.colorcomputerarchive.com/coco/Documents/Manuals/Progra
>      mming/Microware%20C%20Compiler%20User's%20Guide%20(Microware).pdf
>      It agrees with with me!!!
>      However searching through the manual the term PDP-1 only appears
>      once and the term PDP-11 appears 13 times.
>      My guess is I have found a typo!!!
>      And I think you are right and It should be PDP-11. Which memorably
>      is the computer I was baptised into computing with!
>      Walter
>      -----Original Message-----
>      From: Coco [mailto:[3]coco-bounces at maltedmedia.com] On Behalf Of
>      Walter Zambotti
>      Sent: Wednesday, 21 August 2019 7:55 AM
>      To: 'CoCoList for Color Computer Enthusiasts'
>      <[4]coco at maltedmedia.com>
>      Subject: Re: [Coco] Convert floating point formats
>      My manual says:
>      This compiler follows the PDP-1 implementation and format in that
>      CHARs are converted to INTs by sign extension, "SHORT" or "SHORT
>      INT"
>      means INT, "LONG INT" means LONG, and "LONG FLOAT" means DOUBLE. The
>      format of DOUBLE values is as follows:
>      -----Original Message-----
>      From: Coco [mailto:[5]coco-bounces at maltedmedia.com] On Behalf Of
>      Alex Evans
>      Sent: Wednesday, 21 August 2019 6:22 AM
>      To: CoCoList for Color Computer Enthusiasts
>      <[6]coco at maltedmedia.com>
>      Subject: Re: [Coco] Convert floating point formats
>      The OS-9 C Compiler Manual page 1-5
>      This compiler follows the PDP-11 implementation and format in that
>      CHARs are converted to INTs by sign extension, "SHORT" or "SHORT
>      INT"
>      means INT, "LONG INT" means LONG, and "LONG FLOAT" means DOUBLE. The
>      format of DOUBLE values is as follows:
>      <figure removed>
>      The form of the mantissa is sign and magnitude with an implied "1"
>      bit at the sign bit position. The exponent is biased by 128. The
>      format of the FLOAT is identical, except that the mantissa is only
>      three bytes long. Conversion from DOUBLE to FLOAT is carried out by
>      truncating the least significant (right-most) four bytes of the
>      mantissa. The reverse conversion is done by padding the least
>      significant our mantissa bytes with zeros.
>      On Tue, Aug 20, 2019 at 6:25 AM Joel Rees <[7]joel.rees at gmail.com>
>      wrote:
>      >
>
>      2019年8月20日(火) 17:02 Walter Zambotti <[8]zambotti at iinet.net.au>:
>
>      Not sure why it is PDP1 but that is how it is documented in the C
>      manual!
>
>      Which C manual?
>
>      Walter
>      -----Original Message-----
>      From: Coco [mailto:[9]coco-bounces at maltedmedia.com] On Behalf Of
>      James
>      Jones
>      Sent: Tuesday, 20 August 2019 12:13 PM
>      To: CoCoList for Color Computer Enthusiasts
>      <[10]coco at maltedmedia.com>
>      Subject: Re: [Coco] Convert floating point formats
>      I'm a little confused by the name PDP1data; the PDP-1 had an 18-bit
>      word, did one's complement arithmetic, and the floating point
>      library referenced in
>      [11]https://web.archive.org/web/20110514105011/http://www.dbit.com/~
>      gree
>      ng3/pdp1/pdp1.html
>      used
>      two words for a value, with one word for mantissa (and presumably
>      sign
>      bit) and one for the exponent.
>      On Tue, Aug 13, 2019 at 11:12 PM Walter Zambotti
>      <[12]zambotti at iinet.net.au>
>      wrote:
>
>      Here is the PC side code that I ended up making to convert CoCo
>      OS9 C
>      PDP1 floating point numbers to modern PC IEEE754 floating point
>      and visa
>
>      versa.
>      >
>
>      union _Data
>      {
>      unsigned long long llval;
>      double dval;
>      unsigned int lval;
>      unsigned char bytes[8];
>      unsigned short words[4];
>      unsigned int dwords[2];
>      };
>      typedef union _Data PDP1data;
>      typedef union _Data IEEE754data;
>      double ConvertDBLPDP1toIEEE754(PDP1data PDP1data) {
>      IEEE754data iee754;
>      unsigned long long signbit, exp, mantissa;
>      if (PDP1data.llval == 0)
>      {
>      return 0.0;
>      }
>      signbit = PDP1data.llval & 0x8000000000000000;
>      exp = (PDP1data.llval & 0x00000000000000ff) + 0x37e;
>      mantissa = PDP1data.llval & 0x7fffffffffffff00;
>      iee754.llval = signbit | (exp<<52) | (mantissa>>11);
>      return iee754.dval;
>      }
>      PDP1data ConvertDblIEEE754toPDP1(double dvalue) {
>      PDP1data PDP1data;
>      IEEE754data IEEE754data;
>      unsigned long long signbit, exp, mantissa;
>      IEEE754data.dval = dvalue;
>      // IEEE floats can have a negative zero that PDP1 floats
>      cannot have
>      // if the value is zero then we make it a good zero
>      if (IEEE754data.dval == 0.0)
>      {
>      IEEE754data.llval = 0;
>      return IEEE754data;
>      }
>      signbit = IEEE754data.llval & 0x8000000000000000;
>      exp = ((IEEE754data.llval & 0x7ff0000000000000)>>52) - 0x37e;
>      mantissa = IEEE754data.llval & 0x000fffffffffffff;
>      PDP1data.llval = signbit | (exp) | (mantissa<<11);
>      return PDP1data;
>      }
>      -----Original Message-----
>      From: Coco [mailto:[13]coco-bounces at maltedmedia.com] On Behalf Of
>      James Jones
>      Sent: Thursday, 4 July 2019 7:38 PM
>      To: CoCoList for Color Computer Enthusiasts
>      <[14]coco at maltedmedia.com>
>      Subject: Re: [Coco] Convert floating point formats
>      On Fri, May 24, 2019 at 9:30 AM Alex Evans <[15]varmfskii at gmail.com>
>      wrote:
>
>      I don't have a line to a particular solution (though they should
>      be easy to implement), but do you mean IEEE double precision as
>      is used on current x86 CPUs, or are you saying that there was
>      some other floating point format used by x86 FPUs such as the
>      8087 sometime in the past that you are interested in converting
>      to/from. I also was under the impression that the Microware C
>      Compiler used IEEE floating point in which case no conversion
>      needs to be made, it is already in the right format.
>
>      The switch to IEEE 754 floating point came with OS-9/68000.
>      --
>      Coco mailing list
>      [16]Coco at maltedmedia.com
>      [17]https://pairlist5.pair.net/mailman/listinfo/coco
>      --
>      Coco mailing list
>      [18]Coco at maltedmedia.com
>      [19]https://pairlist5.pair.net/mailman/listinfo/coco
>
>      --
>      Coco mailing list
>      [20]Coco at maltedmedia.com
>      [21]https://pairlist5.pair.net/mailman/listinfo/coco
>      --
>      Coco mailing list
>      [22]Coco at maltedmedia.com
>      [23]https://pairlist5.pair.net/mailman/listinfo/coco
>
>      --
>      Coco mailing list
>      [24]Coco at maltedmedia.com
>      [25]https://pairlist5.pair.net/mailman/listinfo/coco
>
>      --
>      Coco mailing list
>      [26]Coco at maltedmedia.com
>      [27]https://pairlist5.pair.net/mailman/listinfo/coco
>      --
>      Coco mailing list
>      [28]Coco at maltedmedia.com
>      [29]https://pairlist5.pair.net/mailman/listinfo/coco
>      --
>      Coco mailing list
>      [30]Coco at maltedmedia.com
>      [31]https://pairlist5.pair.net/mailman/listinfo/coco
>
>    "A designer knows he has achieved perfection not when there is nothing
>    left to add, but when there is nothing left to take away." --  Antoine
>    de Saint-Exupery
>
>    "The names of global variables should start with    // "
>    -- https://isocpp.org
>
> References
>
>    1. mailto:zambotti at iinet.net.au
>    2. http://www.colorcomputerarchive.com/coco/Documents/Manuals/Programming/Microware C Compiler User's Guide (Microware).pdf
>    3. mailto:coco-bounces at maltedmedia.com
>    4. mailto:coco at maltedmedia.com
>    5. mailto:coco-bounces at maltedmedia.com
>    6. mailto:coco at maltedmedia.com
>    7. mailto:joel.rees at gmail.com
>    8. mailto:zambotti at iinet.net.au
>    9. mailto:coco-bounces at maltedmedia.com
>   10. mailto:coco at maltedmedia.com
>   11. https://web.archive.org/web/20110514105011/http://www.dbit.com/~gree
>   12. mailto:zambotti at iinet.net.au
>   13. mailto:coco-bounces at maltedmedia.com
>   14. mailto:coco at maltedmedia.com
>   15. mailto:varmfskii at gmail.com
>   16. mailto:Coco at maltedmedia.com
>   17. https://pairlist5.pair.net/mailman/listinfo/coco
>   18. mailto:Coco at maltedmedia.com
>   19. https://pairlist5.pair.net/mailman/listinfo/coco
>   20. mailto:Coco at maltedmedia.com
>   21. https://pairlist5.pair.net/mailman/listinfo/coco
>   22. mailto:Coco at maltedmedia.com
>   23. https://pairlist5.pair.net/mailman/listinfo/coco
>   24. mailto:Coco at maltedmedia.com
>   25. https://pairlist5.pair.net/mailman/listinfo/coco
>   26. mailto:Coco at maltedmedia.com
>   27. https://pairlist5.pair.net/mailman/listinfo/coco
>   28. mailto:Coco at maltedmedia.com
>   29. https://pairlist5.pair.net/mailman/listinfo/coco
>   30. mailto:Coco at maltedmedia.com
>   31. https://pairlist5.pair.net/mailman/listinfo/coco
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco


More information about the Coco mailing list