Annotation of hatari/src/cpu/fpp-unknown.h, revision 1.1.1.1

1.1       root        1:  /*
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   *
                      4:   * MC68881 emulation
                      5:   *
                      6:   * Conversion routines for hosts with unknown floating point format.
                      7:   *
                      8:   * Copyright 1996 Herman ten Brugge
                      9:   */
                     10: 
                     11: #ifndef HAVE_to_single
                     12: STATIC_INLINE double to_single (uae_u32 value)
                     13: {
                     14:     double frac;
                     15: 
                     16:     if ((value & 0x7fffffff) == 0)
                     17:        return (0.0);
                     18:     frac = (double) ((value & 0x7fffff) | 0x800000) / 8388608.0;
                     19:     if (value & 0x80000000)
                     20:        frac = -frac;
                     21:     return (ldexp (frac, ((value >> 23) & 0xff) - 127));
                     22: }
                     23: #endif
                     24: 
                     25: #ifndef HAVE_from_single
                     26: STATIC_INLINE uae_u32 from_single (double src)
                     27: {
                     28:     int expon;
                     29:     uae_u32 tmp;
                     30:     double frac;
                     31: 
                     32:     if (src == 0.0)
                     33:        return 0;
                     34:     if (src < 0) {
                     35:        tmp = 0x80000000;
                     36:        src = -src;
                     37:     } else {
                     38:        tmp = 0;
                     39:     }
                     40:     frac = frexp (src, &expon);
                     41:     frac += 0.5 / 16777216.0;
                     42:     if (frac >= 1.0) {
                     43:        frac /= 2.0;
                     44:        expon++;
                     45:     }
                     46:     return (tmp | (((expon + 127 - 1) & 0xff) << 23) |
                     47:            (((int) (frac * 16777216.0)) & 0x7fffff));
                     48: }
                     49: #endif
                     50: 
                     51: #ifndef HAVE_to_exten
                     52: STATIC_INLINE double to_exten(uae_u32 wrd1, uae_u32 wrd2, uae_u32 wrd3)
                     53: {
                     54:     double frac;
                     55: 
                     56:     if ((wrd1 & 0x7fff0000) == 0 && wrd2 == 0 && wrd3 == 0)
                     57:        return 0.0;
                     58:     frac = (double) wrd2 / 2147483648.0 +
                     59:        (double) wrd3 / 9223372036854775808.0;
                     60:     if (wrd1 & 0x80000000)
                     61:        frac = -frac;
                     62:     return ldexp (frac, ((wrd1 >> 16) & 0x7fff) - 16383);
                     63: }
                     64: #endif
                     65: 
                     66: #ifndef HAVE_from_exten
                     67: STATIC_INLINE void from_exten(double src, uae_u32 * wrd1, uae_u32 * wrd2, uae_u32 * wrd3)
                     68: {
                     69:     int expon;
                     70:     double frac;
                     71: 
                     72:     if (src == 0.0) {
                     73:        *wrd1 = 0;
                     74:        *wrd2 = 0;
                     75:        *wrd3 = 0;
                     76:        return;
                     77:     }
                     78:     if (src < 0) {
                     79:        *wrd1 = 0x80000000;
                     80:        src = -src;
                     81:     } else {
                     82:        *wrd1 = 0;
                     83:     }
                     84:     frac = frexp (src, &expon);
                     85:     frac += 0.5 / 18446744073709551616.0;
                     86:     if (frac >= 1.0) {
                     87:        frac /= 2.0;
                     88:        expon++;
                     89:     }
                     90:     *wrd1 |= (((expon + 16383 - 1) & 0x7fff) << 16);
                     91:     *wrd2 = (uae_u32) (frac * 4294967296.0);
                     92:     *wrd3 = (uae_u32) (frac * 18446744073709551616.0 - *wrd2 * 4294967296.0);
                     93: }
                     94: #endif
                     95: 
                     96: #ifndef HAVE_to_double
                     97: STATIC_INLINE double to_double(uae_u32 wrd1, uae_u32 wrd2)
                     98: {
                     99:     double frac;
                    100: 
                    101:     if ((wrd1 & 0x7fffffff) == 0 && wrd2 == 0)
                    102:        return 0.0;
                    103:     frac = (double) ((wrd1 & 0xfffff) | 0x100000) / 1048576.0 +
                    104:        (double) wrd2 / 4503599627370496.0;
                    105:     if (wrd1 & 0x80000000)
                    106:        frac = -frac;
                    107:     return ldexp (frac, ((wrd1 >> 20) & 0x7ff) - 1023);
                    108: }
                    109: #endif
                    110: 
                    111: #ifndef HAVE_from_double
                    112: STATIC_INLINE void from_double(double src, uae_u32 * wrd1, uae_u32 * wrd2)
                    113: {
                    114:     int expon;
                    115:     int tmp;
                    116:     double frac;
                    117: 
                    118:     if (src == 0.0) {
                    119:        *wrd1 = 0;
                    120:        *wrd2 = 0;
                    121:        return;
                    122:     }
                    123:     if (src < 0) {
                    124:        *wrd1 = 0x80000000;
                    125:        src = -src;
                    126:     } else {
                    127:        *wrd1 = 0;
                    128:     }
                    129:     frac = frexp (src, &expon);
                    130:     frac += 0.5 / 9007199254740992.0;
                    131:     if (frac >= 1.0) {
                    132:        frac /= 2.0;
                    133:        expon++;
                    134:     }
                    135:     tmp = (uae_u32) (frac * 2097152.0);
                    136:     *wrd1 |= (((expon + 1023 - 1) & 0x7ff) << 20) | (tmp & 0xfffff);
                    137:     *wrd2 = (uae_u32) (frac * 9007199254740992.0 - tmp * 4294967296.0);
                    138: }
                    139: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.