EightBit/src/Processor.cpp
Adrian.Conlon 211c75d84d Add Z80 processor and tests.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
2017-06-05 22:39:15 +01:00

44 lines
776 B
C++

#include "stdafx.h"
#include "Processor.h"
EightBit::Processor::Processor(Memory& memory)
: m_memory(memory),
cycles(0),
m_halted(false) {
sp.word = 0xffff;
pc.word = 0;
}
void EightBit::Processor::reset() {
pc.word = 0;
}
void EightBit::Processor::initialise() {
sp.word = 0xffff;
reset();
}
void EightBit::Processor::push(uint8_t value) {
sp.word--;
m_memory.ADDRESS() = sp;
m_memory.reference() = value;
}
void EightBit::Processor::pushWord(register16_t value) {
push(value.high);
push(value.low);
}
uint8_t EightBit::Processor::pop() {
m_memory.ADDRESS() = sp;
sp.word++;
return m_memory.reference();
}
EightBit::register16_t EightBit::Processor::popWord() {
register16_t returned;
returned.low = pop();
returned.high = pop();
return returned;
}