From a3658f7f015989bc9e2b81d7e8dbbe5a1afc1c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sat, 2 Jul 2022 12:47:23 +0100 Subject: [PATCH] feat: new jump instruction --- src/inst.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/inst.rs b/src/inst.rs index 0dd5e6bb..8ff0b303 100644 --- a/src/inst.rs +++ b/src/inst.rs @@ -209,7 +209,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ (ret_nz, 8, "RET NZ"), (pop_bc, 12, "POP BC"), (noimpl, 4, "! UNIMP !"), - (noimpl, 4, "! UNIMP !"), + (jp_u16, 16, "JP u16"), (noimpl, 4, "! UNIMP !"), (push_bc, 16, "PUSH BC"), (noimpl, 4, "! UNIMP !"), @@ -770,6 +770,11 @@ fn pop_bc(cpu: &mut Cpu) { cpu.set_bc(word); } +fn jp_u16(cpu: &mut Cpu) { + let word = cpu.read_u16(); + cpu.pc = word; +} + fn push_bc(cpu: &mut Cpu) { cpu.push_word(cpu.bc()); } -- GitLab