From 98a3cbdf84e3c7e8a6ed9f6a7be2b423be867572 Mon Sep 17 00:00:00 2001 From: Danila Malyutin Date: Thu, 6 Aug 2015 03:10:14 +0300 Subject: [PATCH] Fix MTOCRF instruction to be the same as interpreter. --- rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp b/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp index 2d432f17b9..134c283035 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp @@ -2660,16 +2660,16 @@ void Compiler::MTOCRF(u32 l, u32 crm, u32 rs) { for (u32 i = 0; i < 8; i++) { if (crm & (1 << i)) { - mask |= 0xF << ((7 - i) * 4); + mask |= 0xF << (i * 4); // move 0xF to the left i positions (in hex form) if (l) { break; } } } - cr_i32 = m_ir_builder->CreateAnd(cr_i32, mask); - rs_i32 = m_ir_builder->CreateAnd(rs_i32, ~mask); - cr_i32 = m_ir_builder->CreateOr(cr_i32, rs_i32); + cr_i32 = m_ir_builder->CreateAnd(cr_i32, ~mask); // null ith nibble + rs_i32 = m_ir_builder->CreateAnd(rs_i32, mask); // null everything except ith nibble + cr_i32 = m_ir_builder->CreateOr(cr_i32, rs_i32); // now ith cr nibble == ith rs nibble SetCr(cr_i32); } @@ -5314,4 +5314,4 @@ void Compiler::InitRotateMask() { } } } -#endif \ No newline at end of file +#endif