#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Size {
Byte,
Word,
Long,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Reg {
Byte(u8),
Word(u8),
Long(u8),
Ccr,
Exr,
Mach,
Macl,
Vbr,
Sbr,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Ea {
Indirect(Reg),
PostIncrement(Reg),
PreDecrement(Reg),
PostDecrement(Reg),
PreIncrement(Reg),
Displacement {
base: Reg,
value: i32,
bits: u8,
},
Indexed {
index: Reg,
value: i32,
bits: u8,
},
Absolute {
value: u32,
bits: u8,
},
PcRelative {
value: i32,
bits: u8,
},
PcIndexed(Reg),
MemoryIndirect(u8),
ExtendedIndirect(u8),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Operand {
None,
Register(Reg),
Immediate {
value: u32,
bits: u8,
},
Address(Ea),
IndexedMemory {
address: Ea,
index_size: Size,
value: i32,
bits: u8,
},
Registers {
first: u8,
last: u8,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Encoding {
Standard,
DisplacementStoreAlias,
SxAlternative(u16),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Insn {
pub mnemonic: &'static str,
pub size: Option<Size>,
pub operands: [Operand; 3],
pub encoding: Encoding,
}
impl Insn {
pub const fn new(mnemonic: &'static str, size: Option<Size>, operands: [Operand; 3]) -> Self {
Self {
mnemonic,
size,
operands,
encoding: Encoding::Standard,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Decoded {
pub insn: Insn,
pub len: usize,
}