Add easy to use Register16 assignment methods

This commit is contained in:
Adrian Conlon 2024-07-01 23:27:35 +01:00
parent a9020ef0f0
commit 0c8ed57b0d
9 changed files with 98 additions and 112 deletions

View File

@ -54,8 +54,7 @@ namespace EightBit
public byte Read(byte low, byte high) public byte Read(byte low, byte high)
{ {
this.Address.Low = low; this.Address.Assign(low, high);
this.Address.High = high;
return this.Read(); return this.Read();
} }
@ -83,8 +82,7 @@ namespace EightBit
public void Write(byte low, byte high, byte value) public void Write(byte low, byte high, byte value)
{ {
this.Address.Low = low; this.Address.Assign(low, high);
this.Address.High = high;
this.Write(value); this.Write(value);
} }

View File

@ -143,24 +143,21 @@ namespace EightBit
protected sealed override Register16 GetWord() protected sealed override Register16 GetWord()
{ {
var returned = base.GetWord(); var returned = base.GetWord();
this.MEMPTR.Low = this.Bus.Address.Low; this.MEMPTR.Assign(this.Bus.Address);
this.MEMPTR.High = this.Bus.Address.High;
return returned; return returned;
} }
protected sealed override void SetWord(Register16 value) protected sealed override void SetWord(Register16 value)
{ {
base.SetWord(value); base.SetWord(value);
this.MEMPTR.Low = this.Bus.Address.Low; this.MEMPTR.Assign(this.Bus.Address);
this.MEMPTR.High = this.Bus.Address.High;
} }
//// ////
protected void Restart(byte address) protected void Restart(byte address)
{ {
this.MEMPTR.Low = address; this.MEMPTR.Assign(address, 0);
this.MEMPTR.High = 0;
this.Call(this.MEMPTR); this.Call(this.MEMPTR);
} }
@ -199,8 +196,7 @@ namespace EightBit
protected void FetchWordMEMPTR() protected void FetchWordMEMPTR()
{ {
this.FetchWord(); this.FetchWord();
this.MEMPTR.Low = this.Intermediate.Low; this.MEMPTR.Assign(this.Intermediate);
this.MEMPTR.High = this.Intermediate.High;
} }
protected void JumpIndirect() protected void JumpIndirect()
@ -223,8 +219,7 @@ namespace EightBit
protected bool JumpRelativeConditional(bool condition) protected bool JumpRelativeConditional(bool condition)
{ {
this.Intermediate.Low = this.PC.Low; this.Intermediate.Assign(this.PC);
this.Intermediate.High = this.PC.High;
++this.PC.Word; ++this.PC.Word;
if (condition) if (condition)
{ {
@ -238,8 +233,7 @@ namespace EightBit
protected override sealed void Return() protected override sealed void Return()
{ {
base.Return(); base.Return();
this.MEMPTR.Low = this.PC.Low; this.MEMPTR.Assign(this.PC);
this.MEMPTR.High = this.PC.High;
} }
} }
} }

View File

