From 845d6e1d24d38d8bc71a2d14fa88ccbeb9f863ad Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 16 Nov 2014 20:51:36 -0800 Subject: [PATCH] ARM: Run tighter loop in CPU --- src/arm/arm.c | 8 +++++--- src/arm/isa-inlines.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/arm/arm.c b/src/arm/arm.c index c31c91997..fe6bf10c2 100644 --- a/src/arm/arm.c +++ b/src/arm/arm.c @@ -290,10 +290,12 @@ void ARMRun(struct ARMCore* cpu) { } void ARMRunLoop(struct ARMCore* cpu) { - while (cpu->cycles < cpu->nextEvent) { - if (cpu->executionMode == MODE_THUMB) { + if (cpu->executionMode == MODE_THUMB) { + while (cpu->cycles < cpu->nextEvent) { ThumbStep(cpu); - } else { + } + } else { + while (cpu->cycles < cpu->nextEvent) { ARMStep(cpu); } } diff --git a/src/arm/isa-inlines.h b/src/arm/isa-inlines.h index 1ef92caf8..d2657cffa 100644 --- a/src/arm/isa-inlines.h +++ b/src/arm/isa-inlines.h @@ -74,6 +74,7 @@ static inline void _ARMSetMode(struct ARMCore* cpu, enum ExecutionMode execution case MODE_THUMB: cpu->cpsr.t = 1; } + cpu->nextEvent = 0; } static inline void _ARMReadCPSR(struct ARMCore* cpu) {