From aa9a4c6bce98f27f49e7d631a6a93a432c54c5ec Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 25 Nov 2023 23:04:01 +0100 Subject: [PATCH] SPC700: implement RET/RET1 --- src/snes/cpu_spc700/cpu.rs | 22 ++++++++++++++++++++++ src/test/processortests_spc700.rs | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/snes/cpu_spc700/cpu.rs b/src/snes/cpu_spc700/cpu.rs index eb96644..810b1d8 100644 --- a/src/snes/cpu_spc700/cpu.rs +++ b/src/snes/cpu_spc700/cpu.rs @@ -283,6 +283,28 @@ where InstructionType::DAA => self.op_daa(), InstructionType::DAS => self.op_das(), InstructionType::JMP => self.op_jmp(instr), + InstructionType::RET => { + // Discarded read + internal cycle + self.read_tick(self.regs.read(Register::PC)); + self.tick_bus(1)?; + + let pc = self.pop16(); + self.regs.write(Register::PC, pc); + + Ok(()) + } + InstructionType::RET1 => { + // Discarded read + internal cycle + self.read_tick(self.regs.read(Register::PC)); + self.tick_bus(1)?; + + let flags = self.pop8(); + self.regs.write(Register::PSW, flags.into()); + let pc = self.pop16(); + self.regs.write(Register::PC, pc); + + Ok(()) + } _ => todo!(), } } diff --git a/src/test/processortests_spc700.rs b/src/test/processortests_spc700.rs index d7b6ad0..05e7d0c 100644 --- a/src/test/processortests_spc700.rs +++ b/src/test/processortests_spc700.rs @@ -303,7 +303,7 @@ cpu_test!(instr_6a, 0x6a); cpu_test!(instr_6d, 0x6d); // Read indirection during fetch cpu_test_no_trace!(instr_6e, 0x6e); -//cpu_test!(instr_6f, 0x6f); +cpu_test!(instr_6f, 0x6f); cpu_test!(instr_70, 0x70); cpu_test!(instr_71, 0x71); cpu_test!(instr_72, 0x72); @@ -320,7 +320,7 @@ cpu_test!(instr_7a, 0x7a); //cpu_test!(instr_7c, 0x7c); cpu_test!(instr_7d, 0x7d); cpu_test!(instr_7e, 0x7e); -//cpu_test!(instr_7f, 0x7f); +cpu_test!(instr_7f, 0x7f); cpu_test!(instr_80, 0x80); cpu_test!(instr_81, 0x81); cpu_test!(instr_82, 0x82);