ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/fpp.cpp
(Generate patch)

Comparing BasiliskII/src/uae_cpu/fpp.cpp (file contents):
Revision 1.3 by cebix, 1999-10-27T17:50:08Z vs.
Revision 1.4 by cebix, 1999-10-28T09:31:41Z

# Line 79 | Line 79
79   // Only define if you have IEEE 64 bit doubles.
80   #define HAVE_IEEE_DOUBLE 1
81  
82 + #ifdef WORDS_BIGENDIAN
83 + #define FLO 1
84 + #define FHI 0
85 + #else
86 + #define FLO 0
87 + #define FHI 1
88 + #endif
89 +
90   // fpcr rounding modes
91   #define ROUND_TO_NEAREST                        0
92   #define ROUND_TO_ZERO                           0x10
# Line 173 | Line 181 | double_flags fl_dest, fl_source;
181  
182   static __inline__ uae_u32 IS_NAN(uae_u32 *p)
183   {
184 <        if( (p[1] & 0x7FF00000) == 0x7FF00000 ) {
184 >        if( (p[FHI] & 0x7FF00000) == 0x7FF00000 ) {
185                  // logical or is faster here.
186 <                if( (p[1] & 0x000FFFFF) || p[0] ) {
186 >                if( (p[FHI] & 0x000FFFFF) || p[FLO] ) {
187                          return(1);
188                  }
189          }
# Line 184 | Line 192 | static __inline__ uae_u32 IS_NAN(uae_u32
192  
193   static __inline__ uae_u32 IS_INFINITY(uae_u32 *p)
194   {
195 <        if( ((p[1] & 0x7FF00000) == 0x7FF00000) && p[0] == 0 ) {
195 >        if( ((p[FHI] & 0x7FF00000) == 0x7FF00000) && p[FLO] == 0 ) {
196                  return(1);
197          }
198          return(0);
# Line 192 | Line 200 | static __inline__ uae_u32 IS_INFINITY(ua
200  
201   static __inline__ uae_u32 IS_NEGATIVE(uae_u32 *p)
202   {
203 <        return( (p[1] & 0x80000000) != 0 );
203 >        return( (p[FHI] & 0x80000000) != 0 );
204   }
205  
206   static __inline__ uae_u32 IS_ZERO(uae_u32 *p)
207   {
208 <        return( ((p[1] & 0x7FF00000) == 0) && p[0] == 0 );
208 >        return( ((p[FHI] & 0x7FF00000) == 0) && p[FLO] == 0 );
209   }
210  
211   // This should not touch the quotient.
# Line 236 | Line 244 | static __inline__ void GET_SOURCE_FLAGS(
244  
245   static __inline__ void MAKE_NAN(uae_u32 *p)
246   {
247 <        p[0] = 0xFFFFFFFF;
248 <        p[1] = 0x7FFFFFFF;
247 >        p[FLO] = 0xFFFFFFFF;
248 >        p[FHI] = 0x7FFFFFFF;
249   }
250  
251   static __inline__ void MAKE_ZERO_POSITIVE(uae_u32 *p)
252   {
253 <        p[0] = p[1] = 0;
253 >        p[FLO] = p[FHI] = 0;
254   }
255  
256   static __inline__ void MAKE_ZERO_NEGATIVE(uae_u32 *p)
257   {
258 <        p[0] = 0;
259 <        p[1] = 0x80000000;
258 >        p[FLO] = 0;
259 >        p[FHI] = 0x80000000;
260   }
261  
262   static __inline__ void MAKE_INF_POSITIVE(uae_u32 *p)
263   {
264 <        p[0] = 0;
265 <        p[1] = 0x7FF00000;
264 >        p[FLO] = 0;
265 >        p[FHI] = 0x7FF00000;
266   }
267  
268   static __inline__ void MAKE_INF_NEGATIVE(uae_u32 *p)
269   {
270 <        p[0] = 0;
271 <        p[1] = 0xFFF00000;
270 >        p[FLO] = 0;
271 >        p[FHI] = 0xFFF00000;
272   }
273  
274   static __inline__ void FAST_SCALE(uae_u32 *p, int add)
275   {
276          int exp;
277  
278 <        exp = (p[1] & 0x7FF00000) >> 20;
278 >        exp = (p[FHI] & 0x7FF00000) >> 20;
279          // TODO: overflow flags
280          exp += add;
281          if(exp >= 2047) {
282                  MAKE_INF_POSITIVE(p);
283          } else if(exp < 0) {
284                  // keep sign (+/- 0)
285 <                p[1] &= 0x80000000;
285 >                p[FHI] &= 0x80000000;
286          } else {
287 <                p[1] = (p[1] & 0x800FFFFF) | ((uae_u32)exp << 20);
287 >                p[FHI] = (p[FHI] & 0x800FFFFF) | ((uae_u32)exp << 20);
288          }
289   }
290  
291   static __inline__ double FAST_FGETEXP(uae_u32 *p)
292   {
293 <        int exp = (p[1] & 0x7FF00000) >> 20;
293 >        int exp = (p[FHI] & 0x7FF00000) >> 20;
294          return( exp - 1023 );
295   }
296  
297   // Normalize to range 1..2
298   static __inline__ void FAST_REMOVE_EXPONENT(uae_u32 *p)
299   {
300 <        p[1] = (p[1] & 0x800FFFFF) | 0x3FF00000;
300 >        p[FHI] = (p[FHI] & 0x800FFFFF) | 0x3FF00000;
301   }
302  
303   // The sign of the quotient is the exclusive-OR of the sign bits
304   // of the source and destination operands.
305   static __inline__ uae_u32 GET_QUOTIENT_SIGN(uae_u32 *a, uae_u32 *b)
306   {
307 <        return( ((a[1] ^ b[1]) & 0x80000000) ? 0x800000 : 0);
307 >        return( ((a[FHI] ^ b[FHI]) & 0x80000000) ? 0x800000 : 0);
308   }
309  
310   // Quotient Byte is loaded with the sign and least significant
# Line 319 | Line 327 | static __inline__ double to_single (uae_
327          uae_u32 sign = (value & 0x80000000);
328          uae_u32 exp  = ((value & 0x7F800000) >> 23) + 1023 - 127;
329  
330 <        p[0] = value << 29;
331 <        p[1] = sign | (exp << 20) | ((value & 0x007FFFFF) >> 3);
330 >        p[FLO] = value << 29;
331 >        p[FHI] = sign | (exp << 20) | ((value & 0x007FFFFF) >> 3);
332  
333          D(bug("to_single (%X) = %.04f\r\n",value,(float)result));
334  
# Line 334 | Line 342 | static __inline__ uae_u32 from_single (d
342  
343    if (src == 0.0) return 0;
344  
345 <        uae_u32 sign = (p[1] & 0x80000000);
346 <        uae_u32 exp  = (p[1] & 0x7FF00000) >> 20;
345 >        uae_u32 sign = (p[FHI] & 0x80000000);
346 >        uae_u32 exp  = (p[FHI] & 0x7FF00000) >> 20;
347  
348          if(exp + 127 < 1023) {
349                  exp = 0;
# Line 345 | Line 353 | static __inline__ uae_u32 from_single (d
353                  exp = exp + 127 - 1023;
354          }
355  
356 <        result = sign | (exp << 23) | ((p[1] & 0x000FFFFF) << 3) | (p[0] >> 29);
356 >        result = sign | (exp << 23) | ((p[FHI] & 0x000FFFFF) << 3) | (p[FLO] >> 29);
357  
358          D(bug("from_single (%.04f) = %X\r\n",(float)src,result));
359  
# Line 395 | Line 403 | static __inline__ double to_exten(uae_u3
403          }
404  
405          // drop the explicit integer bit.
406 <        p[0] = (wrd2 << 21) | (wrd3 >> 11);
407 <        p[1] = sign | (exp << 20) | ((wrd2 & 0x7FFFFFFF) >> 11);
406 >        p[FLO] = (wrd2 << 21) | (wrd3 >> 11);
407 >        p[FHI] = sign | (exp << 20) | ((wrd2 & 0x7FFFFFFF) >> 11);
408  
409          D(bug("to_exten (%X,%X,%X) = %.04f\r\n",wrd1,wrd2,wrd3,(float)result));
410  
# Line 412 | Line 420 | static __inline__ void from_exten(double
420                  return;
421    }
422  
423 <        D(bug("from_exten (%X,%X)\r\n",p[0],p[1]));
423 >        D(bug("from_exten (%X,%X)\r\n",p[FLO],p[FHI]));
424  
425 <        uae_u32 sign =  p[1] & 0x80000000;
425 >        uae_u32 sign =  p[FHI] & 0x80000000;
426  
427 <        uae_u32 exp  = ((p[1] >> 20) & 0x7ff);
427 >        uae_u32 exp  = ((p[FHI] >> 20) & 0x7ff);
428          // Check for maximum
429          if(exp == 0x7FF) {
430                  exp = 0x7FFF;
# Line 426 | Line 434 | static __inline__ void from_exten(double
434  
435          *wrd1 = sign | (exp << 16);
436          // always set the explicit integer bit.
437 <        *wrd2 = 0x80000000 | ((p[1] & 0x000FFFFF) << 11) | ((p[0] & 0xFFE00000) >> 21);
438 <        *wrd3 = p[0] << 11;
437 >        *wrd2 = 0x80000000 | ((p[FHI] & 0x000FFFFF) << 11) | ((p[FLO] & 0xFFE00000) >> 21);
438 >        *wrd3 = p[FLO] << 11;
439  
440          D(bug("from_exten (%.04f) = %X,%X,%X\r\n",(float)src,*wrd1,*wrd2,*wrd3));
441   }
# Line 440 | Line 448 | static __inline__ double to_double(uae_u
448    if ((wrd1 & 0x7fffffff) == 0 && wrd2 == 0) return 0.0;
449  
450          p = (uae_u32 *)&result;
451 <        p[0] = wrd2;
452 <        p[1] = wrd1;
451 >        p[FLO] = wrd2;
452 >        p[FHI] = wrd1;
453  
454          D(bug("to_double (%X,%X) = %.04f\r\n",wrd1,wrd2,(float)result));
455  
# Line 455 | Line 463 | static __inline__ void from_double(doubl
463                  return;
464    }
465          uae_u32 *p = (uae_u32 *)&src;
466 <        *wrd2 = p[0];
467 <        *wrd1 = p[1];
466 >        *wrd2 = p[FLO];
467 >        *wrd1 = p[FHI];
468  
469          D(bug("from_double (%.04f) = %X,%X\r\n",(float)src,*wrd1,*wrd2));
470   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines