feat(cpu): implement RRX for Barrel Shifter

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:11:58 -03:00
parent 9b867c02e0
commit f3ad5e90ff
1 changed files with 9 additions and 0 deletions

View File

@ -91,3 +91,12 @@ pub fn rotateRight(comptime S: bool, cpsr: *CPSR, rm: u32, amount: u8) u32 {
return result; return result;
} }
pub fn rotateRightExtended(comptime S: bool, cpsr: *CPSR, rm: u32) u32 {
if (!S) std.debug.panic("[BarrelShifter] Turns out I don't know how RRX works", .{});
const carry: u32 = @boolToInt(cpsr.c.read());
cpsr.c.write(rm & 1 == 1);
return (carry << 31) | (rm >> 1);
}