Ensure to advance cycles when waiting for interrupt to avoid stalling when mtimecmp is based on cycles.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user