Ensure to advance cycles when waiting for interrupt to avoid stalling when mtimecmp is based on cycles.

This commit is contained in:
Florian Nücke
2020-09-14 17:50:42 +02:00
parent b7955d5c97
commit 5abd6d4e65

View File

@@ -199,6 +199,11 @@ public class R5CPU implements Steppable, RealTimeCounter, InterruptController {
}
public void step(final int cycles) {
if (waitingForInterrupt) {
mcycle += cycles;
return;
}
final long cycleLimit = mcycle + cycles;
while (!waitingForInterrupt && mcycle < cycleLimit) {
final int pending = mip.get() & mie;
@@ -232,6 +237,10 @@ public class R5CPU implements Steppable, RealTimeCounter, InterruptController {
raiseException(e.getExceptionCause(), e.getExceptionValue());
}
}
if (waitingForInterrupt && mcycle < cycleLimit) {
mcycle = cycleLimit;
}
}
private void interpret() throws R5Exception, MemoryAccessException {