#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Opcode {
DOD = 0b00001, ODE = 0b00010, LAD = 0b00011, POB = 0b00100, SOB = 0b00101, SOM = 0b00110, STP = 0b00111, DNS = 0b01000, PZS = 0b01001, SDP = 0b01010, CZM = 0b01011, MSK = 0b01100, PWR = 0b01101, WEJSCIE = 0b01110, WYJSCIE = 0b01111, SOZ = 0b10000,
MNO = 0b10001, DZI = 0b10010, MOD = 0b10011, }
impl Opcode {
pub fn from_u8(value: u8) -> Option<Self> {
match value {
0b00001 => Some(Self::DOD),
0b00010 => Some(Self::ODE),
0b00011 => Some(Self::LAD),
0b00100 => Some(Self::POB),
0b00101 => Some(Self::SOB),
0b00110 => Some(Self::SOM),
0b00111 => Some(Self::STP),
0b01000 => Some(Self::DNS),
0b01001 => Some(Self::PZS),
0b01010 => Some(Self::SDP),
0b01011 => Some(Self::CZM),
0b01100 => Some(Self::MSK),
0b01101 => Some(Self::PWR),
0b01110 => Some(Self::WEJSCIE),
0b01111 => Some(Self::WYJSCIE),
0b10000 => Some(Self::SOZ),
0b10001 => Some(Self::MNO), 0b10010 => Some(Self::DZI), 0b10011 => Some(Self::MOD), _ => None,
}
}
pub fn requires_operand(self) -> bool {
!matches!(self, Self::STP | Self::DNS | Self::PZS | Self::SDP | Self::CZM | Self::PWR)
}
pub fn is_extended(self) -> bool {
matches!(self, Self::MNO | Self::DZI | Self::MOD)
}
}