chore: improve arm ldm/stm

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-02-05 23:29:34 -04:00
parent adfd501fc4
commit 798987eba0
2 changed files with 8 additions and 4 deletions

View File

@ -9,11 +9,14 @@ pub fn blockDataTransfer(comptime P: bool, comptime U: bool, comptime S: bool, c
fn inner(cpu: *Arm7tdmi, bus: *Bus, opcode: u32) void { fn inner(cpu: *Arm7tdmi, bus: *Bus, opcode: u32) void {
const r15_present = opcode >> 15 & 1 == 1; const r15_present = opcode >> 15 & 1 == 1;
const rn = opcode >> 16 & 0xF; const rn = opcode >> 16 & 0xF;
const base = cpu.r[rn]; var address: u32 = cpu.r[rn];
const in_list = opcode >> @truncate(u4, rn) & 1 == 1; if (opcode & 0xFFFF == 0) {
if (L) cpu.r[15] = bus.read32(address) else bus.write32(address, cpu.r[15] + 8);
cpu.r[rn] += 0x40;
return;
}
var address: u32 = base;
if (U) { if (U) {
// Increment // Increment
var i: u5 = 0; var i: u5 = 0;
@ -40,6 +43,7 @@ pub fn blockDataTransfer(comptime P: bool, comptime U: bool, comptime S: bool, c
} }
if (W) { if (W) {
const in_list = opcode >> @truncate(u4, rn) & 1 == 1;
if (!L or (L and !in_list)) { if (!L or (L and !in_list)) {
cpu.r[rn] = address; cpu.r[rn] = address;
} }

View File

@ -54,7 +54,7 @@ pub fn format15(comptime L: bool, comptime rb: u3) InstrFn {
const end_address = cpu.r[rb] + 4 * countRlist(opcode); const end_address = cpu.r[rb] + 4 * countRlist(opcode);
if (opcode & 0xFF == 0) { if (opcode & 0xFF == 0) {
if (L) cpu.r[15] = bus.read32(address) else bus.write32(address, cpu.r[15] + 4); // TODO: Why is this r[15] + 4? if (L) cpu.r[15] = bus.read32(address) else bus.write32(address, cpu.r[15] + 4);
cpu.r[rb] += 0x40; cpu.r[rb] += 0x40;
return; return;
} }