From 89fe647f1e17c93a9a3816af48e7e3dfb57f29db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sun, 3 Jul 2022 20:43:21 +0100
Subject: [PATCH] feat: add reti instruction

---
 src/inst.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/inst.rs b/src/inst.rs
index e8bfa101..eff4bf48 100644
--- a/src/inst.rs
+++ b/src/inst.rs
@@ -232,7 +232,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
     (sub_a_u8, 8, "SUB A, u8"),
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
-    (noimpl, 4, "! UNIMP !"),
+    (reti, 16, "RETI"),
     (jp_c_u16, 12, "JP C, u16"),
     (noimpl, 4, "! UNIMP !"),
     (call_c_u16, 12, "CALL C, u16"),
@@ -1212,6 +1212,11 @@ fn sub_a_u8(cpu: &mut Cpu) {
     cpu.a = sub_set_flags(cpu, cpu.a, byte);
 }
 
+fn reti(cpu: &mut Cpu) {
+    cpu.pc = cpu.pop_word();
+    cpu.enable_int();
+}
+
 fn jp_c_u16(cpu: &mut Cpu) {
     let word = cpu.read_u16();
 
-- 
GitLab