diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 2925ec984..2b7baf4c3 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4B01A6881F22F0DB001FD6E3 /* Z80MemptrTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B01A6871F22F0DB001FD6E3 /* Z80MemptrTests.swift */; }; 4B049CDD1DA3C82F00322067 /* BCDTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B049CDC1DA3C82F00322067 /* BCDTest.swift */; }; 4B08A2751EE35D56008B7065 /* Z80InterruptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */; }; 4B08A2781EE39306008B7065 /* TestMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B08A2771EE39306008B7065 /* TestMachine.mm */; }; @@ -456,6 +457,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4B01A6871F22F0DB001FD6E3 /* Z80MemptrTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80MemptrTests.swift; sourceTree = ""; }; 4B046DC31CFE651500E9E45E /* CRTMachine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CRTMachine.hpp; sourceTree = ""; }; 4B049CDC1DA3C82F00322067 /* BCDTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BCDTest.swift; sourceTree = ""; }; 4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80InterruptTests.swift; sourceTree = ""; }; @@ -1880,6 +1882,7 @@ 4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */, 4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */, 4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */, + 4B01A6871F22F0DB001FD6E3 /* Z80MemptrTests.swift */, 4BFCA12A1ECBE7C400AC40C1 /* ZexallTests.swift */, 4B3BA0C41D318B44005DD7A7 /* Bridges */, 4B1414631B588A1100E04248 /* Test Binaries */, @@ -2709,6 +2712,7 @@ 4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */, 4BFCA1201ECBDC1500AC40C1 /* Z80AllRAM.cpp in Sources */, 4BB73EB71B587A5100552FC2 /* AllSuiteATests.swift in Sources */, + 4B01A6881F22F0DB001FD6E3 /* Z80MemptrTests.swift in Sources */, 4B121F9B1E06293F00BFDA12 /* PCMSegmentEventSourceTests.mm in Sources */, 4BEF6AAC1D35D1C400E73575 /* DPLLTests.swift in Sources */, 4B3BA0CF1D318B44005DD7A7 /* MOS6522Bridge.mm in Sources */, diff --git a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.h b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.h index 592b1bca3..1abdf63d8 100644 --- a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.h +++ b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.h @@ -42,7 +42,8 @@ typedef NS_ENUM(NSInteger, CSTestMachineZ80Register) { CSTestMachineZ80RegisterHLDash, CSTestMachineZ80RegisterIX, CSTestMachineZ80RegisterIY, CSTestMachineZ80RegisterI, CSTestMachineZ80RegisterR, - CSTestMachineZ80RegisterIFF1, CSTestMachineZ80RegisterIFF2, CSTestMachineZ80RegisterIM + CSTestMachineZ80RegisterIFF1, CSTestMachineZ80RegisterIFF2, CSTestMachineZ80RegisterIM, + CSTestMachineZ80RegisterMemPtr }; @interface CSTestMachineZ80 : CSTestMachine diff --git a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.mm b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.mm index 37f64f599..83cc41033 100644 --- a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.mm +++ b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachineZ80.mm @@ -65,6 +65,8 @@ static CPU::Z80::Register registerForRegister(CSTestMachineZ80Register reg) { case CSTestMachineZ80RegisterProgramCounter: return CPU::Z80::Register::ProgramCounter; case CSTestMachineZ80RegisterStackPointer: return CPU::Z80::Register::StackPointer; + + case CSTestMachineZ80RegisterMemPtr: return CPU::Z80::Register::MemPtr; } } diff --git a/OSBindings/Mac/Clock SignalTests/Z80MemptrTests.swift b/OSBindings/Mac/Clock SignalTests/Z80MemptrTests.swift new file mode 100644 index 000000000..5b7dd6aef --- /dev/null +++ b/OSBindings/Mac/Clock SignalTests/Z80MemptrTests.swift @@ -0,0 +1,34 @@ +// +// Z80MemptrTests.swift +// Clock Signal +// +// Created by Thomas Harte on 21/07/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +import XCTest + +class Z80MemptrTests: XCTestCase { + private func test(program : [UInt8], length : Int32, initialValue : UInt16) -> UInt16 { + // Create a machine and install the supplied program at address 0, setting the PC to run from there + let machine = CSTestMachineZ80() + machine.setValue(0x0000, for: .programCounter) + machine.setData(Data(bytes: program), atAddress: 0x0000) + + // Set the initial value of memptr, run for the requested number of cycles, + // return the new value + machine.setValue(initialValue, for: .memPtr) + machine.runForNumber(ofCycles: length) + return machine.value(for: .memPtr) + } + + // LD A,(addr) + func testLDAnn() { + let program: [UInt8] = [ + 0x3a, 0x00, 0x00 + ] + let result = test(program: program, length: 13, initialValue: 0xffff) + XCTAssertEqual(result, 0x0001) + } + +}