@ -138,15 +138,13 @@ namespace EightBit
protected void MemoryWrite(byte low, byte high) protected void MemoryWrite(byte low, byte high)
{ {
this.Bus.Address.Low = low; this.Bus.Address.Assign(low, high);
this.Bus.Address.High = high;
this.MemoryWrite(); this.MemoryWrite();
} }
protected void MemoryWrite(byte low, byte high, byte data) protected void MemoryWrite(byte low, byte high, byte data)
{ {
this.Bus.Address.Low = low; this.Bus.Address.Assign(low, high);
this.Bus.Address.High = high;
this.MemoryWrite(data); this.MemoryWrite(data);
} }
@ -172,8 +170,7 @@ namespace EightBit
protected byte MemoryRead(byte low, byte high) protected byte MemoryRead(byte low, byte high)
{ {
this.Bus.Address.Low = low; this.Bus.Address.Assign(low, high);
this.Bus.Address.High = high;
return this.MemoryRead(); return this.MemoryRead();
} }
@ -191,9 +188,9 @@ namespace EightBit
protected byte FetchByte() protected byte FetchByte()
{ {
var returned = this.MemoryRead(this.PC); this.Bus.Address.Assign(this.PC);
this.PC.Word++; this.PC.Word++;
return returned; return this.MemoryRead();
} }
protected abstract Register16 GetWord(); protected abstract Register16 GetWord();
@ -209,8 +206,7 @@ namespace EightBit
protected Register16 GetWordPaged(byte page, byte offset) protected Register16 GetWordPaged(byte page, byte offset)
{ {
this.Bus.Address.Low = offset; this.Bus.Address.Assign(offset, page);
this.Bus.Address.High = page;
return this.GetWordPaged(); return this.GetWordPaged();
} }
@ -223,8 +219,7 @@ namespace EightBit
protected void SetWordPaged(byte page, byte offset, Register16 value) protected void SetWordPaged(byte page, byte offset, Register16 value)
{ {
this.Bus.Address.Low = offset; this.Bus.Address.Assign(offset, page);
this.Bus.Address.High = page;
this.SetWordPaged(value); this.SetWordPaged(value);
} }
@ -233,8 +228,7 @@ namespace EightBit
protected void FetchWordAddress() protected void FetchWordAddress()
{ {
this.FetchWord(); this.FetchWord();
this.Bus.Address.Low = this.Intermediate.Low; this.Bus.Address.Assign(this.Intermediate);
this.Bus.Address.High = this.Intermediate.High;
} }
protected abstract void Push(byte value); protected abstract void Push(byte value);
@ -253,8 +247,7 @@ namespace EightBit
protected Register16 GetWord(Register16 address) protected Register16 GetWord(Register16 address)
{ {
this.Bus.Address.Low = address.Low; this.Bus.Address.Assign(address);
this.Bus.Address.High = address.High;
return this.GetWord(); return this.GetWord();
} }
@ -266,8 +259,7 @@ namespace EightBit
protected void SetWord(Register16 address, Register16 value) protected void SetWord(Register16 address, Register16 value)
{ {
this.Bus.Address.Low = address.Low; this.Bus.Address.Assign(address);
this.Bus.Address.High = address.High;
this.SetWord(value); this.SetWord(value);
} }
@ -275,8 +267,7 @@ namespace EightBit
protected void Jump(Register16 destination) protected void Jump(Register16 destination)
{ {
this.PC.Low = destination.Low; this.PC.Assign(destination);
this.PC.High = destination.High;
} }
protected void Call(ushort destination) protected void Call(ushort destination)

View File

@ -90,5 +90,16 @@ namespace EightBit
return rhs.Low == this.Low && rhs.High == this.High; return rhs.Low == this.Low && rhs.High == this.High;
} }
public void Assign(byte low, byte high)
{
this.low = low;
this.high = high;
}
public void Assign(Register16 from)
{
this.Assign(from.low, from.high);
}
} }
} }

View File

@ -203,6 +203,7 @@ namespace M6502.Test
{ {
var proportion = (double)e.Cycles / this.profiler.TotalCycleCount; var proportion = (double)e.Cycles / this.profiler.TotalCycleCount;
Console.Out.Write(string.Format(CultureInfo.InvariantCulture, "\t[{0:P2}][{1:d9}][{2:d9}]\t{3}\n", proportion, e.Cycles, e.Count, e.Scope)); Console.Out.Write(string.Format(CultureInfo.InvariantCulture, "\t[{0:P2}][{1:d9}][{2:d9}]\t{3}\n", proportion, e.Cycles, e.Count, e.Scope));
Console.Out.Write(string.Format(CultureInfo.InvariantCulture, "\t[{0:P2}][{1:d9}][{2:d9}]\t{3}\n", proportion, cycles, count, name));
} }
private void Profiler_EmitLine(object? sender, ProfileLineEventArgs e) private void Profiler_EmitLine(object? sender, ProfileLineEventArgs e)

