2017-06-04 20:38:34 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Processor.h"
|
|
|
|
|
2017-09-06 12:22:23 +00:00
|
|
|
EightBit::Processor::Processor(Bus& bus)
|
2017-11-10 22:41:50 +00:00
|
|
|
: m_bus(bus) {
|
2017-06-04 20:38:34 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 00:34:30 +00:00
|
|
|
void EightBit::Processor::powerOn() {
|
|
|
|
raise(RESET());
|
|
|
|
raise(HALT());
|
2017-12-10 21:41:48 +00:00
|
|
|
raise(INT());
|
|
|
|
raise(NMI());
|
2018-08-25 00:34:30 +00:00
|
|
|
raise(POWER());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::Processor::handleRESET() {
|
2017-12-10 21:41:48 +00:00
|
|
|
raise(RESET());
|
2018-08-11 20:19:19 +00:00
|
|
|
PC() = 0;
|
2017-06-04 20:38:34 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 00:34:30 +00:00
|
|
|
void EightBit::Processor::handleNMI() {
|
|
|
|
raise(NMI());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::Processor::handleINT() {
|
|
|
|
raise(INT());
|
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
int EightBit::Processor::run(const int limit) {
|
2017-08-30 22:17:34 +00:00
|
|
|
int current = 0;
|
2018-08-11 20:19:19 +00:00
|
|
|
while (LIKELY(powered()) && current < limit)
|
2018-08-25 00:34:30 +00:00
|
|
|
current += step();
|
2017-08-30 22:17:34 +00:00
|
|
|
return current;
|
|
|
|
}
|