feat(cpu): implement format 18 THUMB instructions

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-02-01 18:38:31 -04:00
parent c5681d5d75
commit 46b404ebd5
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,7 @@ const format13 = @import("cpu/thumb/format13.zig").format13;
const format14 = @import("cpu/thumb/format14.zig").format14;
const format15 = @import("cpu/thumb/format15.zig").format15;
const format16 = @import("cpu/thumb/format16.zig").format16;
const format18 = @import("cpu/thumb/format18.zig").format18;
const format19 = @import("cpu/thumb/format19.zig").format19;
pub const ArmInstrFn = fn (*Arm7tdmi, *Bus, u32) void;
@ -452,6 +453,10 @@ fn thumbPopulate() [0x400]ThumbInstrFn {
lut[i] = format16(cond);
}
if (i >> 5 & 0x1F == 0b11100) {
lut[i] = format18();
}
if (i >> 6 & 0xF == 0b1111) {
const is_low = i >> 5 & 1 == 1;

View File

@ -0,0 +1,15 @@
const std = @import("std");
const Bus = @import("../../Bus.zig");
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
const u32SignExtend = @import("../../util.zig").u32SignExtend;
pub fn format18() InstrFn {
return struct {
fn inner(cpu: *Arm7tdmi, _: *Bus, opcode: u16) void {
const offset = u32SignExtend(11, opcode & 0x7FF) << 1;
cpu.r[15] = (cpu.r[15] + 2) +% offset;
}
}.inner;
}