Don't write at all on bad mode instead of sneakily adjusting mode.

This commit is contained in:
Florian Nücke
2020-09-17 23:29:49 +02:00
parent c1238469c3
commit 79f7a9403e

View File

@@ -2117,7 +2117,9 @@ public final class R5CPU implements Steppable, RealTimeCounter, InterruptControl
break;
}
case 0x105: { // stvec, Supervisor trap handler base address.
stvec = value & ~0b10; // Don't allow reserved modes.
if ((value & 0b11) < 2) { // Don't allow reserved modes.
stvec = value;
}
break;
}
case 0x106: { // scounteren, Supervisor counter enable.
@@ -2202,7 +2204,9 @@ public final class R5CPU implements Steppable, RealTimeCounter, InterruptControl
break;
}
case 0x305: { // mtvec Machine trap-handler base address.
mtvec = value & ~0b10; // Don't allow reserved modes.
if ((value & 0b11) < 2) { // Don't allow reserved modes.
mtvec = value;
}
}
case 0x306: { // mcounteren Machine counter enable.
mcounteren = value & COUNTEREN_MASK;