diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/display.rs | 20 | ||||
-rw-r--r-- | src/lib.rs | 15 |
2 files changed, 12 insertions, 23 deletions
diff --git a/src/display.rs b/src/display.rs index 76db507..dfddeca 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,13 +1,9 @@ extern crate yaxpeax_arch; extern crate termion; -use termion::color; - use std::fmt; -use std::hint::unreachable_unchecked; - -use yaxpeax_arch::{Arch, Colorize, ColorSettings, Decodable, LengthedInstruction, ShowContextual, YaxColors}; +use yaxpeax_arch::{Colorize, ColorSettings, ShowContextual, YaxColors}; use yaxpeax_arch::display::*; use ::{RegSpec, RegisterBank, Opcode, Operand, Instruction, Segment}; @@ -545,7 +541,7 @@ impl <T: std::fmt::Write> Colorize<T> for Instruction { } impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instruction { - fn contextualize(&self, colors: Option<&ColorSettings>, address: u64, context: Option<&[Option<String>]>, out: &mut T) -> std::fmt::Result { + fn contextualize(&self, colors: Option<&ColorSettings>, _address: u64, context: Option<&[Option<String>]>, out: &mut T) -> std::fmt::Result { if self.prefixes.lock { write!(out, "lock ")?; } @@ -561,7 +557,7 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi ref x @ _ => { write!(out, " ")?; if let Some(prefix) = self.segment_override_for_op(0) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out)?; } @@ -580,14 +576,14 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi x @ &Operand::Register(_) => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } x @ _ => { write!(out, ", byte ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } @@ -606,14 +602,14 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi x @ &Operand::Register(_) => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } x @ _ => { write!(out, ", word ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } @@ -632,7 +628,7 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi x @ _ => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } @@ -10,13 +10,9 @@ extern crate termion; mod display; -use termion::color; - -use std::fmt; - use std::hint::unreachable_unchecked; -use yaxpeax_arch::{Arch, ColorSettings, Decodable, LengthedInstruction}; +use yaxpeax_arch::{Arch, Decodable, LengthedInstruction}; #[cfg(feature="use-serde")] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] @@ -212,6 +208,7 @@ pub enum RegisterBank { X, Y, Z, // XMM, YMM, ZMM ST, MM, // ST, MM regs (x87, mmx) } +#[allow(non_camel_case_types)] #[cfg(not(feature="use-serde"))] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub enum RegisterBank { @@ -2586,11 +2583,11 @@ fn read_operands<T: Iterator<Item=u8>>( } else if r == 7 { if mod_bits == 0b11 { if m == 1 { - instruction.opcode == Opcode::SWAPGS; + instruction.opcode = Opcode::SWAPGS; instruction.operands = [Operand::Nothing, Operand::Nothing]; Ok(()) } else if m == 2 { - instruction.opcode == Opcode::RDTSCP; + instruction.opcode = Opcode::RDTSCP; instruction.operands = [Operand::Nothing, Operand::Nothing]; Ok(()) } else { @@ -2697,7 +2694,6 @@ fn read_operands<T: Iterator<Item=u8>>( } } OperandCode::Rq_Cq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2717,7 +2713,6 @@ fn read_operands<T: Iterator<Item=u8>>( Ok(()) } OperandCode::Rq_Dq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2736,7 +2731,6 @@ fn read_operands<T: Iterator<Item=u8>>( Ok(()) } OperandCode::Cq_Rq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2756,7 +2750,6 @@ fn read_operands<T: Iterator<Item=u8>>( Ok(()) } OperandCode::Dq_Rq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) |