parser/instructions/
ld.rs

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