fix(cpu): use barrel shifter in data processing immediates

This commit is contained in:
2022-01-17 11:02:34 -04:00
parent 2a416fb2c6
commit d05a924420
3 changed files with 31 additions and 15 deletions

View File

@@ -22,7 +22,18 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4
var op2: u32 = undefined;
if (I) {
op2 = std.math.rotr(u32, opcode & 0xFF, (opcode >> 8 & 0xF) << 1);
const amt = @truncate(u8, (opcode >> 8 & 0xF) << 1);
if (S) {
op2 = BarrelShifter.rotateRight(&cpu.cpsr, opcode & 0xFF, amt);
} else {
const PSR = @import("../../cpu.zig").PSR;
var dummy = PSR{ .raw = 0x0000_0000 };
op2 = BarrelShifter.rotateRight(&dummy, opcode & 0xFF, amt);
}
// op2 = std.math.rotr(u32, opcode & 0xFF, (opcode >> 8 & 0xF) << 1);
} else {
op2 = BarrelShifter.exec(S, cpu, opcode);
}