1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-01 22:41:32 +00:00

This is the same test either way around.

This commit is contained in:
Thomas Harte 2023-10-09 16:47:02 -04:00
parent 1cb26cb141
commit e46e42d896
4 changed files with 50 additions and 57 deletions

View File

@ -409,7 +409,7 @@ void adc(IntT &destination, IntT source, Status &status) {
const IntT result = destination + source + status.carry_bit<IntT>();
status.carry = Numeric::carried_out<true, bit_size<IntT>() - 1>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<true, 4>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<true, IntT>(destination, source, result);
@ -428,7 +428,7 @@ void add(IntT &destination, IntT source, Status &status) {
const IntT result = destination + source;
status.carry = Numeric::carried_out<true, bit_size<IntT>() - 1>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<true, 4>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<true, IntT>(destination, source, result);
@ -447,7 +447,7 @@ void sbb(IntT &destination, IntT source, Status &status) {
const IntT result = destination - source - status.carry_bit<IntT>();
status.carry = Numeric::carried_out<false, bit_size<IntT>() - 1>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<false, 4>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<false, IntT>(destination, source, result);
@ -466,7 +466,7 @@ void sub(IntT &destination, IntT source, Status &status) {
const IntT result = destination - source;
status.carry = Numeric::carried_out<false, bit_size<IntT>() - 1>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<false, 4>(destination, source, result);
status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<false, IntT>(destination, source, result);

View File

@ -11,7 +11,7 @@
namespace Numeric {
/// @returns @c true if there, from @c bit there was
/// @returns @c true if from @c bit there was:
/// • carry after calculating @c lhs + @c rhs if @c is_add is true; or
/// • borrow after calculating @c lhs - @c rhs if @c is_add is false;
/// producing @c result.
@ -30,21 +30,14 @@ template <bool is_add, int bit, typename IntT> bool carried_out(IntT lhs, IntT r
}
}
// ~carried_out<>(d, ~s, r)
/// @returns @c true if there was carry into @c bit when @c source1 and @c source2 were added, producing @c result.
template <bool is_add, int bit, typename IntT> bool carried_in(IntT lhs, IntT rhs, IntT result) {
// 0 and 0 or 1 and 1 => did if 1
// 0 and 1 or 1 and 0 => did if 0
if constexpr (!is_add) {
rhs = ~rhs;
}
const bool carry = IntT(1 << bit) & (lhs ^ rhs ^ result);
if constexpr (!is_add) {
return !carry;
} else {
return carry;
}
/// @returns @c true if there was carry into @c bit when computing either:
/// • @c lhs + @c rhs; or
/// • @c lhs - @c rhs;
/// producing @c result.
template <int bit, typename IntT> bool carried_in(IntT lhs, IntT rhs, IntT result) {
// 0 and 0 or 1 and 1 => did if 1.
// 0 and 1 or 1 and 0 => did if 0.
return IntT(1 << bit) & (lhs ^ rhs ^ result);
}
}

View File

@ -278,30 +278,30 @@ struct FailedExecution {
- (NSArray<NSString *> *)testFiles {
NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
NSSet *allowList = [NSSet setWithArray:@[
@"37.json.gz", // AAA
@"3F.json.gz", // AAS
@"D4.json.gz", // AAM
@"D5.json.gz", // AAD
@"27.json.gz", // DAA
@"2F.json.gz", // DAS
@"98.json.gz", // CBW
@"99.json.gz", // CWD
// ESC
@"D8.json.gz", @"D9.json.gz", @"DA.json.gz", @"DB.json.gz",
@"DC.json.gz", @"DD.json.gz", @"DE.json.gz", @"DE.json.gz",
// NOP
@"90.json.gz",
// ADC
@"10.json.gz", @"11.json.gz", @"12.json.gz", @"13.json.gz", @"14.json.gz", @"15.json.gz",
@"80.2.json.gz", @"81.2.json.gz", @"83.2.json.gz",
// ADD
@"00.json.gz", @"01.json.gz", @"02.json.gz", @"03.json.gz", @"04.json.gz", @"05.json.gz",
@"80.0.json.gz", @"81.0.json.gz", @"83.0.json.gz",
// @"37.json.gz", // AAA
// @"3F.json.gz", // AAS
// @"D4.json.gz", // AAM
// @"D5.json.gz", // AAD
// @"27.json.gz", // DAA
// @"2F.json.gz", // DAS
//
// @"98.json.gz", // CBW
// @"99.json.gz", // CWD
//
// // ESC
// @"D8.json.gz", @"D9.json.gz", @"DA.json.gz", @"DB.json.gz",
// @"DC.json.gz", @"DD.json.gz", @"DE.json.gz", @"DE.json.gz",
//
// // NOP
// @"90.json.gz",
//
// // ADC
// @"10.json.gz", @"11.json.gz", @"12.json.gz", @"13.json.gz", @"14.json.gz", @"15.json.gz",
// @"80.2.json.gz", @"81.2.json.gz", @"83.2.json.gz",
//
// // ADD
// @"00.json.gz", @"01.json.gz", @"02.json.gz", @"03.json.gz", @"04.json.gz", @"05.json.gz",
// @"80.0.json.gz", @"81.0.json.gz", @"83.0.json.gz",
// SBB
@"18.json.gz", @"19.json.gz", @"1A.json.gz", @"1B.json.gz", @"1C.json.gz", @"1D.json.gz",
@ -312,17 +312,17 @@ struct FailedExecution {
@"80.5.json.gz", @"81.5.json.gz", @"83.5.json.gz",
// AND
@"20.json.gz", @"21.json.gz", @"22.json.gz", @"23.json.gz", @"24.json.gz", @"25.json.gz",
@"80.4.json.gz", @"81.4.json.gz", @"83.4.json.gz",
// CALL
@"E8.json.gz", @"FF.2.json.gz",
@"9A.json.gz", @"FF.3.json.gz",
@"F8.json.gz", // CLC
@"FC.json.gz", // CLD
@"FA.json.gz", // CLI
@"F5.json.gz", // CMC
// @"20.json.gz", @"21.json.gz", @"22.json.gz", @"23.json.gz", @"24.json.gz", @"25.json.gz",
// @"80.4.json.gz", @"81.4.json.gz", @"83.4.json.gz",
//
// // CALL
// @"E8.json.gz", @"FF.2.json.gz",
// @"9A.json.gz", @"FF.3.json.gz",
//
// @"F8.json.gz", // CLC
// @"FC.json.gz", // CLD
// @"FA.json.gz", // CLI
// @"F5.json.gz", // CMC
]];
NSSet *ignoreList = nil;

View File

@ -343,7 +343,7 @@ template <Personality personality, typename T, bool uses_ready_line> void Proces
// on a 6502 additional borrow isn't propagated but on a 65C02 it is.
// This difference affects invalid BCD numbers only — valid numbers will
// never be less than -9 so adding 10 will always generate carry.
if(!Numeric::carried_in<true, 4>(a_, operand_, result)) {
if(!Numeric::carried_in<4>(a_, operand_, result)) {
if constexpr (is_65c02(personality)) {
result += 0xfa;
} else {
@ -390,7 +390,7 @@ template <Personality personality, typename T, bool uses_ready_line> void Proces
//
// So if that carry already happened, fix up the bottom without permitting another;
// otherwise permit the carry to happen (and check whether carry then rippled out of bit 7).
if(Numeric::carried_in<true, 4>(a_, operand_, result)) {
if(Numeric::carried_in<4>(a_, operand_, result)) {
result = (result & 0xf0) | ((result + 0x06) & 0x0f);
} else if((result & 0xf) > 0x9) {
flags_.carry |= result >= 0x100 - 0x6;