25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_ppc_instr.c,v 1.73 2007/02/17 10:06:19 debug Exp $ |
* $Id: cpu_ppc_instr.c,v 1.75 2007/06/15 06:26:20 debug Exp $ |
29 |
* |
* |
30 |
* POWER/PowerPC instructions. |
* POWER/PowerPC instructions. |
31 |
* |
* |
190 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
191 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
192 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
193 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
194 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
195 |
cond_ok |= ( ((bo >> 3) & 1) == ((cpu->cd.ppc.cr >> bi31m) & 1) ); |
cond_ok |= ( ((bo >> 3) & 1) == ((cpu->cd.ppc.cr >> bi31m) & 1) ); |
196 |
if (ctr_ok && cond_ok) { |
if (ctr_ok && cond_ok) { |
228 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
229 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
230 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
231 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
232 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
233 |
cond_ok |= ( ((bo >> 3) & 1) == ((cpu->cd.ppc.cr >> bi31m) & 1) ); |
cond_ok |= ( ((bo >> 3) & 1) == ((cpu->cd.ppc.cr >> bi31m) & 1) ); |
234 |
|
|
272 |
*/ |
*/ |
273 |
X(bcctr) |
X(bcctr) |
274 |
{ |
{ |
275 |
unsigned int bo = ic->arg[0], bi31m = ic->arg[1] /*,bh = ic->arg[2]*/; |
unsigned int bo = ic->arg[0], bi31m = ic->arg[1]; |
276 |
uint64_t old_pc = cpu->pc; |
uint64_t old_pc = cpu->pc; |
277 |
MODE_uint_t addr = cpu->cd.ppc.spr[SPR_CTR]; |
MODE_uint_t addr = cpu->cd.ppc.spr[SPR_CTR]; |
278 |
int cond_ok = (bo >> 4) & 1; |
int cond_ok = (bo >> 4) & 1; |
369 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
370 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
371 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
372 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
373 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
374 |
cond_ok |= ( ((bo >> 3) & 1) == |
cond_ok |= ( ((bo >> 3) & 1) == |
375 |
((cpu->cd.ppc.cr >> (bi31m)) & 1) ); |
((cpu->cd.ppc.cr >> (bi31m)) & 1) ); |
393 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
394 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
395 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
396 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
397 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
398 |
cond_ok |= ( ((bo >> 3) & 1) == |
cond_ok |= ( ((bo >> 3) & 1) == |
399 |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
428 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
429 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
430 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
431 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
432 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
433 |
cond_ok |= ( ((bo >> 3) & 1) == |
cond_ok |= ( ((bo >> 3) & 1) == |
434 |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
464 |
cpu->cd.ppc.spr[SPR_CTR] --; |
cpu->cd.ppc.spr[SPR_CTR] --; |
465 |
ctr_ok = (bo >> 2) & 1; |
ctr_ok = (bo >> 2) & 1; |
466 |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
tmp = cpu->cd.ppc.spr[SPR_CTR]; |
467 |
ctr_ok |= ( (tmp != 0) ^ ((bo >> 1) & 1) ); |
ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) ); |
468 |
cond_ok = (bo >> 4) & 1; |
cond_ok = (bo >> 4) & 1; |
469 |
cond_ok |= ( ((bo >> 3) & 1) == |
cond_ok |= ( ((bo >> 3) & 1) == |
470 |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
((cpu->cd.ppc.cr >> bi31m) & 1) ); |
2766 |
ic->arg[1] = 19; |
ic->arg[1] = 19; |
2767 |
ic->arg[2] = 19; |
ic->arg[2] = 19; |
2768 |
} else { |
} else { |
2769 |
fatal("[ TODO: Unimplemented ALTIVEC, iword" |
if (!cpu->translation_readahead) |
2770 |
" = 0x%08"PRIx32"x ]\n", iword); |
fatal("[ TODO: Unimplemented ALTIVEC, iword" |
2771 |
|
" = 0x%08"PRIx32"x ]\n", iword); |
2772 |
goto bad; |
goto bad; |
2773 |
} |
} |
2774 |
break; |
break; |
2823 |
case PPC_HI6_ADDIC: |
case PPC_HI6_ADDIC: |
2824 |
case PPC_HI6_ADDIC_DOT: |
case PPC_HI6_ADDIC_DOT: |
2825 |
if (cpu->cd.ppc.bits == 64) { |
if (cpu->cd.ppc.bits == 64) { |
2826 |
fatal("addic for 64-bit: TODO\n"); |
if (!cpu->translation_readahead) |
2827 |
|
fatal("addic for 64-bit: TODO\n"); |
2828 |
goto bad; |
goto bad; |
2829 |
} |
} |
2830 |
rt = (iword >> 21) & 31; |
rt = (iword >> 21) & 31; |
2942 |
+ 32*update]; |
+ 32*update]; |
2943 |
} |
} |
2944 |
if (ra == 0 && update) { |
if (ra == 0 && update) { |
2945 |
fatal("TODO: ra=0 && update?\n"); |
if (!cpu->translation_readahead) |
2946 |
|
fatal("TODO: ra=0 && update?\n"); |
2947 |
goto bad; |
goto bad; |
2948 |
} |
} |
2949 |
if (fp) |
if (fp) |
2964 |
bi = (iword >> 16) & 31; |
bi = (iword >> 16) & 31; |
2965 |
tmp_addr = (int64_t)(int16_t)(iword & 0xfffc); |
tmp_addr = (int64_t)(int16_t)(iword & 0xfffc); |
2966 |
if (aa_bit) { |
if (aa_bit) { |
2967 |
fatal("aa_bit: NOT YET\n"); |
if (!cpu->translation_readahead) |
2968 |
|
fatal("aa_bit: NOT YET\n"); |
2969 |
goto bad; |
goto bad; |
2970 |
} |
} |
2971 |
if (lk_bit) { |
if (lk_bit) { |
3080 |
ic->f = instr(bclr_20); |
ic->f = instr(bclr_20); |
3081 |
} |
} |
3082 |
} else { |
} else { |
3083 |
|
if (!(bo & 4)) { |
3084 |
|
if (!cpu->translation_readahead) |
3085 |
|
fatal("TODO: bclr/bcctr " |
3086 |
|
"bo bit 2 clear!\n"); |
3087 |
|
goto bad; |
3088 |
|
} |
3089 |
if (lk_bit) |
if (lk_bit) |
3090 |
ic->f = instr(bcctr_l); |
ic->f = instr(bcctr_l); |
3091 |
else |
else |
3208 |
} |
} |
3209 |
ic->arg[0] = iword; |
ic->arg[0] = iword; |
3210 |
if (cpu->cd.ppc.bits == 32) { |
if (cpu->cd.ppc.bits == 32) { |
3211 |
fatal("TODO: rld* in 32-bit mode?\n"); |
if (!cpu->translation_readahead) |
3212 |
|
fatal("TODO: rld* in 32-bit mode?\n"); |
3213 |
goto bad; |
goto bad; |
3214 |
} |
} |
3215 |
break; |
break; |
3253 |
ra = (iword >> 16) & 31; |
ra = (iword >> 16) & 31; |
3254 |
rc = iword & 1; |
rc = iword & 1; |
3255 |
if (rc) { |
if (rc) { |
3256 |
fatal("TODO: rc\n"); |
if (!cpu->translation_readahead) |
3257 |
|
fatal("TODO: rc\n"); |
3258 |
goto bad; |
goto bad; |
3259 |
} |
} |
3260 |
ic->arg[0] = (size_t)(&cpu->cd.ppc.gpr[rs]); |
ic->arg[0] = (size_t)(&cpu->cd.ppc.gpr[rs]); |
3308 |
rs = (iword >> 21) & 31; |
rs = (iword >> 21) & 31; |
3309 |
l_bit = (iword >> 16) & 1; |
l_bit = (iword >> 16) & 1; |
3310 |
if (l_bit) { |
if (l_bit) { |
3311 |
fatal("TODO: mtmsr l-bit\n"); |
if (!cpu->translation_readahead) |
3312 |
|
fatal("TODO: mtmsr l-bit\n"); |
3313 |
goto bad; |
goto bad; |
3314 |
} |
} |
3315 |
ic->arg[0] = (size_t)(&cpu->cd.ppc.gpr[rs]); |
ic->arg[0] = (size_t)(&cpu->cd.ppc.gpr[rs]); |
3345 |
case PPC_31_MTSRIN: ic->f = instr(mtsrin); break; |
case PPC_31_MTSRIN: ic->f = instr(mtsrin); break; |
3346 |
} |
} |
3347 |
if (cpu->cd.ppc.bits == 64) { |
if (cpu->cd.ppc.bits == 64) { |
3348 |
fatal("Not yet for 64-bit mode\n"); |
if (!cpu->translation_readahead) |
3349 |
|
fatal("Not yet for 64-bit mode\n"); |
3350 |
goto bad; |
goto bad; |
3351 |
} |
} |
3352 |
break; |
break; |
3361 |
case PPC_31_MTSR: ic->f = instr(mtsr); break; |
case PPC_31_MTSR: ic->f = instr(mtsr); break; |
3362 |
} |
} |
3363 |
if (cpu->cd.ppc.bits == 64) { |
if (cpu->cd.ppc.bits == 64) { |
3364 |
fatal("Not yet for 64-bit mode\n"); |
if (!cpu->translation_readahead) |
3365 |
|
fatal("Not yet for 64-bit mode\n"); |
3366 |
goto bad; |
goto bad; |
3367 |
} |
} |
3368 |
break; |
break; |
3447 |
switch (spr) { |
switch (spr) { |
3448 |
case 268: ic->f = instr(mftb); break; |
case 268: ic->f = instr(mftb); break; |
3449 |
case 269: ic->f = instr(mftbu); break; |
case 269: ic->f = instr(mftbu); break; |
3450 |
default:fatal("mftb spr=%i?\n", spr); |
default:if (!cpu->translation_readahead) |
3451 |
|
fatal("mftb spr=%i?\n", spr); |
3452 |
goto bad; |
goto bad; |
3453 |
} |
} |
3454 |
break; |
break; |
3583 |
[size + 4*zero + 8*load + 16*update]; |
[size + 4*zero + 8*load + 16*update]; |
3584 |
} |
} |
3585 |
if (ra == 0 && update) { |
if (ra == 0 && update) { |
3586 |
fatal("TODO: ra=0 && update?\n"); |
if (!cpu->translation_readahead) |
3587 |
|
fatal("TODO: ra=0 && update?\n"); |
3588 |
goto bad; |
goto bad; |
3589 |
} |
} |
3590 |
break; |
break; |
3670 |
oe_bit = (iword >> 10) & 1; |
oe_bit = (iword >> 10) & 1; |
3671 |
rc = iword & 1; |
rc = iword & 1; |
3672 |
if (oe_bit) { |
if (oe_bit) { |
3673 |
fatal("oe_bit not yet implemented\n"); |
if (!cpu->translation_readahead) |
3674 |
|
fatal("oe_bit not yet implemented\n"); |
3675 |
goto bad; |
goto bad; |
3676 |
} |
} |
3677 |
switch (xo) { |
switch (xo) { |
3721 |
ic->f = instr(subfme_dot); break; |
ic->f = instr(subfme_dot); break; |
3722 |
case PPC_31_SUBFZE: |
case PPC_31_SUBFZE: |
3723 |
ic->f = instr(subfze_dot); break; |
ic->f = instr(subfze_dot); break; |
3724 |
default:fatal("RC bit not yet implemented\n"); |
default:if (!cpu->translation_readahead) |
3725 |
|
fatal("RC bit not yet " |
3726 |
|
"implemented\n"); |
3727 |
goto bad; |
goto bad; |
3728 |
} |
} |
3729 |
} |
} |
3731 |
ic->arg[1] = (size_t)(&cpu->cd.ppc.gpr[rb]); |
ic->arg[1] = (size_t)(&cpu->cd.ppc.gpr[rb]); |
3732 |
ic->arg[2] = (size_t)(&cpu->cd.ppc.gpr[rt]); |
ic->arg[2] = (size_t)(&cpu->cd.ppc.gpr[rt]); |
3733 |
if (cpu->cd.ppc.bits == 64 && n64) { |
if (cpu->cd.ppc.bits == 64 && n64) { |
3734 |
fatal("Not yet for 64-bit mode\n"); |
if (!cpu->translation_readahead) |
3735 |
|
fatal("Not yet for 64-bit mode\n"); |
3736 |
goto bad; |
goto bad; |
3737 |
} |
} |
3738 |
break; |
break; |
3772 |
rc = iword & 1; |
rc = iword & 1; |
3773 |
|
|
3774 |
if (rc) { |
if (rc) { |
3775 |
fatal("Floating point (59) with rc bit! TODO\n"); |
if (!cpu->translation_readahead) |
3776 |
|
fatal("Floating point (59) " |
3777 |
|
"with rc bit! TODO\n"); |
3778 |
goto bad; |
goto bad; |
3779 |
} |
} |
3780 |
|
|
3815 |
rc = iword & 1; |
rc = iword & 1; |
3816 |
|
|
3817 |
if (rc) { |
if (rc) { |
3818 |
fatal("Floating point (63) with rc bit! TODO\n"); |
if (!cpu->translation_readahead) |
3819 |
|
fatal("Floating point (63) " |
3820 |
|
"with rc bit! TODO\n"); |
3821 |
goto bad; |
goto bad; |
3822 |
} |
} |
3823 |
|
|