1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Add DAA, which doesn't yet pass all tests.

This commit is contained in:
Thomas Harte 2023-10-09 14:27:02 -04:00
parent 59521f9d38
commit 1b9e6e8c8e
2 changed files with 49 additions and 4 deletions

View File

@ -292,6 +292,48 @@ inline void aas(CPU::RegisterPair16 &ax, Status &status) {
ax.halves.low &= 0x0f;
}
inline void daa(uint8_t &al, Status &status) {
/*
IF (((AL AND 0FH) > 9) or AF = 1)
THEN
AL AL + 6;
CF CF OR CarryFromLastAddition; (* CF OR carry from AL AL + 6 *)
AF 1;
ELSE
AF 0;
FI;
IF ((AL AND F0H) > 90H) or CF = 1)
THEN
AL AL + 60H;
CF 1;
ELSE
CF 0;
FI;
*/
/*
The CF and AF flags are set if the adjustment of the value results in a
decimal carry in either digit of the result (see the Operation section above).
The SF, ZF, and PF flags are set according to the result. The OF flag is undefined.
*/
if((al & 0x0f) > 0x09 || status.auxiliary_carry) {
status.carry |= al > 0xf9;
al += 0x06;
status.auxiliary_carry = 1;
} else {
status.auxiliary_carry = 0;
}
if((al & 0xf0) > 0x90 || status.carry) {
al += 0x60;
status.carry = 1;
} else {
status.carry = 0;
}
status.sign = al & 0x80;
status.zero = status.parity = al;
}
template <typename IntT>
void adc(IntT &destination, IntT source, Status &status) {
/*
@ -455,6 +497,7 @@ template <
case Operation::AAD: Primitive::aad(registers.axp(), instruction.operand(), status); return;
case Operation::AAM: Primitive::aam(registers.axp(), instruction.operand(), status, flow_controller); return;
case Operation::AAS: Primitive::aas(registers.axp(), status); return;
case Operation::DAA: Primitive::daa(registers.al(), status); return;
case Operation::ADC: Primitive::adc(destination(), source(), status); break;
case Operation::ADD: Primitive::add(destination(), source(), status); break;

View File

@ -275,6 +275,12 @@ 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
// 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",
@ -291,10 +297,6 @@ struct FailedExecution {
@"E8.json.gz", @"FF.2.json.gz",
@"9A.json.gz", @"FF.3.json.gz",
@"37.json.gz", // AAA
@"3F.json.gz", // AAS
@"D4.json.gz", // AAM
@"D5.json.gz", // AAD
@"98.json.gz", // CBW
@"F8.json.gz", // CLC
@"FC.json.gz", // CLD