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

Implement TEST.

This commit is contained in:
Thomas Harte 2023-10-10 22:28:10 -04:00
parent 08867f4970
commit 5125907048
2 changed files with 35 additions and 4 deletions

View File

@ -476,6 +476,32 @@ void sub(IntT &destination, IntT source, Status &status) {
}
}
template <typename IntT>
void test(IntT &destination, IntT source, Status &status) {
/*
TEMP SRC1 AND SRC2;
SF MSB(TEMP);
IF TEMP = 0
THEN ZF 0;
ELSE ZF 1;
FI:
PF BitwiseXNOR(TEMP[0:7]);
CF 0;
OF 0;
*/
/*
The OF and CF flags are cleared to 0.
The SF, ZF, and PF flags are set according to the result (see the Operation section above).
The state of the AF flag is undefined.
*/
const IntT result = destination & source;
status.sign = result & top_bit<IntT>();
status.zero = result;
status.carry = status.overflow = 0;
status.parity = result;
}
template <typename IntT>
void mul(IntT &destination_high, IntT &destination_low, IntT source, Status &status) {
/*
@ -938,6 +964,7 @@ template <
case Operation::SBB: Primitive::sbb(destination(), source(), status); break;
case Operation::SUB: Primitive::sub<true>(destination(), source(), status); break;
case Operation::CMP: Primitive::sub<false>(destination(), source(), status); break;
case Operation::TEST: Primitive::test(destination(), source(), status); break;
// TODO: all the below could call a common registers getter?
case Operation::MUL:

View File

@ -413,11 +413,15 @@ struct FailedExecution {
*/
// 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",
// @"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",
// TEST
@"84.json.gz", @"85.json.gz",
@"A8.json.gz", @"A9.json.gz",
@"F6.0.json.gz", @"F7.0.json.gz",
// TODO: CMP, TEST
// TODO: XCHG, XLAT
// TODO: SALC, SETMO, SETMOC