Skip to content

Commit

Permalink
reorder done
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-sven committed Mar 21, 2023
1 parent 599217b commit 2d31282
Show file tree
Hide file tree
Showing 33 changed files with 124 additions and 135 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
using Sim80C51.Interfaces;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace Sim80C51.Processors
namespace Sim80C51.Interfaces
{
public interface I80C51Core : I80C51
public interface I80C51 : INotifyPropertyChanged
{
/// <summary>
/// Program Counter
/// </summary>
ushort PC { get; set; }
/// <summary>
/// Cycle Counter
/// </summary>
ulong Cycles { get; set; }

/// <summary>
/// Data Pointer
/// </summary>
ushort DPTR { get; set; }

/// <summary>
/// Port 1
/// </summary>
byte P1 { get; set; }

// TODO: add more registers as required


/// <summary>
/// Internal RAM Address space
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace Sim80C51.Processors
namespace Sim80C51.Interfaces
{
public interface IByteRow : INotifyPropertyChanged
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sim80C51.Processors
namespace Sim80C51.Interfaces
{
public interface ICallStackEntry
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Sim80C51.Processors
using Sim80C51.Processors;

namespace Sim80C51.Interfaces
{
public interface IListingInstruction
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sim80C51.Processors
namespace Sim80C51.Processors.Attributes
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class IVAttribute : Attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sim80C51.Processors
namespace Sim80C51.Processors.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class SFR16Attribute : Attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sim80C51.Processors
namespace Sim80C51.Processors.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class SFRAttribute : Attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Sim80C51.Processors
namespace Sim80C51.Processors.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class SFRBitAttribute : Attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Sim80C51.Toolbox.Wpf;
using Sim80C51.Interfaces;
using Sim80C51.Toolbox.Wpf;
using System.Collections.ObjectModel;
using System.IO;

namespace Sim80C51.Processors
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Sim80C51.Toolbox.Wpf;
using Sim80C51.Interfaces;
using Sim80C51.Processors.Attributes;
using Sim80C51.Toolbox.Wpf;
using System.Reflection;
using System.Runtime.CompilerServices;

Expand All @@ -7,7 +9,7 @@ namespace Sim80C51.Processors
/// <summary>
/// Register setter and getter logic from properties
/// </summary>
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51Core
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51
{
/// <summary>
/// map for sfr addresses
Expand Down Expand Up @@ -380,5 +382,35 @@ protected byte SetMem(ushort address, byte value)
return (byte)(oldValue ^ value);
}
#endregion

public static byte ParseIntermediateByte(string value)
{
if (!value.StartsWith("#"))
{
throw new ArgumentOutOfRangeException(value);
}

if (value.EndsWith("h"))
{
return Convert.ToByte(value[1..3], 16);
}

return (byte)int.Parse(value[1..]);
}

public static ushort ParseIntermediateUShort(string value)
{
if (!value.StartsWith("#"))
{
throw new ArgumentOutOfRangeException(value);
}

if (value.EndsWith("h"))
{
return Convert.ToUInt16(value[1..5], 16);
}

return (ushort)int.Parse(value[1..]);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sim80C51.Common;
using Sim80C51.Interfaces;
using Sim80C51.Toolbox.Wpf;
using System.Reflection;

Expand All @@ -7,7 +7,7 @@ namespace Sim80C51.Processors
/// <summary>
/// Debug and process logic
/// </summary>
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51Core
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51
{
private static readonly string[] regNames = new string[] { nameof(R0), nameof(R1), nameof(R2), nameof(R3), nameof(R4), nameof(R5), nameof(R6), nameof(R7) };

Expand Down Expand Up @@ -212,7 +212,7 @@ public void Process(IListingInstruction entry)
}
else if (entry.Arguments[0] == "DPTR")
{
DPTR = ListingFactory.ParseIntermediateUShort(entry.Arguments[1]);
DPTR = ParseIntermediateUShort(entry.Arguments[1]);
}
else
{
Expand Down Expand Up @@ -444,7 +444,7 @@ public void Process(IListingInstruction entry)
_ => throw new Exception("Instruction Argument unknown: " + entry.Arguments[0])
};

byte compSecond = entry.Arguments[1].StartsWith('#') ? ListingFactory.ParseIntermediateByte(entry.Arguments[1]) : GetDirectRam(entry.Arguments[1]);
byte compSecond = entry.Arguments[1].StartsWith('#') ? ParseIntermediateByte(entry.Arguments[1]) : GetDirectRam(entry.Arguments[1]);
if (compFirst != compSecond)
{
PC = entry.TargetAddress;
Expand Down Expand Up @@ -490,7 +490,7 @@ public void Process(IListingInstruction entry)
}
else
{
tmpByte ^= ListingFactory.ParseIntermediateByte(entry.Arguments[1]);
tmpByte ^= ParseIntermediateByte(entry.Arguments[1]);
}
SetDirectRam(entry.Arguments[0], tmpByte);
}
Expand Down Expand Up @@ -886,7 +886,7 @@ private byte GetByteFromInstructionArgument(string arg)
// 8-bit constant
if (arg.StartsWith('#'))
{
return ListingFactory.ParseIntermediateByte(arg);
return ParseIntermediateByte(arg);
}

return GetDirectRam(arg);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Sim80C51.Toolbox.Wpf;
using Sim80C51.Interfaces;
using Sim80C51.Processors.Attributes;
using Sim80C51.Toolbox.Wpf;
using System.Collections.ObjectModel;

namespace Sim80C51.Processors
Expand All @@ -11,7 +13,7 @@ namespace Sim80C51.Processors
[IV(0x0013, 7, "X1")]
[IV(0x001B, 10, "T1")]
[IV(0x0023, 13, "S0")]
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51Core
public abstract partial class C80C51 : NotifyPropertyChanged, I80C51
{
/// <summary>
/// Program Counter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Sim80C51.Processors
using Sim80C51.Interfaces;

namespace Sim80C51.Processors
{
public class CallStackEntry : ICallStackEntry
{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Sim80C51.Interfaces;
using Sim80C51.Processors.Attributes;
using Sim80C51.Toolbox;
using System.ComponentModel;

Expand Down
15 changes: 15 additions & 0 deletions Sim80C51.Core/Sim80C51.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Sven Fabricius</Authors>
<RootNamespace>Sim80C51</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Sim80C51.Toolbox\Sim80C51.Toolbox.csproj" />
</ItemGroup>

</Project>
28 changes: 0 additions & 28 deletions Sim80C51.Interfaces/I80C51.cs

This file was deleted.

10 changes: 0 additions & 10 deletions Sim80C51.Interfaces/Sim80C51.Interfaces.csproj

This file was deleted.

14 changes: 0 additions & 14 deletions Sim80C51.Processors/Sim80C51.Processors.csproj

This file was deleted.

3 changes: 1 addition & 2 deletions Sim80C51.TanningBed/Sim80C51.TanningBed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Sim80C51.Interfaces\Sim80C51.Interfaces.csproj" />
<ProjectReference Include="..\Sim80C51.Toolbox\Sim80C51.Toolbox.csproj" />
<ProjectReference Include="..\Sim80C51.Core\Sim80C51.Core.csproj" />
</ItemGroup>

</Project>
8 changes: 1 addition & 7 deletions Sim80C51.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sim80C51", "Sim80C51\Sim80C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sim80C51.TanningBed", "Sim80C51.TanningBed\Sim80C51.TanningBed.csproj", "{0806D140-190C-4706-8360-FB318E043A76}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sim80C51.Interfaces", "Sim80C51.Interfaces\Sim80C51.Interfaces.csproj", "{B8EEAF4D-903A-4BFC-91E2-BD576A807C6F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sim80C51.Toolbox", "Sim80C51.Toolbox\Sim80C51.Toolbox.csproj", "{F2C79B21-1A4F-4D1E-8447-DDC272BA00D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sim80C51.Processors", "Sim80C51.Processors\Sim80C51.Processors.csproj", "{907C65E0-72E4-46E6-AD79-895EDA55B08A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sim80C51.Core", "Sim80C51.Core\Sim80C51.Core.csproj", "{907C65E0-72E4-46E6-AD79-895EDA55B08A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,10 +25,6 @@ Global
{0806D140-190C-4706-8360-FB318E043A76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0806D140-190C-4706-8360-FB318E043A76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0806D140-190C-4706-8360-FB318E043A76}.Release|Any CPU.Build.0 = Release|Any CPU
{B8EEAF4D-903A-4BFC-91E2-BD576A807C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8EEAF4D-903A-4BFC-91E2-BD576A807C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8EEAF4D-903A-4BFC-91E2-BD576A807C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8EEAF4D-903A-4BFC-91E2-BD576A807C6F}.Release|Any CPU.Build.0 = Release|Any CPU
{F2C79B21-1A4F-4D1E-8447-DDC272BA00D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2C79B21-1A4F-4D1E-8447-DDC272BA00D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2C79B21-1A4F-4D1E-8447-DDC272BA00D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
3 changes: 2 additions & 1 deletion Sim80C51/Common/ListingEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Sim80C51.Processors;
using Sim80C51.Interfaces;
using Sim80C51.Processors;
using Sim80C51.Toolbox.Wpf;

namespace Sim80C51.Common
Expand Down
Loading

0 comments on commit 2d31282

Please sign in to comment.