2018-08-25 21:51:56 +00:00
|
|
|
#include "stdafx.h"
|
2021-05-29 09:31:32 +00:00
|
|
|
#include "../inc/BigEndianProcessor.h"
|
2018-08-25 21:51:56 +00:00
|
|
|
|
2022-03-26 16:06:29 +00:00
|
|
|
EightBit::BigEndianProcessor::BigEndianProcessor(Bus& memory) noexcept
|
2018-08-25 21:51:56 +00:00
|
|
|
: Processor(memory) {}
|
|
|
|
|
2024-01-13 10:24:21 +00:00
|
|
|
EightBit::register16_t EightBit::BigEndianProcessor::getWord() {
|
2020-02-09 11:51:58 +00:00
|
|
|
const auto high = memoryRead();
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS();
|
2020-02-09 11:51:58 +00:00
|
|
|
const auto low = memoryRead();
|
2019-12-29 01:18:54 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-13 10:24:21 +00:00
|
|
|
void EightBit::BigEndianProcessor::setWord(const register16_t value) {
|
2020-02-09 11:51:58 +00:00
|
|
|
memoryWrite(value.high);
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS();
|
2020-02-09 11:51:58 +00:00
|
|
|
memoryWrite(value.low);
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2024-03-01 20:06:39 +00:00
|
|
|
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged() {
|
2024-03-18 13:03:41 +00:00
|
|
|
const auto high = memoryRead();
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS().low;
|
2020-02-09 11:51:58 +00:00
|
|
|
const auto low = memoryRead();
|
2019-12-29 01:18:54 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2024-03-01 20:06:39 +00:00
|
|
|
void EightBit::BigEndianProcessor::setWordPaged(const register16_t value) {
|
2024-03-18 13:03:41 +00:00
|
|
|
memoryWrite(value.high);
|
2018-08-25 21:51:56 +00:00
|
|
|
++BUS().ADDRESS().low;
|
2020-02-09 11:51:58 +00:00
|
|
|
memoryWrite(value.low);
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-13 10:24:21 +00:00
|
|
|
EightBit::register16_t EightBit::BigEndianProcessor::fetchWord() {
|
2018-08-25 21:51:56 +00:00
|
|
|
const auto high = fetchByte();
|
|
|
|
const auto low = fetchByte();
|
2019-12-29 01:18:54 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-13 10:24:21 +00:00
|
|
|
void EightBit::BigEndianProcessor::pushWord(const register16_t value) {
|
2018-08-25 21:51:56 +00:00
|
|
|
push(value.low);
|
|
|
|
push(value.high);
|
|
|
|
}
|
|
|
|
|
2024-01-13 10:24:21 +00:00
|
|
|
EightBit::register16_t EightBit::BigEndianProcessor::popWord() {
|
2018-08-25 21:51:56 +00:00
|
|
|
const auto high = pop();
|
|
|
|
const auto low = pop();
|
2019-12-29 01:18:54 +00:00
|
|
|
return { low, high };
|
2018-08-25 21:51:56 +00:00
|
|
|
}
|
2018-08-27 10:27:33 +00:00
|
|
|
|
2021-07-18 13:28:40 +00:00
|
|
|
EightBit::register16_t EightBit::BigEndianProcessor::peekWord(const register16_t address) noexcept {
|
2018-08-29 12:52:25 +00:00
|
|
|
const auto high = BUS().peek(address);
|
|
|
|
const auto low = BUS().peek(address + 1);
|
2019-12-29 01:18:54 +00:00
|
|
|
return { low, high };
|
2018-08-27 10:27:33 +00:00
|
|
|
}
|
2018-10-14 09:05:43 +00:00
|
|
|
|
2021-07-18 13:28:40 +00:00
|
|
|
void EightBit::BigEndianProcessor::pokeWord(const register16_t address, const register16_t value) noexcept {
|
2018-10-14 09:05:43 +00:00
|
|
|
BUS().poke(address, value.high);
|
|
|
|
BUS().poke(address + 1, value.low);
|
|
|
|
}
|