chore(cpu): refactor barrel shifter

This commit is contained in:
2022-01-17 11:17:04 -04:00
parent d05a924420
commit 1025500407
3 changed files with 31 additions and 55 deletions

View File

@@ -22,18 +22,8 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4
var op2: u32 = undefined;
if (I) {
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);
const amount = @truncate(u8, (opcode >> 8 & 0xF) << 1);
op2 = BarrelShifter.rotateRight(S, &cpu.cpsr, opcode & 0xFF, amount);
} else {
op2 = BarrelShifter.exec(S, cpu, opcode);
}