diff options
author | iximeow <me@iximeow.net> | 2023-12-23 13:20:53 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2023-12-23 13:20:53 -0800 |
commit | 372d903e98953817c818211243fbc6f7e9294884 (patch) | |
tree | 02a20d66f5499f0d2aee5fd4fb031a8ac3461bb0 /src/lib.rs | |
parent | d7cc1c7c82a7995bdbdb67f791e378967f93f880 (diff) |
add fuzz target for no panicking plz (it found panics)
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -62,14 +62,14 @@ impl fmt::Display for Instruction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.opcode())?; let ops = self.operands(); - if ops[0] != Operand::Nothing { - write!(f, " {}", ops[0])?; + if let Some(op) = ops.get(0) { + write!(f, " {}", op)?; } - if ops[1] != Operand::Nothing { - write!(f, ", {}", ops[1])?; + if let Some(op) = ops.get(1) { + write!(f, ", {}", op)?; } - if ops[2] != Operand::Nothing { - write!(f, ", {}", ops[2])?; + if let Some(op) = ops.get(2) { + write!(f, ", {}", op)?; } Ok(()) } @@ -725,6 +725,18 @@ impl Default for InstDecoder { } impl InstDecoder { + pub fn v1() -> Self { + Self { version: RxVersion::V1 } + } + + pub fn v2() -> Self { + Self { version: RxVersion::V2 } + } + + pub fn v3() -> Self { + Self { version: RxVersion::V3 } + } + fn num_to_psw_bit(&self, reg: u8) -> Result<Operand, <RX as Arch>::DecodeError> { match reg { 0b0000 => Ok(Operand::PSWBit { bit: PSWBit::C }), |