1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-09 05:25:01 +00:00

Implement CMP.

This commit is contained in:
Thomas Harte
2023-10-10 22:15:33 -04:00
parent d0a9b5cb81
commit 08867f4970
2 changed files with 21 additions and 11 deletions

View File

@@ -455,7 +455,7 @@ void sbb(IntT &destination, IntT source, Status &status) {
destination = result; destination = result;
} }
template <typename IntT> template <bool write_back, typename IntT>
void sub(IntT &destination, IntT source, Status &status) { void sub(IntT &destination, IntT source, Status &status) {
/* /*
DEST ← DEST - SRC; DEST ← DEST - SRC;
@@ -471,7 +471,9 @@ void sub(IntT &destination, IntT source, Status &status) {
status.zero = status.parity = result; status.zero = status.parity = result;
status.overflow = overflow<false, IntT>(destination, source, result); status.overflow = overflow<false, IntT>(destination, source, result);
destination = result; if constexpr (write_back) {
destination = result;
}
} }
template <typename IntT> template <typename IntT>
@@ -931,10 +933,13 @@ template <
case Operation::HLT: flow_controller.halt(); return; case Operation::HLT: flow_controller.halt(); return;
case Operation::WAIT: flow_controller.wait(); return; case Operation::WAIT: flow_controller.wait(); return;
case Operation::ADC: Primitive::adc(destination(), source(), status); break; case Operation::ADC: Primitive::adc(destination(), source(), status); break;
case Operation::ADD: Primitive::add(destination(), source(), status); break; case Operation::ADD: Primitive::add(destination(), source(), status); break;
case Operation::SBB: Primitive::sbb(destination(), source(), status); break; case Operation::SBB: Primitive::sbb(destination(), source(), status); break;
case Operation::SUB: Primitive::sub(destination(), source(), status); break; case Operation::SUB: Primitive::sub<true>(destination(), source(), status); break;
case Operation::CMP: Primitive::sub<false>(destination(), source(), status); break;
// TODO: all the below could call a common registers getter?
case Operation::MUL: case Operation::MUL:
if constexpr (data_size == DataSize::Byte) { if constexpr (data_size == DataSize::Byte) {
Primitive::mul(registers.ah(), registers.al(), source(), status); Primitive::mul(registers.ah(), registers.al(), source(), status);

View File

@@ -390,11 +390,11 @@ struct FailedExecution {
@"80.6.json.gz", @"81.6.json.gz", @"83.6.json.gz", @"80.6.json.gz", @"81.6.json.gz", @"83.6.json.gz",
*/ */
// NEG // // NEG
@"F6.3.json.gz", @"F7.3.json.gz", // @"F6.3.json.gz", @"F7.3.json.gz",
//
// NOT // // NOT
@"F6.2.json.gz", @"F7.2.json.gz", // @"F6.2.json.gz", @"F7.2.json.gz",
/* /*
// NOP // NOP
@@ -412,6 +412,11 @@ struct FailedExecution {
@"F5.json.gz", // CMC @"F5.json.gz", // CMC
*/ */
// CMP
@"38.json.gz", @"39.json.gz", @"3A.json.gz",
@"3B.json.gz", @"3C.json.gz", @"3D.json.gz",
@"80.7.json.gz", @"81.7.json.gz", @"83.7.json.gz",
// TODO: CMP, TEST // TODO: CMP, TEST
// TODO: XCHG, XLAT // TODO: XCHG, XLAT
// TODO: SALC, SETMO, SETMOC // TODO: SALC, SETMO, SETMOC