feat(cpu): properly implement STR STRH and STRB
This commit is contained in:
parent
c6de540c8a
commit
182392bf1c
|
@ -51,10 +51,7 @@ pub fn comptimeHalfSignedDataTransfer(comptime P: bool, comptime U: bool, compti
|
||||||
} else {
|
} else {
|
||||||
if (opcode >> 5 & 0x01 == 0x01) {
|
if (opcode >> 5 & 0x01 == 0x01) {
|
||||||
// STRH
|
// STRH
|
||||||
const src = @truncate(u16, cpu.r[rd]);
|
bus.write16(address, @truncate(u16, cpu.r[rd]));
|
||||||
|
|
||||||
bus.write16(address + 2, src);
|
|
||||||
bus.write16(address, src);
|
|
||||||
} else {
|
} else {
|
||||||
std.debug.panic("[CPU] TODO: Figure out if this is also SWP", .{});
|
std.debug.panic("[CPU] TODO: Figure out if this is also SWP", .{});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,11 @@ pub fn comptimeSingleDataTransfer(comptime I: bool, comptime P: bool, comptime U
|
||||||
} else {
|
} else {
|
||||||
if (B) {
|
if (B) {
|
||||||
// STRB
|
// STRB
|
||||||
const src = @truncate(u8, cpu.r[rd]);
|
bus.write8(address, @truncate(u8, cpu.r[rd]));
|
||||||
|
|
||||||
bus.write8(address + 3, src);
|
|
||||||
bus.write8(address + 2, src);
|
|
||||||
bus.write8(address + 1, src);
|
|
||||||
bus.write8(address, src);
|
|
||||||
} else {
|
} else {
|
||||||
// STR
|
// STR
|
||||||
|
const force_aligned = address & 0xFFFF_FFFC;
|
||||||
// FIXME: Is this right?
|
bus.write32(force_aligned, cpu.r[rd]);
|
||||||
const src = cpu.r[rd];
|
|
||||||
const aligned_addr = address - (address % 4);
|
|
||||||
bus.write32(aligned_addr, src);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue