Start adding MC6809 unit tests for each instruction. Just ABX, so far

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-10-06 23:52:39 +01:00
parent 8048165aab
commit fe05d468d6
11 changed files with 354 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "modules/catch2"]
path = modules/catch2
url = https://github.com/catchorg/Catch2.git

View File

@ -31,6 +31,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_MC6809", "MC6809\test\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MC6850", "MC6850\src\MC6850.vcxproj", "{A4ADA650-55C3-4C00-8DAD-E4E4AFF86EFF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest_MC6809", "MC6809\unittest\unittest_MC6809.vcxproj", "{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -151,6 +153,14 @@ Global
{A4ADA650-55C3-4C00-8DAD-E4E4AFF86EFF}.Release|x64.Build.0 = Release|x64
{A4ADA650-55C3-4C00-8DAD-E4E4AFF86EFF}.Release|x86.ActiveCfg = Release|Win32
{A4ADA650-55C3-4C00-8DAD-E4E4AFF86EFF}.Release|x86.Build.0 = Release|Win32
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Debug|x64.ActiveCfg = Debug|x64
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Debug|x64.Build.0 = Debug|x64
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Debug|x86.ActiveCfg = Debug|Win32
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Debug|x86.Build.0 = Debug|Win32
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Release|x64.ActiveCfg = Release|x64
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Release|x64.Build.0 = Release|x64
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Release|x86.ActiveCfg = Release|Win32
{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

17
MC6809/unittest/Board.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "pch.h"
#include "Board.h"
Board::Board()
: m_cpu(EightBit::mc6809(*this)) {
}
void Board::initialise() {
CPU().powerOn();
CPU().raise(CPU().NMI());
CPU().raise(CPU().FIRQ());
CPU().reset();
}
EightBit::MemoryMapping Board::mapping(uint16_t) {
return { m_ram, 0x0000, EightBit::MemoryMapping::ReadWrite };
}

21
MC6809/unittest/Board.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <Ram.h>
#include <Bus.h>
#include <mc6809.h>
class Board : public EightBit::Bus {
public:
Board();
EightBit::mc6809& CPU() { return m_cpu; }
void initialise();
protected:
virtual EightBit::MemoryMapping mapping(uint16_t address) final;
private:
EightBit::Ram m_ram = 0x10000; // 0000 - FFFF, 64K RAM
EightBit::mc6809 m_cpu;
};

View File

@ -0,0 +1,54 @@
#include "pch.h"
#include "Board.h"
// Using examples from 6809 Assembly Language Programming, by Lance A. Leventhal
TEST_CASE("Add Accumulator B to Index Register X Unsigned ", "[ABX]") {
Board board;
board.initialise();
auto& cpu = board.CPU();
cpu.step(); // Jump over the reset
SECTION("Inherent") {
board.poke(0, 0x3a);
cpu.B() = 0x84;
cpu.X() = 0x1097;
cpu.step();
REQUIRE(cpu.X() == 0x111b);
}
}
//TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
//
// std::vector<int> v( 5 );
//
// REQUIRE( v.size() == 5 );
// REQUIRE( v.capacity() >= 5 );
//
// SECTION( "resizing bigger changes size and capacity" ) {
// v.resize( 10 );
//
// REQUIRE( v.size() == 10 );
// REQUIRE( v.capacity() >= 10 );
// }
// SECTION( "resizing smaller changes size but not capacity" ) {
// v.resize( 0 );
//
// REQUIRE( v.size() == 0 );
// REQUIRE( v.capacity() >= 5 );
// }
// SECTION( "reserving bigger changes capacity but not size" ) {
// v.reserve( 10 );
//
// REQUIRE( v.size() == 5 );
// REQUIRE( v.capacity() >= 10 );
// }
// SECTION( "reserving smaller does not change size or capacity" ) {
// v.reserve( 0 );
//
// REQUIRE( v.size() == 5 );
// REQUIRE( v.capacity() >= 5 );
// }
//}

BIN
MC6809/unittest/pch.cpp Normal file

Binary file not shown.

BIN
MC6809/unittest/pch.h Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{9EFEA22E-E981-4342-BE17-7DD0F33F1F52}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>unittestMC6809</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>$(TargetPath)</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>$(TargetPath)</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Board.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Board.cpp" />
<ClCompile Include="mc6809_tests.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="unittest_MC6809.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\EightBit.vcxproj">
<Project>{a9c24bd9-0cb4-4c84-b09b-46b815f9da47}</Project>
</ProjectReference>
<ProjectReference Include="..\src\MC6809.vcxproj">
<Project>{09c1b50e-408e-48b1-a616-8400904b5829}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Board.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="unittest_MC6809.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mc6809_tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Board.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

1
modules/catch2 Submodule

@ -0,0 +1 @@
Subproject commit 9e1bdca4667295fcb16265eae00efa8423f07007