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

Implement SAHF, LAHF.

This commit is contained in:
Thomas Harte 2023-10-12 13:54:51 -04:00
parent 56e639e09a
commit e948a67814
2 changed files with 34 additions and 4 deletions

View File

@ -1,4 +1,5 @@
//
//
// PerformImplementation.hpp
// Clock Signal
//
@ -789,6 +790,30 @@ void into(Status &status, FlowControllerT &flow_controller) {
}
}
inline void sahf(uint8_t &ah, Status &status) {
/*
EFLAGS(SF:ZF:0:AF:0:PF:1:CF) AH;
*/
status.set_from<uint8_t, Flag::Sign>(ah);
status.set_from<Flag::Zero>(!(ah & 0x40));
status.set_from<Flag::AuxiliaryCarry>(ah & 0x10);
status.set_from<Flag::ParityOdd>(!(ah & 0x04));
status.set_from<Flag::Carry>(ah & 0x01);
}
inline void lahf(uint8_t &ah, Status &status) {
/*
AH EFLAGS(SF:ZF:0:AF:0:PF:1:CF);
*/
ah =
(status.flag<Flag::Sign>() ? 0x80 : 0x00) |
(status.flag<Flag::Zero>() ? 0x40 : 0x00) |
(status.flag<Flag::AuxiliaryCarry>() ? 0x10 : 0x00) |
(status.flag<Flag::ParityOdd>() ? 0x00 : 0x04) |
0x02 |
(status.flag<Flag::Carry>() ? 0x01 : 0x00);
}
template <typename IntT>
void cbw(IntT &ax) {
constexpr IntT test_bit = 1 << (sizeof(IntT) * 4 - 1);
@ -941,6 +966,9 @@ template <
case Operation::INT: Primitive::int_(instruction.operand(), flow_controller); return;
case Operation::INTO: Primitive::into(status, flow_controller); return;
case Operation::SAHF: Primitive::sahf(registers.ah(), status); return;
case Operation::LAHF: Primitive::lahf(registers.ah(), status); return;
case Operation::JO: jcc(status.condition<Condition::Overflow>()); return;
case Operation::JNO: jcc(!status.condition<Condition::Overflow>()); return;
case Operation::JB: jcc(status.condition<Condition::Below>()); return;

View File

@ -282,7 +282,7 @@ struct FailedExecution {
- (NSArray<NSString *> *)testFiles {
NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
NSSet *allowList = [NSSet setWithArray:@[
@"37.json.gz", // AAA
/* @"37.json.gz", // AAA
@"3F.json.gz", // AAS
@"D4.json.gz", // AAM
@"D5.json.gz", // AAD
@ -371,8 +371,10 @@ struct FailedExecution {
// INT, INT3
@"CC.json.gz", @"CD.json.gz",
*/
@"9E.json.gz", // SAHF
@"9F.json.gz", // LAHF
// TODO: LAHF, SAHF
// TODO: LDS, LES
// TODO: LEA
@ -381,7 +383,7 @@ struct FailedExecution {
// TODO: LOOP, LOOPE, LOOPNE
// TODO: MOV
/*
// 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",
@ -431,7 +433,7 @@ struct FailedExecution {
// TODO: XLAT
// TODO: SALC, SETMO, SETMOC
*/
]];
NSSet *ignoreList = nil;