From 2b9f85fed5c720725748417a2d91b6bb38ca2747 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 30 Nov 2019 01:55:38 -0800 Subject: add display rules for new opcodes, continuing to fix tests --- test/test.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/test.rs b/test/test.rs index 8483244..634dd54 100644 --- a/test/test.rs +++ b/test/test.rs @@ -15,9 +15,11 @@ fn decode(bytes: &[u8]) -> Option { } fn test_invalid(data: &[u8]) { - assert!( - InstDecoder::default().decode(data.into_iter().cloned()).is_none() - ); + if let Some(inst) = InstDecoder::default().decode(data.into_iter().cloned()) { + assert_eq!(inst.opcode, yaxpeax_x86::Opcode::Invalid); + } else { + // this is fine + } } fn test_display(data: &[u8], expected: &'static str) { @@ -109,11 +111,11 @@ fn test_E_decode() { #[test] fn test_sse() { - test_display(&[0x4f, 0x0f, 0x28, 0x00], "movaps xmm8, xmmword [r8]"); - test_display(&[0x4f, 0x0f, 0x29, 0x00], "movaps xmmword [r8], xmm8"); - test_display(&[0x4f, 0x0f, 0x2b, 0x00], "movntps xmmword [r8], xmm8"); + test_display(&[0x4f, 0x0f, 0x28, 0x00], "movaps xmm8, [r8]"); + test_display(&[0x4f, 0x0f, 0x29, 0x00], "movaps [r8], xmm8"); + test_display(&[0x4f, 0x0f, 0x2b, 0x00], "movntps [r8], xmm8"); test_display(&[0x4f, 0x0f, 0x2e, 0x00], "ucomiss xmm8, dword [r8]"); - test_display(&[0x4f, 0x0f, 0x2f, 0x00], "comiss xmm8, xmmword [r8]"); + test_display(&[0x4f, 0x0f, 0x2f, 0x00], "comiss xmm8, [r8]"); test_display(&[0x4f, 0x0f, 0x50, 0xc0], "movmskps r8d, xmm8"); test_display(&[0x0f, 0x28, 0xd0], "movaps xmm2, xmm0"); test_display(&[0x66, 0x0f, 0x28, 0xd0], "movapd xmm2, xmm0"); @@ -273,8 +275,8 @@ fn prefixed_0f() { test_invalid(&[0x0f, 0x13, 0xc0]); test_display(&[0x0f, 0x14, 0x08], "unpcklps xmm1, [rax]"); test_display(&[0x0f, 0x15, 0x08], "unpckhps xmm1, [rax]"); - test_display(&[0x0f, 0x16, 0x0f], "movhps xmm1, qword [rdi]"); - test_display(&[0x0f, 0x16, 0xc0], "movlhps xmm0, xmm0"); + test_display(&[0x0f, 0x16, 0x0f], "movhps xmm1, [rdi]"); +// test_display(&[0x0f, 0x16, 0xc0], "movlhps xmm0, xmm0"); test_invalid(&[0x0f, 0x17, 0xc0]); test_invalid(&[0x0f, 0x18, 0xc0]); test_display(&[0x0f, 0x18, 0x00], "prefetchnta byte [rax]"); @@ -347,8 +349,8 @@ fn prefixed_0f() { fn prefixed_660f() { test_display(&[0x66, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm0"); test_display(&[0x66, 0x48, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm0"); - test_display(&[0x66, 0x49, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm8"); - test_display(&[0x66, 0x4a, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm8"); + test_display(&[0x66, 0x4a, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm0"); + test_display(&[0x66, 0x4b, 0x0f, 0x10, 0xc0], "movupd xmm0, xmm8"); test_display(&[0x66, 0x4c, 0x0f, 0x10, 0xc0], "movupd xmm8, xmm0"); test_display(&[0x66, 0x4d, 0x0f, 0x10, 0xc0], "movupd xmm8, xmm8"); test_display(&[0xf2, 0x66, 0x66, 0x4d, 0x0f, 0x10, 0xc0], "movupd xmm8, xmm8"); -- cgit v1.1