Previous 15994 Revisions Next

r14504 Saturday 18th February, 2012 at 03:49:35 UTC by R. Belmont
m68k: fix FSGLMUL/FSGLDIV plus some minor MMU improvements [Hans Ostermeyer]
[src/emu/cpu/m68000]m68kfpu.c m68kmmu.h

src/emu/cpu/m68000/m68kfpu.c
r14503r14504
55#define FPCC_I         0x02000000
66#define FPCC_NAN      0x01000000
77
8#define FPES_OE         0x00002000
9#define FPAE_IOP      0x00000080
10
811#define DOUBLE_INFINITY               U64(0x7ff0000000000000)
912#define DOUBLE_EXPONENT               U64(0x7ff0000000000000)
1013#define DOUBLE_MANTISSA               U64(0x000fffffffffffff)
r14503r14504
13901393      }
13911394      case 0x24:      // FSGLDIV
13921395      {
1393         REG_FP(m68k)[dst] = floatx80_div(REG_FP(m68k)[dst], source);
1396         float32 a = floatx80_to_float32( REG_FP(m68k)[dst] );
1397         float32 b = floatx80_to_float32( source );
1398         REG_FP(m68k)[dst] = float32_to_floatx80( float32_div(a, b) );
13941399         m68k->remaining_cycles -= 43; //  // ? (value is from FDIV)
13951400         break;
13961401      }
r14503r14504
14031408      }
14041409      case 0x27:      // FSGLMUL
14051410      {
1406         REG_FP(m68k)[dst] = floatx80_mul(REG_FP(m68k)[dst], source);
1411         float32 a = floatx80_to_float32( REG_FP(m68k)[dst] );
1412         float32 b = floatx80_to_float32( source );
1413         REG_FP(m68k)[dst] = float32_to_floatx80( float32_mul(a, b) );
14071414         SET_CONDITION_CODES(m68k, REG_FP(m68k)[dst]);
14081415         m68k->remaining_cycles -= 11; // ? (value is from FMUL)
14091416         break;
r14503r14504
14711478      }
14721479      case 4:      // Word Integer
14731480      {
1474         WRITE_EA_16(m68k, ea, (INT16)floatx80_to_int32(REG_FP(m68k)[src]));
1481         int32 value = floatx80_to_int32(REG_FP(m68k)[src]);
1482         if (value > 0x7fff || value < -0x8000 )
1483         {
1484            REG_FPSR(m68k) |= FPES_OE | FPAE_IOP;
1485         }
1486         WRITE_EA_16(m68k, ea, (INT16)value);
14751487         break;
14761488      }
14771489      case 5:      // Double-precision Real
r14503r14504
14851497      }
14861498      case 6:      // Byte Integer
14871499      {
1488         WRITE_EA_8(m68k, ea, (INT8)floatx80_to_int32(REG_FP(m68k)[src]));
1500         int32 value = floatx80_to_int32(REG_FP(m68k)[src]);
1501         if (value > 127 || value < -128)
1502         {
1503            REG_FPSR(m68k) |= FPES_OE | FPAE_IOP;
1504         }
1505         WRITE_EA_8(m68k, ea, (INT8) value);
14891506         break;
14901507      }
14911508      case 7:      // Packed-decimal Real with Dynamic K-factor
r14503r14504
15471564      }
15481565   }
15491566
1567#if 0
1568   // FIXME: (2011-12-18 ost)
1569   // rounding_mode and rounding_precision of softfloat.c should be set according to current fpcr
1570   // but:  with this code on Apollo the following programs in /systest/fptest will fail:
1571   // 1. Single Precision Whetstone will return wrong results never the less
1572   // 2. Vector Test will fault with 00040004: reference to illegal address
1573
1574   if ((regsel & 4) && dir == 0)
1575   {
1576      int rnd = (REG_FPCR(m68k) >> 4) & 3;
1577      int prec = (REG_FPCR(m68k) >> 6) & 3;
1578
1579      logerror("m68k_fpsp:fmove_fpcr fpcr=%04x prec=%d rnd=%d\n", REG_FPCR(m68k), prec, rnd);
1580
1581#ifdef FLOATX80
1582      switch (prec)
1583      {
1584      case 0: // Extend (X)
1585         floatx80_rounding_precision = 80;
1586         break;
1587      case 1: // Single (S)
1588         floatx80_rounding_precision = 32;
1589         break;
1590      case 2: // Double (D)
1591         floatx80_rounding_precision = 64;
1592         break;
1593      case 3: // Undefined
1594         floatx80_rounding_precision = 80;
1595         break;
1596      }
1597#endif
1598
1599      switch (rnd)
1600      {
1601      case 0: // To Nearest (RN)
1602         float_rounding_mode = float_round_nearest_even;
1603         break;
1604      case 1: // To Zero (RZ)
1605         float_rounding_mode = float_round_to_zero;
1606         break;
1607      case 2: // To Minus Infinitiy (RM)
1608         float_rounding_mode = float_round_down;
1609         break;
1610      case 3: // To Plus Infinitiy (RP)
1611         float_rounding_mode = float_round_up;
1612         break;
1613      }
1614   }
1615#endif
1616
15501617   m68k->remaining_cycles -= 10;
15511618}
15521619
src/emu/cpu/m68000/m68kmmu.h
r14503r14504
260260      }
261261   }
262262
263   if (m68k->mmu_tt1 & 0x8000)
264   {
265      // transparent translation register 1 enabled
266      UINT32 address_base = m68k->mmu_tt1 & 0xff000000;
267      UINT32 address_mask = ((m68k->mmu_tt1 << 8) & 0xff000000) ^ 0xff000000;
268      if ((addr_in & address_mask) == address_base)
269      {
270//          printf("PMMU: pc=%x TT1 fc=%x addr_in=%08x address_mask=%08x address_base=%08x\n", m68k->ppc, fc, addr_in, address_mask, address_base);
271         return addr_in;
272      }
273   }
274
263275//  if ((++pmmu_access_count % 10000000) == 0) {
264276//      printf("pmmu_translate_addr_with_fc: atc usage = %d%%\n", pmmu_atc_count*100/pmmu_access_count);
265277//      pmmu_atc_count = pmmu_access_count = 0;
r14503r14504
777789      printf("680x0: unhandled PBcc\n");
778790      return;
779791   }
792   else if ((m68k->ir & 0xffe0) == 0xf500)
793   {
794//      logerror("68040 pflush: pc=%08x ir=%04x opmode=%d register=%d\n", REG_PPC(m68k), m68k->ir, (m68k->ir >> 3) & 3, m68k->ir & 7);
795      pmmu_atc_flush(m68k);
796   }
780797   else   // the rest are 1111000xxxXXXXXX where xxx is the instruction family
781798   {
782799      switch ((m68k->ir>>9) & 0x7)
r14503r14504
972989                                    }
973990                                    break;
974991
992                                    case 7: // MC68851 Access Control Register
993                                       if (m68k->cpu_type == CPU_TYPE_020)
994                                       {
995                                          // DomainOS on Apollo DN3000 will only reset this to 0
996                                          UINT16 mmu_ac = READ_EA_16(m68k, ea);
997                                          if (mmu_ac != 0)
998                                          {
999                                             printf("680x0 PMMU: pc=%x PMOVE to mmu_ac=%08x\n",
1000                                                   m68k->ppc, mmu_ac);
1001                                          }
1002                                          break;
1003                                       }
1004                                       // fall through; unknown PMOVE mode unless MC68020 with MC68851
1005
9751006                                 default:
9761007                                    printf("680x0: PMOVE to unknown MMU register %x, PC %x\n", (modes>>10) & 7, m68k->pc);
9771008                                    break;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team