chore: replace unnecessarily complex sign extension implementation
This commit is contained in:
@@ -4,7 +4,7 @@ const Bus = @import("../../Bus.zig");
|
||||
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
|
||||
const InstrFn = @import("../../cpu.zig").ArmInstrFn;
|
||||
|
||||
const u32SignExtend = @import("../../util.zig").u32SignExtend;
|
||||
const sext = @import("../../util.zig").sext;
|
||||
|
||||
pub fn halfAndSignedDataTransfer(comptime P: bool, comptime U: bool, comptime I: bool, comptime W: bool, comptime L: bool) InstrFn {
|
||||
return struct {
|
||||
@@ -42,14 +42,14 @@ pub fn halfAndSignedDataTransfer(comptime P: bool, comptime U: bool, comptime I:
|
||||
},
|
||||
0b10 => {
|
||||
// LDRSB
|
||||
result = u32SignExtend(8, bus.read8(address));
|
||||
result = sext(8, bus.read8(address));
|
||||
},
|
||||
0b11 => {
|
||||
// LDRSH
|
||||
const value = if (address & 1 == 1) blk: {
|
||||
break :blk u32SignExtend(8, bus.read8(address));
|
||||
break :blk sext(8, bus.read8(address));
|
||||
} else blk: {
|
||||
break :blk u32SignExtend(16, bus.read16(address));
|
||||
break :blk sext(16, bus.read16(address));
|
||||
};
|
||||
|
||||
result = std.math.rotr(u32, value, 8 * (address & 1));
|
||||
|
Reference in New Issue
Block a user