summaryrefslogtreecommitdiff
path: root/src/core/arm/interpreter/armemu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/arm/interpreter/armemu.cpp')
-rw-r--r--src/core/arm/interpreter/armemu.cpp57
1 files changed, 6 insertions, 51 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index 12166bf79..adc5c3a05 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -340,7 +340,6 @@ ARMword ARMul_Debug(ARMul_State * state, ARMword pc, ARMword instr)
340 mem_Dbugdump(); 340 mem_Dbugdump();
341 }*/ 341 }*/
342 342
343
344 /*if (pc == 0x0022D168) 343 /*if (pc == 0x0022D168)
345 { 344 {
346 int j = 0; 345 int j = 0;
@@ -1117,7 +1116,6 @@ ARMul_Emulate26 (ARMul_State * state)
1117 1116
1118//chy 2003-08-24 now #if 0 .... #endif process cp14, cp15.reg14, I disable it... 1117//chy 2003-08-24 now #if 0 .... #endif process cp14, cp15.reg14, I disable it...
1119 1118
1120
1121 /* Actual execution of instructions begins here. */ 1119 /* Actual execution of instructions begins here. */
1122 /* If the condition codes don't match, stop here. */ 1120 /* If the condition codes don't match, stop here. */
1123 if (temp) { 1121 if (temp) {
@@ -1178,8 +1176,6 @@ mainswitch:
1178 tmp_rd = ((ARMword)(data << (31 - lsb)) >> (31 - lsb)); 1176 tmp_rd = ((ARMword)(data << (31 - lsb)) >> (31 - lsb));
1179 dst = ((data >> msb) << (msb - lsb)); 1177 dst = ((data >> msb) << (msb - lsb));
1180 dst = (dst << lsb) | tmp_rd; 1178 dst = (dst << lsb) | tmp_rd;
1181 /*SKYEYE_DBG("BFC instr: msb = %d, lsb = %d, Rd[%d] : 0x%x, dst = 0x%x\n",
1182 msb, lsb, Rd, state->Reg[Rd], dst);*/
1183 goto donext; 1179 goto donext;
1184 } // bfc instr 1180 } // bfc instr
1185 else if (((msb >= lsb) && (msb < 32))) { 1181 else if (((msb >= lsb) && (msb < 32))) {
@@ -1189,8 +1185,6 @@ mainswitch:
1189 tmp_rd = ((ARMword)(data << (31 - lsb)) >> (31 - lsb)); 1185 tmp_rd = ((ARMword)(data << (31 - lsb)) >> (31 - lsb));
1190 dst = ((data >> msb) << (msb - lsb)) | tmp_rn; 1186 dst = ((data >> msb) << (msb - lsb)) | tmp_rn;
1191 dst = (dst << lsb) | tmp_rd; 1187 dst = (dst << lsb) | tmp_rd;
1192 /*SKYEYE_DBG("BFI instr:msb = %d, lsb = %d, Rd[%d] : 0x%x, Rn[%d]: 0x%x, dst = 0x%x\n",
1193 msb, lsb, Rd, state->Reg[Rd], Rn, state->Reg[Rn], dst);*/
1194 goto donext; 1188 goto donext;
1195 } // bfi instr 1189 } // bfi instr
1196 } 1190 }
@@ -2215,10 +2209,8 @@ mainswitch:
2215 state->currentexvald == (u32)ARMul_ReadWord(state, state->currentexaddr + 4)) 2209 state->currentexvald == (u32)ARMul_ReadWord(state, state->currentexaddr + 4))
2216 enter = true; 2210 enter = true;
2217 2211
2218
2219 //todo bug this and STREXD and LDREXD http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360e/CHDGJGGC.html 2212 //todo bug this and STREXD and LDREXD http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360e/CHDGJGGC.html
2220 2213
2221
2222 if (enter) { 2214 if (enter) {
2223 ARMul_StoreWordN(state, LHS, state->Reg[RHSReg]); 2215 ARMul_StoreWordN(state, LHS, state->Reg[RHSReg]);
2224 ARMul_StoreWordN(state,LHS + 4 , state->Reg[RHSReg + 1]); 2216 ARMul_StoreWordN(state,LHS + 4 , state->Reg[RHSReg + 1]);
@@ -2254,9 +2246,6 @@ mainswitch:
2254 LHPREUPWB (); 2246 LHPREUPWB ();
2255 /* Continue with remaining instruction decoding. */ 2247 /* Continue with remaining instruction decoding. */
2256 2248
2257
2258
2259
2260#endif 2249#endif
2261 dest = DPSRegRHS; 2250 dest = DPSRegRHS;
2262 WRITESDEST (dest); 2251 WRITESDEST (dest);
@@ -2296,7 +2285,6 @@ mainswitch:
2296 temp = LHS + GetLS7RHS (state, instr); 2285 temp = LHS + GetLS7RHS (state, instr);
2297 LoadHalfWord (state, instr, temp, LSIGNED); 2286 LoadHalfWord (state, instr, temp, LSIGNED);
2298 break; 2287 break;
2299
2300 } 2288 }
2301 if (BITS (4, 7) == 0xb) { 2289 if (BITS (4, 7) == 0xb) {
2302 /* LDRH immediate offset, no write-back, up, pre indexed. */ 2290 /* LDRH immediate offset, no write-back, up, pre indexed. */
@@ -2321,7 +2309,6 @@ mainswitch:
2321 } 2309 }
2322 /* LDR immediate offset, no write-back, up, pre indexed. */ 2310 /* LDR immediate offset, no write-back, up, pre indexed. */
2323 LHPREUP (); 2311 LHPREUP ();
2324
2325 } 2312 }
2326 2313
2327#endif 2314#endif
@@ -2342,7 +2329,6 @@ mainswitch:
2342 2329
2343 if (state->currentexval == (u32)ARMul_LoadHalfWord(state, state->currentexaddr))enter = true; 2330 if (state->currentexval == (u32)ARMul_LoadHalfWord(state, state->currentexaddr))enter = true;
2344 2331
2345
2346 //StoreWord(state, lhs, RHS) 2332 //StoreWord(state, lhs, RHS)
2347 if (state->Aborted) { 2333 if (state->Aborted) {
2348 TAKEABORT; 2334 TAKEABORT;
@@ -2396,7 +2382,6 @@ mainswitch:
2396 WRITESDEST (dest); 2382 WRITESDEST (dest);
2397 break; 2383 break;
2398 2384
2399
2400 /* Data Processing Immediate RHS Instructions. */ 2385 /* Data Processing Immediate RHS Instructions. */
2401 2386
2402 case 0x20: /* AND immed */ 2387 case 0x20: /* AND immed */
@@ -2553,8 +2538,6 @@ mainswitch:
2553 dest = BITS(16, 19); 2538 dest = BITS(16, 19);
2554 dest = ((dest<<12) | BITS(0, 11)); 2539 dest = ((dest<<12) | BITS(0, 11));
2555 WRITEDEST(dest); 2540 WRITEDEST(dest);
2556 //SKYEYE_DBG("In %s, line = %d, pc = 0x%x, instr = 0x%x, R[0:11]: 0x%x, R[16:19]: 0x%x, R[%d]:0x%x\n",
2557 // __func__, __LINE__, pc, instr, BITS(0, 11), BITS(16, 19), DESTReg, state->Reg[DESTReg]);
2558 break; 2541 break;
2559 } else { 2542 } else {
2560 UNDEF_Test; 2543 UNDEF_Test;
@@ -2717,7 +2700,6 @@ mainswitch:
2717 WRITESDEST (~rhs); 2700 WRITESDEST (~rhs);
2718 break; 2701 break;
2719 2702
2720
2721 /* Single Data Transfer Immediate RHS Instructions. */ 2703 /* Single Data Transfer Immediate RHS Instructions. */
2722 2704
2723 case 0x40: /* Store Word, No WriteBack, Post Dec, Immed. */ 2705 case 0x40: /* Store Word, No WriteBack, Post Dec, Immed. */
@@ -2849,7 +2831,6 @@ mainswitch:
2849 state->NtransSig = (state->Mode & 3) ? HIGH : LOW; 2831 state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
2850 break; 2832 break;
2851 2833
2852
2853 case 0x50: /* Store Word, No WriteBack, Pre Dec, Immed. */ 2834 case 0x50: /* Store Word, No WriteBack, Pre Dec, Immed. */
2854 (void) StoreWord (state, instr, LHS - LSImmRHS); 2835 (void) StoreWord (state, instr, LHS - LSImmRHS);
2855 break; 2836 break;
@@ -2946,7 +2927,6 @@ mainswitch:
2946 LSBase = temp; 2927 LSBase = temp;
2947 break; 2928 break;
2948 2929
2949
2950 /* Single Data Transfer Register RHS Instructions. */ 2930 /* Single Data Transfer Register RHS Instructions. */
2951 2931
2952 case 0x60: /* Store Word, No WriteBack, Post Dec, Reg. */ 2932 case 0x60: /* Store Word, No WriteBack, Post Dec, Reg. */
@@ -3234,11 +3214,9 @@ mainswitch:
3234 int Rm = 0; 3214 int Rm = 0;
3235 /* utxb */ 3215 /* utxb */
3236 if (BITS(15, 19) == 0xf && BITS(4, 7) == 0x7) { 3216 if (BITS(15, 19) == 0xf && BITS(4, 7) == 0x7) {
3237
3238 Rm = (RHS >> (8 * BITS(10, 11))) & 0xff; 3217 Rm = (RHS >> (8 * BITS(10, 11))) & 0xff;
3239 DEST = Rm; 3218 DEST = Rm;
3240 } 3219 }
3241
3242 } 3220 }
3243#endif 3221#endif
3244 if (BIT (4)) { 3222 if (BIT (4)) {
@@ -3285,7 +3263,6 @@ mainswitch:
3285 state->NtransSig = (state->Mode & 3) ? HIGH : LOW; 3263 state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
3286 break; 3264 break;
3287 3265
3288
3289 case 0x70: /* Store Word, No WriteBack, Pre Dec, Reg. */ 3266 case 0x70: /* Store Word, No WriteBack, Pre Dec, Reg. */
3290 if (BIT (4)) { 3267 if (BIT (4)) {
3291#ifdef MODE32 3268#ifdef MODE32
@@ -3489,7 +3466,6 @@ mainswitch:
3489 LSBase = temp; 3466 LSBase = temp;
3490 break; 3467 break;
3491 3468
3492
3493 /* Multiple Data Transfer Instructions. */ 3469 /* Multiple Data Transfer Instructions. */
3494 3470
3495 case 0x80: /* Store, No WriteBack, Post Dec. */ 3471 case 0x80: /* Store, No WriteBack, Post Dec. */
@@ -3636,7 +3612,6 @@ mainswitch:
3636 LOADSMULT (instr, temp + 4L, temp + LSMNumRegs); 3612 LOADSMULT (instr, temp + 4L, temp + LSMNumRegs);
3637 break; 3613 break;
3638 3614
3639
3640 /* Branch forward. */ 3615 /* Branch forward. */
3641 case 0xa0: 3616 case 0xa0:
3642 case 0xa1: 3617 case 0xa1:
@@ -3650,7 +3625,6 @@ mainswitch:
3650 FLUSHPIPE; 3625 FLUSHPIPE;
3651 break; 3626 break;
3652 3627
3653
3654 /* Branch backward. */ 3628 /* Branch backward. */
3655 case 0xa8: 3629 case 0xa8:
3656 case 0xa9: 3630 case 0xa9:
@@ -3664,7 +3638,6 @@ mainswitch:
3664 FLUSHPIPE; 3638 FLUSHPIPE;
3665 break; 3639 break;
3666 3640
3667
3668 /* Branch and Link forward. */ 3641 /* Branch and Link forward. */
3669 case 0xb0: 3642 case 0xb0:
3670 case 0xb1: 3643 case 0xb1:
@@ -3690,10 +3663,8 @@ mainswitch:
3690 printf("call %08X %08X %s(%08X %08X %08X %08X %08X %08X %08X)\n", state->Reg[14], state->Reg[15], a, state->Reg[0], state->Reg[1], state->Reg[2], state->Reg[3], mem_Read32(state->Reg[13]), mem_Read32(state->Reg[13] - 4),mem_Read32(state->Reg[13] - 8)); 3663 printf("call %08X %08X %s(%08X %08X %08X %08X %08X %08X %08X)\n", state->Reg[14], state->Reg[15], a, state->Reg[0], state->Reg[1], state->Reg[2], state->Reg[3], mem_Read32(state->Reg[13]), mem_Read32(state->Reg[13] - 4),mem_Read32(state->Reg[13] - 8));
3691#endif 3664#endif
3692 3665
3693
3694 break; 3666 break;
3695 3667
3696
3697 /* Branch and Link backward. */ 3668 /* Branch and Link backward. */
3698 case 0xb8: 3669 case 0xb8:
3699 case 0xb9: 3670 case 0xb9:
@@ -3712,18 +3683,14 @@ mainswitch:
3712 state->Reg[15] = pc + 8 + NEGBRANCH; 3683 state->Reg[15] = pc + 8 + NEGBRANCH;
3713 FLUSHPIPE; 3684 FLUSHPIPE;
3714 3685
3715
3716#ifdef callstacker 3686#ifdef callstacker
3717 memset(a, 0, 256); 3687 memset(a, 0, 256);
3718 aufloeser(a, state->Reg[15]); 3688 aufloeser(a, state->Reg[15]);
3719 printf("call %08X %08X %s(%08X %08X %08X %08X %08X %08X %08X)\n", state->Reg[14], state->Reg[15], a, state->Reg[0], state->Reg[1], state->Reg[2], state->Reg[3], mem_Read32(state->Reg[13]), mem_Read32(state->Reg[13] - 4),mem_Read32(state->Reg[13] - 8)); 3689 printf("call %08X %08X %s(%08X %08X %08X %08X %08X %08X %08X)\n", state->Reg[14], state->Reg[15], a, state->Reg[0], state->Reg[1], state->Reg[2], state->Reg[3], mem_Read32(state->Reg[13]), mem_Read32(state->Reg[13] - 4),mem_Read32(state->Reg[13] - 8));
3720#endif 3690#endif
3721 3691
3722
3723
3724 break; 3692 break;
3725 3693
3726
3727 /* Co-Processor Data Transfers. */ 3694 /* Co-Processor Data Transfers. */
3728 case 0xc4: 3695 case 0xc4:
3729 if ((instr & 0x0FF00FF0) == 0xC400B10) { //vmov BIT(0-3), BIT(12-15), BIT(16-20), vmov d0, r0, r0 3696 if ((instr & 0x0FF00FF0) == 0xC400B10) { //vmov BIT(0-3), BIT(12-15), BIT(16-20), vmov d0, r0, r0
@@ -3859,7 +3826,6 @@ mainswitch:
3859 ARMul_LDC (state, instr, lhs); 3826 ARMul_LDC (state, instr, lhs);
3860 break; 3827 break;
3861 3828
3862
3863 /* Co-Processor Register Transfers (MCR) and Data Ops. */ 3829 /* Co-Processor Register Transfers (MCR) and Data Ops. */
3864 3830
3865 case 0xe2: 3831 case 0xe2:
@@ -3891,7 +3857,6 @@ mainswitch:
3891 ARMul_CDP (state, instr); 3857 ARMul_CDP (state, instr);
3892 break; 3858 break;
3893 3859
3894
3895 /* Co-Processor Register Transfers (MRC) and Data Ops. */ 3860 /* Co-Processor Register Transfers (MRC) and Data Ops. */
3896 case 0xe1: 3861 case 0xe1:
3897 case 0xe3: 3862 case 0xe3:
@@ -3916,7 +3881,6 @@ mainswitch:
3916 ARMul_CDP (state, instr); 3881 ARMul_CDP (state, instr);
3917 break; 3882 break;
3918 3883
3919
3920 /* SWI instruction. */ 3884 /* SWI instruction. */
3921 case 0xf0: 3885 case 0xf0:
3922 case 0xf1: 3886 case 0xf1:
@@ -3936,7 +3900,7 @@ mainswitch:
3936 case 0xff: 3900 case 0xff:
3937 //svc_Execute(state, BITS(0, 23)); 3901 //svc_Execute(state, BITS(0, 23));
3938 HLE::CallSVC(instr); 3902 HLE::CallSVC(instr);
3939 3903
3940 break; 3904 break;
3941 } 3905 }
3942 } 3906 }
@@ -4118,7 +4082,6 @@ TEST_EMULATE:
4118 // continue; 4082 // continue;
4119 else if (state->Emulate != RUN) 4083 else if (state->Emulate != RUN)
4120 break; 4084 break;
4121
4122 } 4085 }
4123 4086
4124 while (state->NumInstrsToExecute); 4087 while (state->NumInstrsToExecute);
@@ -4156,7 +4119,6 @@ exit:
4156 static FILE *fd; 4119 static FILE *fd;
4157 4120
4158 /*if (!init) { 4121 /*if (!init) {
4159
4160 fd = fopen("./pc.txt", "w"); 4122 fd = fopen("./pc.txt", "w");
4161 if (!fd) { 4123 if (!fd) {
4162 exit(-1); 4124 exit(-1);
@@ -4725,8 +4687,6 @@ out:
4725 address, DEST); \ 4687 address, DEST); \
4726 } 4688 }
4727 4689
4728
4729
4730 static unsigned 4690 static unsigned
4731 LoadWord (ARMul_State * state, ARMword instr, ARMword address) { 4691 LoadWord (ARMul_State * state, ARMword instr, ARMword address) {
4732 ARMword dest; 4692 ARMword dest;
@@ -5158,7 +5118,6 @@ out:
5158 /*chy 2004-05-23 chy goto end */ 5118 /*chy 2004-05-23 chy goto end */
5159 if (state->Aborted) 5119 if (state->Aborted)
5160 goto L_ldm_makeabort; 5120 goto L_ldm_makeabort;
5161
5162 } 5121 }
5163 5122
5164 if (BIT (15) && !state->Aborted) 5123 if (BIT (15) && !state->Aborted)
@@ -5202,7 +5161,6 @@ L_ldm_makeabort:
5202 LSBase = WBBase; 5161 LSBase = WBBase;
5203 } 5162 }
5204 /* chy 2005-11-24, over */ 5163 /* chy 2005-11-24, over */
5205
5206 } 5164 }
5207 5165
5208 /* This function does the work of loading the registers listed in an LDM 5166 /* This function does the work of loading the registers listed in an LDM
@@ -5405,7 +5363,6 @@ L_ldm_s_makeabort:
5405 //chy 2004-05-23, needn't store other when aborted 5363 //chy 2004-05-23, needn't store other when aborted
5406 if (state->Aborted) 5364 if (state->Aborted)
5407 goto L_stm_takeabort; 5365 goto L_stm_takeabort;
5408
5409 } 5366 }
5410 5367
5411//chy 2004-05-23,should compare the Abort Models 5368//chy 2004-05-23,should compare the Abort Models
@@ -5508,7 +5465,6 @@ L_stm_takeabort:
5508 /* Restore the correct bank. */ 5465 /* Restore the correct bank. */
5509 (void) ARMul_SwitchMode (state, USER26MODE, state->Mode); 5466 (void) ARMul_SwitchMode (state, USER26MODE, state->Mode);
5510 5467
5511
5512//chy 2004-05-23,should compare the Abort Models 5468//chy 2004-05-23,should compare the Abort Models
5513L_stm_s_takeabort: 5469L_stm_s_takeabort:
5514 if (BIT (21) && LHSReg != 15) { 5470 if (BIT (21) && LHSReg != 15) {
@@ -5763,7 +5719,6 @@ L_stm_s_takeabort:
5763 TAKEABORT; 5719 TAKEABORT;
5764 } 5720 }
5765 5721
5766
5767 if (enter) { 5722 if (enter) {
5768 ARMul_StoreByte(state, lhs, RHS); 5723 ARMul_StoreByte(state, lhs, RHS);
5769 state->Reg[DESTReg] = 0; 5724 state->Reg[DESTReg] = 0;
@@ -6285,7 +6240,7 @@ L_stm_s_takeabort:
6285 u32 rm = ((state->Reg[BITS(0, 3)] >> rotation) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - rotation)) & 0xFF) & 0xFF); 6240 u32 rm = ((state->Reg[BITS(0, 3)] >> rotation) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - rotation)) & 0xFF) & 0xFF);
6286 if (rm & 0x80) 6241 if (rm & 0x80)
6287 rm |= 0xffffff00; 6242 rm |= 0xffffff00;
6288 6243
6289 // SXTB, otherwise SXTAB 6244 // SXTB, otherwise SXTAB
6290 if (BITS(16, 19) == 0xf) 6245 if (BITS(16, 19) == 0xf)
6291 state->Reg[BITS(12, 15)] = rm; 6246 state->Reg[BITS(12, 15)] = rm;
@@ -6371,7 +6326,7 @@ L_stm_s_takeabort:
6371 const s16 max = 0xFFFF >> (16 - num_bits); 6326 const s16 max = 0xFFFF >> (16 - num_bits);
6372 s16 rn_lo = (state->Reg[rn_idx]); 6327 s16 rn_lo = (state->Reg[rn_idx]);
6373 s16 rn_hi = (state->Reg[rn_idx] >> 16); 6328 s16 rn_hi = (state->Reg[rn_idx] >> 16);
6374 6329
6375 if (max < rn_lo) { 6330 if (max < rn_lo) {
6376 rn_lo = max; 6331 rn_lo = max;
6377 SETQ; 6332 SETQ;
@@ -6379,7 +6334,7 @@ L_stm_s_takeabort:
6379 rn_lo = 0; 6334 rn_lo = 0;
6380 SETQ; 6335 SETQ;
6381 } 6336 }
6382 6337
6383 if (max < rn_hi) { 6338 if (max < rn_hi) {
6384 rn_hi = max; 6339 rn_hi = max;
6385 SETQ; 6340 SETQ;
@@ -6387,14 +6342,14 @@ L_stm_s_takeabort:
6387 rn_hi = 0; 6342 rn_hi = 0;
6388 SETQ; 6343 SETQ;
6389 } 6344 }
6390 6345
6391 state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi << 16) & 0xFFFF); 6346 state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi << 16) & 0xFFFF);
6392 return 1; 6347 return 1;
6393 } 6348 }
6394 else if (op2 == 0x03) { 6349 else if (op2 == 0x03) {
6395 const u8 rotate = BITS(10, 11) * 8; 6350 const u8 rotate = BITS(10, 11) * 8;
6396 const u32 rm = ((state->Reg[BITS(0, 3)] >> rotate) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - rotate)) & 0xFF) & 0xFF); 6351 const u32 rm = ((state->Reg[BITS(0, 3)] >> rotate) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - rotate)) & 0xFF) & 0xFF);
6397 6352
6398 if (BITS(16, 19) == 0xf) 6353 if (BITS(16, 19) == 0xf)
6399 /* UXTB */ 6354 /* UXTB */
6400 state->Reg[BITS(12, 15)] = rm; 6355 state->Reg[BITS(12, 15)] = rm;