Compare commits

...

2 Commits

Author SHA1 Message Date
Rekai Nyangadzayi Musuka f601bec0c4 fix: advance r15, even when the pipeline is reloaded from the scheduler
The PC would fall behind whenever an IRQ was called because the pipeline
was reloaded (+8 to PC), however that was never actually done by any code

Now, the PC is always incremented when the pipeline is reloaded
2022-08-26 23:59:59 -05:00
Rekai Nyangadzayi Musuka 2c0c3a8ac4 chore: dump pipeline state on cpu panic 2022-08-26 21:45:35 -05:00
1 changed files with 5 additions and 2 deletions

View File

@ -450,8 +450,7 @@ pub const Arm7tdmi = struct {
}
}
if (self.pipe.flushed) self.r[15] += if (self.cpsr.t.read()) 2 else @as(u32, 4);
self.r[15] += if (self.cpsr.t.read()) 2 else @as(u32, 4);
if (!self.pipe.flushed) self.r[15] += if (self.cpsr.t.read()) 2 else @as(u32, 4);
self.pipe.flushed = false;
}
@ -542,6 +541,8 @@ pub const Arm7tdmi = struct {
std.debug.print("spsr: 0x{X:0>8} ", .{self.spsr.raw});
prettyPrintPsr(&self.spsr);
std.debug.print("pipeline: {??X:0>8}\n", .{self.pipe.stage});
if (self.cpsr.t.read()) {
const opcode = self.bus.dbgRead(u16, self.r[15] - 4);
const id = thumbIdx(opcode);
@ -704,6 +705,8 @@ const Pipline = struct {
self.stage[0] = cpu.bus.read(T, cpu.r[15]);
self.stage[1] = cpu.bus.read(T, cpu.r[15] + if (T == u32) 4 else @as(u32, 2));
cpu.r[15] += if (T == u32) 8 else @as(u32, 4);
self.flushed = true;
}
};