/[gxemul]/trunk/src/cpus/cpu_ppc_instr.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/cpu_ppc_instr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
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   *   *
# Line 190  X(bclr) Line 190  X(bclr)
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) {
# Line 228  X(bclr_l) Line 228  X(bclr_l)
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    
# Line 272  X(bclr_l) Line 272  X(bclr_l)
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;
# Line 369  X(bc) Line 369  X(bc)
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)  );
# Line 393  X(bcl) Line 393  X(bcl)
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)  );
# Line 428  X(bc_samepage) Line 428  X(bc_samepage)
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)  );
# Line 464  X(bcl_samepage) Line 464  X(bcl_samepage)
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)  );
# Line 2766  X(to_be_translated) Line 2766  X(to_be_translated)
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;
# Line 2822  X(to_be_translated) Line 2823  X(to_be_translated)
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;
# Line 2940  X(to_be_translated) Line 2942  X(to_be_translated)
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)
# Line 2961  X(to_be_translated) Line 2964  X(to_be_translated)
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) {
# Line 3076  X(to_be_translated) Line 3080  X(to_be_translated)
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
# Line 3198  X(to_be_translated) Line 3208  X(to_be_translated)
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;
# Line 3242  X(to_be_translated) Line 3253  X(to_be_translated)
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]);
# Line 3296  X(to_be_translated) Line 3308  X(to_be_translated)
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]);
# Line 3332  X(to_be_translated) Line 3345  X(to_be_translated)
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;
# Line 3347  X(to_be_translated) Line 3361  X(to_be_translated)
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;
# Line 3432  X(to_be_translated) Line 3447  X(to_be_translated)
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;
# Line 3567  X(to_be_translated) Line 3583  X(to_be_translated)
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;
# Line 3653  X(to_be_translated) Line 3670  X(to_be_translated)
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) {
# Line 3703  X(to_be_translated) Line 3721  X(to_be_translated)
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                          }                          }
# Line 3711  X(to_be_translated) Line 3731  X(to_be_translated)
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;
# Line 3751  X(to_be_translated) Line 3772  X(to_be_translated)
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    
# Line 3792  X(to_be_translated) Line 3815  X(to_be_translated)
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    

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26