From e59bd9654aa92b50301db0097c768363153ab5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Mon, 4 Jul 2022 00:28:58 +0100 Subject: [PATCH] feat: new ret instruction --- src/inst.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/inst.rs b/src/inst.rs index 2ddc8412..05c7735b 100644 --- a/src/inst.rs +++ b/src/inst.rs @@ -231,7 +231,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ (push_de, 16, "PUSH DE"), (sub_a_u8, 8, "SUB A, u8"), (noimpl, 4, "! UNIMP !"), - (noimpl, 4, "! UNIMP !"), + (ret_c, 8, "RET C"), (reti, 16, "RETI"), (jp_c_u16, 12, "JP C, u16"), (illegal, 4, "ILLEGAL"), @@ -1450,6 +1450,15 @@ fn sub_a_u8(cpu: &mut Cpu) { cpu.a = sub_set_flags(cpu, cpu.a, byte); } +fn ret_c(cpu: &mut Cpu) { + if !cpu.get_carry() { + return; + } + + cpu.pc = cpu.pop_word(); + cpu.ticks = cpu.ticks.wrapping_add(12); +} + fn reti(cpu: &mut Cpu) { cpu.pc = cpu.pop_word(); cpu.enable_int(); -- GitLab