Add a initial port of the MC6809 processor to the .Net collection

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-04-10 19:51:39 +01:00
parent 8b67a827dd
commit 6b33d2b5a5
9 changed files with 1792 additions and 6 deletions
+13
View File
@@ -35,6 +35,15 @@ namespace EightBit
protected byte OpCode { get; set; }
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
public static sbyte SignExtend(int b, byte x)
{
var m = (byte)(1 << (b - 1)); // mask can be pre-computed if b is fixed
x = (byte)(x & ((1 << b) - 1)); // (Skip this if bits in x above position b are already zero.)
var result = (x ^ m) - m;
return (sbyte)result;
}
public ref PinLevel RESET() => ref this.resetLine;
public ref PinLevel INT() => ref this.intLine;
@@ -178,12 +187,16 @@ namespace EightBit
return this.GetWord();
}
protected Register16 GetWord(Register16 address) => this.GetWord(address.Word);
protected void SetWord(ushort address, Register16 value)
{
this.Bus.Address.Word = address;
this.SetWord(value);
}
protected void SetWord(Register16 address, Register16 value) => this.SetWord(address.Word, value);
protected void Jump(ushort destination) => this.PC.Word = destination;
protected void Call(ushort destination)
+10 -3
View File
@@ -5,11 +5,13 @@
namespace EightBit
{
using System.Diagnostics;
using System.Runtime.InteropServices;
[DebuggerDisplay("Word = {Word}")]
public class Register16
{
private byte low;
private byte high;
public Register16(byte low, byte high)
{
this.Low = low;
@@ -32,6 +34,11 @@ namespace EightBit
{
}
public Register16(uint value)
: this((ushort)value)
{
}
public Register16(byte low)
: this(low, 0)
{
@@ -54,9 +61,9 @@ namespace EightBit
}
}
public byte Low { get; set; }
public ref byte Low => ref this.low;
public byte High { get; set; }
public ref byte High => ref this.high;
public static Register16 operator ++(Register16 value) => Increment(value);