Make "Pop" more like "Read". i.e. don't return a result, just use the value placed on the "bus"

This commit is contained in:
Adrian Conlon committed 2026-05-18 18:24:32 +01:00
1 parent 741feb4342
commit dfd4d1928f
9 files changed
+40 -27

No files matched your search

+4 -2
View File
@@ -51,8 +51,10 @@ namespace EightBit
protected override void PopInto(Register16 into)
{
//ArgumentNullException.ThrowIfNull(into);
into.High = this.Pop();
into.Low = this.Pop();
this.Pop();
into.High = this.Bus.Data;
this.Pop();
into.Low = this.Bus.Data;
}
protected override void PushShort(Register16 value)
+1 -2
View File
@@ -148,11 +148,10 @@ namespace EightBit
this.MemoryWrite(this.SP, value);
}
protected sealed override byte Pop()
protected sealed override void Pop()
{
this.MemoryRead(this.SP);
this.SP.Increment();
return this.Bus.Data;
}
protected sealed override void GetShort()
+4 -2
View File
@@ -52,8 +52,10 @@ namespace EightBit
protected override void PopInto(Register16 into)
{
//ArgumentNullException.ThrowIfNull(into);
into.Low = this.Pop();
into.High = this.Pop();
this.Pop();
into.Low = this.Bus.Data;
this.Pop();
into.High = this.Bus.Data;
}
protected override void PushShort(Register16 value)
+1 -1
View File
@@ -267,7 +267,7 @@ namespace EightBit
protected abstract void Push(byte value);
protected abstract byte Pop();
protected abstract void Pop();
protected abstract void PushShort(Register16 value);
+3 -1
View File
@@ -22,12 +22,14 @@ namespace LR35902.FuseTest
private readonly Test<T> test = test;
private readonly Result<T> result = result;
private readonly EightBit.Ram ram = new(0x10000);
private EightBit.MemoryMapping? mapping;
public bool Failed { get; private set; } = false;
public bool Unimplemented { get; private set; } = false;
public override EightBit.MemoryMapping Mapping(ushort address) => new(this.ram, 0, EightBit.Mask.Sixteen, EightBit.AccessLevel.ReadWrite);
public override EightBit.MemoryMapping Mapping(ushort address) =>
this.mapping ??= new EightBit.MemoryMapping(this.ram, 0, EightBit.Mask.Sixteen, EightBit.AccessLevel.ReadWrite);
public void Run()
{
+6 -5
View File
@@ -586,11 +586,10 @@ namespace M6502
#region Stack access
protected override byte Pop()
protected override void Pop()
{
this.RaiseStack();
this.MemoryRead();
return this.Bus.Data;
}
protected override void Push(byte value)
@@ -861,7 +860,7 @@ namespace M6502
private void STX() => this.MemoryWrite(this.X);
private void LDY() => this.Y = this.Through();
protected void LDY() => this.Y = this.Through();
private void STY() => this.MemoryWrite(this.Y);
@@ -1105,7 +1104,8 @@ namespace M6502
private void PLA()
{
this.SwallowPop();
this.A = this.Through(this.Pop());
this.Pop();
this.LDA();
}
private void PHP() => this.Push(SetBit(this.P, StatusBits.BF));
@@ -1113,7 +1113,8 @@ namespace M6502
private void PLP()
{
this.SwallowPop();
this.P = ClearBit(SetBit(this.Pop(), StatusBits.RF), StatusBits.BF);
this.Pop();
this.P = ClearBit(SetBit(this.Bus.Data, StatusBits.RF), StatusBits.BF);
}
private void RTI()
+2 -2
View File
@@ -6,8 +6,8 @@
{
public Ram RAM { get; } = new(0x10000);
public MOS6502 CPU { get; }
//public WDC65C02 CPU { get; }
//public MOS6502 CPU { get; }
public WDC65C02 CPU { get; }
private readonly MemoryMapping _mapping;
+4 -2
View File
@@ -353,7 +353,8 @@ namespace M6502
private void PLX()
{
this.SwallowPop();
this.X = this.Through(this.Pop());
this.Pop();
this.LDX();
}
private void PHY() => this.Push(this.Y);
@@ -361,7 +362,8 @@ namespace M6502
private void PLY()
{
this.SwallowPop();
this.Y = this.Through(this.Pop());
this.Pop();
this.LDY();
}
private void BRA() => this.Branch(true);
+15 -10
View File
@@ -593,7 +593,7 @@ namespace MC6809
#region Push/Pop
protected override byte Pop() => this.PopS();
protected override void Pop() => this.PopS();
protected override void Push(byte value) => this.PushS(value);
@@ -611,19 +611,20 @@ namespace MC6809
this.Push(stack, value.High);
}
protected byte Pop(Register16 stack)
protected void Pop(Register16 stack)
{
this.MemoryRead(stack);
stack.Increment();
return this.Bus.Data;
}
private byte PopS() => this.Pop(this.S);
private void PopS() => this.Pop(this.S);
protected Register16 PopWord(Register16 stack)
{
this.Intermediate.High = this.Pop(stack);
this.Intermediate.Low = this.Pop(stack);
this.Pop(stack);
this.Intermediate.High = this.Bus.Data;
this.Pop(stack);
this.Intermediate.Low = this.Bus.Data;
return this.Intermediate;
}
@@ -1054,22 +1055,26 @@ namespace MC6809
if ((control & (byte)Bits.Bit0) != 0)
{
this.CC = this.Pop(stack);
this.Pop(stack);
this.CC = this.Bus.Data;
}
if ((control & (byte)Bits.Bit1) != 0)
{
this.A = this.Pop(stack);
this.Pop(stack);
this.A = this.Bus.Data;
}
if ((control & (byte)Bits.Bit2) != 0)
{
this.B = this.Pop(stack);
this.Pop(stack);
this.B = this.Bus.Data;
}
if ((control & (byte)Bits.Bit3) != 0)
{
this.DP = this.Pop(stack);
this.Pop(stack);
this.DP = this.Bus.Data;
}
// Sixteen-bit registers