Skip to main content

c6000_disassembler/instruction/
invalid.rs

1use crate::instruction::{C6000Instruction, InstructionData};
2
3pub struct InvalidInstruction {
4    instruction_data: InstructionData,
5}
6
7impl C6000Instruction for InvalidInstruction {
8    fn new(input: &super::InstructionInput) -> std::io::Result<Self> {
9        Ok(InvalidInstruction {
10            instruction_data: InstructionData {
11                opcode: input.opcode,
12                ..Default::default()
13            },
14        })
15    }
16
17    fn new_compact(input: &super::InstructionInput) -> std::io::Result<Self> {
18        Ok(InvalidInstruction {
19            instruction_data: InstructionData {
20                opcode: input.opcode,
21                compact: true,
22                ..Default::default()
23            },
24        })
25    }
26
27    fn instruction(&self) -> String {
28        if self.is_compact() {
29            String::from("INVALID COMPACT INSTRUCTION")
30        } else {
31            String::from("INVALID INSTRUCTION")
32        }
33    }
34
35    fn instruction_data(&self) -> &InstructionData {
36        &self.instruction_data
37    }
38
39    fn instruction_data_mut(&mut self) -> &mut InstructionData {
40        &mut self.instruction_data
41    }
42}