View File

@ -219,8 +219,7 @@ namespace EightBit
private void Jam() private void Jam()
{ {
this.Bus.Address.Low = this.PC.Low; this.Bus.Address.Assign(this.PC);
this.Bus.Address.High = this.PC.High;
--this.PC.Word; --this.PC.Word;
this.MemoryRead(); this.MemoryRead();
this.MemoryRead(); this.MemoryRead();

View File

@ -640,8 +640,7 @@ namespace EightBit
private void UpdateStack(byte position) private void UpdateStack(byte position)
{ {
this.Bus.Address.Low = position; this.Bus.Address.Assign(position, 1);
this.Bus.Address.High = 1;
} }
private void LowerStack() => this.UpdateStack(this.S--); private void LowerStack() => this.UpdateStack(this.S--);
@ -718,10 +717,15 @@ namespace EightBit
this.Bus.Address.Low = this.Intermediate.Low; this.Bus.Address.Low = this.Intermediate.Low;
} }
private void GetAddressPaged()
{
this.GetWordPaged();
this.Bus.Address.Assign(this.Intermediate);
}
protected void ImmediateAddress() protected void ImmediateAddress()
{ {
this.Bus.Address.Low = this.PC.Low; this.Bus.Address.Assign(this.PC);
this.Bus.Address.High = this.PC.High;
++this.PC.Word; ++this.PC.Word;
} }
@ -729,24 +733,19 @@ namespace EightBit
protected void ZeroPageAddress() protected void ZeroPageAddress()
{ {
this.Bus.Address.Low = this.FetchByte(); this.Bus.Address.Assign(this.FetchByte(), 0);
this.Bus.Address.High = 0;
} }
protected void ZeroPageIndirectAddress() protected void ZeroPageIndirectAddress()
{ {
this.ZeroPageAddress(); this.ZeroPageAddress();
this.GetWordPaged(); this.GetAddressPaged();
this.Bus.Address.Low = this.Intermediate.Low;
this.Bus.Address.High = this.Intermediate.High;
} }
protected void IndirectAddress() protected void IndirectAddress()
{ {
this.AbsoluteAddress(); this.AbsoluteAddress();
this.GetWordPaged(); this.GetAddressPaged();
this.Bus.Address.Low = this.Intermediate.Low;
this.Bus.Address.High = this.Intermediate.High;
} }
protected void ZeroPageWithIndexAddress(byte index) protected void ZeroPageWithIndexAddress(byte index)
@ -772,9 +771,7 @@ namespace EightBit
protected void IndexedIndirectXAddress() protected void IndexedIndirectXAddress()
{ {
this.ZeroPageXAddress(); this.ZeroPageXAddress();
this.GetWordPaged(); this.GetAddressPaged();
this.Bus.Address.Low = this.Intermediate.Low;
this.Bus.Address.High = this.Intermediate.High;
} }
protected void IndirectIndexedYAddress() protected void IndirectIndexedYAddress()
@ -1054,8 +1051,8 @@ namespace EightBit
this.Intermediate.Low = this.FetchByte(); this.Intermediate.Low = this.FetchByte();
this.SwallowPop(); this.SwallowPop();
this.PushWord(this.PC); this.PushWord(this.PC);
this.PC.High = this.FetchByte(); this.Intermediate.High = this.FetchByte();
this.PC.Low = this.Intermediate.Low; this.PC.Assign(this.Intermediate);
} }
private void PHP() => this.Push(SetBit(this.P, StatusBits.BF)); private void PHP() => this.Push(SetBit(this.P, StatusBits.BF));

View File

