chore: squash bugs preventing swi_demo.gba from working
This commit is contained in:
parent
8ab7a178c1
commit
d2740e30d9
|
@ -43,7 +43,7 @@ pub fn format19(comptime is_low: bool) InstrFn {
|
||||||
// Instruction 2
|
// Instruction 2
|
||||||
const old_pc = cpu.r[15];
|
const old_pc = cpu.r[15];
|
||||||
|
|
||||||
cpu.r[15] = cpu.r[14] + (offset << 1);
|
cpu.r[15] = cpu.r[14] +% (offset << 1);
|
||||||
cpu.r[14] = old_pc | 1;
|
cpu.r[14] = old_pc | 1;
|
||||||
} else {
|
} else {
|
||||||
// Instruction 1
|
// Instruction 1
|
||||||
|
|
|
@ -116,7 +116,7 @@ pub fn format10(comptime L: bool, comptime offset: u5) InstrFn {
|
||||||
const rb = opcode >> 3 & 0x7;
|
const rb = opcode >> 3 & 0x7;
|
||||||
const rd = opcode & 0x7;
|
const rd = opcode & 0x7;
|
||||||
|
|
||||||
const address = cpu.r[rb] + (offset << 1);
|
const address = cpu.r[rb] + (@as(u6, offset) << 1);
|
||||||
|
|
||||||
if (L) {
|
if (L) {
|
||||||
// LDRH
|
// LDRH
|
||||||
|
|
|
@ -18,12 +18,12 @@ pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn {
|
||||||
0b00 => {
|
0b00 => {
|
||||||
// ADD
|
// ADD
|
||||||
const sum = add(false, cpu, dst, src);
|
const sum = add(false, cpu, dst, src);
|
||||||
cpu.r[dst_idx] = if (dst_idx == 0xF) sum & 0xFFFF_FFFC else sum;
|
cpu.r[dst_idx] = if (dst_idx == 0xF) sum & 0xFFFF_FFFE else sum;
|
||||||
},
|
},
|
||||||
0b01 => cmp(cpu, dst, src), // CMP
|
0b01 => cmp(cpu, dst, src), // CMP
|
||||||
0b10 => {
|
0b10 => {
|
||||||
// MOV
|
// MOV
|
||||||
cpu.r[dst_idx] = if (dst_idx == 0xF) src & 0xFFFF_FFFC else src;
|
cpu.r[dst_idx] = if (dst_idx == 0xF) src & 0xFFFF_FFFE else src;
|
||||||
},
|
},
|
||||||
0b11 => {
|
0b11 => {
|
||||||
// BX
|
// BX
|
||||||
|
|
Loading…
Reference in New Issue