From 49d2e670b56d43d079775f01a02f31555bb9da73 Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 26 Jun 2019 21:44:10 -0700 Subject: add failing decode test cases --- src/lib.rs | 1 + test/test.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e95f4dd..95e727a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,7 @@ pub struct RegSpec { // This is only to select alternate opcode maps for the 0f escape byte. // This often could be treated as a size prefix but in some cases selects // an entirely different operation. +#[derive(Debug)] enum OpcodeMap { Map66, MapF2, diff --git a/test/test.rs b/test/test.rs index 85288a6..3a7aee9 100644 --- a/test/test.rs +++ b/test/test.rs @@ -57,6 +57,7 @@ fn test_system() { #[test] fn test_arithmetic() { test_display(&[0x81, 0xec, 0x10, 0x03, 0x00, 0x00], "sub esp, 0x310"); + test_display(&[0x0f, 0xaf, 0xc2], "imul eax, edx"); } #[test] @@ -68,6 +69,8 @@ fn test_E_decode() { #[test] fn test_sse() { + test_display(&[0x0f, 0x28, 0xd0], "movaps xmm2, xmm0"); + test_display(&[0x66, 0x0f, 0xef, 0xc0], "pxor xmm0, xmm0"); test_display(&[0xf2, 0x0f, 0x10, 0x0c, 0xc6], "movsd xmm1, [rsi + rax * 8]"); test_display(&[0xf3, 0x0f, 0x10, 0x04, 0x86], "movss xmm0, [rsi + rax * 4]"); test_display(&[0xf2, 0x0f, 0x59, 0xc8], "mulsd xmm1, xmm0"); @@ -95,6 +98,7 @@ fn test_mov() { test_display(&[0x0f, 0xb7, 0x06], "movzx eax, word [rsi]"); test_display(&[0x89, 0x55, 0x94], "mov [rbp - 0x6c], edx"); test_display(&[0x65, 0x4c, 0x89, 0x04, 0x25, 0xa8, 0x01, 0x00, 0x00], "mov gs:[0x1a8], r8"); + test_display(&[0x48, 0x63, 0x04, 0xba], "movsxd rax, [rdx + rdi * 4]"); } #[test] @@ -143,7 +147,9 @@ fn test_push_pop() { #[test] fn test_misc() { + test_display(&[0x48, 0x98], "cdqe"); test_display(&[0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00], "nop cs:[rax + rax]"); + test_display(&[0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00], "nop cs:[rax + rax]"); test_display(&[0x48, 0x8d, 0xa4, 0xc7, 0x20, 0x00, 0x00, 0x12], "lea rsp, [rdi + rax * 8 + 0x12000020]"); test_display(&[0x33, 0xc0], "xor eax, eax"); test_display(&[0x48, 0x8d, 0x53, 0x08], "lea rdx, [rbx + 0x8]"); @@ -152,4 +158,7 @@ fn test_misc() { test_display(&[0x48, 0x03, 0x0b], "add rcx, [rbx]"); test_display(&[0x48, 0x8d, 0x0c, 0x12], "lea rcx, [rdx + rdx]"); test_display(&[0xf6, 0xc2, 0x18], "test dl, 0x18"); + test_display(&[0xf3, 0x48, 0xab], "rep stosq"); + test_display(&[0xf3, 0x48, 0xa5], "rep movsq"); + test_display(&[0xf3, 0x45, 0x0f, 0xbc, 0xd7], "tzcnt r10d, r15d"); } -- cgit v1.1