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:
parent
8b67a827dd
commit
6b33d2b5a5
20
EightBit.sln
20
EightBit.sln
|
@ -19,10 +19,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Intel8080", "Intel8080\Inte
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Intel8080.Test", "Intel8080\Intel8080.Test\Intel8080.Test.csproj", "{B09091A2-43A6-4729-9EE2-047895ECAF30}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MC6809", "MC6809\MC6809.csproj", "{3A63972B-AB50-4A01-8A10-0D2165580FAD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
|
@ -128,6 +127,18 @@ Global
|
|||
{B09091A2-43A6-4729-9EE2-047895ECAF30}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B09091A2-43A6-4729-9EE2-047895ECAF30}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B09091A2-43A6-4729-9EE2-047895ECAF30}.Release|x86.Build.0 = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|x64.Build.0 = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3A63972B-AB50-4A01-8A10-0D2165580FAD}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -135,4 +146,7 @@ Global
|
|||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E120AD0F-5939-4F8B-B454-7920E565FA7E}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3A63972B-AB50-4A01-8A10-0D2165580FAD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>EightBit</RootNamespace>
|
||||
<AssemblyName>MC6809</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MC6809.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StatusBits.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="stylecop.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EightBit\EightBit.csproj">
|
||||
<Project>{6ebf8857-62a3-4ef4-af21-c1844031d7e4}</Project>
|
||||
<Name>EightBit</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MC6809")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MC6809")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("3a63972b-ab50-4a01-8a10-0d2165580fad")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,48 @@
|
|||
// <copyright file="StatusBits.cs" company="Adrian Conlon">
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace EightBit
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum StatusBits : byte
|
||||
{
|
||||
// Entire flag: set if the complete machine state was saved in the stack.
|
||||
// If this bit is not set then only program counter and condition code
|
||||
// registers were saved in the stack. This bit is used by interrupt
|
||||
// handling routines only.
|
||||
// The bit is cleared by fast interrupts, and set by all other interrupts.
|
||||
EF = Bits.Bit7,
|
||||
|
||||
// Fast interrupt mask: set if the FIRQ interrupt is disabled.
|
||||
FF = Bits.Bit6,
|
||||
|
||||
// Half carry: set if there was a carry from bit 3 to bit 4 of the result
|
||||
// during the last add operation.
|
||||
HF = Bits.Bit5,
|
||||
|
||||
// Interrupt mask: set if the IRQ interrupt is disabled.
|
||||
IF = Bits.Bit4,
|
||||
|
||||
// Negative: set if the most significant bit of the result is set.
|
||||
// This bit can be set not only by arithmetic and logical operations,
|
||||
// but also by load / store operations.
|
||||
NF = Bits.Bit3,
|
||||
|
||||
// Zero: set if the result is zero. Like the N bit, this bit can be
|
||||
// set not only by arithmetic and logical operations, but also
|
||||
// by load / store operations.
|
||||
ZF = Bits.Bit2,
|
||||
|
||||
// Overflow: set if there was an overflow during last result calculation.
|
||||
// Logical, load and store operations clear this bit.
|
||||
VF = Bits.Bit1,
|
||||
|
||||
// Carry: set if there was a carry from the bit 7 during last add
|
||||
// operation, or if there was a borrow from last subtract operation,
|
||||
// or if bit 7 of the A register was set during last MUL operation.
|
||||
CF = Bits.Bit0,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="StyleCop.Analyzers.Unstable" version="1.1.1.114" targetFramework="net472" developmentDependency="true" />
|
||||
</packages>
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
// ACTION REQUIRED: This file was automatically added to your project, but it
|
||||
// will not take effect until additional steps are taken to enable it. See the
|
||||
// following page for additional information:
|
||||
//
|
||||
// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md
|
||||
|
||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||
"settings": {
|
||||
"documentationRules": {
|
||||
"documentInterfaces": false,
|
||||
"documentExposedElements": false,
|
||||
"documentInternalElements": false,
|
||||
"documentPrivateElements": false,
|
||||
"documentPrivateFields": false,
|
||||
"companyName": "Adrian Conlon"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue