chore: squash bugs preventing swi_demo.gba from working

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:19 -03:00
parent c143aefb01
commit 37fd8dab84
3 changed files with 4 additions and 4 deletions

View File

@ -43,7 +43,7 @@ pub fn format19(comptime is_low: bool) InstrFn {
// Instruction 2
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;
} else {
// Instruction 1

View File

@ -116,7 +116,7 @@ pub fn format10(comptime L: bool, comptime offset: u5) InstrFn {
const rb = opcode >> 3 & 0x7;
const rd = opcode & 0x7;
const address = cpu.r[rb] + (offset << 1);
const address = cpu.r[rb] + (@as(u6, offset) << 1);
if (L) {
// LDRH

View File

@ -18,12 +18,12 @@ pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn {
0b00 => {
// ADD
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
0b10 => {
// 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 => {
// BX