2018-08-25 21:51:56 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "LittleEndianProcessor.h"
|
|
|
|
|
|
|
|
EightBit::LittleEndianProcessor::LittleEndianProcessor(Bus& memory)
|
|
|
|
: Processor(memory) {}
|
|
|
|
|
|
|
|
EightBit::register16_t EightBit::LittleEndianProcessor::getWord() {
|
2018-12-29 19:17:36 +00:00
|
|
|
const auto low = busRead();
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS();
|
2018-12-29 19:17:36 +00:00
|
|
|
const auto high = busRead();
|
2018-10-27 16:30:23 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
|
2018-12-29 19:17:36 +00:00
|
|
|
busWrite(value.low);
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS();
|
2018-12-29 19:17:36 +00:00
|
|
|
busWrite(value.high);
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 23:16:00 +00:00
|
|
|
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
2018-08-25 21:51:56 +00:00
|
|
|
const auto low = getBytePaged(page, offset);
|
|
|
|
++BUS().ADDRESS().low;
|
2018-12-29 19:17:36 +00:00
|
|
|
const auto high = busRead();
|
2018-10-27 16:30:23 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 23:16:00 +00:00
|
|
|
void EightBit::LittleEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
|
2018-08-25 21:51:56 +00:00
|
|
|
setBytePaged(page, offset, value.low);
|
|
|
|
++BUS().ADDRESS().low;
|
2018-12-29 19:17:36 +00:00
|
|
|
busWrite(value.high);
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EightBit::register16_t EightBit::LittleEndianProcessor::fetchWord() {
|
|
|
|
const auto low = fetchByte();
|
|
|
|
const auto high = fetchByte();
|
2018-10-27 16:30:23 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::LittleEndianProcessor::pushWord(const register16_t value) {
|
|
|
|
push(value.high);
|
|
|
|
push(value.low);
|
|
|
|
}
|
|
|
|
|
|
|
|
EightBit::register16_t EightBit::LittleEndianProcessor::popWord() {
|
|
|
|
const auto low = pop();
|
|
|
|
const auto high = pop();
|
2018-10-27 16:30:23 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
2018-08-27 10:27:33 +00:00
|
|
|
|
|
|
|
EightBit::register16_t EightBit::LittleEndianProcessor::peekWord(const register16_t address) {
|
2018-08-29 12:52:25 +00:00
|
|
|
const auto low = BUS().peek(address);
|
|
|
|
const auto high = BUS().peek(address + 1);
|
2018-10-27 16:30:23 +00:00
|
|
|
return { low, high };
|
2018-08-27 10:27:33 +00:00
|
|
|
}
|
2018-10-14 09:05:43 +00:00
|
|
|
|
|
|
|
void EightBit::LittleEndianProcessor::pokeWord(const register16_t address, const register16_t value) {
|
|
|
|
BUS().poke(address, value.low);
|
|
|
|
BUS().poke(address + 1, value.high);
|
|
|
|
}
|