mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-23 23:02:16 +00:00
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:
1 parent
741feb4342
commit
dfd4d1928f
9 files changed
+40
-27
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
@@ -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()
|
||||
|
||||
@@ -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
@@ -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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user