Replaced CP0 register index abstract property by a readonly field.

master
Nabile Rahmani 2018-06-09 18:17:06 +02:00
parent c15c1d0b18
commit a7972ebc0a
4 changed files with 8 additions and 14 deletions

View File

@ -24,8 +24,6 @@ namespace DotN64.CPU
#endregion
#region Properties
protected override RegisterIndex Index => RegisterIndex.Cause;
/// <summary>
/// Exception code field (refer to Table 6-2 for details.)
/// </summary>
@ -73,7 +71,7 @@ namespace DotN64.CPU
#region Constructors
public CauseRegister(SystemControlUnit cp0)
: base(cp0) { }
: base(cp0, RegisterIndex.Cause) { }
#endregion
#region Structures

View File

@ -24,8 +24,6 @@ namespace DotN64.CPU
#endregion
#region Properties
protected override RegisterIndex Index => RegisterIndex.Config;
/// <summary>
/// Sets coherency algorithm of kseg0.
/// </summary>
@ -74,7 +72,7 @@ namespace DotN64.CPU
#region Constructors
public ConfigRegister(SystemControlUnit cp0)
: base(cp0)
: base(cp0, RegisterIndex.Config)
{
this[constant1] = 0b11001000110;
this[constant2] = 0b00000110;

View File

@ -10,6 +10,7 @@ namespace DotN64.CPU
{
#region Fields
private readonly SystemControlUnit cp0;
private readonly RegisterIndex index;
#endregion
#region Properties
@ -17,11 +18,9 @@ namespace DotN64.CPU
protected ulong Data
{
get => cp0.Registers[(int)Index];
set => cp0.Registers[(int)Index] = value;
get => cp0.Registers[(int)index];
set => cp0.Registers[(int)index] = value;
}
protected abstract RegisterIndex Index { get; }
#endregion
#region Indexers
@ -49,9 +48,10 @@ namespace DotN64.CPU
#endregion
#region Constructors
protected Register(SystemControlUnit cp0)
protected Register(SystemControlUnit cp0, RegisterIndex index)
{
this.cp0 = cp0;
this.index = index;
}
#endregion
}

View File

@ -29,8 +29,6 @@ namespace DotN64.CPU
#endregion
#region Properties
protected override RegisterIndex Index => RegisterIndex.Status;
/// <summary>
/// Specifies and indicates global interrupt enable.
/// </summary>
@ -154,7 +152,7 @@ namespace DotN64.CPU
#region Constructors
public StatusRegister(SystemControlUnit cp0)
: base(cp0) { }
: base(cp0, RegisterIndex.Status) { }
#endregion
#region Structures