~sircmpwn/hdmg

46ec03590cf49b45bece9dbec7fea725af3da6ce — Drew DeVault 1 year, 6 months ago 1b1e53f
sm83: implement BIT
1 files changed, 70 insertions(+), 64 deletions(-)

M sm83/prefix.ha
M sm83/prefix.ha => sm83/prefix.ha +70 -64
@@ 80,70 80,76 @@ fn exec_srl_h(cpu: *sm83) void = abort("TODO");
fn exec_srl_l(cpu: *sm83) void = abort("TODO");
fn exec_srl_hl(cpu: *sm83) void = abort("TODO");

fn exec_bit_0_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_0_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_1_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_2_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_3_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_4_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_5_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_6_a(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_b(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_c(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_d(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_e(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_h(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_l(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_hl(cpu: *sm83) void = abort("TODO");
fn exec_bit_7_a(cpu: *sm83) void = abort("TODO");
fn bit(cpu: *sm83, n: u8, reg: u8) void = {
	const z = (reg & (1 << n)) >> n;
	cpu.regs.F &= ~FL_N;
	cpu.regs.F |= FL_H | (n << FB_Z);
};

fn exec_bit_0_b(cpu: *sm83) void = bit(cpu, 0, cpu.regs.B);
fn exec_bit_0_c(cpu: *sm83) void = bit(cpu, 0, cpu.regs.C);
fn exec_bit_0_d(cpu: *sm83) void = bit(cpu, 0, cpu.regs.D);
fn exec_bit_0_e(cpu: *sm83) void = bit(cpu, 0, cpu.regs.E);
fn exec_bit_0_h(cpu: *sm83) void = bit(cpu, 0, cpu.regs.H);
fn exec_bit_0_l(cpu: *sm83) void = bit(cpu, 0, cpu.regs.L);
fn exec_bit_0_hl(cpu: *sm83) void = bit(cpu, 0, readb(cpu, cpu.regs.HL));
fn exec_bit_0_a(cpu: *sm83) void = bit(cpu, 1, cpu.regs.A);
fn exec_bit_1_b(cpu: *sm83) void = bit(cpu, 1, cpu.regs.B);
fn exec_bit_1_c(cpu: *sm83) void = bit(cpu, 1, cpu.regs.C);
fn exec_bit_1_d(cpu: *sm83) void = bit(cpu, 1, cpu.regs.D);
fn exec_bit_1_e(cpu: *sm83) void = bit(cpu, 1, cpu.regs.E);
fn exec_bit_1_h(cpu: *sm83) void = bit(cpu, 1, cpu.regs.H);
fn exec_bit_1_l(cpu: *sm83) void = bit(cpu, 1, cpu.regs.L);
fn exec_bit_1_hl(cpu: *sm83) void = bit(cpu, 1, readb(cpu, cpu.regs.HL));
fn exec_bit_1_a(cpu: *sm83) void = bit(cpu, 1, cpu.regs.A);
fn exec_bit_2_b(cpu: *sm83) void = bit(cpu, 2, cpu.regs.B);
fn exec_bit_2_c(cpu: *sm83) void = bit(cpu, 2, cpu.regs.C);
fn exec_bit_2_d(cpu: *sm83) void = bit(cpu, 2, cpu.regs.D);
fn exec_bit_2_e(cpu: *sm83) void = bit(cpu, 2, cpu.regs.E);
fn exec_bit_2_h(cpu: *sm83) void = bit(cpu, 2, cpu.regs.H);
fn exec_bit_2_l(cpu: *sm83) void = bit(cpu, 2, cpu.regs.L);
fn exec_bit_2_hl(cpu: *sm83) void = bit(cpu, 2, readb(cpu, cpu.regs.HL));
fn exec_bit_2_a(cpu: *sm83) void = bit(cpu, 2, cpu.regs.A);
fn exec_bit_3_b(cpu: *sm83) void = bit(cpu, 3, cpu.regs.B);
fn exec_bit_3_c(cpu: *sm83) void = bit(cpu, 3, cpu.regs.C);
fn exec_bit_3_d(cpu: *sm83) void = bit(cpu, 3, cpu.regs.D);
fn exec_bit_3_e(cpu: *sm83) void = bit(cpu, 3, cpu.regs.E);
fn exec_bit_3_h(cpu: *sm83) void = bit(cpu, 3, cpu.regs.H);
fn exec_bit_3_l(cpu: *sm83) void = bit(cpu, 3, cpu.regs.L);
fn exec_bit_3_hl(cpu: *sm83) void = bit(cpu, 3, readb(cpu, cpu.regs.HL));
fn exec_bit_3_a(cpu: *sm83) void = bit(cpu, 3, cpu.regs.A);
fn exec_bit_4_b(cpu: *sm83) void = bit(cpu, 4, cpu.regs.B);
fn exec_bit_4_c(cpu: *sm83) void = bit(cpu, 4, cpu.regs.C);
fn exec_bit_4_d(cpu: *sm83) void = bit(cpu, 4, cpu.regs.D);
fn exec_bit_4_e(cpu: *sm83) void = bit(cpu, 4, cpu.regs.E);
fn exec_bit_4_h(cpu: *sm83) void = bit(cpu, 4, cpu.regs.H);
fn exec_bit_4_l(cpu: *sm83) void = bit(cpu, 4, cpu.regs.L);
fn exec_bit_4_hl(cpu: *sm83) void = bit(cpu, 4, readb(cpu, cpu.regs.HL));
fn exec_bit_4_a(cpu: *sm83) void = bit(cpu, 4, cpu.regs.A);
fn exec_bit_5_b(cpu: *sm83) void = bit(cpu, 5, cpu.regs.B);
fn exec_bit_5_c(cpu: *sm83) void = bit(cpu, 5, cpu.regs.C);
fn exec_bit_5_d(cpu: *sm83) void = bit(cpu, 5, cpu.regs.D);
fn exec_bit_5_e(cpu: *sm83) void = bit(cpu, 5, cpu.regs.E);
fn exec_bit_5_h(cpu: *sm83) void = bit(cpu, 5, cpu.regs.H);
fn exec_bit_5_l(cpu: *sm83) void = bit(cpu, 5, cpu.regs.L);
fn exec_bit_5_hl(cpu: *sm83) void = bit(cpu, 5, readb(cpu, cpu.regs.HL));
fn exec_bit_5_a(cpu: *sm83) void = bit(cpu, 5, cpu.regs.A);
fn exec_bit_6_b(cpu: *sm83) void = bit(cpu, 6, cpu.regs.B);
fn exec_bit_6_c(cpu: *sm83) void = bit(cpu, 6, cpu.regs.C);
fn exec_bit_6_d(cpu: *sm83) void = bit(cpu, 6, cpu.regs.D);
fn exec_bit_6_e(cpu: *sm83) void = bit(cpu, 6, cpu.regs.E);
fn exec_bit_6_h(cpu: *sm83) void = bit(cpu, 6, cpu.regs.H);
fn exec_bit_6_l(cpu: *sm83) void = bit(cpu, 6, cpu.regs.L);
fn exec_bit_6_hl(cpu: *sm83) void = bit(cpu, 6, readb(cpu, cpu.regs.HL));
fn exec_bit_6_a(cpu: *sm83) void = bit(cpu, 6, cpu.regs.A);
fn exec_bit_7_b(cpu: *sm83) void = bit(cpu, 7, cpu.regs.B);
fn exec_bit_7_c(cpu: *sm83) void = bit(cpu, 7, cpu.regs.C);
fn exec_bit_7_d(cpu: *sm83) void = bit(cpu, 7, cpu.regs.D);
fn exec_bit_7_e(cpu: *sm83) void = bit(cpu, 7, cpu.regs.E);
fn exec_bit_7_h(cpu: *sm83) void = bit(cpu, 7, cpu.regs.H);
fn exec_bit_7_l(cpu: *sm83) void = bit(cpu, 7, cpu.regs.L);
fn exec_bit_7_hl(cpu: *sm83) void = bit(cpu, 7, readb(cpu, cpu.regs.HL));
fn exec_bit_7_a(cpu: *sm83) void = bit(cpu, 7, cpu.regs.A);

fn exec_res_0_b(cpu: *sm83) void = abort("TODO");
fn exec_res_0_c(cpu: *sm83) void = abort("TODO");