1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Introduce and overwhelmingly fail the flamewing BCD tests.

This commit is contained in:
Thomas Harte 2022-05-11 15:19:39 -04:00
parent d492156453
commit 17add4b585
4 changed files with 117 additions and 0 deletions

View File

@ -474,6 +474,8 @@
4B7C681B275196E8001671EC /* MouseJoystick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7C6818275196E8001671EC /* MouseJoystick.cpp */; };
4B7C681E2751A104001671EC /* Bitplanes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7C681C2751A104001671EC /* Bitplanes.cpp */; };
4B7C681F2751A104001671EC /* Bitplanes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7C681C2751A104001671EC /* Bitplanes.cpp */; };
4B7C7A00282C3BCA002D6C0B /* 68000flamewingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B7C79FF282C3BCA002D6C0B /* 68000flamewingTests.mm */; };
4B7C7A07282C3DED002D6C0B /* flamewing 68000 BCD tests in Resources */ = {isa = PBXBuildFile; fileRef = 4B7C7A06282C3DED002D6C0B /* flamewing 68000 BCD tests */; };
4B7F188E2154825E00388727 /* MasterSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F188C2154825D00388727 /* MasterSystem.cpp */; };
4B7F188F2154825E00388727 /* MasterSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F188C2154825D00388727 /* MasterSystem.cpp */; };
4B7F1897215486A200388727 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F1896215486A100388727 /* StaticAnalyser.cpp */; };
@ -1481,6 +1483,8 @@
4B7C681C2751A104001671EC /* Bitplanes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Bitplanes.cpp; sourceTree = "<group>"; };
4B7C681D2751A104001671EC /* Bitplanes.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Bitplanes.hpp; sourceTree = "<group>"; };
4B7C79FE282AFA9B002D6C0B /* ExceptionVectors.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ExceptionVectors.hpp; sourceTree = "<group>"; };
4B7C79FF282C3BCA002D6C0B /* 68000flamewingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = 68000flamewingTests.mm; sourceTree = "<group>"; };
4B7C7A06282C3DED002D6C0B /* flamewing 68000 BCD tests */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "flamewing 68000 BCD tests"; sourceTree = "<group>"; };
4B7F188C2154825D00388727 /* MasterSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MasterSystem.cpp; sourceTree = "<group>"; };
4B7F188D2154825D00388727 /* MasterSystem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MasterSystem.hpp; sourceTree = "<group>"; };
4B7F1895215486A100388727 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StaticAnalyser.hpp; sourceTree = "<group>"; };
@ -2441,6 +2445,7 @@
4B1414631B588A1100E04248 /* Test Binaries */ = {
isa = PBXGroup;
children = (
4B7C7A06282C3DED002D6C0B /* flamewing 68000 BCD tests */,
4B680CE323A555CA00451D43 /* 68000 Comparative Tests */,
4B75F97A280D7C7700121055 /* 68000 Decoding */,
4B683B002727BE6F0043E541 /* Amiga Blitter Tests */,
@ -4212,6 +4217,7 @@
4B680CE123A5553100451D43 /* 68000ComparativeTests.mm */,
4B9D0C4C22C7DA1A00DE1AD3 /* 68000ControlFlowTests.mm */,
4B75F978280D7C5100121055 /* 68000DecoderTests.mm */,
4B7C79FF282C3BCA002D6C0B /* 68000flamewingTests.mm */,
4BC5C3DF22C994CC00795658 /* 68000MoveTests.mm */,
4B9D0C4E22C7E0CF00DE1AD3 /* 68000RollShiftTests.mm */,
4BD388872239E198002D14B5 /* 68000Tests.mm */,
@ -5266,6 +5272,7 @@
4BB2997E1B587D8400A49093 /* ldxb in Resources */,
4BB298F51B587D8400A49093 /* adcb in Resources */,
4BB299981B587D8400A49093 /* nopax in Resources */,
4B7C7A07282C3DED002D6C0B /* flamewing 68000 BCD tests in Resources */,
4BB299931B587D8400A49093 /* lxab in Resources */,
4BB299F01B587D8400A49093 /* trap4 in Resources */,
4B8DF6722550D91600F3433C /* CPUBIT.sfc in Resources */,
@ -6119,6 +6126,7 @@
4B7752B128217EA30073E2C5 /* StaticAnalyser.cpp in Sources */,
4B778F5123A5F2290000D260 /* StaticAnalyser.cpp in Sources */,
4B7752C028217F3D0073E2C5 /* Line.cpp in Sources */,
4B7C7A00282C3BCA002D6C0B /* 68000flamewingTests.mm in Sources */,
4B778F0223A5EBA40000D260 /* MFMSectorDump.cpp in Sources */,
4B7752BD28217F200073E2C5 /* Keyboard.cpp in Sources */,
4BFCA1271ECBE33200AC40C1 /* TestMachineZ80.mm in Sources */,

View File

@ -0,0 +1,104 @@
//
// 68000ComparativeTests.cpp
// Clock SignalTests
//
// Created by Thomas Harte on 14/12/2019.
// Copyright © 2019 Thomas Harte. All rights reserved.
//
#import <XCTest/XCTest.h>
#include "../../../InstructionSets/M68k/Perform.hpp"
using namespace InstructionSet::M68k;
@interface M68000flamewingTests : XCTestCase
@end
@implementation M68000flamewingTests
- (Status)statusWithflamewingFlags:(int)flags {
Status status;
status.carry_flag_ = status.extend_flag_ = flags & 2;
status.zero_result_ = ~(flags & 1);
status.negative_flag_ = 0;
status.overflow_flag_ = 0;
return status;
}
- (void)validate:(const uint8_t *)test source:(int)source dest:(int)dest flags:(int)flags result:(uint32_t)result status:(Status)status operation:(NSString *)operation {
const uint8_t result_flags = test[0];
const uint8_t result_value = test[1];
NSString *const testName =
[NSString stringWithFormat:@"%@ %02x, %02x [%c%c]", operation, source, dest, (flags & 2) ? 'X' : '-', (flags & 1) ? 'Z' : '-'];
XCTAssertEqual(result, uint32_t(result_value), @"Wrong value received for %@", testName);
XCTAssertEqual(status.ccr(), uint16_t(result_flags), @"Wrong status received for %@", testName);
}
- (void)testAll {
// Get the full list of available test files.
NSBundle *const bundle = [NSBundle bundleForClass:[self class]];
NSURL *const testURL = [bundle URLForResource:@"bcd-table" withExtension:@"bin" subdirectory:@"flamewing 68000 BCD tests"];
NSData *const testData = [NSData dataWithContentsOfURL:testURL];
const uint8_t *bytes = reinterpret_cast<const uint8_t *>(testData.bytes);
struct NoFlowController: public NullFlowController {
} flow_controller;
// Test ABCD.
for(int dest = 0; dest < 256; dest++) {
for(int source = 0; source < 256; source++) {
for(int flags = 0; flags < 4; flags++) {
Status status = [self statusWithflamewingFlags:flags];
CPU::SlicedInt32 s, d;
s.l = source;
d.l = dest;
perform<Model::M68000, NoFlowController, Operation::ABCD>(
Preinstruction(), s, d, status, flow_controller);
[self validate:bytes source:source dest:dest flags:flags result:d.l status:status operation:@"ABCD"];
bytes += 2;
}
}
}
// Test SBCD.
for(int dest = 0; dest < 256; dest++) {
for(int source = 0; source < 256; source++) {
for(int flags = 0; flags < 4; flags++) {
Status status = [self statusWithflamewingFlags:flags];
CPU::SlicedInt32 s, d;
s.l = source;
d.l = dest;
perform<Model::M68000, NoFlowController, Operation::SBCD>(
Preinstruction(), s, d, status, flow_controller);
[self validate:bytes source:source dest:dest flags:flags result:d.l status:status operation:@"SBCD"];
bytes += 2;
}
}
}
// Test NBCD.
for(int source = 0; source < 256; source++) {
for(int flags = 0; flags < 4; flags++) {
Status status = [self statusWithflamewingFlags:flags];
CPU::SlicedInt32 s, d;
s.l = source;
perform<Model::M68000, NoFlowController, Operation::SBCD>(
Preinstruction(), s, d, status, flow_controller);
[self validate:bytes source:source dest:0 flags:flags result:d.l status:status operation:@"NBCD"];
bytes += 2;
}
}
}
@end

View File

@ -0,0 +1,5 @@
# flamewing's 68000 BCD tests
These test results were generated by code obtained from https://github.com/flamewing/68k-bcd-verifier
The code itself is licensed under the GPL 3.0; the file included here is not part of the original repository but is generated as part of the build process so it is probably safest to assume it is covered by the GPL despite the rule that program output isn't covered — it is arguably part of the program, not program output.