1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Add faulty SUB, SBB.

This commit is contained in:
Thomas Harte 2023-10-09 16:21:04 -04:00
parent d24fa381c7
commit 67d364cc89
2 changed files with 88 additions and 33 deletions

View File

@ -434,6 +434,44 @@ void add(IntT &destination, IntT source, Status &status) {
destination = result;
}
template <typename IntT>
void sbb(IntT &destination, IntT source, Status &status) {
/*
DEST DEST - (SRC + CF);
*/
/*
The OF, SF, ZF, AF, CF, and PF flags are set according to the result.
*/
const IntT result = destination + source + status.carry_bit<IntT>();
status.carry = !Numeric::carried_out<bit_size<IntT>() - 1>(destination, IntT(~source), result);
status.auxiliary_carry = !Numeric::carried_in<4>(destination, IntT(~source), result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<false, IntT>(destination, source, result);
destination = result;
}
template <typename IntT>
void sub(IntT &destination, IntT source, Status &status) {
/*
DEST DEST - SRC;
*/
/*
The OF, SF, ZF, AF, CF, and PF flags are set according to the result.
*/
const IntT result = destination - source;
status.carry = !Numeric::carried_out<bit_size<IntT>() - 1>(destination, IntT(~source), result);
status.auxiliary_carry = !Numeric::carried_in<4>(destination, IntT(~source), result);
status.sign = result & top_bit<IntT>();
status.zero = status.parity = result;
status.overflow = overflow<false, IntT>(destination, source, result);
destination = result;
}
template <typename IntT>
void and_(IntT &destination, IntT source, Status &status) {
/*
@ -593,8 +631,14 @@ template <
case Operation::ESC:
case Operation::NOP: return;
case Operation::HLT: flow_controller.halt(); return;
case Operation::WAIT: flow_controller.wait(); return;
case Operation::ADC: Primitive::adc(destination(), source(), status); break;
case Operation::ADD: Primitive::add(destination(), source(), status); break;
case Operation::SBB: Primitive::sbb(destination(), source(), status); break;
case Operation::SUB: Primitive::sub(destination(), source(), status); break;
case Operation::AND: Primitive::and_(destination(), source(), status); break;
case Operation::CALLrel:

View File

@ -220,6 +220,9 @@ class FlowController {
registers_.ip_ = offset;
}
void halt() {}
void wait() {}
private:
Memory &memory_;
Registers &registers_;
@ -275,43 +278,51 @@ 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
// @"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",
@"98.json.gz", // CBW
@"99.json.gz", // CWD
// SBB
// @"18.json.gz", @"19.json.gz", @"1A.json.gz", @"1B.json.gz", @"1C.json.gz", @"1D.json.gz",
// @"80.3.json.gz", @"81.3.json.gz", @"83.3.json.gz",
// 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",
// SUB
@"28.json.gz", //@"29.json.gz", @"2A.json.gz", @"2B.json.gz", @"2C.json.gz", @"2D.json.gz",
// @"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;