Previous 15994 Revisions Next

r9914 Tuesday 4th January, 2011 at 14:20:40 UTC by MooglyGuy
[MIPS3] Include branch delay slots in block checksum calculations. Fixes Bomberman 64 booting with MIPS III DRC. [Aaron Giles]

[RSP] Include branch delay slots in block checksum calculations for consistency with the MIPS III DRC. [Harmony]
[src/emu/cpu/mips]mips3drc.c
[src/emu/cpu/rsp]rsp.c rsp.h rspdrc.c

src/emu/cpu/rsp/rsp.c
r9913r9914
6464#define VEC_EL_2(x,z)         (vector_elements[(x)][(z)])
6565
6666#define ACCUM(x)      rsp->accum[((x))].q
67#define ACCUM_H(x)      rsp->accum[((x))].w[0]
68#define ACCUM_M(x)      rsp->accum[((x))].w[1]
69#define ACCUM_L(x)      rsp->accum[((x))].w[2]
67#define ACCUM_H(x)      rsp->accum[((x))].w[3]
68#define ACCUM_M(x)      rsp->accum[((x))].w[2]
69#define ACCUM_L(x)      rsp->accum[((x))].w[1]
7070
7171#define CARRY_FLAG(x)         ((rsp->flag[0] & (1 << ((x)))) ? 1 : 0)
7272#define CLEAR_CARRY_FLAGS()      { rsp->flag[0] &= ~0xff; }
r9913r9914
14811481            s1 = (INT32)(INT16)VREG_S(VS1REG, i);
14821482            s2 = (INT32)(INT16)VREG_S(VS2REG, sel);
14831483
1484            rsp->accum[i].l[0] += s1*s2;
1484            rsp->accum[i].l[1] += s1*s2;
14851485
14861486            res = SATURATE_ACCUM1(rsp, i, 0x8000, 0x7fff);
14871487
src/emu/cpu/rsp/rsp.h
r9913r9914
117117#define IS_FLOAT(o)    (((o) & (1 << 23)) == 0)
118118#define IS_INTEGRAL(o)   (((o) & (1 << 23)) != 0)
119119
120#define SIMMVAL         ((INT16)op)
121#define UIMMVAL         ((UINT16)op)
122#define LIMMVAL         (op & 0x03ffffff)
120#define SIMM16         ((INT16)(op))
121#define UIMM16         ((UINT16)(op))
122#define LIMM16         (op & 0x03ffffff)
123123
124124#define RSP_STATUS_HALT          0x0001
125125#define RSP_STATUS_BROKE         0x0002
src/emu/cpu/rsp/rspdrc.c
r9913r9914
151151static void cfunc_cfc2(void *param);
152152static void cfunc_mtc2(void *param);
153153static void cfunc_ctc2(void *param);
154//static void cfunc_swc2(void *param);
155//static void cfunc_lwc2(void *param);
156154static void cfunc_sp_set_status_cb(void *param);
157155
158156static void cfunc_rsp_lbv(void *param);
r9913r9914
518516
519517/*****************************************************************************/
520518
521/* Legacy.  Going forward, this will be transitioned into unrolled opcode decodes. */
522static const int vector_elements_1[16][8] =
523{
524   { 0, 1, 2, 3, 4, 5, 6, 7 },      // none
525   { 0, 1, 2, 3, 4, 5, 6 ,7 },      // ???
526   { 1, 3, 5, 7, 0, 2, 4, 6 },      // 0q
527   { 0, 2, 4, 6, 1, 3, 5, 7 },      // 1q
528   { 1, 2, 3, 5, 6, 7, 0, 4 },      // 0h
529   { 0, 2, 3, 4, 6, 7, 1, 5 },      // 1h
530   { 0, 1, 3, 4, 5, 7, 2, 6 },      // 2h
531   { 0, 1, 2, 4, 5, 6, 3, 7 },      // 3h
532   { 1, 2, 3, 4, 5, 6, 7, 0 },      // 0
533   { 0, 2, 3, 4, 5, 6, 7, 1 },      // 1
534   { 0, 1, 3, 4, 5, 6, 7, 2 },      // 2
535   { 0, 1, 2, 4, 5, 6, 7, 3 },      // 3
536   { 0, 1, 2, 3, 5, 6, 7, 4 },      // 4
537   { 0, 1, 2, 3, 4, 6, 7, 5 },      // 5
538   { 0, 1, 2, 3, 4, 5, 7, 6 },      // 6
539   { 0, 1, 2, 3, 4, 5, 6, 7 },      // 7
540};
541
542/* Legacy.  Going forward, this will be transitioned into unrolled opcode decodes. */
543519static const int vector_elements_2[16][8] =
544520{
545521   { 0, 1, 2, 3, 4, 5, 6, 7 },      // none
r9913r9914
781757
782758   int end = index + 2;
783759
760   if(end > 16) printf("LSV past end\n");
761
784762   for (int i = index; i < end; i++)
785763   {
786764      VREG_B(dest, i) = READ8(rsp, ea);
r9913r9914
812790
813791   int end = index + 4;
814792
793   if(end > 16) printf("LLV past end\n");
794
815795   for (int i = index; i < end; i++)
816796   {
817797      VREG_B(dest, i) = READ8(rsp, ea);
r9913r9914
843823
844824   int end = index + 8;
845825
826   if(end > 16) printf("LDV past end\n");
827
846828   for (int i = index; i < end; i++)
847829   {
848830      VREG_B(dest, i) = READ8(rsp, ea);
r9913r9914
12391221
12401222   int end = index + 2;
12411223
1224   if(end > 16) printf("SSV past end\n");
1225
12421226   for (int i = index; i < end; i++)
12431227   {
12441228      WRITE8(rsp, ea, VREG_B(dest, i));
r9913r9914
12701254
12711255   int end = index + 4;
12721256
1257   if(end > 16) printf("SLV past end\n");
1258
12731259   for (int i = index; i < end; i++)
12741260   {
12751261      WRITE8(rsp, ea, VREG_B(dest, i));
r9913r9914
13011287
13021288   end = index + 8;
13031289
1290   if(end > 16) printf("SDV past end\n");
1291
13041292   for (int i = index; i < end; i++)
13051293   {
13061294      WRITE8(rsp, ea, VREG_B(dest, i));
r9913r9914
38253813            UML_LOAD(block, IREG(1), base, IMM(0), DWORD);                  // load    i1,base,dword
38263814            UML_ADD(block, IREG(0), IREG(0), IREG(1));                     // add     i0,i0,i1
38273815            sum += curdesc->opptr.l[0];
3816
3817            if (curdesc->delay != NULL && (curdesc == seqlast || (curdesc->next != NULL && curdesc->next->physpc != curdesc->delay->physpc)))
3818            {
3819               base = rsp->direct->read_decrypted_ptr(curdesc->delay->physpc | 0x1000);
3820               UML_LOAD(block, IREG(1), base, IMM(0), DWORD);               // load    i1,base,dword
3821               UML_ADD(block, IREG(0), IREG(0), IREG(1));                  // add     i0,i0,i1
3822               sum += curdesc->delay->opptr.l[0];
3823            }
38283824         }
38293825      UML_CMP(block, IREG(0), IMM(sum));                                 // cmp     i0,sum
38303826      UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead)));         // exne    nocode,seqhead->pc
r9913r9914
42214217
42224218      case 0x0f:   /* LUI - MIPS I */
42234219         if (RTREG != 0)
4224            UML_MOV(block, R32(RTREG), IMM(SIMMVAL << 16));               // dmov    <rtreg>,SIMMVAL << 16
4220            UML_MOV(block, R32(RTREG), IMM(SIMM16 << 16));               // dmov    <rtreg>,SIMM16 << 16
42254221         return TRUE;
42264222
42274223      case 0x08:   /* ADDI - MIPS I */
42284224      case 0x09:   /* ADDIU - MIPS I */
42294225         if (RTREG != 0)
42304226         {
4231            UML_ADD(block, R32(RTREG), R32(RSREG), IMM(SIMMVAL));            // add     i0,<rsreg>,SIMMVAL,V
4227            UML_ADD(block, R32(RTREG), R32(RSREG), IMM(SIMM16));            // add     i0,<rsreg>,SIMM16,V
42324228         }
42334229         return TRUE;
42344230
42354231      case 0x0a:   /* SLTI - MIPS I */
42364232         if (RTREG != 0)
42374233         {
4238            UML_CMP(block, R32(RSREG), IMM(SIMMVAL));                     // dcmp    <rsreg>,SIMMVAL
4234            UML_CMP(block, R32(RSREG), IMM(SIMM16));                     // dcmp    <rsreg>,SIMM16
42394235            UML_SETc(block, IF_L, R32(RTREG));                           // dset    <rtreg>,l
42404236         }
42414237         return TRUE;
r9913r9914
42434239      case 0x0b:   /* SLTIU - MIPS I */
42444240         if (RTREG != 0)
42454241         {
4246            UML_CMP(block, R32(RSREG), IMM(SIMMVAL));                     // dcmp    <rsreg>,SIMMVAL
4242            UML_CMP(block, R32(RSREG), IMM(SIMM16));                     // dcmp    <rsreg>,SIMM16
42474243            UML_SETc(block, IF_B, R32(RTREG));                           // dset    <rtreg>,b
42484244         }
42494245         return TRUE;
r9913r9914
42514247
42524248      case 0x0c:   /* ANDI - MIPS I */
42534249         if (RTREG != 0)
4254            UML_AND(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dand    <rtreg>,<rsreg>,UIMMVAL
4250            UML_AND(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dand    <rtreg>,<rsreg>,UIMMVAL
42554251         return TRUE;
42564252
42574253      case 0x0d:   /* ORI - MIPS I */
42584254         if (RTREG != 0)
4259            UML_OR(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dor     <rtreg>,<rsreg>,UIMMVAL
4255            UML_OR(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dor     <rtreg>,<rsreg>,UIMMVAL
42604256         return TRUE;
42614257
42624258      case 0x0e:   /* XORI - MIPS I */
42634259         if (RTREG != 0)
4264            UML_XOR(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dxor    <rtreg>,<rsreg>,UIMMVAL
4260            UML_XOR(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dxor    <rtreg>,<rsreg>,UIMMVAL
42654261         return TRUE;
42664262
42674263      /* ----- memory load operations ----- */
42684264
42694265      case 0x20:   /* LB - MIPS I */
4270         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4266         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
42714267         UML_CALLH(block, rsp->impstate->read8);                           // callh   read8
42724268         if (RTREG != 0)
42734269            UML_SEXT(block, R32(RTREG), IREG(0), BYTE);                  // dsext   <rtreg>,i0,byte
r9913r9914
42764272         return TRUE;
42774273
42784274      case 0x21:   /* LH - MIPS I */
4279         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4275         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
42804276         UML_CALLH(block, rsp->impstate->read16);                        // callh   read16
42814277         if (RTREG != 0)
42824278            UML_SEXT(block, R32(RTREG), IREG(0), WORD);                  // dsext   <rtreg>,i0,word
r9913r9914
42854281         return TRUE;
42864282
42874283      case 0x23:   /* LW - MIPS I */
4288         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4284         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
42894285         UML_CALLH(block, rsp->impstate->read32);                        // callh   read32
42904286         if (RTREG != 0)
42914287            UML_MOV(block, R32(RTREG), IREG(0));
r9913r9914
42944290         return TRUE;
42954291
42964292      case 0x24:   /* LBU - MIPS I */
4297         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4293         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
42984294         UML_CALLH(block, rsp->impstate->read8);                           // callh   read8
42994295         if (RTREG != 0)
43004296            UML_AND(block, R32(RTREG), IREG(0), IMM(0xff));               // dand    <rtreg>,i0,0xff
r9913r9914
43034299         return TRUE;
43044300
43054301      case 0x25:   /* LHU - MIPS I */
4306         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4302         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
43074303         UML_CALLH(block, rsp->impstate->read16);                        // callh   read16
43084304         if (RTREG != 0)
43094305            UML_AND(block, R32(RTREG), IREG(0), IMM(0xffff));               // dand    <rtreg>,i0,0xffff
r9913r9914
43184314      /* ----- memory store operations ----- */
43194315
43204316      case 0x28:   /* SB - MIPS I */
4321         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4317         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
43224318         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43234319         UML_CALLH(block, rsp->impstate->write8);                        // callh   write8
43244320         if (!in_delay_slot)
r9913r9914
43264322         return TRUE;
43274323
43284324      case 0x29:   /* SH - MIPS I */
4329         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4325         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
43304326         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43314327         UML_CALLH(block, rsp->impstate->write16);                        // callh   write16
43324328         if (!in_delay_slot)
r9913r9914
43344330         return TRUE;
43354331
43364332      case 0x2b:   /* SW - MIPS I */
4337         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
4333         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16 ));                  // add     i0,<rsreg>,SIMM16
43384334         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43394335         UML_CALLH(block, rsp->impstate->write32);                        // callh   write32
43404336         if (!in_delay_slot)
r9913r9914
46734669   rsp_state *rsp = (rsp_state*)param;
46744670   UINT32 op = rsp->impstate->arg0;
46754671   int el = (op >> 7) & 0xf;
4676   VREG_B(VS1REG, (el+0) & 0xf) = (RTVAL >> 8) & 0xff;
4677   VREG_B(VS1REG, (el+1) & 0xf) = (RTVAL >> 0) & 0xff;
4672   VREG_B(RDREG, (el+0) & 0xf) = (RTVAL >> 8) & 0xff;
4673   VREG_B(RDREG, (el+1) & 0xf) = (RTVAL >> 0) & 0xff;
46784674}
46794675
46804676static void cfunc_ctc2(void *param)
src/emu/cpu/mips/mips3drc.c
r9913r9914
15561556            UML_LOAD(block, IREG(1), base, IMM(0), DWORD);                  // load    i1,base,dword
15571557            UML_ADD(block, IREG(0), IREG(0), IREG(1));                     // add     i0,i0,i1
15581558            sum += curdesc->opptr.l[0];
1559
1560            if (curdesc->delay != NULL && (curdesc == seqlast || (curdesc->next != NULL && curdesc->next->physpc != curdesc->delay->physpc)))
1561            {
1562               base = mips3->direct->read_decrypted_ptr(curdesc->delay->physpc);
1563               UML_LOAD(block, IREG(1), base, IMM(0), DWORD);               // load    i1,base,dword
1564               UML_ADD(block, IREG(0), IREG(0), IREG(1));                  // add     i0,i0,i1
1565               sum += curdesc->delay->opptr.l[0];
1566            }
15591567         }
15601568      UML_CMP(block, IREG(0), IMM(sum));                                 // cmp     i0,sum
15611569      UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead)));         // exne    nocode,seqhead->pc

Previous 15994 Revisions Next


© 1998-2018 The MESS Team