From 800ed6f1a767fc2ccff084386fd3b0e97d5f5ac9 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 2 Feb 2022 22:31:21 -0400 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; }