feat(cpu): implement format 6 THUMB instructions
This commit is contained in:
parent
c6608748c6
commit
93922b65e3
|
@ -22,6 +22,7 @@ const softwareInterrupt = @import("cpu/arm/software_interrupt.zig").softwareInte
|
|||
// THUMB Instruction Groups
|
||||
const format3 = @import("cpu/thumb/format3.zig").format3;
|
||||
const format5 = @import("cpu/thumb/format5.zig").format5;
|
||||
const format6 = @import("cpu/thumb/format6.zig").format6;
|
||||
const format12 = @import("cpu/thumb/format12.zig").format12;
|
||||
|
||||
pub const ArmInstrFn = fn (*Arm7tdmi, *Bus, u32) void;
|
||||
|
@ -330,6 +331,12 @@ fn thumbPopulate() [0x400]ThumbInstrFn {
|
|||
lut[i] = format5(op, h1, h2);
|
||||
}
|
||||
|
||||
if (i >> 5 & 0x1F == 0b01001) {
|
||||
const rd = i >> 2 & 0x7;
|
||||
|
||||
lut[i] = format6(rd);
|
||||
}
|
||||
|
||||
if (i >> 6 & 0xF == 0b1010) {
|
||||
const isSP = i >> 5 & 1 == 1;
|
||||
const rd = i >> 2 & 0x7;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
const std = @import("std");
|
||||
|
||||
const Bus = @import("../../Bus.zig");
|
||||
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
|
||||
const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
|
||||
|
||||
pub fn format6(comptime rd: u3) InstrFn {
|
||||
return struct {
|
||||
fn inner(cpu: *Arm7tdmi, bus: *Bus, opcode: u16) void {
|
||||
const offset = (opcode & 0xFF) << 2;
|
||||
|
||||
// FIXME: Should this overflow?
|
||||
cpu.r[rd] = bus.read32((cpu.fakePC() & 0xFFFF_FFFC) + offset);
|
||||
}
|
||||
}.inner;
|
||||
}
|
Loading…
Reference in New Issue