From 4371ed02ac30cb56ec4ddbf60c87e85c183d860b Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 22 Jul 2021 00:31:02 -0700 Subject: fix incorrect decodes with scas and 67-prefixes --- test/long_mode/mod.rs | 9 +++++++++ test/protected_mode/mod.rs | 10 ++++++++++ test/real_mode/mod.rs | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) (limited to 'test') diff --git a/test/long_mode/mod.rs b/test/long_mode/mod.rs index ae79761..bfe21bd 100644 --- a/test/long_mode/mod.rs +++ b/test/long_mode/mod.rs @@ -2676,6 +2676,15 @@ fn prefixed_f30f() { } #[test] +fn only_64bit() { + test_display(&[0xae], "scas byte es:[rdi], al"); + test_display(&[0xaf], "scas dword es:[rdi], eax"); + test_display(&[0x67, 0xaf], "scas dword es:[edi], eax"); + test_display(&[0x67, 0xac], "lods al, byte ds:[esi]"); + test_display(&[0x67, 0xaa], "stos byte es:[edi], al"); +} + +#[test] fn test_adx() { test_display(&[0x66, 0x0f, 0x38, 0xf6, 0xc1], "adcx eax, ecx"); test_display(&[0x66, 0x0f, 0x38, 0xf6, 0x01], "adcx eax, dword [rcx]"); diff --git a/test/protected_mode/mod.rs b/test/protected_mode/mod.rs index 28682ef..c03a19d 100644 --- a/test/protected_mode/mod.rs +++ b/test/protected_mode/mod.rs @@ -2363,6 +2363,16 @@ fn prefixed_f30f() { #[test] fn only_32bit() { + test_display(&[0x67, 0xac], "lods al, byte ds:[si]"); + test_display(&[0x67, 0xae], "scas byte es:[di], al"); + test_display(&[0xac], "lods al, byte ds:[esi]"); + test_display(&[0xae], "scas byte es:[edi], al"); + test_display(&[0x67, 0xf3, 0xa4], "rep movs byte es:[di], byte ds:[si]"); + test_display(&[0xf3, 0xa4], "rep movs byte es:[edi], byte ds:[esi]"); + test_display(&[0x67, 0xf3, 0xa5], "rep movs dword es:[di], dword ds:[si]"); + test_display(&[0xf3, 0xa5], "rep movs dword es:[edi], dword ds:[esi]"); + test_display(&[0x66, 0x67, 0x8b, 0x0e, 0x55, 0xaa], "mov cx, word [0xaa55]"); + test_display(&[0x66, 0x8b, 0x0e], "mov cx, word [esi]"); test_display(&[0x40], "inc eax"); test_display(&[0x41], "inc ecx"); test_display(&[0x47], "inc edi"); diff --git a/test/real_mode/mod.rs b/test/real_mode/mod.rs index 23744e1..82ccfab 100644 --- a/test/real_mode/mod.rs +++ b/test/real_mode/mod.rs @@ -50,6 +50,22 @@ fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str } #[test] +fn only_16bit() { + test_display(&[0xac], "lods al, byte ds:[si]"); + test_display(&[0xae], "scas byte es:[di], al"); + test_display(&[0x67, 0xac], "lods al, byte ds:[esi]"); + test_display(&[0x67, 0xae], "scas byte es:[edi], al"); + test_display(&[0xf3, 0xa4], "rep movs byte es:[di], byte ds:[si]"); + test_display(&[0x67, 0xf3, 0xa4], "rep movs byte es:[edi], byte ds:[esi]"); + test_display(&[0xf3, 0xa5], "rep movs word es:[di], word ds:[si]"); + test_display(&[0x67, 0xf3, 0xa5], "rep movs word es:[edi], word ds:[esi]"); + test_display(&[0x8b, 0x0e, 0x55, 0xaa], "mov cx, word [0xaa55]"); + test_display(&[0x66, 0x8b, 0x0e, 0x55, 0xaa], "mov ecx, dword [0xaa55]"); + test_display(&[0x67, 0x8b, 0x0e], "mov cx, word [esi]"); + test_display(&[0x66, 0x67, 0x8b, 0x0e], "mov ecx, dword [esi]"); +} + +#[test] fn test_real_mode() { test_display(&[0x00, 0xcc], "add ah, cl"); test_display(&[0x03, 0x0b], "add cx, word [bp + di]"); -- cgit v1.1