mirror of
https://github.com/KarolS/millfork.git
synced 2024-06-30 21:29:36 +00:00
Detect stack overflow during Z80 tests
This commit is contained in:
parent
96b020ce62
commit
0f9bb4fb56
|
@ -162,14 +162,18 @@ class EmuZ80Run(cpu: millfork.Cpu.Value, nodeOptimizations: List[NodeOptimizatio
|
||||||
}
|
}
|
||||||
|
|
||||||
val memoryBank = assembler.mem.banks("default")
|
val memoryBank = assembler.mem.banks("default")
|
||||||
(0x1f0 until 0x200).foreach(i => memoryBank.readable(i) = true)
|
(0x1ed until 0x200).foreach(i => memoryBank.readable(i) = true)
|
||||||
(0xff00 to 0xffff).foreach{i =>
|
(0xff00 to 0xffff).foreach{i =>
|
||||||
memoryBank.readable(i) = true
|
memoryBank.readable(i) = true
|
||||||
memoryBank.writeable(i) = true
|
memoryBank.writeable(i) = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LD SP,$fffe
|
||||||
// CALL $0200
|
// CALL $0200
|
||||||
// HALT
|
// HALT
|
||||||
|
memoryBank.output(0x1ed) = 0x31.toByte
|
||||||
|
memoryBank.output(0x1ee) = 0xFE.toByte
|
||||||
|
memoryBank.output(0x1ef) = 0xFF.toByte
|
||||||
memoryBank.output(0x1f0) = 0xCD.toByte
|
memoryBank.output(0x1f0) = 0xCD.toByte
|
||||||
memoryBank.output(0x1f1) = 0
|
memoryBank.output(0x1f1) = 0
|
||||||
memoryBank.output(0x1f2) = 2
|
memoryBank.output(0x1f2) = 2
|
||||||
|
@ -187,13 +191,16 @@ class EmuZ80Run(cpu: millfork.Cpu.Value, nodeOptimizations: List[NodeOptimizatio
|
||||||
case millfork.Cpu.Z80 | millfork.Cpu.Intel8080 =>
|
case millfork.Cpu.Z80 | millfork.Cpu.Intel8080 =>
|
||||||
val cpu = new Z80Core(Z80Memory(memoryBank), DummyIO)
|
val cpu = new Z80Core(Z80Memory(memoryBank), DummyIO)
|
||||||
cpu.reset()
|
cpu.reset()
|
||||||
cpu.setProgramCounter(0x1f0)
|
cpu.setProgramCounter(0x1ed)
|
||||||
cpu.resetTStates()
|
cpu.resetTStates()
|
||||||
while (!cpu.getHalt) {
|
while (!cpu.getHalt) {
|
||||||
cpu.executeOneInstruction()
|
cpu.executeOneInstruction()
|
||||||
if (resetN) {
|
if (resetN) {
|
||||||
resetNMethod.invoke(cpu)
|
resetNMethod.invoke(cpu)
|
||||||
}
|
}
|
||||||
|
if (cpu.getSP.&(0xffff) < 0xd002) {
|
||||||
|
throw new IllegalStateException("stack overflow")
|
||||||
|
}
|
||||||
// dump(cpu)
|
// dump(cpu)
|
||||||
cpu.getTStates should be < TooManyCycles
|
cpu.getTStates should be < TooManyCycles
|
||||||
}
|
}
|
||||||
|
@ -202,7 +209,7 @@ class EmuZ80Run(cpu: millfork.Cpu.Value, nodeOptimizations: List[NodeOptimizatio
|
||||||
case millfork.Cpu.Sharp =>
|
case millfork.Cpu.Sharp =>
|
||||||
var ticks = 0L
|
var ticks = 0L
|
||||||
val cpu = GameboyStubs(memoryBank).cpu
|
val cpu = GameboyStubs(memoryBank).cpu
|
||||||
cpu.getRegisters.setPC(0x1f0)
|
cpu.getRegisters.setPC(0x1ed)
|
||||||
while (cpu.getState != Cpu.State.HALTED) {
|
while (cpu.getState != Cpu.State.HALTED) {
|
||||||
cpu.tick()
|
cpu.tick()
|
||||||
// dump(cpu)
|
// dump(cpu)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user