mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-11-23 23:18:12 +00:00
Couple of small Register16 adjustments
This commit is contained in:
@@ -311,7 +311,7 @@ namespace EightBit
|
|||||||
this.SetWord(value);
|
this.SetWord(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Jump(ushort destination) => this.PC.Assign(destination);
|
protected void Jump(ushort destination) => this.PC.Word = destination;
|
||||||
|
|
||||||
protected void Jump(Register16 destination) => this.PC.Assign(destination);
|
protected void Jump(Register16 destination) => this.PC.Assign(destination);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace EightBit
|
namespace EightBit
|
||||||
{
|
{
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit, Size = 2)]
|
[StructLayout(LayoutKind.Explicit, Size = 2)]
|
||||||
@@ -20,7 +21,7 @@ namespace EightBit
|
|||||||
|
|
||||||
public Register16(ushort value)
|
public Register16(ushort value)
|
||||||
{
|
{
|
||||||
this.Assign(value);
|
this.Word = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Register16()
|
public Register16()
|
||||||
@@ -48,19 +49,22 @@ namespace EightBit
|
|||||||
this.High = rhs.High;
|
this.High = rhs.High;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ushort Word
|
public unsafe ushort Word
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
fixed (byte* bytes = &this._low)
|
||||||
{
|
{
|
||||||
fixed (byte* bytes = &this._low)
|
return *(ushort*)bytes;
|
||||||
{
|
}
|
||||||
return *(ushort*)bytes;
|
}
|
||||||
}
|
set
|
||||||
|
{
|
||||||
|
fixed (byte* bytes = &this._low)
|
||||||
|
{
|
||||||
|
*(ushort*)bytes = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set => this.Assign(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ref byte Low => ref this._low;
|
public ref byte Low => ref this._low;
|
||||||
@@ -88,19 +92,10 @@ namespace EightBit
|
|||||||
this.Assign(from.Low, from.High);
|
this.Assign(from.Low, from.High);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Assign(ushort from)
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
{
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
fixed (byte* bytes = &this._low)
|
|
||||||
{
|
|
||||||
*(ushort*)bytes = from;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ushort Increment() => this.Word++;
|
public ushort Increment() => this.Word++;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ushort Decrement() => this.Word--;
|
public ushort Decrement() => this.Word--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user