--- upstream/dynamips-0.2.7-RC1/ppc32_exec.c 2007/10/06 16:23:47 7 +++ upstream/dynamips-0.2.8-RC1/ppc32_exec.c 2007/10/06 16:33:40 11 @@ -51,7 +51,7 @@ for(i=0,count=0;ppc32_exec_tags[i].exec;i++) count++; - ilt = ilt_create(count+1, + ilt = ilt_create("ppc32e",count, (ilt_get_insn_cbk_t)ppc32_exec_get_insn, (ilt_check_cbk_t)ppc32_exec_chk_lo, (ilt_check_cbk_t)ppc32_exec_chk_hi); @@ -76,13 +76,13 @@ } /* Execute a memory operation */ -static forced_inline int ppc32_exec_memop(cpu_ppc_t *cpu,int memop, - m_uint32_t vaddr,u_int dst_reg) +static forced_inline void ppc32_exec_memop(cpu_ppc_t *cpu,int memop, + m_uint32_t vaddr,u_int dst_reg) { fastcall ppc_memop_fn fn; fn = cpu->mem_op_fn[memop]; - return(fn(cpu,vaddr,dst_reg)); + fn(cpu,vaddr,dst_reg); } /* Fetch an instruction */ @@ -103,6 +103,14 @@ return(0); } +/* Unknown opcode */ +static fastcall int ppc32_exec_unknown(cpu_ppc_t *cpu,ppc_insn_t insn) +{ + printf("PPC32: unknown opcode 0x%8.8x at ia = 0x%x\n",insn,cpu->ia); + ppc32_dump_regs(cpu->gen); + return(0); +} + /* Execute a single instruction */ static forced_inline int ppc32_exec_single_instruction(cpu_ppc_t *cpu,ppc_insn_t instruction) @@ -110,7 +118,7 @@ register fastcall int (*exec)(cpu_ppc_t *,ppc_insn_t) = NULL; struct ppc32_insn_exec_tag *tag; int index; - + #if DEBUG_INSN_PERF_CNT cpu->perf_counter++; #endif @@ -120,18 +128,11 @@ tag = ppc32_exec_get_insn(index); exec = tag->exec; - if (likely(exec != NULL)) { #if NJM_STATS_ENABLE - cpu->insn_exec_count++; - ppc32_exec_tags[index].count++; + cpu->insn_exec_count++; + ppc32_exec_tags[index].count++; #endif - return(exec(cpu,instruction)); - } - - printf("PPC32: unknown opcode 0x%8.8x at ia = 0x%x\n", - instruction,cpu->ia); - ppc32_dump_regs(cpu->gen); - return(0); + return(exec(cpu,instruction)); } /* Execute a single instruction (external) */ @@ -144,6 +145,28 @@ return(res); } +/* Execute a page */ +fastcall int ppc32_exec_page(cpu_ppc_t *cpu) +{ + m_uint32_t exec_page,offset; + ppc_insn_t insn; + int res; + + exec_page = cpu->ia & ~PPC32_MIN_PAGE_IMASK; + cpu->njm_exec_page = exec_page; + cpu->njm_exec_ptr = cpu->mem_op_lookup(cpu,exec_page,PPC32_MTS_ICACHE); + + do { + offset = (cpu->ia & PPC32_MIN_PAGE_IMASK) >> 2; + insn = vmtoh32(cpu->njm_exec_ptr[offset]); + + res = ppc32_exec_single_instruction(cpu,insn); + if (likely(!res)) cpu->ia += sizeof(ppc_insn_t); + }while((cpu->ia & ~PPC32_MIN_PAGE_IMASK) == exec_page); + + return(0); +} + /* Run PowerPC code in step-by-step mode */ void *ppc32_exec_run_cpu(cpu_gen_t *gen) { @@ -163,6 +186,7 @@ } gen->cpu_thread_running = TRUE; + cpu_exec_loop_set(gen); start_cpu: for(;;) { @@ -237,19 +261,18 @@ m_uint32_t res; if (val & 0x80000000) - res = PPC32_CR0_LT; + res = 1 << PPC32_CR_LT_BIT; else { if (val > 0) - res = PPC32_CR0_GT; + res = 1 << PPC32_CR_GT_BIT; else - res = PPC32_CR0_EQ; + res = 1 << PPC32_CR_EQ_BIT; } if (cpu->xer & PPC32_XER_SO) - res |= PPC32_CR0_SO; + res |= 1 << PPC32_CR_SO_BIT; - cpu->cr &= ~(PPC32_CR0_LT|PPC32_CR0_GT|PPC32_CR0_EQ|PPC32_CR0_SO); - cpu->cr |= res; + cpu->cr_fields[0] = res; } /* @@ -312,13 +335,15 @@ { u_int ctr_ok = TRUE; u_int cond_ok; + u_int cr_bit; if (!(bo & 0x04)) { cpu->ctr--; ctr_ok = (cpu->ctr != 0) ^ ((bo >> 1) & 0x1); } - cond_ok = (bo >> 4) | (((cpu->cr >> (31 - bi)) ^ (~bo >> 3)) & 0x1); + cr_bit = ppc32_read_cr_bit(cpu,bi); + cond_ok = (bo >> 4) | ((cr_bit ^ (~bo >> 3)) & 0x1); return(ctr_ok & cond_ok); } @@ -1005,9 +1030,8 @@ if (cpu->xer & PPC32_XER_SO) res |= 0x01; - - cpu->cr &= ~(0xF0000000 >> (rd << 2)); - cpu->cr |= res << (28 - (rd << 2)); + + cpu->cr_fields[rd] = res; return(0); } @@ -1035,8 +1059,7 @@ if (cpu->xer & PPC32_XER_SO) res |= 0x01; - cpu->cr &= ~(0xF0000000 >> (rd << 2)); - cpu->cr |= res << (28 - (rd << 2)); + cpu->cr_fields[rd] = res; return(0); } @@ -1063,8 +1086,7 @@ if (cpu->xer & PPC32_XER_SO) res |= 0x01; - cpu->cr &= ~(0xF0000000 >> (rd << 2)); - cpu->cr |= res << (28 - (rd << 2)); + cpu->cr_fields[rd] = res; return(0); } @@ -1090,8 +1112,7 @@ if (cpu->xer & PPC32_XER_SO) res |= 0x01; - cpu->cr &= ~(0xF0000000 >> (rd << 2)); - cpu->cr |= res << (28 - (rd << 2)); + cpu->cr_fields[rd] = res; return(0); } @@ -1125,13 +1146,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp &= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp &= ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1144,13 +1165,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp ^= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp ^= ppc32_read_cr_bit(cpu,bb); if (!(tmp & 0x1)) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1163,13 +1184,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp &= ~(cpu->cr >> (31 - bb)); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp &= ~ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1182,13 +1203,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp &= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp &= ppc32_read_cr_bit(cpu,bb); if (!(tmp & 0x1)) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1201,13 +1222,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp |= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp |= ppc32_read_cr_bit(cpu,bb); if (!(tmp & 0x1)) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1220,13 +1241,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp |= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp |= ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1239,13 +1260,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp |= ~(cpu->cr >> (31 - bb)); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp |= ~ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1258,13 +1279,13 @@ int ba = bits(insn,11,15); m_uint32_t tmp; - tmp = cpu->cr >> (31 - ba); - tmp ^= cpu->cr >> (31 - bb); + tmp = ppc32_read_cr_bit(cpu,ba); + tmp ^= ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) - cpu->cr |= 1 << (31 - bd); + ppc32_set_cr_bit(cpu,bd); else - cpu->cr &= ~(1 << (31 - bd)); + ppc32_clear_cr_bit(cpu,bd); return(0); } @@ -1480,7 +1501,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0)); + ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0); + return(0); } /* ISYNC - Instruction Synchronize */ @@ -1502,7 +1524,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); + return(0); } /* LBZU - Load Byte and Zero with Update */ @@ -1512,12 +1535,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LBZUX - Load Byte and Zero with Update Indexed */ @@ -1527,12 +1549,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LBZX - Load Byte and Zero Indexed */ @@ -1548,7 +1569,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); + return(0); } /* LHA - Load Half-Word Algebraic */ @@ -1564,7 +1586,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); + return(0); } /* LHAU - Load Half-Word Algebraic with Update */ @@ -1574,12 +1597,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LHAUX - Load Half-Word Algebraic with Update Indexed */ @@ -1589,12 +1611,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LHAX - Load Half-Word Algebraic ndexed */ @@ -1610,7 +1631,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); + return(0); } /* LHZ - Load Half-Word and Zero */ @@ -1626,7 +1648,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); + return(0); } /* LHZU - Load Half-Word and Zero with Update */ @@ -1636,12 +1659,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LHZUX - Load Half-Word and Zero with Update Indexed */ @@ -1651,12 +1673,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LHZX - Load Half-Word and Zero Indexed */ @@ -1672,7 +1693,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); + return(0); } /* LMW - Load Multiple Word */ @@ -1682,7 +1704,7 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int r,res; + int r; vaddr = sign_extend_32(imm,16); @@ -1690,9 +1712,7 @@ vaddr += cpu->gpr[ra]; for(r=rd;r<=31;r++) { - res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r); - if (res != 0) return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r); vaddr += sizeof(m_uint32_t); } @@ -1712,7 +1732,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd); + return(0); } /* LWZ - Load Word and Zero */ @@ -1728,7 +1749,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); + return(0); } /* LWZU - Load Word and Zero with Update */ @@ -1738,12 +1760,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LWZUX - Load Word and Zero with Update Indexed */ @@ -1753,12 +1774,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LWZX - Load Word and Zero Indexed */ @@ -1774,7 +1794,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); + return(0); } /* LWARX - Load Word and Reserve Indexed */ @@ -1791,8 +1812,8 @@ vaddr += cpu->gpr[ra]; cpu->reserve = 1; - - return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); + return(0); } /* LFD - Load Floating-Point Double */ @@ -1808,7 +1829,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); + return(0); } /* LFDU - Load Floating-Point Double with Update */ @@ -1818,12 +1840,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LFDUX - Load Floating-Point Double with Update Indexed */ @@ -1833,12 +1854,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); + ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* LFDX - Load Floating-Point Double Indexed */ @@ -1854,7 +1874,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd)); + ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); + return(0); } /* LSWI - Load String Word Immediate */ @@ -1864,7 +1885,7 @@ int ra = bits(insn,16,20); int nb = bits(insn,11,15); m_uint32_t vaddr = 0; - int res,r; + int r; if (ra != 0) vaddr += cpu->gpr[ra]; @@ -1881,9 +1902,7 @@ cpu->gpr[r] = 0; } - if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r)) != 0) - return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r); cpu->sw_pos += 8; if (cpu->sw_pos == 32) @@ -1903,7 +1922,7 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res,r,nb; + int r,nb; vaddr = cpu->gpr[rb]; @@ -1920,9 +1939,7 @@ cpu->gpr[r] = 0; } - if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r)) != 0) - return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r); cpu->sw_pos += 8; if (cpu->sw_pos == 32) @@ -1940,16 +1957,8 @@ { int rd = bits(insn,23,25); int rs = bits(insn,18,20); - m_uint32_t tmp,dmask; - - tmp = (cpu->cr >> (28 - (rs << 2))) & 0xF; - - /* clear the destination bits */ - dmask = (0xF0000000 >> (rd << 2)); - cpu->cr &= ~dmask; - /* set the new field value */ - cpu->cr |= tmp << (28 - (rd << 2)); + cpu->cr_fields[rd] = cpu->cr_fields[rs]; return(0); } @@ -1958,7 +1967,7 @@ { int rd = bits(insn,21,25); - cpu->gpr[rd] = cpu->cr; + cpu->gpr[rd] = ppc32_get_cr(cpu); return(0); } @@ -2064,7 +2073,7 @@ /* MPC860 IMMR */ case 638: - cpu->gpr[rd] = 0x68010000; + cpu->gpr[rd] = cpu->mpc860_immr; break; default: @@ -2100,14 +2109,12 @@ { int rs = bits(insn,21,25); int crm = bits(insn,12,19); - m_uint32_t mask = 0; int i; for(i=0;i<8;i++) - if (crm & (1 << i)) - mask |= 0xF << (i << 2); + if (crm & (1 << (7 - i))) + cpu->cr_fields[i] = (cpu->gpr[rs] >> (28 - (i << 2))) & 0x0F; - cpu->cr = (cpu->gpr[rs] & mask) | (cpu->cr & ~mask); return(0); } @@ -2827,7 +2834,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); + return(0); } /* STBU - Store Byte with Update */ @@ -2837,12 +2845,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STBUX - Store Byte with Update Indexed */ @@ -2852,12 +2859,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STBX - Store Byte Indexed */ @@ -2873,7 +2879,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); + return(0); } /* STH - Store Half-Word */ @@ -2889,7 +2896,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); + return(0); } /* STHU - Store Half-Word with Update */ @@ -2899,12 +2907,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STHUX - Store Half-Word with Update Indexed */ @@ -2914,12 +2921,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STHX - Store Half-Word Indexed */ @@ -2935,7 +2941,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); + return(0); } /* STMW - Store Multiple Word */ @@ -2945,7 +2952,7 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int r,res; + int r; vaddr = sign_extend_32(imm,16); @@ -2953,9 +2960,7 @@ vaddr += cpu->gpr[ra]; for(r=rs;r<=31;r++) { - res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,r); - if (res != 0) return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,r); vaddr += sizeof(m_uint32_t); } @@ -2975,7 +2980,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); + return(0); } /* STWU - Store Word with Update */ @@ -2985,12 +2991,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STWUX - Store Word with Update Indexed */ @@ -3000,12 +3005,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STWX - Store Word Indexed */ @@ -3021,7 +3025,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); + return(0); } /* STWBRX - Store Word Byte-Reverse Indexed */ @@ -3037,7 +3042,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STWBR,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STWBR,vaddr,rs); + return(0); } /* STWCX. - Store Word Conditional Indexed */ @@ -3047,7 +3053,6 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[rb]; @@ -3055,21 +3060,19 @@ vaddr += cpu->gpr[ra]; if (cpu->reserve) { - res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); - if (res != 0) return(res); + ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); - cpu->cr &= ~0xF0000000; - cpu->cr |= PPC32_CR0_EQ; + cpu->cr_fields[0] = 1 << PPC32_CR_EQ_BIT; if (cpu->xer & PPC32_XER_SO) - cpu->cr |= PPC32_CR0_SO; + cpu->cr_fields[0] |= 1 << PPC32_CR_SO_BIT; cpu->reserve = 0; } else { - cpu->cr &= ~0xF0000000; + cpu->cr_fields[0] = 0; if (cpu->xer & PPC32_XER_SO) - cpu->cr |= PPC32_CR0_SO; + cpu->cr_fields[0] |= 1 << PPC32_CR_SO_BIT; } return(0); @@ -3088,7 +3091,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); + return(0); } /* STFDU - Store Floating-Point Double with Update */ @@ -3098,12 +3102,11 @@ int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); - res = ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STFDUX - Store Floating-Point Double with Update Indexed */ @@ -3113,12 +3116,11 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res; vaddr = cpu->gpr[ra] + cpu->gpr[rb]; - res = ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); + ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); cpu->gpr[ra] = vaddr; - return(res); + return(0); } /* STFDX - Store Floating-Point Double Indexed */ @@ -3134,7 +3136,8 @@ if (ra != 0) vaddr += cpu->gpr[ra]; - return(ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs)); + ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); + return(0); } /* STSWI - Store String Word Immediate */ @@ -3144,7 +3147,7 @@ int ra = bits(insn,16,20); int nb = bits(insn,11,15); m_uint32_t vaddr = 0; - int res,r; + int r; if (ra != 0) vaddr += cpu->gpr[ra]; @@ -3159,9 +3162,7 @@ if (cpu->sw_pos == 0) r = (r + 1) & 0x1F; - if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r)) != 0) - return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r); cpu->sw_pos += 8; if (cpu->sw_pos == 32) @@ -3181,7 +3182,7 @@ int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t vaddr; - int res,r,nb; + int r,nb; vaddr = cpu->gpr[rb]; @@ -3196,9 +3197,7 @@ if (cpu->sw_pos == 0) r = (r + 1) & 0x1F; - if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r)) != 0) - return(res); - + ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r); cpu->sw_pos += 8; if (cpu->sw_pos == 32) @@ -3847,5 +3846,8 @@ { "tlbre" , ppc32_exec_TLBRE , 0xfc0007ff , 0x7c000764, 0 }, { "tlbwe" , ppc32_exec_TLBWE , 0xfc0007ff , 0x7c0007a4, 0 }, - { NULL , NULL , 0x00000000 , 0x00000000, 0 }, + /* Unknown opcode fallback */ + { "unknown" , ppc32_exec_unknown , 0x00000000 , 0x00000000, 0 }, + + { NULL , NULL, 0, 0, 0 }, };