Previous 199869 Revisions Next

r36777 Sunday 29th March, 2015 at 17:20:52 UTC by Ryan Holtz
- mips3: Made fast RAM option common to both interpreter and DRC. [MooglyGuy]
[src/emu/cpu/mips]mips3.c mips3.h mips3drc.c
[src/mame/drivers]hng64.c kinst.c namcos23.c seattle.c vegas.c
[src/mame/machine]n64.c

trunk/src/emu/cpu/mips/mips3.c
r245288r245289
148148   , m_pfnmask(0)
149149   , m_tlbentries(0)
150150   , m_bigendian(endianness == ENDIANNESS_BIG)
151   , m_byte_xor(m_bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0))
152   , m_word_xor(m_bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0))
151153   , c_icache_size(0)
152154   , c_dcache_size(0)
153155   , m_vtlb(NULL)
156   , m_fastram_select(0)
154157   , m_debugger_temp(0)
155158   , m_cache(CACHE_SIZE + sizeof(internal_mips3_state))
156159   , m_drcuml(NULL)
r245288r245289
161164   , m_nocode(NULL)
162165   , m_out_of_cycles(NULL)
163166   , m_tlb_mismatch(NULL)
164   , m_fastram_select(0)
165167   , m_hotspot_select(0)
166168{
167169   memset(m_fpmode, 0, sizeof(m_fpmode));
r245288r245289
996998    TLB HANDLING
997999***************************************************************************/
9981000
999inline int mips3_device::RBYTE(offs_t address, UINT32 *result)
1001bool mips3_device::RBYTE(offs_t address, UINT32 *result)
10001002{
1001   UINT32 tlbval = m_tlb_table[address >> 12];
1003   const UINT32 tlbval = m_tlb_table[address >> 12];
10021004   if (tlbval & VTLB_READ_ALLOWED)
10031005   {
1004      *result = (*m_memory.read_byte)(*m_program, (tlbval & ~0xfff) | (address & 0xfff));
1006      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1007      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1008      {
1009         if (tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1010         {
1011            continue;
1012         }
1013         UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1014         *result = fastbase[tlbaddress ^ m_byte_xor];
1015         return true;
1016      }
1017      *result = (*m_memory.read_byte)(*m_program, tlbaddress);
10051018   }
10061019   else
10071020   {
r245288r245289
10141027         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
10151028      }
10161029      *result = 0;
1017      return 0;
1030      return false;
10181031   }
1019   return 1;
1032   return true;
10201033}
10211034
1022
1023inline int mips3_device::RHALF(offs_t address, UINT32 *result)
1035bool mips3_device::RHALF(offs_t address, UINT32 *result)
10241036{
1025   UINT32 tlbval = m_tlb_table[address >> 12];
1037   const UINT32 tlbval = m_tlb_table[address >> 12];
10261038   if (tlbval & VTLB_READ_ALLOWED)
10271039   {
1028      *result = (*m_memory.read_word)(*m_program, (tlbval & ~0xfff) | (address & 0xfff));
1040      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1041      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1042      {
1043         if (tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1044         {
1045            continue;
1046         }
1047         UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1048         *result = ((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1];
1049         return true;
1050      }
1051      *result = (*m_memory.read_word)(*m_program, tlbaddress);
10291052   }
10301053   else
10311054   {
r245288r245289
10381061         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
10391062      }
10401063      *result = 0;
1041      return 0;
1064      return false;
10421065   }
1043   return 1;
1066   return true;
10441067}
10451068
1046
1047inline int mips3_device::RWORD(offs_t address, UINT32 *result)
1069bool mips3_device::RWORD(offs_t address, UINT32 *result)
10481070{
1049   UINT32 tlbval = m_tlb_table[address >> 12];
1071   const UINT32 tlbval = m_tlb_table[address >> 12];
10501072   if (tlbval & VTLB_READ_ALLOWED)
10511073   {
1052      *result = (*m_memory.read_dword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff));
1074      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1075      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1076      {
1077         if (tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1078         {
1079            continue;
1080         }
1081         UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1082         *result = ((UINT32*)fastbase)[tlbaddress >> 2];
1083         return true;
1084      }
1085      *result = (*m_memory.read_dword)(*m_program, tlbaddress);
10531086   }
10541087   else
10551088   {
r245288r245289
10621095         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
10631096      }
10641097      *result = 0;
1065      return 0;
1098      return false;
10661099   }
1067   return 1;
1100   return true;
10681101}
10691102
1070
1071inline int mips3_device::RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask)
1103bool mips3_device::RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask)
10721104{
1073   UINT32 tlbval = m_tlb_table[address >> 12];
1105   const UINT32 tlbval = m_tlb_table[address >> 12];
10741106   if (tlbval & VTLB_READ_ALLOWED)
10751107   {
10761108      *result = (*m_memory.read_dword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask);
r245288r245289
10861118         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
10871119      }
10881120      *result = 0;
1089      return 0;
1121      return false;
10901122   }
1091   return 1;
1123   return true;
10921124}
10931125
1094
1095inline int mips3_device::RDOUBLE(offs_t address, UINT64 *result)
1126bool mips3_device::RDOUBLE(offs_t address, UINT64 *result)
10961127{
1097   UINT32 tlbval = m_tlb_table[address >> 12];
1128   const UINT32 tlbval = m_tlb_table[address >> 12];
10981129   if (tlbval & VTLB_READ_ALLOWED)
10991130   {
11001131      *result = (*m_memory.read_qword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff));
r245288r245289
11101141         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
11111142      }
11121143      *result = 0;
1113      return 0;
1144      return false;
11141145   }
1115   return 1;
1146   return true;
11161147}
11171148
1118
1119inline int mips3_device::RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask)
1149bool mips3_device::RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask)
11201150{
1121   UINT32 tlbval = m_tlb_table[address >> 12];
1151   const UINT32 tlbval = m_tlb_table[address >> 12];
11221152   if (tlbval & VTLB_READ_ALLOWED)
11231153   {
11241154      *result = (*m_memory.read_qword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), mem_mask);
r245288r245289
11341164         generate_tlb_exception(EXCEPTION_TLBLOAD_FILL, address);
11351165      }
11361166      *result = 0;
1137      return 0;
1167      return false;
11381168   }
1139   return 1;
1169   return true;
11401170}
11411171
1142
1143inline void mips3_device::WBYTE(offs_t address, UINT8 data)
1172void mips3_device::WBYTE(offs_t address, UINT8 data)
11441173{
1145   UINT32 tlbval = m_tlb_table[address >> 12];
1174   const UINT32 tlbval = m_tlb_table[address >> 12];
11461175   if (tlbval & VTLB_WRITE_ALLOWED)
11471176   {
1148      (*m_memory.write_byte)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data);
1177      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1178      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1179      {
1180         if (m_fastram[ramnum].readonly == TRUE || tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1181         {
1182            continue;
1183         }
1184         UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1185         fastbase[tlbaddress ^ m_byte_xor] = data;
1186         return;
1187      }
1188      (*m_memory.write_byte)(*m_program, tlbaddress, data);
11491189   }
11501190   else
11511191   {
r245288r245289
11641204   }
11651205}
11661206
1167
1168inline void mips3_device::WHALF(offs_t address, UINT16 data)
1207void mips3_device::WHALF(offs_t address, UINT16 data)
11691208{
1170   UINT32 tlbval = m_tlb_table[address >> 12];
1209   const UINT32 tlbval = m_tlb_table[address >> 12];
11711210   if (tlbval & VTLB_WRITE_ALLOWED)
11721211   {
1173      (*m_memory.write_word)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data);
1212      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1213      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1214      {
1215         if (m_fastram[ramnum].readonly == TRUE || tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1216         {
1217            continue;
1218         }
1219         void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1220         ((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1] = data;
1221         return;
1222      }
1223      (*m_memory.write_word)(*m_program, tlbaddress, data);
11741224   }
11751225   else
11761226   {
r245288r245289
11891239   }
11901240}
11911241
1192
1193inline void mips3_device::WWORD(offs_t address, UINT32 data)
1242void mips3_device::WWORD(offs_t address, UINT32 data)
11941243{
1195   UINT32 tlbval = m_tlb_table[address >> 12];
1244   const UINT32 tlbval = m_tlb_table[address >> 12];
11961245   if (tlbval & VTLB_WRITE_ALLOWED)
11971246   {
1198      (*m_memory.write_dword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data);
1247      const UINT32 tlbaddress = (tlbval & ~0xfff) | (address & 0xfff);
1248      for (int ramnum = 0; ramnum < m_fastram_select; ramnum++)
1249      {
1250         if (m_fastram[ramnum].readonly == TRUE || tlbaddress < m_fastram[ramnum].start || tlbaddress > m_fastram[ramnum].end)
1251         {
1252            continue;
1253         }
1254         void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
1255         ((UINT32*)fastbase)[tlbaddress >> 2] = data;
1256         return;
1257      }
1258      (*m_memory.write_dword)(*m_program, tlbaddress, data);
11991259   }
12001260   else
12011261   {
r245288r245289
12141274   }
12151275}
12161276
1217
1218inline void mips3_device::WWORD_MASKED(offs_t address, UINT32 data, UINT32 mem_mask)
1277void mips3_device::WWORD_MASKED(offs_t address, UINT32 data, UINT32 mem_mask)
12191278{
1220   UINT32 tlbval = m_tlb_table[address >> 12];
1279   const UINT32 tlbval = m_tlb_table[address >> 12];
12211280   if (tlbval & VTLB_WRITE_ALLOWED)
12221281   {
12231282      (*m_memory.write_dword_masked)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data, mem_mask);
r245288r245289
12391298   }
12401299}
12411300
1242
1243inline void mips3_device::WDOUBLE(offs_t address, UINT64 data)
1301void mips3_device::WDOUBLE(offs_t address, UINT64 data)
12441302{
1245   UINT32 tlbval = m_tlb_table[address >> 12];
1246   //printf("%08x: %08x\n", (UINT32)address, (UINT32)tlbval);
1303   const UINT32 tlbval = m_tlb_table[address >> 12];
12471304   if (tlbval & VTLB_WRITE_ALLOWED)
12481305   {
1249      (*m_memory.write_qword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data);
1306      (*m_memory.write_qword)(*m_program, (tlbval & ~0xfff) | (address & 0xfff), data);
12501307   }
12511308   else
12521309   {
r245288r245289
12651322   }
12661323}
12671324
1268
1269inline void mips3_device::WDOUBLE_MASKED(offs_t address, UINT64 data, UINT64 mem_mask)
1325void mips3_device::WDOUBLE_MASKED(offs_t address, UINT64 data, UINT64 mem_mask)
12701326{
1271   UINT32 tlbval = m_tlb_table[address >> 12];
1327   const UINT32 tlbval = m_tlb_table[address >> 12];
12721328   if (tlbval & VTLB_WRITE_ALLOWED)
12731329   {
12741330      (*m_memory.write_qword_masked)(*m_program, (tlbval & ~0xfff)  | (address & 0xfff), data, mem_mask);
r245288r245289
12961352    COP0 (SYSTEM) EXECUTION HANDLING
12971353***************************************************************************/
12981354
1299inline UINT64 mips3_device::get_cop0_reg(int idx)
1355UINT64 mips3_device::get_cop0_reg(int idx)
13001356{
13011357   if (idx == COP0_Count)
13021358   {
r245288r245289
13291385   return m_core->cpr[0][idx];
13301386}
13311387
1332inline void mips3_device::set_cop0_reg(int idx, UINT64 val)
1388void mips3_device::set_cop0_reg(int idx, UINT64 val)
13331389{
13341390   switch (idx)
13351391   {
r245288r245289
14061462   m_core->ccr[0][idx] = val;
14071463}
14081464
1409inline void mips3_device::handle_cop0(UINT32 op)
1465void mips3_device::handle_cop0(UINT32 op)
14101466{
14111467   if ((SR & SR_KSU_MASK) != SR_KSU_KERNEL && !(SR & SR_COP0))
14121468   {
r245288r245289
15411597   }
15421598}
15431599
1544inline void mips3_device::handle_cop1_fr0(UINT32 op)
1600void mips3_device::handle_cop1_fr0(UINT32 op)
15451601{
15461602   double dtemp;
15471603
r245288r245289
19001956}
19011957
19021958
1903inline void mips3_device::handle_cop1_fr1(UINT32 op)
1959void mips3_device::handle_cop1_fr1(UINT32 op)
19041960{
19051961   double dtemp;
19061962
r245288r245289
22642320    COP1X (FPU EXTRA) EXECUTION HANDLING
22652321***************************************************************************/
22662322
2267inline void mips3_device::handle_cop1x_fr0(UINT32 op)
2323void mips3_device::handle_cop1x_fr0(UINT32 op)
22682324{
22692325   UINT64 temp64;
22702326   UINT32 temp;
r245288r245289
23422398   }
23432399}
23442400
2345
2346inline void mips3_device::handle_cop1x_fr1(UINT32 op)
2401void mips3_device::handle_cop1x_fr1(UINT32 op)
23472402{
23482403   UINT64 temp64;
23492404   UINT32 temp;
r245288r245289
24472502   m_core->ccr[2][idx] = val;
24482503}
24492504
2450inline void mips3_device::handle_integer_divide_by_zero(UINT32 op)
2505void mips3_device::handle_cop2(UINT32 op)
24512506{
2452   HIVAL64 = (INT32)RSVAL32;
2453   if (m_flavor == MIPS3_TYPE_VR4300)
2454   {
2455      if (RSVAL32 >= 0)
2456      {
2457         LOVAL64 = (INT32)0x7fffffff;
2458      }
2459      else
2460      {
2461         LOVAL64 = (INT32)0x80000001;
2462      }
2463   }
2464   else
2465   {
2466      if (RSVAL32 >= 0)
2467      {
2468         LOVAL64 = -1;
2469      }
2470      else
2471      {
2472         LOVAL64 = 1;
2473      }
2474   }
2475}
2476
2477inline void mips3_device::handle_cop2(UINT32 op)
2478{
24792507   if (!(SR & SR_COP2))
24802508   {
24812509      m_badcop_value = 2;
r245288r245289
25262554    CORE EXECUTION LOOP
25272555***************************************************************************/
25282556
2557void mips3_device::handle_regimm(UINT32 op)
2558{
2559   switch (RTREG)
2560   {
2561      case 0x00:  /* BLTZ */      if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL);                         break;
2562      case 0x01:  /* BGEZ */      if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL);                        break;
2563      case 0x02:  /* BLTZL */     if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL); else m_core->pc += 4;        break;
2564      case 0x03:  /* BGEZL */     if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL); else m_core->pc += 4;   break;
2565      case 0x08:  /* TGEI */      if ((INT64)RSVAL64 >= SIMMVAL) generate_exception(EXCEPTION_TRAP, 1);   break;
2566      case 0x09:  /* TGEIU */     if (RSVAL64 >= UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2567      case 0x0a:  /* TLTI */      if ((INT64)RSVAL64 < SIMMVAL) generate_exception(EXCEPTION_TRAP, 1);    break;
2568      case 0x0b:  /* TLTIU */     if (RSVAL64 >= UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2569      case 0x0c:  /* TEQI */      if (RSVAL64 == UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2570      case 0x0e:  /* TNEI */      if (RSVAL64 != UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2571      case 0x10:  /* BLTZAL */    if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31);                     break;
2572      case 0x11:  /* BGEZAL */    if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31);                    break;
2573      case 0x12:  /* BLTZALL */   if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4; break;
2574      case 0x13:  /* BGEZALL */   if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4;    break;
2575      default:    /* ??? */       invalid_instruction(op);                                        break;
2576   }
2577}
2578
2579void mips3_device::handle_special(UINT32 op)
2580{
2581   switch (op & 63)
2582   {
2583      case 0x00:  /* SLL */       if (RDREG) RDVAL64 = (INT32)(RTVAL32 << SHIFT);                 break;
2584      case 0x01:  /* MOVF - R5000*/if (RDREG && GET_FCC((op >> 18) & 7) == ((op >> 16) & 1)) RDVAL64 = RSVAL64;   break;
2585      case 0x02:  /* SRL */       if (RDREG) RDVAL64 = (INT32)(RTVAL32 >> SHIFT);                 break;
2586      case 0x03:  /* SRA */       if (RDREG) RDVAL64 = (INT32)RTVAL32 >> SHIFT;                   break;
2587      case 0x04:  /* SLLV */      if (RDREG) RDVAL64 = (INT32)(RTVAL32 << (RSVAL32 & 31));        break;
2588      case 0x06:  /* SRLV */      if (RDREG) RDVAL64 = (INT32)(RTVAL32 >> (RSVAL32 & 31));        break;
2589      case 0x07:  /* SRAV */      if (RDREG) RDVAL64 = (INT32)RTVAL32 >> (RSVAL32 & 31);          break;
2590      case 0x08:  /* JR */        SETPC(RSVAL32);                                                 break;
2591      case 0x09:  /* JALR */      SETPCL(RSVAL32,RDREG);                                          break;
2592      case 0x0a:  /* MOVZ - R5000 */if (RTVAL64 == 0) { if (RDREG) RDVAL64 = RSVAL64; }           break;
2593      case 0x0b:  /* MOVN - R5000 */if (RTVAL64 != 0) { if (RDREG) RDVAL64 = RSVAL64; }           break;
2594      case 0x0c:  /* SYSCALL */   generate_exception(EXCEPTION_SYSCALL, 1);                       break;
2595      case 0x0d:  /* BREAK */     generate_exception(EXCEPTION_BREAK, 1);                         break;
2596      case 0x0f:  /* SYNC */      /* effective no-op */                                           break;
2597      case 0x10:  /* MFHI */      if (RDREG) RDVAL64 = HIVAL64;                                   break;
2598      case 0x11:  /* MTHI */      HIVAL64 = RSVAL64;                                              break;
2599      case 0x12:  /* MFLO */      if (RDREG) RDVAL64 = LOVAL64;                                   break;
2600      case 0x13:  /* MTLO */      LOVAL64 = RSVAL64;                                              break;
2601      case 0x14:  /* DSLLV */     if (RDREG) RDVAL64 = RTVAL64 << (RSVAL32 & 63);                 break;
2602      case 0x16:  /* DSRLV */     if (RDREG) RDVAL64 = RTVAL64 >> (RSVAL32 & 63);                 break;
2603      case 0x17:  /* DSRAV */     if (RDREG) RDVAL64 = (INT64)RTVAL64 >> (RSVAL32 & 63);          break;
2604      case 0x18:  /* MULT */
2605      {
2606         UINT64 temp64 = (INT64)(INT32)RSVAL32 * (INT64)(INT32)RTVAL32;
2607         LOVAL64 = (INT32)temp64;
2608         HIVAL64 = (INT32)(temp64 >> 32);
2609         m_core->icount -= 3;
2610         break;
2611      }
2612      case 0x19:  /* MULTU */
2613      {
2614         UINT64 temp64 = (UINT64)RSVAL32 * (UINT64)RTVAL32;
2615         LOVAL64 = (INT32)temp64;
2616         HIVAL64 = (INT32)(temp64 >> 32);
2617         m_core->icount -= 3;
2618         break;
2619      }
2620      case 0x1a:  /* DIV */
2621         if (RTVAL32)
2622         {
2623            LOVAL64 = (INT32)((INT32)RSVAL32 / (INT32)RTVAL32);
2624            HIVAL64 = (INT32)((INT32)RSVAL32 % (INT32)RTVAL32);
2625         }
2626         m_core->icount -= 35;
2627         break;
2628      case 0x1b:  /* DIVU */
2629         if (RTVAL32)
2630         {
2631            LOVAL64 = (INT32)(RSVAL32 / RTVAL32);
2632            HIVAL64 = (INT32)(RSVAL32 % RTVAL32);
2633         }
2634         m_core->icount -= 35;
2635         break;
2636      case 0x1c:  /* DMULT */
2637      {
2638         UINT64 temp64 = (INT64)RSVAL64 * (INT64)RTVAL64;
2639         LOVAL64 = temp64;
2640         HIVAL64 = (INT64)temp64 >> 63;
2641         m_core->icount -= 7;
2642         break;
2643      }
2644      case 0x1d:  /* DMULTU */
2645      {
2646         UINT64 temp64 = (UINT64)RSVAL64 * (UINT64)RTVAL64;
2647         LOVAL64 = temp64;
2648         HIVAL64 = 0;
2649         m_core->icount -= 7;
2650         break;
2651      }
2652      case 0x1e:  /* DDIV */
2653         if (RTVAL64)
2654         {
2655            LOVAL64 = (INT64)RSVAL64 / (INT64)RTVAL64;
2656            HIVAL64 = (INT64)RSVAL64 % (INT64)RTVAL64;
2657         }
2658         m_core->icount -= 67;
2659         break;
2660      case 0x1f:  /* DDIVU */
2661         if (RTVAL64)
2662         {
2663            LOVAL64 = RSVAL64 / RTVAL64;
2664            HIVAL64 = RSVAL64 % RTVAL64;
2665         }
2666         m_core->icount -= 67;
2667         break;
2668      case 0x20:  /* ADD */
2669         if (ENABLE_OVERFLOWS && RSVAL32 > ~RTVAL32) generate_exception(EXCEPTION_OVERFLOW, 1);
2670         else if (RDREG) RDVAL64 = (INT32)(RSVAL32 + RTVAL32);
2671         break;
2672      case 0x21:  /* ADDU */      if (RDREG) RDVAL64 = (INT32)(RSVAL32 + RTVAL32);                break;
2673      case 0x22:  /* SUB */
2674         if (ENABLE_OVERFLOWS && RSVAL32 < RTVAL32) generate_exception(EXCEPTION_OVERFLOW, 1);
2675         else if (RDREG) RDVAL64 = (INT32)(RSVAL32 - RTVAL32);
2676         break;
2677      case 0x23:  /* SUBU */      if (RDREG) RDVAL64 = (INT32)(RSVAL32 - RTVAL32);                break;
2678      case 0x24:  /* AND */       if (RDREG) RDVAL64 = RSVAL64 & RTVAL64;                         break;
2679      case 0x25:  /* OR */        if (RDREG) RDVAL64 = RSVAL64 | RTVAL64;                         break;
2680      case 0x26:  /* XOR */       if (RDREG) RDVAL64 = RSVAL64 ^ RTVAL64;                         break;
2681      case 0x27:  /* NOR */       if (RDREG) RDVAL64 = ~(RSVAL64 | RTVAL64);                      break;
2682      case 0x2a:  /* SLT */       if (RDREG) RDVAL64 = (INT64)RSVAL64 < (INT64)RTVAL64;           break;
2683      case 0x2b:  /* SLTU */      if (RDREG) RDVAL64 = (UINT64)RSVAL64 < (UINT64)RTVAL64;         break;
2684      case 0x2c:  /* DADD */
2685         if (ENABLE_OVERFLOWS && RSVAL64 > ~RTVAL64) generate_exception(EXCEPTION_OVERFLOW, 1);
2686         else if (RDREG) RDVAL64 = RSVAL64 + RTVAL64;
2687         break;
2688      case 0x2d:  /* DADDU */     if (RDREG) RDVAL64 = RSVAL64 + RTVAL64;                         break;
2689      case 0x2e:  /* DSUB */
2690         if (ENABLE_OVERFLOWS && RSVAL64 < RTVAL64) generate_exception(EXCEPTION_OVERFLOW, 1);
2691         else if (RDREG) RDVAL64 = RSVAL64 - RTVAL64;
2692         break;
2693      case 0x2f:  /* DSUBU */     if (RDREG) RDVAL64 = RSVAL64 - RTVAL64;                         break;
2694      case 0x30:  /* TGE */       if ((INT64)RSVAL64 >= (INT64)RTVAL64) generate_exception(EXCEPTION_TRAP, 1); break;
2695      case 0x31:  /* TGEU */      if (RSVAL64 >= RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2696      case 0x32:  /* TLT */       if ((INT64)RSVAL64 < (INT64)RTVAL64) generate_exception(EXCEPTION_TRAP, 1); break;
2697      case 0x33:  /* TLTU */      if (RSVAL64 < RTVAL64) generate_exception(EXCEPTION_TRAP, 1);   break;
2698      case 0x34:  /* TEQ */       if (RSVAL64 == RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2699      case 0x36:  /* TNE */       if (RSVAL64 != RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2700      case 0x38:  /* DSLL */      if (RDREG) RDVAL64 = RTVAL64 << SHIFT;                          break;
2701      case 0x3a:  /* DSRL */      if (RDREG) RDVAL64 = RTVAL64 >> SHIFT;                          break;
2702      case 0x3b:  /* DSRA */      if (RDREG) RDVAL64 = (INT64)RTVAL64 >> SHIFT;                   break;
2703      case 0x3c:  /* DSLL32 */    if (RDREG) RDVAL64 = RTVAL64 << (SHIFT + 32);                   break;
2704      case 0x3e:  /* DSRL32 */    if (RDREG) RDVAL64 = RTVAL64 >> (SHIFT + 32);                   break;
2705      case 0x3f:  /* DSRA32 */    if (RDREG) RDVAL64 = (INT64)RTVAL64 >> (SHIFT + 32);            break;
2706      default:    /* ??? */       invalid_instruction(op);                                        break;
2707   }
2708}
2709
25292710void mips3_device::execute_run()
25302711{
25312712   if (m_isdrc)
r245288r245289
26022783      switch (op >> 26)
26032784      {
26042785         case 0x00:  /* SPECIAL */
2605            switch (op & 63)
2606            {
2607               case 0x00:  /* SLL */       if (RDREG) RDVAL64 = (INT32)(RTVAL32 << SHIFT);                 break;
2608               case 0x01:  /* MOVF - R5000*/if (RDREG && GET_FCC((op >> 18) & 7) == ((op >> 16) & 1)) RDVAL64 = RSVAL64;   break;
2609               case 0x02:  /* SRL */       if (RDREG) RDVAL64 = (INT32)(RTVAL32 >> SHIFT);                 break;
2610               case 0x03:  /* SRA */       if (RDREG) RDVAL64 = (INT32)RTVAL32 >> SHIFT;                   break;
2611               case 0x04:  /* SLLV */      if (RDREG) RDVAL64 = (INT32)(RTVAL32 << (RSVAL32 & 31));        break;
2612               case 0x06:  /* SRLV */      if (RDREG) RDVAL64 = (INT32)(RTVAL32 >> (RSVAL32 & 31));        break;
2613               case 0x07:  /* SRAV */      if (RDREG) RDVAL64 = (INT32)RTVAL32 >> (RSVAL32 & 31);          break;
2614               case 0x08:  /* JR */        SETPC(RSVAL32);                                                 break;
2615               case 0x09:  /* JALR */      SETPCL(RSVAL32,RDREG);                                          break;
2616               case 0x0a:  /* MOVZ - R5000 */if (RTVAL64 == 0) { if (RDREG) RDVAL64 = RSVAL64; }           break;
2617               case 0x0b:  /* MOVN - R5000 */if (RTVAL64 != 0) { if (RDREG) RDVAL64 = RSVAL64; }           break;
2618               case 0x0c:  /* SYSCALL */   generate_exception(EXCEPTION_SYSCALL, 1);                       break;
2619               case 0x0d:  /* BREAK */     generate_exception(EXCEPTION_BREAK, 1);                         break;
2620               case 0x0f:  /* SYNC */      /* effective no-op */                                           break;
2621               case 0x10:  /* MFHI */      if (RDREG) RDVAL64 = HIVAL64;                                   break;
2622               case 0x11:  /* MTHI */      HIVAL64 = RSVAL64;                                              break;
2623               case 0x12:  /* MFLO */      if (RDREG) RDVAL64 = LOVAL64;                                   break;
2624               case 0x13:  /* MTLO */      LOVAL64 = RSVAL64;                                              break;
2625               case 0x14:  /* DSLLV */     if (RDREG) RDVAL64 = RTVAL64 << (RSVAL32 & 63);                 break;
2626               case 0x16:  /* DSRLV */     if (RDREG) RDVAL64 = RTVAL64 >> (RSVAL32 & 63);                 break;
2627               case 0x17:  /* DSRAV */     if (RDREG) RDVAL64 = (INT64)RTVAL64 >> (RSVAL32 & 63);          break;
2628               case 0x18:  /* MULT */
2629                  temp64 = (INT64)(INT32)RSVAL32 * (INT64)(INT32)RTVAL32;
2630                  LOVAL64 = (INT32)temp64;
2631                  HIVAL64 = (INT32)(temp64 >> 32);
2632                  m_core->icount -= 3;
2633                  break;
2634               case 0x19:  /* MULTU */
2635                  temp64 = (UINT64)RSVAL32 * (UINT64)RTVAL32;
2636                  LOVAL64 = (INT32)temp64;
2637                  HIVAL64 = (INT32)(temp64 >> 32);
2638                  m_core->icount -= 3;
2639                  break;
2640               case 0x1a:  /* DIV */
2641                  if (RTVAL32)
2642                  {
2643                     LOVAL64 = (INT32)((INT32)RSVAL32 / (INT32)RTVAL32);
2644                     HIVAL64 = (INT32)((INT32)RSVAL32 % (INT32)RTVAL32);
2645                  }
2646                  else
2647                  {
2648                     handle_integer_divide_by_zero(op);
2649                  }
2650                  m_core->icount -= 35;
2651                  break;
2652               case 0x1b:  /* DIVU */
2653                  if (RTVAL32)
2654                  {
2655                     LOVAL64 = (INT32)(RSVAL32 / RTVAL32);
2656                     HIVAL64 = (INT32)(RSVAL32 % RTVAL32);
2657                  }
2658                  else
2659                  {
2660                     handle_integer_divide_by_zero(op);
2661                  }
2662                  m_core->icount -= 35;
2663                  break;
2664               case 0x1c:  /* DMULT */
2665                  temp64 = (INT64)RSVAL64 * (INT64)RTVAL64;
2666                  LOVAL64 = temp64;
2667                  HIVAL64 = (INT64)temp64 >> 63;
2668                  m_core->icount -= 7;
2669                  break;
2670               case 0x1d:  /* DMULTU */
2671                  temp64 = (UINT64)RSVAL64 * (UINT64)RTVAL64;
2672                  LOVAL64 = temp64;
2673                  HIVAL64 = 0;
2674                  m_core->icount -= 7;
2675                  break;
2676               case 0x1e:  /* DDIV */
2677                  if (RTVAL64)
2678                  {
2679                     LOVAL64 = (INT64)RSVAL64 / (INT64)RTVAL64;
2680                     HIVAL64 = (INT64)RSVAL64 % (INT64)RTVAL64;
2681                  }
2682                  m_core->icount -= 67;
2683                  break;
2684               case 0x1f:  /* DDIVU */
2685                  if (RTVAL64)
2686                  {
2687                     LOVAL64 = RSVAL64 / RTVAL64;
2688                     HIVAL64 = RSVAL64 % RTVAL64;
2689                  }
2690                  m_core->icount -= 67;
2691                  break;
2692               case 0x20:  /* ADD */
2693                  if (ENABLE_OVERFLOWS && RSVAL32 > ~RTVAL32) generate_exception(EXCEPTION_OVERFLOW, 1);
2694                  else if (RDREG) RDVAL64 = (INT32)(RSVAL32 + RTVAL32);
2695                  break;
2696               case 0x21:  /* ADDU */      if (RDREG) RDVAL64 = (INT32)(RSVAL32 + RTVAL32);                break;
2697               case 0x22:  /* SUB */
2698                  if (ENABLE_OVERFLOWS && RSVAL32 < RTVAL32) generate_exception(EXCEPTION_OVERFLOW, 1);
2699                  else if (RDREG) RDVAL64 = (INT32)(RSVAL32 - RTVAL32);
2700                  break;
2701               case 0x23:  /* SUBU */      if (RDREG) RDVAL64 = (INT32)(RSVAL32 - RTVAL32);                break;
2702               case 0x24:  /* AND */       if (RDREG) RDVAL64 = RSVAL64 & RTVAL64;                         break;
2703               case 0x25:  /* OR */        if (RDREG) RDVAL64 = RSVAL64 | RTVAL64;                         break;
2704               case 0x26:  /* XOR */       if (RDREG) RDVAL64 = RSVAL64 ^ RTVAL64;                         break;
2705               case 0x27:  /* NOR */       if (RDREG) RDVAL64 = ~(RSVAL64 | RTVAL64);                      break;
2706               case 0x2a:  /* SLT */       if (RDREG) RDVAL64 = (INT64)RSVAL64 < (INT64)RTVAL64;           break;
2707               case 0x2b:  /* SLTU */      if (RDREG) RDVAL64 = (UINT64)RSVAL64 < (UINT64)RTVAL64;         break;
2708               case 0x2c:  /* DADD */
2709                  if (ENABLE_OVERFLOWS && RSVAL64 > ~RTVAL64) generate_exception(EXCEPTION_OVERFLOW, 1);
2710                  else if (RDREG) RDVAL64 = RSVAL64 + RTVAL64;
2711                  break;
2712               case 0x2d:  /* DADDU */     if (RDREG) RDVAL64 = RSVAL64 + RTVAL64;                         break;
2713               case 0x2e:  /* DSUB */
2714                  if (ENABLE_OVERFLOWS && RSVAL64 < RTVAL64) generate_exception(EXCEPTION_OVERFLOW, 1);
2715                  else if (RDREG) RDVAL64 = RSVAL64 - RTVAL64;
2716                  break;
2717               case 0x2f:  /* DSUBU */     if (RDREG) RDVAL64 = RSVAL64 - RTVAL64;                         break;
2718               case 0x30:  /* TGE */       if ((INT64)RSVAL64 >= (INT64)RTVAL64) generate_exception(EXCEPTION_TRAP, 1); break;
2719               case 0x31:  /* TGEU */      if (RSVAL64 >= RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2720               case 0x32:  /* TLT */       if ((INT64)RSVAL64 < (INT64)RTVAL64) generate_exception(EXCEPTION_TRAP, 1); break;
2721               case 0x33:  /* TLTU */      if (RSVAL64 < RTVAL64) generate_exception(EXCEPTION_TRAP, 1);   break;
2722               case 0x34:  /* TEQ */       if (RSVAL64 == RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2723               case 0x36:  /* TNE */       if (RSVAL64 != RTVAL64) generate_exception(EXCEPTION_TRAP, 1);  break;
2724               case 0x38:  /* DSLL */      if (RDREG) RDVAL64 = RTVAL64 << SHIFT;                          break;
2725               case 0x3a:  /* DSRL */      if (RDREG) RDVAL64 = RTVAL64 >> SHIFT;                          break;
2726               case 0x3b:  /* DSRA */      if (RDREG) RDVAL64 = (INT64)RTVAL64 >> SHIFT;                   break;
2727               case 0x3c:  /* DSLL32 */    if (RDREG) RDVAL64 = RTVAL64 << (SHIFT + 32);                   break;
2728               case 0x3e:  /* DSRL32 */    if (RDREG) RDVAL64 = RTVAL64 >> (SHIFT + 32);                   break;
2729               case 0x3f:  /* DSRA32 */    if (RDREG) RDVAL64 = (INT64)RTVAL64 >> (SHIFT + 32);            break;
2730               default:    /* ??? */       invalid_instruction(op);                                        break;
2731            }
2786            handle_special(op);
27322787            break;
27332788
27342789         case 0x01:  /* REGIMM */
2735            switch (RTREG)
2736            {
2737               case 0x00:  /* BLTZ */      if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL);                         break;
2738               case 0x01:  /* BGEZ */      if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL);                        break;
2739               case 0x02:  /* BLTZL */     if ((INT64)RSVAL64 < 0) ADDPC(SIMMVAL); else m_core->pc += 4;        break;
2740               case 0x03:  /* BGEZL */     if ((INT64)RSVAL64 >= 0) ADDPC(SIMMVAL); else m_core->pc += 4;   break;
2741               case 0x08:  /* TGEI */      if ((INT64)RSVAL64 >= SIMMVAL) generate_exception(EXCEPTION_TRAP, 1);   break;
2742               case 0x09:  /* TGEIU */     if (RSVAL64 >= UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2743               case 0x0a:  /* TLTI */      if ((INT64)RSVAL64 < SIMMVAL) generate_exception(EXCEPTION_TRAP, 1);    break;
2744               case 0x0b:  /* TLTIU */     if (RSVAL64 >= UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2745               case 0x0c:  /* TEQI */      if (RSVAL64 == UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2746               case 0x0e:  /* TNEI */      if (RSVAL64 != UIMMVAL) generate_exception(EXCEPTION_TRAP, 1);  break;
2747               case 0x10:  /* BLTZAL */    if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31);                     break;
2748               case 0x11:  /* BGEZAL */    if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31);                    break;
2749               case 0x12:  /* BLTZALL */   if ((INT64)RSVAL64 < 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4; break;
2750               case 0x13:  /* BGEZALL */   if ((INT64)RSVAL64 >= 0) ADDPCL(SIMMVAL,31) else m_core->pc += 4;    break;
2751               default:    /* ??? */       invalid_instruction(op);                                        break;
2752            }
2790            handle_regimm(op);
27532791            break;
27542792
27552793         case 0x02:  /* J */         ABSPC(LIMMVAL);                                                         break;
r245288r245289
28192857         case 0x36:  /* LDC2 */      if (RDOUBLE(SIMMVAL+RSVAL32, &temp64)) set_cop2_reg(RTREG, temp64);     break;
28202858         case 0x37:  /* LD */        if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG) RTVAL64 = temp64;       break;
28212859         case 0x38:  /* SC */        if (RWORD(SIMMVAL+RSVAL32, &temp) && RTREG)
2822                        {
2823                           if (temp == m_ll_value)
2824                           {
2825                              WWORD(SIMMVAL+RSVAL32, RTVAL32);
2826                              RTVAL64 = (UINT32)1;
2827                           }
2828                           else
2829                           {
2830                              RTVAL64 = (UINT32)0;
2831                           }
2832                        }
2833                        break;
2860         {
2861            if (temp == m_ll_value)
2862            {
2863               WWORD(SIMMVAL+RSVAL32, RTVAL32);
2864               RTVAL64 = (UINT32)1;
2865            }
2866            else
2867            {
2868               RTVAL64 = (UINT32)0;
2869            }
2870         }
2871         break;
28342872         case 0x39:  /* SWC1 */      WWORD(SIMMVAL+RSVAL32, get_cop1_reg32(RTREG));                          break;
28352873         case 0x3a:  /* SWC2 */      WWORD(SIMMVAL+RSVAL32, get_cop2_reg(RTREG));                            break;
28362874         case 0x3b:  /* SWC3 */      invalid_instruction(op);                                                break;
28372875         case 0x3c:  /* SCD */       if (RDOUBLE(SIMMVAL+RSVAL32, &temp64) && RTREG)
2838                        {
2839                           if (temp64 == m_lld_value)
2840                           {
2841                              WDOUBLE(SIMMVAL+RSVAL32, RTVAL64);
2842                              RTVAL64 = 1;
2843                           }
2844                           else
2845                           {
2846                              RTVAL64 = 0;
2847                           }
2848                        }
2849                        break;
2876         {
2877            if (temp64 == m_lld_value)
2878            {
2879               WDOUBLE(SIMMVAL+RSVAL32, RTVAL64);
2880               RTVAL64 = 1;
2881            }
2882            else
2883            {
2884               RTVAL64 = 0;
2885            }
2886         }
2887         break;
28502888         case 0x3d:  /* SDC1 */      WDOUBLE(SIMMVAL+RSVAL32, get_cop1_reg64(RTREG));                            break;
28512889         case 0x3e:  /* SDC2 */      WDOUBLE(SIMMVAL+RSVAL32, get_cop2_reg(RTREG));                          break;
28522890         case 0x3f:  /* SD */        WDOUBLE(SIMMVAL+RSVAL32, RTVAL64);                                      break;
trunk/src/emu/cpu/mips/mips3.h
r245288r245289
194194   MIPS3_BADVADDR
195195};
196196
197#define MIPS3_MAX_FASTRAM       4
197#define MIPS3_MAX_FASTRAM       3
198198#define MIPS3_MAX_HOTSPOTS      16
199199
200200enum
r245288r245289
296296
297297   TIMER_CALLBACK_MEMBER(compare_int_callback);
298298
299   void add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base);
300
299301   void mips3drc_set_options(UINT32 options);
300   void mips3drc_add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base);
301302   void mips3drc_add_hotspot(offs_t pc, UINT32 opcode, UINT32 cycles);
302303
303304protected:
r245288r245289
326327   virtual UINT32 disasm_max_opcode_bytes() const { return 4; }
327328   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
328329
330
329331private:
330332   struct internal_mips3_state
331333   {
r245288r245289
394396
395397   /* memory accesses */
396398   bool            m_bigendian;
399   UINT32         m_byte_xor;
400   UINT32         m_word_xor;
397401   data_accessors  m_memory;
398402
399403   /* cache memory */
r245288r245289
404408   vtlb_state *    m_vtlb;
405409   mips3_tlb_entry m_tlb[MIPS3_MAX_TLB_ENTRIES];
406410
411   /* fast RAM */
412   UINT32              m_fastram_select;
413   struct
414   {
415      offs_t              start;                      /* start of the RAM block */
416      offs_t              end;                        /* end of the RAM block */
417      UINT8               readonly;                   /* TRUE if read-only */
418      void *              base;                       /* base in memory where the RAM lives */
419   }       m_fastram[MIPS3_MAX_FASTRAM];
420
407421   UINT64 m_debugger_temp;
408422
409423   /* core state */
r245288r245289
442456   uml::code_handle *   m_exception[18/*EXCEPTION_COUNT*/]; /* array of exception handlers */
443457   uml::code_handle *   m_exception_norecover[18/*EXCEPTION_COUNT*/];   /* array of no-recover exception handlers */
444458
445   /* fast RAM */
446   UINT32              m_fastram_select;
447   struct
448   {
449      offs_t              start;                      /* start of the RAM block */
450      offs_t              end;                        /* end of the RAM block */
451      UINT8               readonly;                   /* TRUE if read-only */
452      void *              base;                       /* base in memory where the RAM lives */
453   }       m_fastram[MIPS3_MAX_FASTRAM];
454
455459   /* hotspots */
456460   UINT32              m_hotspot_select;
457461   struct
r245288r245289
477481private:
478482   UINT32 compute_config_register();
479483   UINT32 compute_prid_register();
484
480485   void tlb_map_entry(int tlbindex);
481486   void tlb_write_common(int tlbindex);
482   int RBYTE(offs_t address, UINT32 *result);
483   int RHALF(offs_t address, UINT32 *result);
484   int RWORD(offs_t address, UINT32 *result);
485   int RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask);
486   int RDOUBLE(offs_t address, UINT64 *result);
487   int RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask);
487
488   bool RBYTE(offs_t address, UINT32 *result);
489   bool RHALF(offs_t address, UINT32 *result);
490   bool RWORD(offs_t address, UINT32 *result);
491   bool RWORD_MASKED(offs_t address, UINT32 *result, UINT32 mem_mask);
492   bool RDOUBLE(offs_t address, UINT64 *result);
493   bool RDOUBLE_MASKED(offs_t address, UINT64 *result, UINT64 mem_mask);
488494   void WBYTE(offs_t address, UINT8 data);
489495   void WHALF(offs_t address, UINT16 data);
490496   void WWORD(offs_t address, UINT32 data);
491497   void WWORD_MASKED(offs_t address, UINT32 data, UINT32 mem_mask);
492498   void WDOUBLE(offs_t address, UINT64 data);
493499   void WDOUBLE_MASKED(offs_t address, UINT64 data, UINT64 mem_mask);
500
494501   UINT64 get_cop0_reg(int idx);
495502   void set_cop0_reg(int idx, UINT64 val);
496503   UINT64 get_cop0_creg(int idx);
497504   void set_cop0_creg(int idx, UINT64 val);
498505   void handle_cop0(UINT32 op);
506
499507   UINT32 get_cop1_reg32(int idx);
500508   UINT64 get_cop1_reg64(int idx);
501509   void set_cop1_reg32(int idx, UINT32 val);
r245288r245289
506514   void handle_cop1_fr1(UINT32 op);
507515   void handle_cop1x_fr0(UINT32 op);
508516   void handle_cop1x_fr1(UINT32 op);
517
509518   UINT64 get_cop2_reg(int idx);
510519   void set_cop2_reg(int idx, UINT64 val);
511520   UINT64 get_cop2_creg(int idx);
512521   void set_cop2_creg(int idx, UINT64 val);
513522   void handle_cop2(UINT32 op);
514   void handle_integer_divide_by_zero(UINT32 op);
523
524   void handle_special(UINT32 op);
525   void handle_regimm(UINT32 op);
526
515527   void lwl_be(UINT32 op);
516528   void lwr_be(UINT32 op);
517529   void ldl_be(UINT32 op);
trunk/src/emu/cpu/mips/mips3drc.c
r245288r245289
160160    region
161161-------------------------------------------------*/
162162
163void mips3_device::mips3drc_add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base)
163void mips3_device::add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base)
164164{
165   if (!machine().options().drc()) return;
166165   if (m_fastram_select < ARRAY_LENGTH(m_fastram))
167166   {
168167      m_fastram[m_fastram_select].start = start;
r245288r245289
20542053         return TRUE;
20552054
20562055      case 0x1a:  /* DIV - MIPS I */
2057      {
2058         if (m_drcoptions & MIPS3DRC_ACCURATE_DIVZERO)
2059         {
2060            code_label divzero, done;
2061
2062            UML_CMP(block, R32(RTREG), 0);                                      // cmp     <rtreg>, 0
2063            UML_JMPc(block, COND_E, divzero = compiler->labelnum++);         // jmp     divzero,E
2064
2065            UML_DIVS(block, I0, I1, R32(RSREG), R32(RTREG));                    // divs    i0,i1,<rsreg>,<rtreg>
2066            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2067            UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
2068            UML_JMP(block, done = compiler->labelnum++);                        // jmp     done
2069
2070            UML_LABEL(block, divzero);                                          // divzero:
2071            if (m_flavor != MIPS3_TYPE_VR4300)
2072            {
2073               UML_MOVc(block, COND_L, I0, 0x00000001);                        // mov     i0,0x00000001,L
2074               UML_MOVc(block, COND_GE, I0, 0xffffffff);                       // mov     i0,0xffffffff,GE
2075            }
2076            else
2077            {
2078               UML_MOVc(block, COND_L, I0, 0x80000001);                        // mov     i0,0x80000001,L
2079               UML_MOVc(block, COND_GE, I0, 0x7fffffff);                       // mov     i0,0x7fffffff,GE
2080            }
2081            UML_DSEXT(block, HI64, R32(RSREG), SIZE_DWORD);                     // dsext   hi,<rsreg>,dword
2082            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2083
2084            UML_LABEL(block, done);                                             // done:
2085         }
2086         else
2087         {
2088            UML_DIVS(block, I0, I1, R32(RSREG), R32(RTREG));                    // divs    i0,i1,<rsreg>,<rtreg>
2089            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2090            UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
2091         }
2056         UML_DIVS(block, I0, I1, R32(RSREG), R32(RTREG));                    // divs    i0,i1,<rsreg>,<rtreg>
2057         UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2058         UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
20922059         return TRUE;
2093      }
20942060
20952061      case 0x1b:  /* DIVU - MIPS I */
2096         if (m_drcoptions & MIPS3DRC_ACCURATE_DIVZERO)
2097         {
2098            code_label divzero, done;
2099
2100            UML_CMP(block, R32(RTREG), 0);                                      // cmp     <rtreg>, 0
2101            UML_JMPc(block, COND_E, divzero = compiler->labelnum++);         // jmp     divzero,E
2102
2103            UML_DIVU(block, I0, I1, R32(RSREG), R32(RTREG));                    // divu    i0,i1,<rsreg>,<rtreg>
2104            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2105            UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
2106            UML_JMP(block, done = compiler->labelnum++);                        // jmp     done
2107
2108            UML_LABEL(block, divzero);                                          // divzero:
2109            if (m_flavor != MIPS3_TYPE_VR4300)
2110            {
2111               UML_MOVc(block, COND_L, I0, 0x00000001);                        // mov     i0,0x00000001,L
2112               UML_MOVc(block, COND_GE, I0, 0xffffffff);                       // mov     i0,0xffffffff,GE
2113            }
2114            else
2115            {
2116               UML_MOVc(block, COND_L, I0, 0x80000001);                        // mov     i0,0x80000001,L
2117               UML_MOVc(block, COND_GE, I0, 0x7fffffff);                       // mov     i0,0x7fffffff,GE
2118            }
2119            UML_DSEXT(block, HI64, R32(RSREG), SIZE_DWORD);                     // dsext   hi,<rsreg>,dword
2120            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2121
2122            UML_LABEL(block, done);                                             // done:
2123         }
2124         else
2125         {
2126            UML_DIVU(block, I0, I1, R32(RSREG), R32(RTREG));                    // divu    i0,i1,<rsreg>,<rtreg>
2127            UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2128            UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
2129         }
2062         UML_DIVU(block, I0, I1, R32(RSREG), R32(RTREG));                    // divu    i0,i1,<rsreg>,<rtreg>
2063         UML_DSEXT(block, LO64, I0, SIZE_DWORD);                             // dsext   lo,i0,dword
2064         UML_DSEXT(block, HI64, I1, SIZE_DWORD);                             // dsext   hi,i1,dword
21302065         return TRUE;
21312066
21322067      case 0x1e:  /* DDIV - MIPS III */
trunk/src/mame/drivers/hng64.c
r245288r245289
14901490   /* set the fastest DRC options */
14911491   m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY);
14921492
1493   /* configure fast RAM regions for DRC */
1494   m_maincpu->mips3drc_add_fastram(0x00000000, 0x00ffffff, FALSE, m_mainram);
1495   m_maincpu->mips3drc_add_fastram(0x04000000, 0x05ffffff, TRUE,  m_cart);
1496   m_maincpu->mips3drc_add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
1493   /* configure fast RAM regions */
1494   m_maincpu->add_fastram(0x00000000, 0x00ffffff, FALSE, m_mainram);
1495   m_maincpu->add_fastram(0x04000000, 0x05ffffff, TRUE,  m_cart);
1496   m_maincpu->add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
14971497
14981498   m_comm_rom = memregion("user2")->base();
14991499   m_comm_ram = auto_alloc_array(machine(),UINT8,0x10000);
trunk/src/mame/drivers/kinst.c
r245288r245289
203203   /* set the fastest DRC options */
204204   m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS);
205205
206   /* configure fast RAM regions for DRC */
207   m_maincpu->mips3drc_add_fastram(0x08000000, 0x087fffff, FALSE, m_rambase2);
208   m_maincpu->mips3drc_add_fastram(0x00000000, 0x0007ffff, FALSE, m_rambase);
209   m_maincpu->mips3drc_add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
206   /* configure fast RAM regions */
207   m_maincpu->add_fastram(0x08000000, 0x087fffff, FALSE, m_rambase2);
208   m_maincpu->add_fastram(0x00000000, 0x0007ffff, FALSE, m_rambase);
209   m_maincpu->add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
210210}
211211
212212
trunk/src/mame/drivers/namcos23.c
r245288r245289
32233223   m_c361.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos23_state::c361_timer_cb),this));
32243224   m_c361.timer->adjust(attotime::never);
32253225
3226   m_maincpu->mips3drc_add_fastram(0, m_mainram.bytes()-1, FALSE, reinterpret_cast<UINT32 *>(memshare("mainram")->ptr()));
3226   m_maincpu->add_fastram(0, m_mainram.bytes()-1, FALSE, reinterpret_cast<UINT32 *>(memshare("mainram")->ptr()));
32273227}
32283228
32293229
trunk/src/mame/drivers/seattle.c
r245288r245289
566566   /* set the fastest DRC options, but strict verification */
567567   m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY);
568568
569   /* configure fast RAM regions for DRC */
570   m_maincpu->mips3drc_add_fastram(0x00000000, 0x007fffff, FALSE, m_rambase);
571   m_maincpu->mips3drc_add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
569   /* configure fast RAM regions */
570   m_maincpu->add_fastram(0x00000000, 0x007fffff, FALSE, m_rambase);
571   m_maincpu->add_fastram(0x1fc00000, 0x1fc7ffff, TRUE,  m_rombase);
572572
573573   /* register for save states */
574574   save_item(NAME(m_galileo.reg));
trunk/src/mame/drivers/vegas.c
r245288r245289
595595   /* set the fastest DRC options, but strict verification */
596596   m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY + MIPS3DRC_FLUSH_PC);
597597
598   /* configure fast RAM regions for DRC */
599   m_maincpu->mips3drc_add_fastram(0x00000000, m_rambase.bytes() - 1, FALSE, m_rambase);
600   m_maincpu->mips3drc_add_fastram(0x1fc00000, 0x1fc7ffff, TRUE, m_rombase);
598   /* configure fast RAM regions */
599   m_maincpu->add_fastram(0x00000000, m_rambase.bytes() - 1, FALSE, m_rambase);
600   m_maincpu->add_fastram(0x1fc00000, 0x1fc7ffff, TRUE, m_rombase);
601601
602602   /* register for save states */
603603   save_item(NAME(m_nile_irq_state));
trunk/src/mame/machine/n64.c
r245288r245289
14581458   //pi_status |= 8; // Set INTERRUPT ?? Does this bit exist ??
14591459
14601460   if(update_bm)
1461      dd_update_bm();   
1461      dd_update_bm();
14621462
14631463   signal_rcp_interrupt(PI_INTERRUPT);
14641464
r245288r245289
21892189   {
21902190      if(((dd_track_reg & 0xFFF) == 6) && (dd_start_block == 0))
21912191      {
2192         dd_status_reg &= ~DD_ASIC_STATUS_DREQ;     
2192         dd_status_reg &= ~DD_ASIC_STATUS_DREQ;
21932193      }
21942194      else if(dd_current_reg < SECTORS_PER_BLOCK)
21952195      {
r245288r245289
22392239   sector += (dd_current_reg - 1) * ddZoneSecSize[dd_zone];
22402240
22412241   //logerror("Write Block %d, Sector %d\n", dd_start_block, dd_current_reg - 1);
2242   
2242
22432243   for(int i = 0; i < ddZoneSecSize[dd_zone]/4; i++)
22442244   {
22452245      sector[i*4 + 0] = (dd_sector_data[i] >> 24) & 0xFF;
r245288r245289
24922492         logerror("dd BM Status write\n");
24932493         dd_start_sector = (data >> 16) & 0xFF;
24942494         if(dd_start_sector == 0x00)
2495         {         
2495         {
24962496            dd_start_block = 0;
24972497            dd_current_reg = 0;
24982498         }
24992499         else if (dd_start_sector == 0x5A)
2500         {   
2500         {
25012501            dd_start_block = 1;
25022502            dd_current_reg = 0;
25032503         }
r245288r245289
26202620
26212621   dynamic_cast<mips3_device *>(machine().device("maincpu"))->mips3drc_set_options(MIPS3DRC_COMPATIBLE_OPTIONS);
26222622
2623   /* configure fast RAM regions for DRC */
2624   dynamic_cast<mips3_device *>(machine().device("maincpu"))->mips3drc_add_fastram(0x00000000, 0x007fffff, FALSE, rdram);
2623   /* configure fast RAM regions */
2624   dynamic_cast<mips3_device *>(machine().device("maincpu"))->add_fastram(0x00000000, 0x007fffff, FALSE, rdram);
26252625
26262626   rsp_device *rsp = machine().device<rsp_device>("rsp");
26272627   rsp->rspdrc_set_options(RSPDRC_STRICT_VERIFY);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team