From 6595f8f527f51530821a227d00ec380fb7a9b63d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Jan 2020 22:35:28 -0500 Subject: [PATCH] Introduces a timing test for LSL. Which already passes. --- .../Mac/Clock SignalTests/68000Tests.mm | 26 +++++++++++++++++++ .../Mac/Clock SignalTests/TestRunner68000.hpp | 4 +++ 2 files changed, 30 insertions(+) diff --git a/OSBindings/Mac/Clock SignalTests/68000Tests.mm b/OSBindings/Mac/Clock SignalTests/68000Tests.mm index a192a05fe..716b2e880 100644 --- a/OSBindings/Mac/Clock SignalTests/68000Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000Tests.mm @@ -261,6 +261,32 @@ class CPU::MC68000::ProcessorStorageTests { XCTAssertEqual(stack_frame[6], 0x1004); } +- (void)testShiftDuration { + // + _machine->set_program({ + 0x7004, // MOVE.l #$4, D0 + 0x7207, // MOVE.l #$7, D1 + 0x7401, // MOVE.l #$1, D2 + + 0xe16e, // lsl d0, d6 + 0xe36e, // lsl d1, d6 + 0xe56e, // lsl d2, d6 + }); + _machine->run_for_instructions(3); + + _machine->reset_cycle_count(); + _machine->run_for_instructions(1); + XCTAssertEqual(_machine->get_cycle_count(), 6 + 8); + _machine->reset_cycle_count(); + + _machine->run_for_instructions(1); + XCTAssertEqual(_machine->get_cycle_count(), 6 + 14); + _machine->reset_cycle_count(); + + _machine->run_for_instructions(1); + XCTAssertEqual(_machine->get_cycle_count(), 6 + 2); +} + - (void)testOpcodeCoverage { // Perform an audit of implemented instructions. CPU::MC68000::ProcessorStorageTests storage_tests( diff --git a/OSBindings/Mac/Clock SignalTests/TestRunner68000.hpp b/OSBindings/Mac/Clock SignalTests/TestRunner68000.hpp index 0f9d437fb..0a912b3dc 100644 --- a/OSBindings/Mac/Clock SignalTests/TestRunner68000.hpp +++ b/OSBindings/Mac/Clock SignalTests/TestRunner68000.hpp @@ -130,6 +130,10 @@ class RAM68000: public CPU::MC68000::BusHandler { return int(duration_.as_integral()) >> 1; } + void reset_cycle_count() { + duration_ = HalfCycles(0); + } + private: CPU::MC68000::Processor m68000_; std::array ram_{};