Tidy register increment/decrement a little.

This commit is contained in:
Adrian Conlon
2025-07-25 16:32:30 +01:00
parent c271b28495
commit 2f338c6c46
10 changed files with 68 additions and 58 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ namespace EightBit
protected override Register16 GetWord()
{
this.Intermediate.High = this.MemoryRead();
this.Bus.Address.Increment();
_ = this.Bus.Address.Increment();
this.Intermediate.Low = this.MemoryRead();
return this.Intermediate;
}
@@ -57,7 +57,7 @@ namespace EightBit
protected override void SetWord(Register16 value)
{
this.MemoryWrite(value.High);
this.Bus.Address.Increment();
_ = this.Bus.Address.Increment();
this.MemoryWrite(value.Low);
}
+5 -5
View File
@@ -100,12 +100,13 @@ namespace EightBit
protected abstract void EnableInterrupts();
protected override void IncrementPC()
protected override Register16 IncrementPC()
{
if (this.HALT.Raised())
{
base.IncrementPC();
return base.IncrementPC();
}
return this.PC;
}
protected override byte FetchInstruction()
@@ -149,14 +150,13 @@ namespace EightBit
protected sealed override void Push(byte value)
{
this.SP.Decrement();
this.MemoryWrite(this.SP, value);
this.MemoryWrite(this.SP.Decrement(), value);
}
protected sealed override byte Pop()
{
var returned = this.MemoryRead(this.SP);
this.SP.Increment();
_ = this.SP.Increment();
return returned;
}
+2 -2
View File
@@ -29,7 +29,7 @@ namespace EightBit
protected override Register16 GetWord()
{
this.Intermediate.Low = this.MemoryRead();
this.Bus.Address.Increment();
_ = this.Bus.Address.Increment();
this.Intermediate.High = this.MemoryRead();
return this.Intermediate;
}
@@ -58,7 +58,7 @@ namespace EightBit
protected override void SetWord(Register16 value)
{
this.MemoryWrite(value.Low);
this.Bus.Address.Increment();
_ = this.Bus.Address.Increment();
this.MemoryWrite(value.High);
}
+3 -3
View File
@@ -261,14 +261,14 @@ namespace EightBit
protected virtual byte BusRead() => this.Bus.Read(); // N.B. Should be the only real call into the "Bus.Read" code.
protected virtual void IncrementPC() => this.PC.Increment();
protected virtual Register16 IncrementPC() => this.PC.Increment();
protected virtual void DecrementPC() => this.PC.Decrement();
protected virtual Register16 DecrementPC() => this.PC.Decrement();
protected virtual void ImmediateAddress()
{
this.Bus.Address.Assign(this.PC);
this.IncrementPC();
_ = this.IncrementPC();
}
protected virtual byte FetchByte()
+2 -2
View File
@@ -95,14 +95,14 @@ namespace EightBit
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Register16 Increment()
{
this.Word++;
++this.Word;
return this;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Register16 Decrement()
{
this.Word--;
--this.Word;
return this;
}
}