From e2dfe00574e8648134118dce696a512e02092b6a Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Tue, 6 Apr 2010 21:28:14 +0000 Subject: [PATCH] - fix CPSR flags in ADC/SBC :P --- desmume/src/thumb_instructions.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index e88e07052..fd8a06c7e 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -449,8 +449,8 @@ TEMPLATE static u32 FASTCALL OP_ADC_REG(const u32 i) cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); cpu->CPSR.bits.Z = (cpu->R[REG_NUM(i, 0)] == 0); - cpu->CPSR.bits.C = CarryFrom(Rd, Rm + cpu->CPSR.bits.C); - cpu->CPSR.bits.V = OverflowFromADD(cpu->R[REG_NUM(i, 0)], Rd, Rm + cpu->CPSR.bits.C); + cpu->CPSR.bits.C = CarryFrom(Rd + cpu->CPSR.bits.C, Rm + cpu->CPSR.bits.C); + cpu->CPSR.bits.V = OverflowFromADD(cpu->R[REG_NUM(i, 0)], Rd + cpu->CPSR.bits.C, Rm + cpu->CPSR.bits.C); return 1; } @@ -469,8 +469,8 @@ TEMPLATE static u32 FASTCALL OP_SBC_REG(const u32 i) cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); cpu->CPSR.bits.Z = (cpu->R[REG_NUM(i, 0)] == 0); - cpu->CPSR.bits.C = !CarryFrom(Rd, Rm - !cpu->CPSR.bits.C); - cpu->CPSR.bits.V = OverflowFromSUB(cpu->R[REG_NUM(i, 0)], Rd, Rm - !cpu->CPSR.bits.C); + cpu->CPSR.bits.C = !CarryFrom(Rd - !cpu->CPSR.bits.C, Rm - !cpu->CPSR.bits.C); + cpu->CPSR.bits.V = OverflowFromSUB(cpu->R[REG_NUM(i, 0)], Rd - !cpu->CPSR.bits.C, Rm - !cpu->CPSR.bits.C); return 1; }