mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-04-12 05:37:00 +00:00
Remove get/getWord and set/setWord from memory class. Just use address and data lines on the memory.
Signed-off-by: Adrian.Conlon <adrian.conlon@arup.com>
This commit is contained in:
parent
a4f8770eb0
commit
052df61250
@ -190,11 +190,13 @@ namespace EightBit {
|
||||
}
|
||||
|
||||
void mov_m_r(uint8_t value) {
|
||||
m_memory.set(HL().word, value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
m_memory.reference() = value;
|
||||
}
|
||||
|
||||
uint8_t mov_r_m() {
|
||||
return m_memory.get(HL().word);
|
||||
m_memory.ADDRESS() = HL();
|
||||
return m_memory.reference();
|
||||
}
|
||||
|
||||
//
|
||||
@ -285,18 +287,29 @@ namespace EightBit {
|
||||
|
||||
void mvi_m() {
|
||||
auto data = fetchByte();
|
||||
m_memory.set(HL().word, data);
|
||||
m_memory.ADDRESS() = HL();
|
||||
m_memory.reference() = data;
|
||||
}
|
||||
|
||||
void lxi_b() { Processor::fetchWord(BC()); }
|
||||
void lxi_d() { Processor::fetchWord(DE()); }
|
||||
void lxi_h() { Processor::fetchWord(HL()); }
|
||||
|
||||
void stax_b() { m_memory.set(BC().word, A()); }
|
||||
void stax_d() { m_memory.set(DE().word, A()); }
|
||||
void stax_r(register16_t& destination) {
|
||||
m_memory.ADDRESS() = destination;
|
||||
m_memory.reference() = A();
|
||||
}
|
||||
|
||||
void ldax_b() { A() = m_memory.get(BC().word); }
|
||||
void ldax_d() { A() = m_memory.get(DE().word); }
|
||||
void stax_b() { stax_r(BC()); }
|
||||
void stax_d() { stax_r(DE()); }
|
||||
|
||||
void ldax_r(register16_t& source) {
|
||||
m_memory.ADDRESS() = source;
|
||||
A() = m_memory.reference();
|
||||
}
|
||||
|
||||
void ldax_b() { ldax_r(BC()); }
|
||||
void ldax_d() { ldax_r(DE()); }
|
||||
|
||||
void sta() {
|
||||
fetchWord();
|
||||
@ -339,9 +352,14 @@ namespace EightBit {
|
||||
}
|
||||
|
||||
void xhtl() {
|
||||
auto tos = m_memory.getWord(SP().word);
|
||||
m_memory.setWord(SP().word, HL());
|
||||
HL() = tos;
|
||||
m_memory.ADDRESS() = SP();
|
||||
MEMPTR().low = m_memory.reference();
|
||||
m_memory.reference() = L();
|
||||
L() = MEMPTR().low;
|
||||
m_memory.ADDRESS().word++;
|
||||
MEMPTR().high = m_memory.reference();
|
||||
m_memory.reference() = H();
|
||||
H() = MEMPTR().high;
|
||||
}
|
||||
|
||||
void sphl() {
|
||||
@ -430,9 +448,10 @@ namespace EightBit {
|
||||
void inr_l() { postIncrement(F(), ++L()); }
|
||||
|
||||
void inr_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
m_memory.ADDRESS() = HL();
|
||||
auto value = m_memory.reference();
|
||||
postIncrement(F(), ++value);
|
||||
m_memory.set(HL().word, value);
|
||||
m_memory.reference() = value;
|
||||
}
|
||||
|
||||
void dcr_a() { postDecrement(F(), --A()); }
|
||||
@ -444,9 +463,10 @@ namespace EightBit {
|
||||
void dcr_l() { postDecrement(F(), --L()); }
|
||||
|
||||
void dcr_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
m_memory.ADDRESS() = HL();
|
||||
auto value = m_memory.reference();
|
||||
postDecrement(F(), --value);
|
||||
m_memory.set(HL().word, value);
|
||||
m_memory.reference() = value;
|
||||
}
|
||||
|
||||
void inx_b() { ++BC().word; }
|
||||
@ -468,8 +488,8 @@ namespace EightBit {
|
||||
void add_l() { add(L()); }
|
||||
|
||||
void add_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
add(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
add(m_memory.reference());
|
||||
}
|
||||
|
||||
void adi() { add(fetchByte()); }
|
||||
@ -483,8 +503,8 @@ namespace EightBit {
|
||||
void adc_l() { adc(L()); }
|
||||
|
||||
void adc_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
adc(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
adc(m_memory.reference());
|
||||
}
|
||||
|
||||
void aci() { adc(fetchByte()); }
|
||||
@ -505,8 +525,8 @@ namespace EightBit {
|
||||
void sub_l() { sub(L()); }
|
||||
|
||||
void sub_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
sub(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
sub(m_memory.reference());
|
||||
}
|
||||
|
||||
void sbb_a() { sbb(A()); }
|
||||
@ -518,8 +538,8 @@ namespace EightBit {
|
||||
void sbb_l() { sbb(L()); }
|
||||
|
||||
void sbb_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
sbb(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
sbb(m_memory.reference());
|
||||
}
|
||||
|
||||
void sbi() {
|
||||
@ -543,8 +563,8 @@ namespace EightBit {
|
||||
void ana_l() { anda(L()); }
|
||||
|
||||
void ana_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
anda(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
anda(m_memory.reference());
|
||||
}
|
||||
|
||||
void ani() { anda(fetchByte()); }
|
||||
@ -558,8 +578,8 @@ namespace EightBit {
|
||||
void xra_l() { xra(L()); }
|
||||
|
||||
void xra_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
xra(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
xra(m_memory.reference());
|
||||
}
|
||||
|
||||
void xri() { xra(fetchByte()); }
|
||||
@ -573,8 +593,8 @@ namespace EightBit {
|
||||
void ora_l() { ora(L()); }
|
||||
|
||||
void ora_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
ora(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
ora(m_memory.reference());
|
||||
}
|
||||
|
||||
void ori() { ora(fetchByte()); }
|
||||
@ -588,8 +608,8 @@ namespace EightBit {
|
||||
void cmp_l() { compare(L()); }
|
||||
|
||||
void cmp_m() {
|
||||
auto value = m_memory.get(HL().word);
|
||||
compare(value);
|
||||
m_memory.ADDRESS() = HL();
|
||||
compare(m_memory.reference());
|
||||
}
|
||||
|
||||
void cpi() { compare(fetchByte()); }
|
||||
|
@ -75,7 +75,8 @@ int EightBit::Intel8080::execute(uint8_t opcode) {
|
||||
//
|
||||
|
||||
void EightBit::Intel8080::___() {
|
||||
auto opcode = m_memory.get(PC().word - 1);
|
||||
m_memory.ADDRESS().word = PC().word - 1;
|
||||
auto opcode = m_memory.reference();
|
||||
auto message = Disassembler::invalid(opcode);
|
||||
throw std::domain_error(message);
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ void Board::initialise() {
|
||||
m_memory.loadRam(romDirectory + "/8080EX1.COM", 0x100); // Cringle/Bartholomew
|
||||
//m_memory.loadRam(romDirectory + "/CPUTEST.COM", 0x100); // SuperSoft diagnostics
|
||||
|
||||
m_memory.set(5, 0xc9); // ret
|
||||
m_memory.ADDRESS().word = 5;
|
||||
m_memory.reference() = 0xc9; // ret
|
||||
m_cpu.ExecutingInstruction.connect(std::bind(&Board::Cpu_ExecutingInstruction_Cpm, this, std::placeholders::_1));
|
||||
|
||||
if (m_configuration.isProfileMode()) {
|
||||
@ -60,8 +61,8 @@ void Board::bdos() {
|
||||
break;
|
||||
}
|
||||
case 0x9:
|
||||
for (uint16_t i = m_cpu.DE().word; m_memory.get(i) != '$'; ++i) {
|
||||
std::cout << m_memory.get(i);
|
||||
for (uint16_t i = m_cpu.DE().word; m_memory.peek(i) != '$'; ++i) {
|
||||
std::cout << m_memory.peek(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
|
||||
break;
|
||||
case 1: // GB: LD (nn),SP
|
||||
fetchWord();
|
||||
m_memory.setWord(MEMPTR().word, SP());
|
||||
setWordViaMemptr(SP());
|
||||
cycles += 5;
|
||||
break;
|
||||
case 2: // GB: STOP
|
||||
@ -698,7 +698,8 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
|
||||
} else {
|
||||
switch (y) {
|
||||
case 4: // GB: LD (FF00 + n),A
|
||||
m_memory.set(0xff00 + fetchByte(), A());
|
||||
m_memory.ADDRESS().word = 0xff00 + fetchByte();
|
||||
m_memory.reference() = A();
|
||||
cycles += 3;
|
||||
break;
|
||||
case 5: { // GB: ADD SP,dd
|
||||
@ -714,7 +715,8 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
|
||||
cycles += 4;
|
||||
break;
|
||||
case 6: // GB: LD A,(FF00 + n)
|
||||
A() = m_memory.get(0xff00 + fetchByte());
|
||||
m_memory.ADDRESS().word = 0xff00 + fetchByte();
|
||||
A() = m_memory.reference();
|
||||
cycles += 3;
|
||||
break;
|
||||
case 7: { // GB: LD HL,SP + dd
|
||||
@ -766,7 +768,8 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
|
||||
} else {
|
||||
switch (y) {
|
||||
case 4: // GB: LD (FF00 + C),A
|
||||
m_memory.set(0xff00 + C(), A());
|
||||
m_memory.ADDRESS().word = 0xff00 + C();
|
||||
m_memory.reference() = A();
|
||||
cycles += 2;
|
||||
break;
|
||||
case 5: // GB: LD (nn),A
|
||||
|
14
inc/Memory.h
14
inc/Memory.h
@ -56,20 +56,6 @@ namespace EightBit {
|
||||
virtual uint8_t peek(uint16_t address) const;
|
||||
virtual uint16_t peekWord(uint16_t address) const;
|
||||
|
||||
virtual uint8_t get(uint16_t address) {
|
||||
ADDRESS().word = address;
|
||||
return reference();
|
||||
}
|
||||
|
||||
virtual register16_t getWord(uint16_t address);
|
||||
|
||||
virtual void set(uint16_t address, uint8_t value) {
|
||||
ADDRESS().word = address;
|
||||
reference() = value;
|
||||
}
|
||||
|
||||
virtual void setWord(uint16_t address, register16_t value);
|
||||
|
||||
virtual uint8_t& reference() {
|
||||
auto effective = effectiveAddress(ADDRESS().word);
|
||||
return m_locked[effective] ? placeDATA(m_bus[effective]) : referenceDATA(m_bus[effective]);
|
||||
|
@ -25,18 +25,6 @@ uint16_t EightBit::Memory::peekWord(uint16_t address) const {
|
||||
return returned.word;
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::Memory::getWord(uint16_t address) {
|
||||
register16_t returned;
|
||||
returned.low = get(address);
|
||||
returned.high = get(address + 1);
|
||||
return returned;
|
||||
}
|
||||
|
||||
void EightBit::Memory::setWord(uint16_t address, register16_t value) {
|
||||
set(address, value.low);
|
||||
set(address + 1, value.high);
|
||||
}
|
||||
|
||||
void EightBit::Memory::clear() {
|
||||
m_bus.fill(0);
|
||||
m_locked.fill(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user