use binbun_isa::Flow;
use crate::Instruction;
use crate::generated;
use crate::operand::{Condition as Cond, Register};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Condition {
Flags(Cond),
Zero {
register: Register,
zero: bool,
},
Bit {
register: Register,
bit: u8,
set: bool,
},
Compare {
cond: Cond,
left: Register,
right: CompareOperand,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum CompareOperand {
Register(Register),
Immediate(i64),
}
impl Instruction {
#[inline]
pub fn flow(self, address: u64) -> Flow {
generated::flow::flow(self.encoding(), self.word(), address)
}
pub fn condition(self) -> Option<Condition> {
generated::flow::condition(self.encoding(), self.word())
}
}