From af10c1b076ca148620ecf4df0cadbffec4ada47f Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:12 -0300 Subject: [PATCH] feat(cpu): implement format 13 While bugs do exist, at this point all THUMB and ARMv4 instructions have been implemented! Yay! --- src/cpu/thumb/format13.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cpu/thumb/format13.zig b/src/cpu/thumb/format13.zig index 3b32718..ae6c58d 100644 --- a/src/cpu/thumb/format13.zig +++ b/src/cpu/thumb/format13.zig @@ -4,10 +4,11 @@ const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").ThumbInstrFn; -pub fn format13(comptime _: bool) InstrFn { +pub fn format13(comptime S: bool) InstrFn { return struct { - fn inner(cpu: *Arm7tdmi, _: *Bus, _: u16) void { - cpu.panic("[CPU|THUMB|Fmt13] Implement Format 13 THUMB Instructions", .{}); + fn inner(cpu: *Arm7tdmi, _: *Bus, opcode: u16) void { + const offset = (opcode & 0x7F) << 2; + cpu.r[13] = if (S) cpu.r[13] - offset else cpu.r[13] + offset; } }.inner; }