This commit is contained in:
edmccard 2012-04-14 02:43:03 -04:00
parent a572ea9146
commit cf369d4d2b
2 changed files with 17 additions and 8 deletions

View File

@ -93,9 +93,6 @@ else
ubyte data; ubyte data;
} }
// TODO: other methods for stopping cpu
bool keepRunning;
this(MEM memory, CLK clock) this(MEM memory, CLK clock)
{ {
version(RunTest) {} version(RunTest) {}
@ -128,10 +125,11 @@ else
(N & 0x80); (N & 0x80);
} }
bool keepRunning;
final void run(bool continuous) final void run(bool continuous)
{ {
keepRunning = continuous; keepRunning = continuous;
// TODO debugging info?
ubyte opcode; ubyte opcode;
static if (!opArray) static if (!opArray)
{ {
@ -139,7 +137,8 @@ else
ushort address, base; ushort address, base;
ubyte data; ubyte data;
} }
do { do
{
version(Cumulative) version(Cumulative)
{ {
static if (!opArray) cycles = 1; static if (!opArray) cycles = 1;

View File

@ -218,8 +218,9 @@ version(Benchmark)
{ {
auto runner = new BreakRunner(mem); auto runner = new BreakRunner(mem);
auto cpu = new T(runner, runner); auto cpu = new T(runner, runner);
runner.keepRunning = &cpu.keepRunning;
setPC(cpu, 0x8000); setPC(cpu, 0x8000);
try { cpu.run(true); } catch (StopException e) {} cpu.run(true);
} }
else else
{ {
@ -243,6 +244,7 @@ version(Benchmark)
final class BreakRunner final class BreakRunner
{ {
TestMemory* mem; TestMemory* mem;
bool* keepRunning;
this(ref TestMemory mem) this(ref TestMemory mem)
{ {
@ -251,8 +253,16 @@ version(Benchmark)
final ubyte read(ushort addr) final ubyte read(ushort addr)
{ {
if (addr == 0xFFFE) throw new StopException("BRK"); if (addr == 0xfffe)
return mem.read(addr); {
*keepRunning = false;
return 0x00;
}
else if (addr == 0xffff)
{
return 0x80;
}
else return mem.read(addr);
} }
final void write(ushort addr, ubyte val) final void write(ushort addr, ubyte val)