Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/asm/src/instr/cond.rs

80 lines
2.1 KiB

use std::fmt::{self, Display, Formatter};
use std::ops::Not;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum Cond {
Equal,
NotEqual,
Zero,
NotZero,
Lower,
LowerOrEqual,
Greater,
GreaterOrEqual,
Positive,
NonPositive,
Negative,
NonNegative,
Overflow,
NotOverflow,
Invalid,
Valid,
Carry,
NotCarry,
}
impl Display for Cond {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Cond::Equal => "eq",
Cond::NotEqual => "ne",
Cond::Zero => "z",
Cond::NotZero => "nz",
Cond::Lower => "lt",
Cond::LowerOrEqual => "le",
Cond::Greater => "gt",
Cond::GreaterOrEqual => "ge",
Cond::Positive => "pos",
Cond::Negative => "neg",
Cond::NonPositive => "npos",
Cond::NonNegative => "nneg",
Cond::Overflow => "ov",
Cond::NotOverflow => "nov",
Cond::Carry => "c",
Cond::NotCarry => "nc",
Cond::Invalid => "inval",
Cond::Valid => "ok",
})
}
}
impl Not for Cond {
type Output = Cond;
fn not(self) -> Self::Output {
match self {
Cond::Equal => Cond::NotEqual,
Cond::Zero => Cond::NotZero,
Cond::Overflow => Cond::NotOverflow,
Cond::Carry => Cond::NotCarry,
Cond::Positive => Cond::NonPositive,
Cond::Negative => Cond::NonNegative,
Cond::NonPositive => Cond::Positive,
Cond::NonNegative => Cond::Negative,
Cond::NotEqual => Cond::Equal,
Cond::NotZero => Cond::Zero,
Cond::NotOverflow => Cond::Overflow,
Cond::NotCarry => Cond::Carry,
Cond::Lower => Cond::GreaterOrEqual,
Cond::Greater => Cond::LowerOrEqual,
Cond::LowerOrEqual => Cond::Greater,
Cond::GreaterOrEqual => Cond::Lower,
Cond::Invalid => Cond::Valid,
Cond::Valid => Cond::Invalid,
}
}
}