From 179d5d9cb7e94851ba69bf67f6d2dfbafa6aa6fe Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 28 Nov 2019 02:21:34 -0800 Subject: update arm to revised decoder trait --- test/armv7.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'test/armv7.rs') diff --git a/test/armv7.rs b/test/armv7.rs index 09f5333..7b0c2b6 100644 --- a/test/armv7.rs +++ b/test/armv7.rs @@ -1,9 +1,8 @@ -use yaxpeax_arch::{Decodable, LengthedInstruction}; +use yaxpeax_arch::{Arch, Decoder, LengthedInstruction}; use yaxpeax_arm::armv7::{ARMv7, Instruction, ConditionCode, Operands, Opcode, ShiftSpec}; fn test_decode(data: [u8; 4], expected: Instruction) { - let mut instr = Instruction::blank(); - instr.decode_into(data.to_vec()); + let instr = ::Decoder::default().decode(data.to_vec()).unwrap(); assert!( instr == expected, "decode error for {:02x}{:02x}{:02x}{:02x}:\n decoded: {:?}\n expected: {:?}\n", @@ -13,8 +12,7 @@ fn test_decode(data: [u8; 4], expected: Instruction) { } fn test_display(data: [u8; 4], expected: &'static str) { - let mut instr = Instruction::blank(); - instr.decode_into(data.to_vec()); + let instr = ::Decoder::default().decode(data.to_vec()).unwrap(); let text = format!("{}", instr); assert!( text == expected, @@ -318,8 +316,7 @@ static instruction_bytes: [u8; 4 * 60] = [ fn test_decode_span() { let mut i = 0u32; while i < instruction_bytes.len() as u32 { - let mut instr = Instruction::blank(); - instr.decode_into(instruction_bytes[(i as usize)..].iter().map(|x| *x)); + let instr = ::Decoder::default().decode(instruction_bytes[(i as usize)..].iter().cloned()).unwrap(); println!( "Decoded {:02x}{:02x}{:02x}{:02x}: {}", //{:?}\n {}", instruction_bytes[i as usize], @@ -402,9 +399,10 @@ pub fn bench_60000_instrs(b: &mut Bencher) { b.iter(|| { for i in (0..1000) { let mut iter = instruction_bytes.iter().map(|x| *x); + let decoder = ::Decoder::default(); let mut result = Instruction::blank(); loop { - match result.decode_into(&mut iter) { + match decoder.decode_into(&mut result, &mut iter) { Some(result) => { test::black_box(&result); }, -- cgit v1.1