mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-24 14:05:42 +00:00
Better arrangement of decimal SBC/ADC implementations
This commit is contained in:
1 parent
6d4d2f22e2
commit
b5f646c641
3 files changed
+23
-24
No files matched your search
@@ -915,10 +915,7 @@ namespace M6502
|
||||
{
|
||||
var operand = this.A;
|
||||
this.A = this.SUB(operand, CarryTest((byte)~this.P));
|
||||
|
||||
this.PostSUB(operand);
|
||||
//this.AdjustOverflowSubtract(operand);
|
||||
//this.ResetFlag(StatusBits.CF, this.Intermediate.High);
|
||||
}
|
||||
|
||||
private byte SUB(byte operand, int borrow) => this.Denary != 0 ? this.DecimalSUB(operand, borrow) : this.BinarySUB(operand, borrow);
|
||||
|
||||
+8
-8
@@ -343,24 +343,24 @@ namespace M6502
|
||||
|
||||
protected override byte BinaryADC(byte data)
|
||||
{
|
||||
var returned = base.BinaryADC(data);
|
||||
this.AdjustNZ(returned);
|
||||
return returned;
|
||||
var result = base.BinaryADC(data);
|
||||
this.AdjustNZ(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override byte BinarySUB(byte operand, int borrow = 0)
|
||||
{
|
||||
var returned = base.BinarySUB(operand, borrow);
|
||||
this.AdjustNZ(this.Intermediate.Low);
|
||||
return returned;
|
||||
var result = base.BinarySUB(operand, borrow);
|
||||
this.AdjustNZ(result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
protected override byte DecimalSUB(byte operand, int borrow)
|
||||
{
|
||||
var returned = base.DecimalSUB(operand, borrow);
|
||||
var result = base.DecimalSUB(operand, borrow);
|
||||
this.AdjustNZ(this.Intermediate.Low);
|
||||
return returned;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
+15
-13
@@ -296,24 +296,18 @@ namespace M6502
|
||||
return returned;
|
||||
}
|
||||
|
||||
protected override void SBC()
|
||||
protected override void PostSUB(byte operand)
|
||||
{
|
||||
base.SBC();
|
||||
if (this.Denary != 0)
|
||||
{
|
||||
this.AdjustNZ(this.A);
|
||||
if (this.ImmediateInstruction)
|
||||
this.MemoryRead(0x00, 0x00);
|
||||
else
|
||||
this.SwallowSpin();
|
||||
}
|
||||
// PostSUB needs to be empty, so we can sort out the
|
||||
// post calculations memory operations in DecimalSUB.
|
||||
}
|
||||
|
||||
protected override byte BinarySUB(byte operand, int borrow = 0)
|
||||
{
|
||||
var returned = base.BinarySUB(operand, borrow);
|
||||
this.AdjustNZ(this.Intermediate.Low);
|
||||
return returned;
|
||||
var result = base.BinarySUB(operand, borrow);
|
||||
base.PostSUB(operand);
|
||||
this.AdjustNZ(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override byte DecimalSUB(byte operand, int borrow)
|
||||
@@ -334,6 +328,14 @@ namespace M6502
|
||||
result -= 0x60;
|
||||
}
|
||||
|
||||
base.PostSUB(operand);
|
||||
this.AdjustNZ(result);
|
||||
|
||||
if (this.ImmediateInstruction)
|
||||
this.MemoryRead(0x00, 0x00);
|
||||
else
|
||||
this.SwallowSpin();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user