fix(cpu): account for rn in rlist in block data transfer
This commit is contained in:
parent
d95efa5b12
commit
c2901ee0d8
|
@ -11,34 +11,39 @@ pub fn blockDataTransfer(comptime P: bool, comptime U: bool, comptime S: bool, c
|
||||||
const rn = opcode >> 16 & 0xF;
|
const rn = opcode >> 16 & 0xF;
|
||||||
const base = cpu.r[rn];
|
const base = cpu.r[rn];
|
||||||
|
|
||||||
var address: u32 = undefined;
|
const in_list = opcode >> @truncate(u4, rn) & 1 == 1;
|
||||||
|
|
||||||
|
var address: u32 = base;
|
||||||
if (U) {
|
if (U) {
|
||||||
// Increment
|
// Increment
|
||||||
address = if (P) base + 4 else base;
|
|
||||||
|
|
||||||
var i: u5 = 0;
|
var i: u5 = 0;
|
||||||
while (i < 0x10) : (i += 1) {
|
while (i < 0x10) : (i += 1) {
|
||||||
if (opcode >> i & 1 == 1) {
|
if (opcode >> i & 1 == 1) {
|
||||||
|
if (P) address += 4;
|
||||||
transfer(cpu, bus, r15_present, i, address);
|
transfer(cpu, bus, r15_present, i, address);
|
||||||
address += 4;
|
if (!P) address += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Decrement
|
// Decrement
|
||||||
address = if (P) base - 4 else base;
|
|
||||||
|
|
||||||
var i: u5 = 0x10;
|
var i: u5 = 0x10;
|
||||||
while (i > 0) : (i -= 1) {
|
while (i > 0) : (i -= 1) {
|
||||||
const j = i - 1;
|
const j = i - 1;
|
||||||
|
|
||||||
if (opcode >> j & 1 == 1) {
|
if (opcode >> j & 1 == 1) {
|
||||||
|
if (P) address -= 4;
|
||||||
transfer(cpu, bus, r15_present, j, address);
|
transfer(cpu, bus, r15_present, j, address);
|
||||||
address -= 4;
|
if (!P) address -= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W and P or !P) cpu.r[rn] = if (U) address else address + 4;
|
if (W) {
|
||||||
|
if (!L or (L and !in_list)) {
|
||||||
|
cpu.r[rn] = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transfer(cpu: *Arm7tdmi, bus: *Bus, r15_present: bool, i: u5, address: u32) void {
|
fn transfer(cpu: *Arm7tdmi, bus: *Bus, r15_present: bool, i: u5, address: u32) void {
|
||||||
|
|
Loading…
Reference in New Issue