From f9a42d87d18ac8869d510b35f5c9477373fca8cc Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 23 May 2020 21:31:55 -0700 Subject: [PATCH] ARM: Fix timing on Thumb shift instructions --- CHANGES | 1 + src/arm/isa-thumb.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 8f7ff14e8..c2e4a0827 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ Features: Emulation fixes: - ARM: Fix ALU reading PC after shifting - ARM: Fix STR storing PC after address calculation + - ARM: Fix timing on Thumb shift instructions - GB: Fix GBC game registers after skipping BIOS - GB MBC: Support 4MB MBC30 ROMs (fixes mgba.io/i/1713) - GB Video: Fix state after skipping BIOS (fixes mgba.io/i/1715 and mgba.io/i/1716) diff --git a/src/arm/isa-thumb.c b/src/arm/isa-thumb.c index 15f845a29..edd15fe2c 100644 --- a/src/arm/isa-thumb.c +++ b/src/arm/isa-thumb.c @@ -157,6 +157,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(LSL2, cpu->gprs[rd] = 0; } } + ++currentCycles; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(LSR2, @@ -174,6 +175,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(LSR2, cpu->gprs[rd] = 0; } } + ++currentCycles; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ASR2, @@ -191,6 +193,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ASR2, } } } + ++currentCycles; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ADC, @@ -215,6 +218,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ROR, cpu->cpsr.c = ARM_SIGN(cpu->gprs[rd]); } } + ++currentCycles; THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(TST, int32_t aluOut = cpu->gprs[rd] & cpu->gprs[rn]; THUMB_NEUTRAL_S(cpu->gprs[rd], cpu->gprs[rn], aluOut)) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(NEG, THUMB_SUBTRACTION(cpu->gprs[rd], 0, cpu->gprs[rn]))