From 8c4d4bb3a136069922cd5b1f94ed5acc45f2f1c7 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Mon, 26 Apr 2010 22:33:08 +0000 Subject: [PATCH] core: - a bit fixes on THUMB opcodes; --- desmume/src/thumb_instructions.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index 08cb67edd..8eb41ed3c 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -403,8 +403,8 @@ TEMPLATE static u32 FASTCALL OP_CMP_SPE(const u32 i) cpu->CPSR.bits.N = BIT31(tmp); cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !BorrowFrom(cpu->R[Rn], cpu->R[REG_NUM(i, 3)]); - cpu->CPSR.bits.V = OverflowFromSUB(tmp, cpu->R[Rn], cpu->R[REG_NUM(i, 3)]); + cpu->CPSR.bits.C = !BorrowFrom(cpu->R[Rn], cpu->R[REG_POS(i, 3)]); + cpu->CPSR.bits.V = OverflowFromSUB(tmp, cpu->R[Rn], cpu->R[REG_POS(i, 3)]); return 1; } @@ -555,13 +555,11 @@ TEMPLATE static u32 FASTCALL OP_NEG(const u32 i) TEMPLATE static u32 FASTCALL OP_CMN(const u32 i) { u32 tmp = cpu->R[REG_NUM(i, 0)] + cpu->R[REG_NUM(i, 3)]; - - //emu_halt(); - //log::ajouter("OP_CMN THUMB"); + cpu->CPSR.bits.N = BIT31(tmp); cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); + cpu->CPSR.bits.C = CarryFrom(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)]); + cpu->CPSR.bits.V = OverflowFromADD(tmp, cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)]); return 1; } @@ -1149,9 +1147,9 @@ TEMPLATE static u32 FASTCALL OP_BLX_THUMB(const u32 i) u32 Rm = cpu->R[REG_POS(i, 3)]; cpu->CPSR.bits.T = BIT0(Rm); - cpu->R[14] = cpu->next_instruction | 1; //cpu->R[15] = (Rm & (0xFFFFFFFC|(1<CPSR.bits.T))); - cpu->R[15] = (Rm & (0xFFFFFFFC|(1<CPSR.bits.T))); + cpu->R[15] = Rm & 0xFFFFFFFE; + cpu->R[14] = cpu->next_instruction | 1; cpu->next_instruction = cpu->R[15]; return 4;