From 30eb5464455cc22cd504d83e50e833d4a7294e57 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 01:31:05 +0100
Subject: [PATCH] feat: added ld_b_b

---
 src/inst.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/inst.rs b/src/inst.rs
index 752279d6..17e43c9b 100644
--- a/src/inst.rs
+++ b/src/inst.rs
@@ -70,7 +70,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
     (ld_a_u8, 8, "LD A, u8"),
     (noimpl, 4, "! UNIMP !"),
     // 0x4 opcodes
-    (noimpl, 4, "! UNIMP !"),
+    (ld_b_b, 4, "LD B, B"),
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
@@ -224,7 +224,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
     (rst_08h, 16, "RST 08h"),
     // 0xd opcodes
     (noimpl, 4, "! UNIMP !"),
-    (noimpl, 4, "! UNIMP !"),
+    (pop_de, 12, "POP DE"),
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
     (noimpl, 4, "! UNIMP !"),
@@ -820,6 +820,10 @@ fn ld_a_u8(cpu: &mut Cpu) {
     cpu.a = byte;
 }
 
+fn ld_b_b(cpu: &mut Cpu) {
+    cpu.b = cpu.b;
+}
+
 fn ld_b_h(cpu: &mut Cpu) {
     cpu.b = cpu.h;
 }
@@ -1031,6 +1035,11 @@ fn rst_08h(cpu: &mut Cpu) {
     rst(cpu, 0x0008);
 }
 
+fn pop_de(cpu: &mut Cpu) {
+    let word = cpu.pop_word();
+    cpu.set_de(word);
+}
+
 fn push_de(cpu: &mut Cpu) {
     cpu.push_word(cpu.de());
 }
-- 
GitLab