From 440f52c943b377e6d59b7f8f9d71d7eeb0a667e1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 19 Jun 2019 21:18:30 -0400 Subject: [PATCH] Incorporates TRAP test. --- .../Mac/Clock SignalTests/68000Tests.mm | 28 +++++++++++++++++-- .../68000/Implementation/68000Storage.cpp | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/68000Tests.mm b/OSBindings/Mac/Clock SignalTests/68000Tests.mm index c94d8749f..0be48c86e 100644 --- a/OSBindings/Mac/Clock SignalTests/68000Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000Tests.mm @@ -26,9 +26,9 @@ class RAM68000: public CPU::MC68000::BusHandler { // Setup the /RESET vector. ram_[0] = 0; - ram_[1] = 0xffff; + ram_[1] = 0x206; // Supervisor stack pointer. ram_[2] = 0; - ram_[3] = 0x1000; + ram_[3] = 0x1000; // Initial PC. } void set_program(const std::vector &program) { @@ -806,4 +806,28 @@ class CPU::MC68000::ProcessorStorageTests { XCTAssertEqual(state.status & CPU::MC68000::Flag::ConditionCodes, CPU::MC68000::Flag::Negative); } +// MARK: TRAP + +- (void)testTrap { + _machine->set_program({ + 0x4e41 // TRAP #1 + }); + auto state = _machine->get_processor_state(); + state.status = 0x700; + state.user_stack_pointer = 0x200; + state.supervisor_stack_pointer = 0x206; + *_machine->ram_at(0x84) = 0xfffe; + *_machine->ram_at(0xfffe) = 0x4e71; + + _machine->set_processor_state(state); + _machine->run_for_instructions(2); + + state = _machine->get_processor_state(); + XCTAssertEqual(state.status, 0x2700); + XCTAssertEqual(*_machine->ram_at(0x200), 0x700); + XCTAssertEqual(*_machine->ram_at(0x202), 0x0000); + XCTAssertEqual(*_machine->ram_at(0x204), 0x1002); + XCTAssertEqual(state.supervisor_stack_pointer, 0x200); +} + @end diff --git a/Processors/68000/Implementation/68000Storage.cpp b/Processors/68000/Implementation/68000Storage.cpp index b07f4790e..e52443582 100644 --- a/Processors/68000/Implementation/68000Storage.cpp +++ b/Processors/68000/Implementation/68000Storage.cpp @@ -808,7 +808,7 @@ struct ProcessorStorageConstructor { // Temporary storage for the Program fields. ProcessorBase::Program program; -// if(instruction == 0xc30a) { +// if(instruction == 0x4e41) { // printf(""); // }