@ -83,7 +83,12 @@ namespace Z80.Test
private void CPU_ExecutingInstruction_CPM(object sender, System.EventArgs e) private void CPU_ExecutingInstruction_CPM(object sender, System.EventArgs e)
{ {
switch (this.CPU.PC.Word) if (this.CPU.PC.High != 0)
{
// We're only interested in zero page
return;
}
switch (this.CPU.PC.Low)
{ {
case 0x0: // CP/M warm start case 0x0: // CP/M warm start
if (++this.warmstartCount == 2) if (++this.warmstartCount == 2)

View File

@ -538,8 +538,7 @@ namespace EightBit
break; break;
case 2: case 2:
this.Tick(7); this.Tick(7);
this.MEMPTR.Low = data; this.MEMPTR.Assign(data, this.IV);
this.MEMPTR.High = this.IV;
this.Call(this.MEMPTR); this.Call(this.MEMPTR);
break; break;
default: default:
@ -804,8 +803,8 @@ namespace EightBit
switch (z) switch (z)
{ {
case 0: // Input from port with 16-bit address case 0: // Input from port with 16-bit address
this.MEMPTR.Low = this.Bus.Address.Low = this.BC.Low; this.Bus.Address.Assign(this.BC);
this.MEMPTR.High = this.Bus.Address.High = this.BC.High; this.MEMPTR.Assign(Bus.Address);
this.MEMPTR.Word++; this.MEMPTR.Word++;
this.ReadPort(); this.ReadPort();
if (y != 6) if (y != 6)
@ -817,19 +816,19 @@ namespace EightBit
this.F = ClearBit(this.F, StatusBits.NF | StatusBits.HC); this.F = ClearBit(this.F, StatusBits.NF | StatusBits.HC);
break; break;
case 1: // Output to port with 16-bit address case 1: // Output to port with 16-bit address
this.MEMPTR.Low = this.Bus.Address.Low = this.BC.Low; this.Bus.Address.Assign(this.BC);
this.MEMPTR.High = this.Bus.Address.High = this.BC.High; this.MEMPTR.Assign(Bus.Address);
this.MEMPTR.Word++; this.MEMPTR.Word++;
this.Bus.Data = y != 6 ? this.R(y) : (byte)0; this.Bus.Data = y != 6 ? this.R(y) : (byte)0;
this.WritePort(); this.WritePort();
break; break;
case 2: // 16-bit add/subtract with carry case 2: // 16-bit add/subtract with carry
this.HL2().Word = q switch this.HL2().Assign(q switch
{ {
0 => this.SBC(this.HL2(), this.RP(p)), // SBC HL, rp[p] 0 => this.SBC(this.HL2(), this.RP(p)), // SBC HL, rp[p]
1 => this.ADC(this.HL2(), this.RP(p)), // ADC HL, rp[p] 1 => this.ADC(this.HL2(), this.RP(p)), // ADC HL, rp[p]
_ => throw new NotSupportedException("Invalid operation mode"), _ => throw new NotSupportedException("Invalid operation mode"),
}; });
break; break;
case 3: // Retrieve/store register pair from/to immediate address case 3: // Retrieve/store register pair from/to immediate address
this.FetchWordAddress(); this.FetchWordAddress();
@ -839,7 +838,7 @@ namespace EightBit
this.SetWord(this.RP(p)); this.SetWord(this.RP(p));
break; break;
case 1: // LD rp[p], (nn) case 1: // LD rp[p], (nn)
this.RP(p).Word = this.GetWord().Word; this.RP(p).Assign(this.GetWord());
break; break;
default: default:
throw new NotSupportedException("Invalid operation mode"); throw new NotSupportedException("Invalid operation mode");
@ -924,8 +923,7 @@ namespace EightBit
if (this.LDIR()) if (this.LDIR())
{ {
--this.PC.Word; --this.PC.Word;
this.MEMPTR.Low = this.PC.Low; this.MEMPTR.Assign(this.PC);
this.MEMPTR.High = this.PC.High;
--this.PC.Word; --this.PC.Word;
} }
@ -935,8 +933,7 @@ namespace EightBit
if (this.LDDR()) if (this.LDDR())
{ {
--this.PC.Word; --this.PC.Word;
this.MEMPTR.Low = this.PC.Low; this.MEMPTR.Assign(this.PC);
this.MEMPTR.High = this.PC.High;
--this.PC.Word; --this.PC.Word;
} }
@ -958,8 +955,7 @@ namespace EightBit
if (this.CPIR()) if (this.CPIR())
{ {
--this.PC.Word; --this.PC.Word;
this.MEMPTR.Low = this.PC.Low; this.MEMPTR.Assign(this.PC);
this.MEMPTR.High = this.PC.High;
--this.PC.Word; --this.PC.Word;
this.Tick(5); this.Tick(5);
} }
@ -970,8 +966,7 @@ namespace EightBit
if (this.CPDR()) if (this.CPDR())
{ {
--this.PC.Word; --this.PC.Word;
this.MEMPTR.Low = this.PC.Low; this.MEMPTR.Assign(this.PC);
this.MEMPTR.High = this.PC.High;
--this.PC.Word; --this.PC.Word;
this.Tick(3); this.Tick(3);
} }
@ -1093,10 +1088,10 @@ namespace EightBit
switch (q) switch (q)
{ {
case 0: // LD rp,nn case 0: // LD rp,nn
this.RP(p).Word = this.FetchWord().Word; this.RP(p).Assign(this.FetchWord());
break; break;
case 1: // ADD HL,rp case 1: // ADD HL,rp
this.HL2().Word = this.Add(this.HL2(), this.RP(p)); this.HL2().Assign(this.Add(this.HL2(), this.RP(p)));
break; break;
default: default:
throw new NotSupportedException("Invalid operation mode"); throw new NotSupportedException("Invalid operation mode");
@ -1110,15 +1105,15 @@ namespace EightBit
switch (p) switch (p)
{ {
case 0: // LD (BC),A case 0: // LD (BC),A
this.MEMPTR.Low = this.Bus.Address.Low = this.BC.Low; this.Bus.Address.Assign(this.BC);
this.MEMPTR.High = this.Bus.Address.High = this.BC.High; this.MEMPTR.Assign(Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.MEMPTR.High = this.Bus.Data = this.A; this.MEMPTR.High = this.Bus.Data = this.A;
this.MemoryWrite(); this.MemoryWrite();
break; break;
case 1: // LD (DE),A case 1: // LD (DE),A
this.MEMPTR.Low = this.Bus.Address.Low = this.DE.Low; this.Bus.Address.Assign(this.DE);
this.MEMPTR.High = this.Bus.Address.High = this.DE.High; this.MEMPTR.Assign(Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.MEMPTR.High = this.Bus.Data = this.A; this.MEMPTR.High = this.Bus.Data = this.A;
this.MemoryWrite(); this.MemoryWrite();
@ -1129,8 +1124,7 @@ namespace EightBit
break; break;
case 3: // LD (nn),A case 3: // LD (nn),A
this.FetchWordMEMPTR(); this.FetchWordMEMPTR();
this.Bus.Address.Low = this.MEMPTR.Low; this.Bus.Address.Assign(this.MEMPTR);
this.Bus.Address.High = this.MEMPTR.High;
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.MEMPTR.High = this.Bus.Data = this.A; this.MEMPTR.High = this.Bus.Data = this.A;
this.MemoryWrite(); this.MemoryWrite();
@ -1144,25 +1138,24 @@ namespace EightBit
switch (p) switch (p)
{ {
case 0: // LD A,(BC) case 0: // LD A,(BC)
this.MEMPTR.Low = this.Bus.Address.Low = this.BC.Low; this.Bus.Address.Assign(this.BC);
this.MEMPTR.High = this.Bus.Address.High = this.BC.High; this.MEMPTR.Assign(Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.A = this.MemoryRead(); this.A = this.MemoryRead();
break; break;
case 1: // LD A,(DE) case 1: // LD A,(DE)
this.MEMPTR.Low = this.Bus.Address.Low = this.DE.Low; this.Bus.Address.Assign(this.DE);
this.MEMPTR.High = this.Bus.Address.High = this.DE.High; this.MEMPTR.Assign(Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.A = this.MemoryRead(); this.A = this.MemoryRead();
break; break;
case 2: // LD HL,(nn) case 2: // LD HL,(nn)
this.FetchWordAddress(); this.FetchWordAddress();
this.HL2().Word = this.GetWord().Word; this.HL2().Assign(this.GetWord());
break; break;
case 3: // LD A,(nn) case 3: // LD A,(nn)
this.FetchWordMEMPTR(); this.FetchWordMEMPTR();
this.Bus.Address.Low = this.MEMPTR.Low; this.Bus.Address.Assign(this.MEMPTR);
this.Bus.Address.High = this.MEMPTR.High;
++this.MEMPTR.Word; ++this.MEMPTR.Word;
this.A = this.MemoryRead(); this.A = this.MemoryRead();
break; break;
@ -1402,7 +1395,7 @@ namespace EightBit
switch (q) switch (q)
{ {
case 0: // POP rp2[p] case 0: // POP rp2[p]
this.RP2(p).Word = this.PopWord().Word; this.RP2(p).Assign(this.PopWord());
break; break;
case 1: case 1:
switch (p) switch (p)
@ -1417,7 +1410,7 @@ namespace EightBit
this.Jump(this.HL2()); this.Jump(this.HL2());
break; break;
case 3: // LD SP,HL case 3: // LD SP,HL
this.SP.Word = this.HL2().Word; this.SP.Assign(this.HL2());
break; break;
default: default:
throw new NotSupportedException("Invalid operation mode"); throw new NotSupportedException("Invalid operation mode");
@ -1598,8 +1591,7 @@ namespace EightBit
this.LowerM1(); this.LowerM1();
var returned = this.MemoryRead(this.PC); var returned = this.MemoryRead(this.PC);
this.RaiseM1(); this.RaiseM1();
this.Bus.Address.Low = this.REFRESH; this.Bus.Address.Assign(this.REFRESH, this.IV);
this.Bus.Address.High = this.IV;
this.LowerRFSH(); this.LowerRFSH();
this.LowerMREQ(); this.LowerMREQ();
this.RaiseMREQ(); this.RaiseMREQ();
@ -1678,7 +1670,7 @@ namespace EightBit
private void CallConditionalFlag(int flag) => this.CallConditional(this.ConvertCondition(flag)); private void CallConditionalFlag(int flag) => this.CallConditional(this.ConvertCondition(flag));
private ushort SBC(Register16 operand, Register16 value) private Register16 SBC(Register16 operand, Register16 value)
{ {
var subtraction = operand.Word - value.Word - (this.F & (byte)StatusBits.CF); var subtraction = operand.Word - value.Word - (this.F & (byte)StatusBits.CF);
this.Intermediate.Word = (ushort)subtraction; this.Intermediate.Word = (ushort)subtraction;
@ -1698,10 +1690,10 @@ namespace EightBit
this.MEMPTR.Word = (ushort)(operand.Word + 1); this.MEMPTR.Word = (ushort)(operand.Word + 1);
return this.Intermediate.Word; return this.Intermediate;
} }
private ushort ADC(Register16 operand, Register16 value) private Register16 ADC(Register16 operand, Register16 value)
{ {
this.Add(operand, value, this.F & (byte)StatusBits.CF); // Leaves result in intermediate anyway this.Add(operand, value, this.F & (byte)StatusBits.CF); // Leaves result in intermediate anyway
this.F = ClearBit(this.F, StatusBits.ZF, this.Intermediate.Word); this.F = ClearBit(this.F, StatusBits.ZF, this.Intermediate.Word);
@ -1713,10 +1705,10 @@ namespace EightBit
this.F = SetBit(this.F, StatusBits.SF, afterNegative); this.F = SetBit(this.F, StatusBits.SF, afterNegative);
this.F = AdjustOverflowAdd(this.F, beforeNegative, valueNegative, afterNegative); this.F = AdjustOverflowAdd(this.F, beforeNegative, valueNegative, afterNegative);
return this.Intermediate.Word; return this.Intermediate;
} }
private ushort Add(Register16 operand, Register16 value, int carry = 0) private Register16 Add(Register16 operand, Register16 value, int carry = 0)
{ {
var addition = operand.Word + value.Word + carry; var addition = operand.Word + value.Word + carry;
this.Intermediate.Word = (ushort)addition; this.Intermediate.Word = (ushort)addition;
@ -1728,7 +1720,7 @@ namespace EightBit
this.MEMPTR.Word = (ushort)(operand.Word + 1); this.MEMPTR.Word = (ushort)(operand.Word + 1);
return this.Intermediate.Word; return this.Intermediate;
} }
private byte Add(byte operand, byte value, int carry = 0) private byte Add(byte operand, byte value, int carry = 0)
@ -2022,8 +2014,8 @@ namespace EightBit
private void BlockIn(Register16 source, Register16 destination) private void BlockIn(Register16 source, Register16 destination)
{ {
this.MEMPTR.Low = this.Bus.Address.Low = source.Low; this.Bus.Address.Assign(source);
this.MEMPTR.High = this.Bus.Address.High = source.High; this.MEMPTR.Assign(Bus.Address);
this.Tick(); this.Tick();
this.ReadPort(); this.ReadPort();
this.Tick(3); this.Tick(3);
@ -2063,11 +2055,9 @@ namespace EightBit
this.Tick(); this.Tick();
this.MemoryRead(source); this.MemoryRead(source);
destination.High = this.Decrement(destination.High); destination.High = this.Decrement(destination.High);
this.Bus.Address.Low = destination.Low; this.Bus.Address.Assign(destination);
this.Bus.Address.High = destination.High;
this.WritePort(); this.WritePort();
this.MEMPTR.Low = destination.Low; this.MEMPTR.Assign(destination);
this.MEMPTR.High = destination.High;
} }
private void AdjustBlockOutFlags() private void AdjustBlockOutFlags()
@ -2125,8 +2115,8 @@ namespace EightBit
private void RRD() private void RRD()
{ {
this.MEMPTR.Low = this.Bus.Address.Low = this.HL.Low; this.Bus.Address.Assign(this.HL);
this.MEMPTR.High = this.Bus.Address.High = this.HL.High; this.MEMPTR.Assign(this.Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
var memory = this.MemoryRead(); var memory = this.MemoryRead();
this.Tick(4); this.Tick(4);
@ -2138,8 +2128,8 @@ namespace EightBit
private void RLD() private void RLD()
{ {
this.MEMPTR.Low = this.Bus.Address.Low = this.HL.Low; this.Bus.Address.Assign(this.HL);
this.MEMPTR.High = this.Bus.Address.High = this.HL.High; this.MEMPTR.Assign(this.Bus.Address);
++this.MEMPTR.Word; ++this.MEMPTR.Word;
var memory = this.MemoryRead(); var memory = this.MemoryRead();
this.Tick(4); this.Tick(4);
@ -2151,8 +2141,8 @@ namespace EightBit
private void WritePort(byte port) private void WritePort(byte port)
{ {
this.MEMPTR.Low = this.Bus.Address.Low = port; this.Bus.Address.Assign(port, this.Bus.Data = this.A);
this.MEMPTR.High = this.Bus.Address.High = this.Bus.Data = this.A; this.MEMPTR.Assign(this.Bus.Address);
this.WritePort(); this.WritePort();
++this.MEMPTR.Low; ++this.MEMPTR.Low;
} }
@ -2169,8 +2159,8 @@ namespace EightBit
private byte ReadPort(byte port) private byte ReadPort(byte port)
{ {
this.MEMPTR.Low = this.Bus.Address.Low = port; this.Bus.Address.Assign(port, this.Bus.Data = this.A);
this.MEMPTR.High = this.Bus.Address.High = this.A; this.MEMPTR.Assign(this.Bus.Address);
++this.MEMPTR.Low; ++this.MEMPTR.Low;
return this.ReadPort(); return this.ReadPort();
} }