1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Added a test to confirm interrupts are disabled, and a response to the interrupt cycle within the all-RAM machine.

This commit is contained in:
Thomas Harte 2017-06-03 17:53:44 -04:00
parent 3e9212aaff
commit 8c41a0f0ed
2 changed files with 37 additions and 0 deletions

View File

@ -42,4 +42,35 @@ class Z80InterruptTests: XCTestCase {
XCTAssertEqual(machine.value(for: .IFF2), 0)
}
func testIRQDisabled() {
let machine = CSTestMachineZ80()
// start the PC at 0x0100, interrupts disabled
machine.setValue(0x0100, for: .programCounter)
machine.setValue(0, for: .IFF1)
machine.setValue(0, for: .IFF2)
// install six NOPs
for address: UInt16 in 0x0100 ..< 0x0106 {
machine.setValue(0x00, atAddress: address)
}
// replace the fourth NOP with an EI
machine.setValue(0xfb, atAddress: 0x0103)
// run for four cycles, signal IRQ and run for 8 more
machine.runForNumber(ofCycles: 4)
machine.irqLine = true
machine.runForNumber(ofCycles: 8)
// confirm that the request was ignored
XCTAssertEqual(machine.value(for: .programCounter), 0x0103)
// run for 12 more cycles, hitting the EI and, if no interrupt occured, the two NOPs after it
machine.runForNumber(ofCycles: 12)
// confirm that an interruption occurred, causing the PC not yet to have proceeded beyond 0x0105
XCTAssertEqual(machine.value(for: .programCounter), 0x0105)
}
}

View File

@ -42,6 +42,12 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public Processor<Concrete
case BusOperation::Internal:
break;
case BusOperation::Interrupt:
// A pick that means LD HL, (nn) if interpreted as an instruction but is otherwise
// arbitrary.
*cycle.value = 0x21;
break;
default:
printf("???\n");
break;