📄 ppc32_exec.c
字号:
if (((b + carry) < b) || (d < a)) cpu->xer_ca = 1; ppc32_exec_ov_sum(cpu,d,a,b); cpu->gpr[rd] = d; return(0);}/* ADDEO. */static fastcall int ppc32_exec_ADDEO_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); register m_uint32_t a,b,d; m_uint32_t carry; carry = cpu->xer_ca; cpu->xer_ca = 0; a = cpu->gpr[ra]; b = cpu->gpr[rb]; d = a + b + carry; if (((b + carry) < b) || (d < a)) cpu->xer_ca = 1; ppc32_exec_ov_sum(cpu,d,a,b); ppc32_exec_update_cr0(cpu,d); cpu->gpr[rd] = d; return(0);}/* ADDI - ADD Immediate */static fastcall int ppc32_exec_ADDI(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); int imm = bits(insn,0,15); register m_uint32_t tmp; tmp = sign_extend_32(imm,16); if (ra != 0) tmp += cpu->gpr[ra]; cpu->gpr[rd] = tmp; return(0);}/* ADDIC - ADD Immediate with Carry */static fastcall int ppc32_exec_ADDIC(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); int imm = bits(insn,0,15); register m_uint32_t a,d; a = cpu->gpr[ra]; d = a + sign_extend_32(imm,16); ppc32_exec_ca_sum(cpu,d,a,0); cpu->gpr[rd] = d; return(0);}/* ADDIC. */static fastcall int ppc32_exec_ADDIC_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); int imm = bits(insn,0,15); register m_uint32_t a,d; a = cpu->gpr[ra]; d = a + sign_extend_32(imm,16); ppc32_exec_ca_sum(cpu,d,a,0); ppc32_exec_update_cr0(cpu,d); cpu->gpr[rd] = d; return(0);}/* ADDIS - ADD Immediate Shifted */static fastcall int ppc32_exec_ADDIS(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); m_uint32_t imm = bits(insn,0,15); register m_uint32_t tmp; tmp = imm << 16; if (ra != 0) tmp += cpu->gpr[ra]; cpu->gpr[rd] = tmp; return(0);}/* ADDME - Add to Minus One Extended */static fastcall int ppc32_exec_ADDME(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); register m_uint32_t a,b,d; m_uint32_t carry; carry = cpu->xer_ca; cpu->xer_ca = 0; a = cpu->gpr[ra]; b = 0xFFFFFFFF; d = a + b + carry; if (((b + carry) < b) || (d < a)) cpu->xer_ca = 1; cpu->gpr[rd] = d; return(0);}/* ADDME. */static fastcall int ppc32_exec_ADDME_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); register m_uint32_t a,b,d; m_uint32_t carry; carry = cpu->xer_ca; cpu->xer_ca = 0; a = cpu->gpr[ra]; b = 0xFFFFFFFF; d = a + b + carry; if (((b + carry) < b) || (d < a)) cpu->xer_ca = 1; ppc32_exec_update_cr0(cpu,d); cpu->gpr[rd] = d; return(0);}/* ADDZE - Add to Zero Extended */static fastcall int ppc32_exec_ADDZE(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); register m_uint32_t a,d; m_uint32_t carry; carry = cpu->xer_ca; cpu->xer_ca = 0; a = cpu->gpr[ra]; d = a + carry; if (d < a) cpu->xer_ca = 1; cpu->gpr[rd] = d; return(0);}/* ADDZE. */static fastcall int ppc32_exec_ADDZE_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,21,25); int ra = bits(insn,16,20); register m_uint32_t a,d; m_uint32_t carry; carry = cpu->xer_ca; cpu->xer_ca = 0; a = cpu->gpr[ra]; d = a + carry; if (d < a) cpu->xer_ca = 1; ppc32_exec_update_cr0(cpu,d); cpu->gpr[rd] = d; return(0);}/* AND */static fastcall int ppc32_exec_AND(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); cpu->gpr[ra] = cpu->gpr[rs] & cpu->gpr[rb]; return(0);}/* AND. */static fastcall int ppc32_exec_AND_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t tmp; tmp = cpu->gpr[rs] & cpu->gpr[rb]; ppc32_exec_update_cr0(cpu,tmp); cpu->gpr[ra] = tmp; return(0);}/* ANDC - AND with Complement */static fastcall int ppc32_exec_ANDC(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); cpu->gpr[ra] = cpu->gpr[rs] & (~cpu->gpr[rb]); return(0);}/* ANDC. - AND with Complement */static fastcall int ppc32_exec_ANDC_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t tmp; tmp = cpu->gpr[rs] & (~cpu->gpr[rb]); ppc32_exec_update_cr0(cpu,tmp); cpu->gpr[ra] = tmp; return(0);}/* ANDI. - AND Immediate */static fastcall int ppc32_exec_ANDI_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); register m_uint32_t tmp; tmp = cpu->gpr[rs] & imm; ppc32_exec_update_cr0(cpu,tmp); cpu->gpr[ra] = tmp; return(0);}/* ANDIS. - AND Immediate Shifted */static fastcall int ppc32_exec_ANDIS_dot(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); m_uint32_t imm = bits(insn,0,15); register m_uint32_t tmp; tmp = cpu->gpr[rs] & (imm << 16); ppc32_exec_update_cr0(cpu,tmp); cpu->gpr[ra] = tmp; return(0);}/* B - Branch */static fastcall int ppc32_exec_B(cpu_ppc_t *cpu,ppc_insn_t insn){ m_uint32_t offset = bits(insn,2,25); cpu->ia += sign_extend_32(offset << 2,26); return(1);}/* BA - Branch Absolute */static fastcall int ppc32_exec_BA(cpu_ppc_t *cpu,ppc_insn_t insn){ m_uint32_t offset = bits(insn,2,25); cpu->ia = sign_extend_32(offset << 2,26); return(1);}/* BL - Branch and Link */static fastcall int ppc32_exec_BL(cpu_ppc_t *cpu,ppc_insn_t insn){ m_uint32_t offset = bits(insn,2,25); cpu->lr = cpu->ia + 4; cpu->ia += sign_extend_32(offset << 2,26); return(1);}/* BLA - Branch and Link Absolute */static fastcall int ppc32_exec_BLA(cpu_ppc_t *cpu,ppc_insn_t insn){ m_uint32_t offset = bits(insn,2,25); cpu->lr = cpu->ia + 4; cpu->ia = sign_extend_32(offset << 2,26); return(1);}/* BC - Branch Conditional */static fastcall int ppc32_exec_BC(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); int bd = bits(insn,2,15); if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia += sign_extend_32(bd << 2,16); return(1); } return(0);}/* BCA - Branch Conditional (absolute) */static fastcall int ppc32_exec_BCA(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); int bd = bits(insn,2,15); if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = sign_extend_32(bd << 2,16); return(1); } return(0);}/* BCL - Branch Conditional and Link */static fastcall int ppc32_exec_BCL(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); int bd = bits(insn,2,15); cpu->lr = cpu->ia + 4; if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia += sign_extend_32(bd << 2,16); return(1); } return(0);}/* BCLA - Branch Conditional and Link (absolute) */static fastcall int ppc32_exec_BCLA(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); int bd = bits(insn,2,15); cpu->lr = cpu->ia + 4; if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = sign_extend_32(bd << 2,16); return(1); } return(0);}/* BCLR - Branch Conditional to Link register */static fastcall int ppc32_exec_BCLR(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = cpu->lr & ~0x3; return(1); } return(0);}/* BCLRL - Branch Conditional to Link register */static fastcall int ppc32_exec_BCLRL(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); m_uint32_t new_ia; new_ia = cpu->lr & ~0x03; cpu->lr = cpu->ia + 4; if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = new_ia; return(1); } return(0);}/* BCCTR - Branch Conditional to Count register */static fastcall int ppc32_exec_BCCTR(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = cpu->ctr & ~0x3; return(1); } return(0);}/* BCCTRL - Branch Conditional to Count register and Link */static fastcall int ppc32_exec_BCCTRL(cpu_ppc_t *cpu,ppc_insn_t insn){ int bo = bits(insn,21,25); int bi = bits(insn,16,20); cpu->lr = cpu->ia + 4; if (ppc32_check_cond(cpu,bo,bi)) { cpu->ia = cpu->ctr & ~0x3; return(1); } return(0);}/* CMP - Compare */static fastcall int ppc32_exec_CMP(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,23,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t res; m_int32_t a,b; a = (m_int32_t)cpu->gpr[ra]; b = (m_int32_t)cpu->gpr[rb]; if (a < b) res = 0x08; else { if (a > b) res = 0x04; else res = 0x02; } if (cpu->xer & PPC32_XER_SO) res |= 0x01; cpu->cr_fields[rd] = res; return(0);}/* CMPI - Compare Immediate */static fastcall int ppc32_exec_CMPI(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,23,25); int ra = bits(insn,16,20); m_uint16_t imm = bits(insn,0,15); m_uint32_t res; m_int32_t a,b; a = (m_int32_t)cpu->gpr[ra]; b = sign_extend_32(imm,16); if (a < b) res = 0x08; else { if (a > b) res = 0x04; else res = 0x02; } if (cpu->xer & PPC32_XER_SO) res |= 0x01; cpu->cr_fields[rd] = res; return(0);}/* CMPL - Compare Logical */static fastcall int ppc32_exec_CMPL(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,23,25); int ra = bits(insn,16,20); int rb = bits(insn,11,15); m_uint32_t res,a,b; a = cpu->gpr[ra]; b = cpu->gpr[rb]; if (a < b) res = 0x08; else { if (a > b) res = 0x04; else res = 0x02; } if (cpu->xer & PPC32_XER_SO) res |= 0x01; cpu->cr_fields[rd] = res; return(0);}/* CMPLI - Compare Logical Immediate */static fastcall int ppc32_exec_CMPLI(cpu_ppc_t *cpu,ppc_insn_t insn){ int rd = bits(insn,23,25); int ra = bits(insn,16,20); m_uint32_t imm = bits(insn,0,15); m_uint32_t res,a; a = cpu->gpr[ra]; if (a < imm) res = 0x08; else { if (a > imm) res = 0x04; else res = 0x02; } if (cpu->xer & PPC32_XER_SO) res |= 0x01; cpu->cr_fields[rd] = res; return(0);}/* CNTLZW - Count Leading Zeros Word */static fastcall int ppc32_exec_CNTLZW(cpu_ppc_t *cpu,ppc_insn_t insn){ int rs = bits(insn,21,25); int ra = bits(insn,16,20); m_uint32_t val,mask; int i; val = cpu->gpr[rs]; mask = 0x80000000; for(i=0;i<32;i++) { if (val & mask) break; mask >>= 1; } cpu->gpr[ra] = i; return(0);}/* CRAND - Condition Register AND */static fastcall int ppc32_exec_CRAND(cpu_ppc_t *cpu,ppc_insn_t insn){ int bd = bits(insn,21,25); int bb = bits(insn,16,20); int ba = bits(insn,11,15); m_uint32_t tmp; tmp = ppc32_read_cr_bit(cpu,ba); tmp &= ppc32_read_cr_bit(cpu,bb); if (tmp & 0x1) ppc32_set_cr_bit(cpu,bd); else ppc32_clear_cr_bit(cpu,bd); return(0);}/* CREQV - Condition Register Equivalent */static fastcall int ppc32_exec_CREQV(cpu_ppc_t *cpu,ppc_insn_t insn){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -