feat(cpu): implement THUMB ldmia stmia

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-01-29 21:10:14 -04:00
parent 2dde47318c
commit 00058f6094
2 changed files with 37 additions and 0 deletions

View File

@ -26,6 +26,7 @@ const format2 = @import("cpu/thumb/format2.zig").format2;
const format5 = @import("cpu/thumb/format5.zig").format5;
const format6 = @import("cpu/thumb/format6.zig").format6;
const format12 = @import("cpu/thumb/format12.zig").format12;
const format15 = @import("cpu/thumb/format15.zig").format15;
const format16 = @import("cpu/thumb/format16.zig").format16;
const format19 = @import("cpu/thumb/format19.zig").format19;
@ -375,6 +376,13 @@ fn thumbPopulate() [0x400]ThumbInstrFn {
lut[i] = format12(isSP, rd);
}
if (i >> 6 & 0xF == 0b1100) {
const L = i >> 5 & 1 == 1;
const rb = i >> 2 & 0x3;
lut[i] = format15(L, rb);
}
if (i >> 6 & 0xF == 0b1101) {
const cond = i >> 2 & 0xF;

View File

@ -0,0 +1,29 @@
const std = @import("std");
const Bus = @import("../../Bus.zig");
const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi;
const InstrFn = @import("../../cpu.zig").ThumbInstrFn;
pub fn format15(comptime L: bool, comptime rb: u3) InstrFn {
return struct {
fn inner(cpu: *Arm7tdmi, bus: *Bus, opcode: u16) void {
const base = cpu.r[rb];
var address: u32 = base;
var i: usize = 0;
while (i < 8) : (i += 1) {
if ((opcode >> @truncate(u3, i)) & 1 == 1) {
if (L) {
cpu.r[i] = bus.read32(address);
} else {
bus.write32(address, cpu.r[i]);
}
address += 4;
}
}
cpu.r[rb] = address;
}
}.inner;
}