1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::fmt::Display;

pub use crate::modules::riscv::basic::assembler::assembler::RiscVAssembler;
use crate::{
    interface::assembler::{InstructionSet, InstructionSetTrait},
    modules::riscv::basic::interface::parser::*,
};

impl InstructionSetTrait for RISCV {
    type Register = ParserRISCVRegister;
    type Immediate = RISCVImmediate;
}

impl Display for InstructionSet<RISCV> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "line_number:{:3}; address:0x{:08x}; code:0x{:08x}; basic:{}; Instruction:{:?}",
            self.line_number, self.address, self.code, self.basic, self.instruction.operation,
        )?;
        write!(
            f,
            "{}",
            self.instruction
                .operands
                .iter()
                .map(|ins| ins.to_string())
                .collect::<Vec<_>>()
                .join(",")
        )
        .expect("panic");
        Ok(())
    }
}