Low level processor simplifications.

This commit is contained in:
Adrian Conlon 2024-03-01 20:06:39 +00:00
parent 4e536ee7ed
commit f3c694303d
6 changed files with 28 additions and 14 deletions

View File

@ -19,8 +19,8 @@ namespace EightBit {
[[nodiscard]] register16_t getWord() override; [[nodiscard]] register16_t getWord() override;
void setWord(register16_t value) override; void setWord(register16_t value) override;
[[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset) override; [[nodiscard]] register16_t getWordPaged() override;
void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override; void setWordPaged(register16_t value) override;
[[nodiscard]] register16_t fetchWord() final; [[nodiscard]] register16_t fetchWord() final;

View File

@ -19,8 +19,8 @@ namespace EightBit {
[[nodiscard]] register16_t getWord() override; [[nodiscard]] register16_t getWord() override;
void setWord(register16_t value) override; void setWord(register16_t value) override;
[[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset) override; [[nodiscard]] register16_t getWordPaged() override;
void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override; void setWordPaged(register16_t value) override;
[[nodiscard]] register16_t fetchWord() final; [[nodiscard]] register16_t fetchWord() final;

View File

@ -57,7 +57,9 @@ namespace EightBit {
virtual uint8_t memoryRead(); virtual uint8_t memoryRead();
virtual uint8_t busRead(); virtual uint8_t busRead();
uint8_t getBytePaged() { return memoryRead(); }
uint8_t getBytePaged(uint8_t page, uint8_t offset); uint8_t getBytePaged(uint8_t page, uint8_t offset);
void setBytePaged(uint8_t value) { memoryWrite(value); }
void setBytePaged(uint8_t page, uint8_t offset, uint8_t value); void setBytePaged(uint8_t page, uint8_t offset, uint8_t value);
uint8_t fetchByte(); uint8_t fetchByte();
@ -65,8 +67,10 @@ namespace EightBit {
[[nodiscard]] virtual register16_t getWord() = 0; [[nodiscard]] virtual register16_t getWord() = 0;
virtual void setWord(register16_t value) = 0; virtual void setWord(register16_t value) = 0;
[[nodiscard]] virtual register16_t getWordPaged(uint8_t page, uint8_t offset) = 0; [[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset);
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) = 0; [[nodiscard]] virtual register16_t getWordPaged() = 0;
void setWordPaged(uint8_t page, uint8_t offset, register16_t value);
virtual void setWordPaged(register16_t value) = 0;
[[nodiscard]] virtual register16_t fetchWord() = 0; [[nodiscard]] virtual register16_t fetchWord() = 0;

View File

@ -17,15 +17,15 @@ void EightBit::BigEndianProcessor::setWord(const register16_t value) {
memoryWrite(value.low); memoryWrite(value.low);
} }
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) { EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged() {
const auto high = getBytePaged(page, offset); const auto high = getBytePaged();
++BUS().ADDRESS().low; ++BUS().ADDRESS().low;
const auto low = memoryRead(); const auto low = memoryRead();
return { low, high }; return { low, high };
} }
void EightBit::BigEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) { void EightBit::BigEndianProcessor::setWordPaged(const register16_t value) {
setBytePaged(page, offset, value.high); setBytePaged(value.high);
++BUS().ADDRESS().low; ++BUS().ADDRESS().low;
memoryWrite(value.low); memoryWrite(value.low);
} }

View File

@ -20,15 +20,15 @@ void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
memoryWrite(value.high); memoryWrite(value.high);
} }
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) { EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged() {
const auto low = getBytePaged(page, offset); const auto low = getBytePaged();
++BUS().ADDRESS().low; ++BUS().ADDRESS().low;
const auto high = memoryRead(); const auto high = memoryRead();
return { low, high }; return { low, high };
} }
void EightBit::LittleEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) { void EightBit::LittleEndianProcessor::setWordPaged(register16_t value) {
setBytePaged(page, offset, value.low); setBytePaged(value.low);
++BUS().ADDRESS().low; ++BUS().ADDRESS().low;
memoryWrite(value.high); memoryWrite(value.high);
} }

View File

@ -68,6 +68,16 @@ void EightBit::Processor::setBytePaged(const uint8_t page, const uint8_t offset,
memoryWrite(register16_t(offset, page), value); memoryWrite(register16_t(offset, page), value);
} }
EightBit::register16_t EightBit::Processor::getWordPaged(const uint8_t page, const uint8_t offset) {
BUS().ADDRESS() = { offset, page };
return getWordPaged();
}
void EightBit::Processor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
BUS().ADDRESS() = { offset, page };
setWordPaged(value);
}
uint8_t EightBit::Processor::fetchByte() { uint8_t EightBit::Processor::fetchByte() {
return memoryRead(PC()++); return memoryRead(PC()++);
} }