diff --git a/Common/ppcEmitter.cpp b/Common/ppcEmitter.cpp index 776b57b25e..9c96fa341e 100644 --- a/Common/ppcEmitter.cpp +++ b/Common/ppcEmitter.cpp @@ -125,33 +125,39 @@ namespace PpcGen { } void PPCXEmitter::BA (const void *fnptr) { - s32 func = (s32)fnptr - s32(code); + s32 func = (s32)fnptr; u32 instr = (0x48000002 | ((s32)((func) & 0x3fffffc))); Write32(instr); } void PPCXEmitter::BLA (const void *fnptr) { - s32 func = (s32)fnptr - s32(code); + s32 func = (s32)fnptr; u32 instr = (0x48000003 | ((s32)((func) & 0x3fffffc))); Write32(instr); } void PPCXEmitter::BEQ (const void *fnptr) { s32 func = (s32)fnptr - s32(code); - u32 instr = (0x41820000 | ( func & 0xffff)); + u32 instr = (0x41820000 | ( func & 0xfffc)); Write32(instr); } void PPCXEmitter::BGT(const void *fnptr) { s32 func = (s32)fnptr - s32(code); - u32 instr = (0x41810000 | (((s16)(((func)+1))) & 0xffff)); + u32 instr = (0x41810000 | (((s16)(((func)+1))) & 0xfffc)); Write32(instr); } void PPCXEmitter::BLT (const void *fnptr) { s32 func = (s32)fnptr - s32(code); - u32 instr = (0x41800000 | (((s16)(((func)+1))) & 0xffff)); + u32 instr = (0x41800000 | (((s16)(((func)+1))) & 0xfffc)); + Write32(instr); + } + + void PPCXEmitter::BLE (const void *fnptr) { + s32 func = (s32)fnptr - s32(code); + u32 instr = (0x40810000 | (((s16)(((func)+1))) & 0xfffc)); Write32(instr); } @@ -235,6 +241,16 @@ namespace PpcGen { return branch; } + FixupBranch PPCXEmitter::BLE() { + FixupBranch branch; + branch.type = _BLE; + branch.ptr = code; + branch.condition = condition; + //We'll write NOP here for now. + Write32(0x60000000); + return branch; + } + FixupBranch PPCXEmitter::B_Cond(FixupBranchType type) { FixupBranch branch; branch.type = type; @@ -287,11 +303,16 @@ namespace PpcGen { // Compare void PPCXEmitter::CMPLWI(PPCReg dest, unsigned short imm) { - Write32((0x28000000 | (dest << 16) | ((imm) & 0xffff))); + Write32((10<<26) | (dest << 16) | ((imm) & 0xffff)); + Break(); } - + + void PPCXEmitter::CMPI(PPCReg dest, unsigned short imm) { + Write32((11<<26) | (dest << 16) | ((imm) & 0xffff)); + } + void PPCXEmitter::CMPLI(PPCReg dest, unsigned short imm) { - Write32((0x2C000000 | (dest << 16) | ((imm) & 0xffff))); + Write32((10<<26) | (dest << 16) | ((imm) & 0xffff)); } void PPCXEmitter::CMP(PPCReg a, PPCReg b) { diff --git a/Common/ppcEmitter.h b/Common/ppcEmitter.h index 8ff065a531..4c0c97d914 100644 --- a/Common/ppcEmitter.h +++ b/Common/ppcEmitter.h @@ -178,6 +178,7 @@ public: FixupBranch BL(); FixupBranch BNE(); FixupBranch BLT(); + FixupBranch BLE(); FixupBranch B_Cond(FixupBranchType type); @@ -189,6 +190,7 @@ public: void BA (const void *fnptr); void BLA(const void *fnptr); void BEQ(const void *fnptr); + void BLE(const void *fnptr); void BLT(const void *fnptr); void BGT(const void *fnptr); void BEQ (PPCReg r); @@ -263,7 +265,8 @@ public: // Compare void CMPLWI (PPCReg dest, unsigned short imm); - void CMPLI (PPCReg dest, unsigned short imm); + void CMPLI (PPCReg dest, unsigned short imm); + void CMPI (PPCReg dest, unsigned short imm); void CMP (PPCReg a, PPCReg b); // Debug !