fix: don't mask away MSB in THUMB.5 add

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:19 -03:00
parent f9e7128061
commit 05bf245b5a
1 changed files with 5 additions and 1 deletions

View File

@ -15,7 +15,11 @@ pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn {
const dst = if (dst_idx == 0xF) (cpu.r[dst_idx] + 2) & 0xFFFF_FFFE else cpu.r[dst_idx];
switch (op) {
0b00 => cpu.r[dst_idx] = add(false, cpu, dst, src) & if (dst_idx == 0xF) 0xFFFF_FFFC else @as(u32, 0xFFF_FFFF), // ADD
0b00 => {
// ADD
const sum = add(false, cpu, dst, src);
cpu.r[dst_idx] = if (dst_idx == 0xF) sum & 0xFFFF_FFFC else sum;
},
0b01 => cmp(cpu, dst, src), // CMP
0b10 => {
// MOV