1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-19 08:31:11 +00:00

Add getters to obscure internal flag storage.

This commit is contained in:
Thomas Harte 2023-10-10 16:14:20 -04:00
parent f083eab011
commit ec982444f7
2 changed files with 50 additions and 0 deletions

View File

@ -70,6 +70,55 @@ struct Status {
uint32_t parity;
// Flag getters.
enum class Flag {
Carry,
AuxiliaryCarry,
Sign,
Overflow,
Trap,
Interrupt,
Direction,
Zero,
ParityOdd
};
template <Flag flag> bool flag() {
switch(flag) {
case Flag::Carry: return carry;
case Flag::AuxiliaryCarry: return auxiliary_carry;
case Flag::Sign: return sign;
case Flag::Overflow: return overflow;
case Flag::Trap: return trap;
case Flag::Interrupt: return interrupt;
case Flag::Direction: return direction;
case Flag::Zero: return !zero;
case Flag::ParityOdd: return not_parity_bit();
}
}
// Condition evaluation.
enum class Condition {
Overflow,
Below,
Zero,
BelowOrEqual,
Sign,
ParityOdd,
Less,
LessOrEqual
};
template <Condition test> bool condition() {
switch(test) {
case Condition::Overflow: return flag<Flag::Overflow>();
case Condition::Below: return flag<Flag::Carry>();
case Condition::Zero: return flag<Flag::Zero>();
case Condition::BelowOrEqual: return flag<Flag::Zero>() || flag<Flag::Carry>();
case Condition::Sign: return flag<Flag::Sign>();
case Condition::ParityOdd: return flag<Flag::ParityOdd>();
case Condition::Less: return flag<Flag::Sign>() != flag<Flag::Overflow>();
case Condition::LessOrEqual: return flag<Flag::Zero>() || flag<Flag::Sign>() != flag<Flag::Overflow>();
}
}
template <typename IntT> IntT carry_bit() const { return carry ? 1 : 0; }
bool not_parity_bit() const {
// x86 parity always considers the lowest 8-bits only.

View File

@ -335,6 +335,7 @@ struct FailedExecution {
@"FF.1.json.gz",
// TODO: IN, OUT
// TODO: JO, JNO, JB, JNB, JZ, JNZ, JBE, JNBE, JS, JNS, JP, JNP, JL, JNL, JLE, JNLE,
// CALL