parser/instructions/
xor.rs

1use super::Instruction;
2use super::InstructionTrait;
3use super::operand::Operand;
4
5#[derive(Debug, PartialEq, Clone, Copy)]
6pub struct Xor {
7    operand: Operand,
8}
9
10impl Xor {
11    pub fn new(operand: Operand) -> Xor {
12        Xor { operand }
13    }
14
15    pub fn get_operand(&self) -> &Operand {
16        &self.operand
17    }
18}
19
20impl From<Xor> for Instruction {
21    fn from(item: Xor) -> Self {
22        Self::Xor(item)
23    }
24}
25
26impl std::fmt::Display for Xor {
27    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28        write!(f, "XOR {}", self.operand)
29    }
30}
31
32impl InstructionTrait for Xor {
33    fn size(&self) -> usize {
34        if let Operand::Imm8(_) = self.operand {
35            2
36        } else {
37            1
38        }
39    }
40}