feat: implement LDR STR

This commit is contained in:
2021-12-29 17:16:32 -06:00
parent 7cc3f40a85
commit c660ca8922
4 changed files with 24 additions and 6 deletions

View File

@@ -24,7 +24,9 @@ pub fn comptimeSingleDataTransfer(comptime I: bool, comptime P: bool, comptime U
cpu.r[rd] = bus.readByte(address);
} else {
// LDR
std.debug.panic("Implement LDR", .{});
// FIXME: Unsure about how I calculate the boundary offset
cpu.r[rd] = std.math.rotl(u32, bus.readWord(address), address % 4);
}
} else {
if (B) {
@@ -37,7 +39,11 @@ pub fn comptimeSingleDataTransfer(comptime I: bool, comptime P: bool, comptime U
bus.writeByte(address, src);
} else {
// STR
std.debug.panic("Implement STR", .{});
// FIXME: Is this right?
const src = cpu.r[rd];
const aligned_addr = address - (address % 4);
bus.writeWord(aligned_addr, src);
}
}