fix: properly decode format 11 instructions

This commit is contained in:
2022-02-12 03:13:38 -04:00
parent b93bd53529
commit 783706193b
2 changed files with 5 additions and 5 deletions

View File

@@ -5,12 +5,12 @@ const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
pub fn format14(comptime L: bool, comptime R: bool) InstrFn {
return struct {
fn inner(cpu: *Arm7tdmi, bus: *Bus, opcode: u16) void {
const count = countRlist(opcode);
const start = cpu.r[13] - if (!L) 4 * (@boolToInt(R) + count) else 0;
const count = @boolToInt(R) + countRlist(opcode);
const start = cpu.r[13] - if (!L) count * 4 else 0;
var end = cpu.r[13];
if (L) {
end += 4 * (@boolToInt(R) + count);
end += count * 4;
} else {
end -= 4;
}
@@ -40,7 +40,7 @@ pub fn format14(comptime L: bool, comptime R: bool) InstrFn {
address += 4;
}
cpu.r[13] = if (L) end else cpu.r[13] - 4 * (@boolToInt(R) + count);
cpu.r[13] = if (L) end else start;
}
}.inner;
}