Start moving towards reset being just another style of interrupt.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2018-08-25 01:34:30 +01:00
parent bca7977a23
commit 6d4223c368
17 changed files with 189 additions and 136 deletions

View File

@@ -5,24 +5,30 @@ EightBit::Processor::Processor(Bus& bus)
: m_bus(bus) {
}
void EightBit::Processor::reset() {
if (lowered(POWER()))
throw std::logic_error("POWER cannot be low");
void EightBit::Processor::powerOn() {
raise(RESET());
raise(HALT());
raise(INT());
raise(NMI());
raise(POWER());
}
void EightBit::Processor::handleRESET() {
raise(RESET());
PC() = 0;
}
void EightBit::Processor::handleNMI() {
raise(NMI());
}
void EightBit::Processor::handleINT() {
raise(INT());
}
int EightBit::Processor::run(const int limit) {
int current = 0;
while (LIKELY(powered()) && current < limit)
current += singleStep();
current += step();
return current;
}
int EightBit::Processor::singleStep() {
if (UNLIKELY(lowered(RESET())))
reset();
return step();
}