mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-04-10 23:41:09 +00:00
Refactor the *EndianProcessor classes, such that their implementation is no longer in header files.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
3a4235f651
commit
8823bb6610
@ -7,50 +7,18 @@
|
||||
namespace EightBit {
|
||||
class BigEndianProcessor : public Processor {
|
||||
protected:
|
||||
BigEndianProcessor(Bus& memory) : Processor(memory) {}
|
||||
BigEndianProcessor(Bus& memory);
|
||||
virtual ~BigEndianProcessor() = default;
|
||||
|
||||
virtual register16_t getWord() override {
|
||||
const auto high = BUS().read();
|
||||
++BUS().ADDRESS();
|
||||
const auto low = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual register16_t getWord() override;
|
||||
virtual void setWord(register16_t value) override;
|
||||
|
||||
virtual void setWord(const register16_t value) override {
|
||||
BUS().write(value.high);
|
||||
++BUS().ADDRESS();
|
||||
BUS().write(value.low);
|
||||
}
|
||||
virtual register16_t getWordPaged(uint8_t page, uint8_t offset) override;
|
||||
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override;
|
||||
|
||||
virtual register16_t getWordPaged(uint8_t page, uint8_t offset) override {
|
||||
const auto high = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto low = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual register16_t fetchWord() final;
|
||||
|
||||
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override {
|
||||
setBytePaged(page, offset, value.high);
|
||||
++BUS().ADDRESS().low;
|
||||
BUS().read(value.low);
|
||||
}
|
||||
|
||||
virtual register16_t fetchWord() final {
|
||||
const auto high = fetchByte();
|
||||
const auto low = fetchByte();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
virtual void pushWord(const register16_t value) final {
|
||||
push(value.low);
|
||||
push(value.high);
|
||||
}
|
||||
|
||||
virtual register16_t popWord() final {
|
||||
const auto high = pop();
|
||||
const auto low = pop();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual void pushWord(register16_t value) final;
|
||||
virtual register16_t popWord() final;
|
||||
};
|
||||
}
|
||||
|
@ -7,50 +7,18 @@
|
||||
namespace EightBit {
|
||||
class LittleEndianProcessor : public Processor {
|
||||
protected:
|
||||
LittleEndianProcessor(Bus& memory) : Processor(memory) {}
|
||||
LittleEndianProcessor(Bus& memory);
|
||||
virtual ~LittleEndianProcessor() = default;
|
||||
|
||||
virtual register16_t getWord() override {
|
||||
const auto low = BUS().read();
|
||||
++BUS().ADDRESS();
|
||||
const auto high = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual register16_t getWord() override;
|
||||
virtual void setWord(register16_t value) override;
|
||||
|
||||
virtual void setWord(const register16_t value) override {
|
||||
BUS().write(value.low);
|
||||
++BUS().ADDRESS();
|
||||
BUS().write(value.high);
|
||||
}
|
||||
virtual register16_t getWordPaged(uint8_t page, uint8_t offset) override;
|
||||
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override;
|
||||
|
||||
virtual register16_t getWordPaged(uint8_t page, uint8_t offset) override {
|
||||
const auto low = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto high = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual register16_t fetchWord() final;
|
||||
|
||||
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override {
|
||||
setBytePaged(page, offset, value.low);
|
||||
++BUS().ADDRESS().low;
|
||||
BUS().read(value.high);
|
||||
}
|
||||
|
||||
virtual register16_t fetchWord() final {
|
||||
const auto low = fetchByte();
|
||||
const auto high = fetchByte();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
virtual void pushWord(const register16_t value) final {
|
||||
push(value.high);
|
||||
push(value.low);
|
||||
}
|
||||
|
||||
virtual register16_t popWord() final {
|
||||
const auto low = pop();
|
||||
const auto high = pop();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
virtual void pushWord(register16_t value) final;
|
||||
virtual register16_t popWord() final;
|
||||
};
|
||||
}
|
||||
|
48
src/BigEndianProcessor.cpp
Normal file
48
src/BigEndianProcessor.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "stdafx.h"
|
||||
#include "BigEndianProcessor.h"
|
||||
|
||||
EightBit::BigEndianProcessor::BigEndianProcessor(Bus& memory)
|
||||
: Processor(memory) {}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWord() {
|
||||
const auto high = BUS().read();
|
||||
++BUS().ADDRESS();
|
||||
const auto low = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
void EightBit::BigEndianProcessor::setWord(const register16_t value) {
|
||||
BUS().write(value.high);
|
||||
++BUS().ADDRESS();
|
||||
BUS().write(value.low);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(uint8_t page, uint8_t offset) {
|
||||
const auto high = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto low = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
void EightBit::BigEndianProcessor::setWordPaged(uint8_t page, uint8_t offset, register16_t value) {
|
||||
setBytePaged(page, offset, value.high);
|
||||
++BUS().ADDRESS().low;
|
||||
BUS().read(value.low);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::fetchWord() {
|
||||
const auto high = fetchByte();
|
||||
const auto low = fetchByte();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
void EightBit::BigEndianProcessor::pushWord(const register16_t value) {
|
||||
push(value.low);
|
||||
push(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::popWord() {
|
||||
const auto high = pop();
|
||||
const auto low = pop();
|
||||
return register16_t(low, high);
|
||||
}
|
@ -152,10 +152,12 @@
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BigEndianProcessor.cpp" />
|
||||
<ClCompile Include="Bus.cpp" />
|
||||
<ClCompile Include="EventArgs.cpp" />
|
||||
<ClCompile Include="InputOutput.cpp" />
|
||||
<ClCompile Include="IntelProcessor.cpp" />
|
||||
<ClCompile Include="LittleEndianProcessor.cpp" />
|
||||
<ClCompile Include="Memory.cpp" />
|
||||
<ClCompile Include="Processor.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
@ -76,5 +76,11 @@
|
||||
<ClCompile Include="Bus.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LittleEndianProcessor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BigEndianProcessor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
48
src/LittleEndianProcessor.cpp
Normal file
48
src/LittleEndianProcessor.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "stdafx.h"
|
||||
#include "LittleEndianProcessor.h"
|
||||
|
||||
EightBit::LittleEndianProcessor::LittleEndianProcessor(Bus& memory)
|
||||
: Processor(memory) {}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWord() {
|
||||
const auto low = BUS().read();
|
||||
++BUS().ADDRESS();
|
||||
const auto high = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
|
||||
BUS().write(value.low);
|
||||
++BUS().ADDRESS();
|
||||
BUS().write(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(uint8_t page, uint8_t offset) {
|
||||
const auto low = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto high = BUS().read();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
void EightBit::LittleEndianProcessor::setWordPaged(uint8_t page, uint8_t offset, register16_t value) {
|
||||
setBytePaged(page, offset, value.low);
|
||||
++BUS().ADDRESS().low;
|
||||
BUS().read(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::fetchWord() {
|
||||
const auto low = fetchByte();
|
||||
const auto high = fetchByte();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
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();
|
||||
return register16_t(low, high);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user