feat: implement obscure behaviour for ARM data processing instrs

When a test instruction is called when rd == 15, then the CPSR is
reloaded from the SPSR, the pipline is not flushed
This commit is contained in:
Rekai Nyangadzayi Musuka 2022-07-02 10:07:52 -03:00
parent f500da5f10
commit 446b5f6aea
2 changed files with 6 additions and 1 deletions

View File

@ -154,6 +154,11 @@ pub const Arm7tdmi = struct {
return self.bus.io.haltcnt == .Halt; return self.bus.io.haltcnt == .Halt;
} }
pub fn setCpsrNoFlush(self: *Self, value: u32) void {
if (value & 0x1F != self.cpsr.raw & 0x1F) self.changeModeFromIdx(@truncate(u5, value & 0x1F));
self.cpsr.raw = value;
}
pub fn setCpsr(self: *Self, value: u32) void { pub fn setCpsr(self: *Self, value: u32) void {
if (value & 0x1F != self.cpsr.raw & 0x1F) self.changeModeFromIdx(@truncate(u5, value & 0x1F)); if (value & 0x1F != self.cpsr.raw & 0x1F) self.changeModeFromIdx(@truncate(u5, value & 0x1F));

View File

@ -282,5 +282,5 @@ fn setTestOpFlags(comptime S: bool, cpu: *Arm7tdmi, opcode: u32, result: u32) vo
fn undefinedTestBehaviour(cpu: *Arm7tdmi) void { fn undefinedTestBehaviour(cpu: *Arm7tdmi) void {
@setCold(true); @setCold(true);
cpu.setCpsr(cpu.spsr.raw); cpu.setCpsrNoFlush(cpu.spsr.raw);
} }