chore(v4t,v5te): don't give SWP/SWPB its own separate handler
This commit is contained in:
@@ -38,10 +38,28 @@ pub fn halfAndSignedDataTransfer(comptime InstrFn: type, comptime P: bool, compt
|
||||
// FIXME: I shouldn't have to use @as(u8, ...) here
|
||||
result = if (address & 1 == 1) sext(u32, u8, @as(u8, @truncate(value >> 8))) else sext(u32, u16, value);
|
||||
},
|
||||
0b00 => unreachable, // SWP / SWPB dealt with in single_data_swap.zig
|
||||
0b00 => unreachable,
|
||||
}
|
||||
} else {
|
||||
switch (op) {
|
||||
0b00 => {
|
||||
const B = I;
|
||||
const swap_addr = cpu.r[rn];
|
||||
|
||||
if (B) {
|
||||
// SWPB
|
||||
const value = cpu.read(u8, swap_addr);
|
||||
cpu.write(u8, swap_addr, @as(u8, @truncate(cpu.r[rm])));
|
||||
|
||||
cpu.r[rd] = value;
|
||||
} else {
|
||||
// SWP
|
||||
const value = rotr(u32, cpu.read(u32, swap_addr), 8 * (swap_addr & 0x3));
|
||||
cpu.write(u32, swap_addr, cpu.r[rm]);
|
||||
|
||||
cpu.r[rd] = value;
|
||||
}
|
||||
},
|
||||
0b01 => {
|
||||
// STRH
|
||||
|
||||
@@ -76,7 +94,6 @@ pub fn halfAndSignedDataTransfer(comptime InstrFn: type, comptime P: bool, compt
|
||||
cpu.write(u32, address, cpu.r[rd]);
|
||||
cpu.write(u32, address + 4, cpu.r[rd + 1]);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
const rotr = @import("zba-util").rotr;
|
||||
|
||||
pub fn singleDataSwap(comptime InstrFn: type, comptime B: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
const rn = opcode >> 16 & 0xF;
|
||||
const rd = opcode >> 12 & 0xF;
|
||||
const rm = opcode & 0xF;
|
||||
|
||||
const address = cpu.r[rn];
|
||||
|
||||
if (B) {
|
||||
// SWPB
|
||||
const value = cpu.read(u8, address);
|
||||
|
||||
// FIXME: I shouldn't have to use @as(u8, ...) here
|
||||
cpu.write(u8, address, @as(u8, @truncate(cpu.r[rm])));
|
||||
cpu.r[rd] = value;
|
||||
} else {
|
||||
// SWP
|
||||
const value = rotr(u32, cpu.read(u32, address), 8 * (address & 0x3));
|
||||
cpu.write(u32, address, cpu.r[rm]);
|
||||
cpu.r[rd] = value;
|
||||
}
|
||||
}
|
||||
}.inner;
|
||||
}
|
||||
Reference in New Issue
Block a user