From cb277b8d1eda039b3ef1882a2593aef4cf8026af Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 19 Jun 2017 21:27:23 -0400 Subject: [PATCH] Added JP and JR tests. --- .../Z80MachineCycleTests.swift | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift b/OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift index e9ada6bb2..c37cb98ba 100644 --- a/OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift +++ b/OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift @@ -863,4 +863,97 @@ class Z80MachineCycleTests: XCTestCase { ] ) } + + // JP nn + func testJPnn() { + test( + program: [0xc3, 0x00, 0x80], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + MachineCycle(operation: .read, length: 3), + ] + ) + } + + // JP cc, nn + func testJPccnn() { + test( + program: [ + 0x37, // SCF + 0xd2, 0x00, 0x80, // JP NC, 0x8000 + 0xda, 0x00, 0x80, // JP C, 0x8000 + ], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + MachineCycle(operation: .read, length: 3), + + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + MachineCycle(operation: .read, length: 3), + ] + ) + } + + // JR e + func testJRe() { + test( + program: [0x18, 0x80], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + MachineCycle(operation: .internalOperation, length: 5), + MachineCycle(operation: .readOpcode, length: 4), + ] + ) + } + + // JR cc, e + func testJRcce() { + test( + program: [ + 0x37, // SCF + 0x30, 0x80, // JR NC, 0x8000 + 0x38, 0x80, // JR C, 0x8000 + ], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .read, length: 3), + MachineCycle(operation: .internalOperation, length: 5), + + MachineCycle(operation: .readOpcode, length: 4), + ] + ) + } + + // JP (HL) + func testJPHL() { + test( + program: [0xe9], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .readOpcode, length: 4), + ] + ) + } + + // JP (IX) + func testJPIX() { + test( + program: [0xdd, 0xe9], + busCycles: [ + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .readOpcode, length: 4), + MachineCycle(operation: .readOpcode, length: 4), + ] + ) + } }